I assume that the movement of the circles is linear. Let, say, the position of the center of the circle A be given by the vector equation Ca = Oa + t*Da , where
Ca = (Cax, Cay) - current position
Oa = (Oax, Oay) - starting position
t - elapsed time
Da = (Dax, Day) - shift per unit time (speed).
Similarly for the center B: Cb = Ob + t*Db .
Then you want to find t so that ||Ca - Cb|| = (ra + rb) ||Ca - Cb|| = (ra + rb) , where ra and rb are the radii of circles A and B, respectively.
Compression of both sides:
||Ca-Cb||^2 = (ra+rb)^2
and extension:
(Oax + t*Dax - Obx - t*Dbx)^2 + (Oay + t*Day - Oby - t*Dby)^2 = (ra + rb)^2
From this you should get a quadratic polynomial that you can solve for t (if such t exists).
Andrew Durward
source share