Circle Collision Prediction

I know how to check if two circles intersect with each other. However, sometimes circles move too fast and ultimately avoid collisions in the next frame.

My current solution to the problem is to check the circular collision an arbitrary number of times between the previous position and the current position.

Is there a mathematical way to find the time needed for a collision of two circles? If I could get this value of time, I could move the circle to this position at this time, and then collide with it at this point.

Edit: constant speed

+7
source share
2 answers

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).

+11
source

You can predict collisions using the direction and velocity vector, this will give you the next steps and when they make a collision (if any).

You just need to check the line crossing algorithm to find that ...

-2
source

All Articles