Circle-Circle collision intersection point

Started by
9 comments, last by reaperrar 12 years, 9 months ago
Given two circles, each with an old position (where they are not colliding) and a new position (where they are colliding)... How can I find at what point they collide between the old and new position?
Advertisement
Wouldn't they technically collide at a minimum of two points?

Edit: re-read it. Perhaps you mean at what time ??
I'm that imaginary number in the parabola of life.
yes, at what point in time does the distance between the two circles, minus the radius of both circles... equal zero
Hmm. I'm trying to think of a way to do this and I'll try to do some math on paper but I have a sort of quick way you could figure it out.
Find the two points the circles collide at.
Reverse the velocities of the circles.
Increment the positions of the circles with the negative velocities at a set amount of time.
When the two points of intersection are roughly the same point calculate the number of time steps to get to this point.

So you have the point in time from the current time the two circles first intersected.
I attempted to write it out algebraically... not sure if this is right:
D - distance between circles
T - time
C1/C2 - circle1/circle2

D =
Sqrt(
(C1.XOLD + T * (C1.XNEW - C1.XOLD) - (C2.XOLD + T * (C2.XNEW - C2.XOLD)))^2 +
(C1.YOLD + T * (C1.YNEW - C1.YOLD) - (C2.YOLD + T * (C2.YNEW - C2.YOLD)))^2
) - C1Radius - C2Radius

If that is correct, I'd probably have trouble rearranging it to make T the subject : /
let x1/2 be circle positions, r1/2 radii, v1/2 velocities

||x1+t.v1 - x2-t.v2||=r1+r2
||(x1-x2) + t(v1-v2)||=r1+r2
||x1-x2||^2 + t^2||v1-v2||^2 + 2t(x1-x2).(v1-v2) = (r1+r2)^2

and done. quadratic equation in t. solve for both values; choose minimum t value >= 0
Sorry I don't understand... how can I find out what time they collide if t isn't the subject?
It's a quadratic equation, whos solutions have been known for over a thousand years and is taught in high school ;)

at^2 + bt + c = 0 -> t = (-b +/- sqrt(b^2 - 4ac)) / 2a

here, a = ||v1-v2||^2, b = 2(x1-x2).(v1-v2), c = ||x1-x2||^2 - (r1+r2)^2
Ok I'll attempt to implement that, though I'd like to clarify...

Anything between || || is to be normalized, and the " 2(x1-x2).(v1-v2)" part is the (dot product between the two resulting vectors) * 2?
normalized, what no. ||x|| means the length of x

This topic is closed to new replies.

Advertisement