Circles – How to Calculate Angle of Reflection Off a Circle

circlescollision detectionreflection

I've made simple 2D games in the past using mostly just squares. If an object collided with another object (all squares/rectangles) it would just change the slope to the opposite based on what side it hit.

If the object was moving at a slope of 1/1 and it hit the right wall, it would just change the slope to 1/-1. A similar example is demonstrated in this image:

enter image description here

Problem is, now I want to work with circles:

enter image description here

Specifically, I want circles bouncing off of circles. I can determine collisions between the two easily. Problem is, a circle theoretically has an infinite number of sides. Knowing only the slope of the object colliding (assume the second circle is static and wont react to the collision), how can I figure out the new slope of the circle?

Thanks!

Best Answer

If you draw the radius of the circle to the point of contact, the tangent is perpendicular to the radius. You can use that tangent as a flat surface to bounce off of, so the two angles you have drawn go from the green arrows to the tangent line and are equal. The problem is quite ill-conditioned. A small error in locating the impact point will make an error in the angle you calculate, which will propagate to the next collision with a lever arm of the free path. Maybe the ill conditioning doesn't matter too much for your application.

Related Question