Code covered by the BSD License
Maxim Vedenyov (view profile)
07 Nov 2011
Simulation of balls collisions. Balls are same. Elastic collisions. No gravity.
% Compute pairwise distances
sum_X = sum(X .^ 2, 2);
D = bsxfun(@plus, sum_X, bsxfun(@plus, sum_X', -2 * X * X'));