The coordinate of center of mass Xcm=(m1*X1+m2*X2)/(m1+m2)=(m1*X1+m2*X2)/mcm;

So mcm=m1+m2 is the sum of those two particles.

It is defined to make calculate property in the center of mass system much easier.

e.g. Vcm=(m1*V1+m2*V2)/(m1+m2)=(m1*V1+m2*V2)/mcm;

The radius of two circles are R1 and R2, the distance between two center of the curcle d=|x2-x1|,

if d < R1+R2 then we know the circles should have collided with each other when d=R1+R2;

So we need to move time backward with ddt=(R1+R2-d)/|V2-V1|.

X1=X1-V1*ddt;

X2=X2-V2*ddt;

This is moment those two circle collide with each other.

Then, use the formula shown at the first message (or check out standard physics textbook) to calculate velocity for each circle. (V1', V2')

Then move the time forward to t:

X1=X1+V1'*ddt;

X2=X2+V2'*ddt;