Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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!

share|improve this question

2 Answers 2

up vote 5 down vote accepted

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.

share|improve this answer
    
Alright, I'm going to go try this now. I can't believe I didn't think of finding the tangent myself. Thanks! –  Xan Nov 12 '11 at 2:26

you can figure the contact point (radius weighted average of the centers)

and you can take the line perpendicular to the line from that point to the center as your contact face

or

$M_s, r_s$ is the center and radius of the static circle and $M_c, r_c$ are the same for the colliding circle with $\vec v$ the speed of the colliding circle

$P = \frac{M_s*r_s+M_c*r_c}{r_s+r_c}$ is the colliding point

and thus $\vec v' = \vec v - 2(\vec v*\vec{M_sP})*\vec{M_sP}$ is the new speed (assuming no energy loss)

you should normalise $\vec{M_sP}$ first though

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.