# Simple circle circle collision detection

1. Dec 30, 2007

### kfour31

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

2. Dec 30, 2007

### Staff: Mentor

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?

3. Dec 30, 2007

### kfour31

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)

4. Dec 30, 2007

### Staff: Mentor

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.

5. Dec 30, 2007

### Astronuc

Staff Emeritus
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.

Last edited: Dec 30, 2007
6. Dec 30, 2007

### kfour31

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

7. Aug 1, 2008

### PhilEH

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.