Circle-Circle collision intersection point
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?
Wouldn't they technically collide at a minimum of two points?
Edit: re-read it. Perhaps you mean at what time ??
Edit: re-read it. Perhaps you mean at what time ??
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.
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 : /
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
||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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement