PDA

View Full Version : simple circle circle collision detection


kfour31
Dec30-07, 03:00 AM
hi all,
I am testing the collision detection between two circle using classic the distance < sumRadius.

now i need help to detect the penetration of circles and to resolve the penetration before

collision reaction

Doc Al
Dec30-07, 08:22 AM
Can you be clearer about what you are asking? Seems that you are trying to detect whether two circles are overlapping and how far they overlap. Do you have a physics-related question? A math question?

kfour31
Dec30-07, 09:25 AM
ya i need to detect
1. how far they are overlapping
2. and need to pull back the circles to the correct position(ie just touching each other, need to avoid overlap)

thanx in advance

Doc Al
Dec30-07, 09:31 AM
I'm still unclear as to what you need. (In your first post it sounded like you knew how to determine when two circles overlap.) When you say that you "need to detect" how far they overlap, what are you given? Is this a math question? I don't quite see the physics question yet.

Astronuc
Dec30-07, 09:41 AM
Is this a matter of find the point where two circles of different radii (diameters) are tangent? If this is like a scattering problem, then one input would be the impact parameter which is the shortest distance between the parallel lines passing between the centers of the circles. Those lines would also be parallel to the velocity of the circle which is approaching the other.

kfour31
Dec30-07, 09:49 AM
thanks for showing interest,

Let me explain, i am detecting collision between two moving circles, i know their X,Y, and radius.
so in each frame i am checking this condition
distance_between_circles <= sum_of_their_radii then collision occurs,

when the circles are moving really fast enough, it skips frames and the collision is detected after one circles penetrates half the other,

so at the time of collision i don't know which direction the ball came from and collided.

1.i need to move the circles so that they can just touch each other (not penetrated)

thats it

PhilEH
Aug1-08, 12:13 PM
I'm no physicist but the problem isn't that hard to figure out. What you want to do is rotate one of the circles around the other circle by the angle between their two center points. Once you do that, they are then lying on the x axis. From there you can perform any calculations you want on them then when you're done, just rotate them back. If your using velocities, you'll have to rotate them too. It's easier to think of this problem in one dimension.

Hope this helps, and hope it's not too late.