image thumbnail

3d balls dynamics

by

 

Simulation of balls collisions. Balls are same. Elastic collisions. No gravity.

D=distances(r)
function D=distances(r)

X=r';

% Compute pairwise distances
sum_X = sum(X .^ 2, 2);
D = bsxfun(@plus, sum_X, bsxfun(@plus, sum_X', -2 * X * X'));

Contact us