# Calculate point of circle–circle collision between frames

I need to find the exact XY coordinate where a circle collides with another circle calculated between frames. This means that I take the coordinate of the moving circle on the previous frame and take its coordinate on the current frame. Then I need to find the position where the circle collides some time along this line segment.

In the diagram below, the blue circle moves from the previous frame (upper) to the current frame (intersecting, lower). During this time it would have hit where the dashed circle is. I need to find the coordinate of the green point. Also note that it may be possible for the blue circle to entirely pass through the red circle. There would then be two points, so the first must be used.

• You calculate the exact position of the moving circle in the desired moment between frames and then equate two circle equations which gives you the collision point(s). What is problematic here for you? EDIT: Do you want to find the collision point(s) in a specific moment in time or do you want to find out the collision point (one) and the time when the two circles first touch each other?
– NPS
Mar 14, 2014 at 22:13
• That's a good idea. I was thinking of an equation to "move" the circle until it hit (not actually, but mathematically move it). I didn't think about calculating the circle where it should have been. Great idea. However, I'm not really sure how to place this circle along the path. Mar 14, 2014 at 22:15
• @NPS I added the diagram. Hopefully that makes more sense now. Mar 14, 2014 at 22:45
• I've post my idea to solve this problem. If you don't understand it - ask in the comment. If you think it's ok, accept it or say it in comment and I will polish it/add some formulas/add some captions to the picture.
– NPS
Mar 14, 2014 at 22:53
• I made this diagram to help solve the problem. I'll just leave it here as a resource for future generations. Note that it assumes the two circles are the same size. Mar 14, 2014 at 23:10

Here's my idea (sorry for terrible picture, I've used Paint :P): In the first picture you see a moving circle #1 (red arrow is its moving direction) and a static circle #2. Red line is drawn along the moving direction vector. Let's say the moving circle's radius is R1 and the static one's is R2. Circle #1's center point is C1 and the other one's is C2. Circle #1's center point after moving is C1'.

In the second picture you can see the moment of collision. You can imagine a third circle #3 - one that has its center in the same point as circle #2 (C2) and its radius equals R1+R2.

Now you calculate the crossing points of the red line and the circle #3 (equate line's and circle's equations). The will give you 2 points (or 1 in a special case, or 0 if the circles actually don't collide). You should discard the point that is farther away from circle #1's original center position (from the previous frame) - 'C1'.

Now you just calculate the point between circle #2's center C2 and the line-circle crossing point (C1') calculated in the previous step - which is exactly R2 away from circle #2's center C2. You can do that easily by using lerp (linear interpolation): collision_point = lerp(C2, C1', R2/(R1+R2)). That is the 2 circles' collision point you wanted.

One more note - when you calculate all that on paper try to simplify/reduce the formulas - I didn't do that myself now but there's a good chance you end up with a nice concise formula.

And now that I think about it, it's actually a very important step - if I'm not mistaken, if you can bring all the transformations down to one formula and simplify it maximally, you should get the optimal formula for calculating the collision point regardless of the method used to derive it.