Rahat Ahmed
Rahat Ahmed

Reputation: 2180

How do you calculate direction of velocity of a circle bouncing off another static circle?

I've got code for two moving circles to bounce off each other properly, but when applying the same code for the situation where one of the two moving circles is static and does not move, the moving circle seems to orbit the static one. How can I fix this?

Upvotes: 0

Views: 1017

Answers (2)

trashgod
trashgod

Reputation: 205785

The article 2-Dimensional Elastic Collisions offers a vector approach to the problem. In particular, "The tangential components of the velocities are not changed by the collision because there is no force along the line tangent to the collision surface. The normal components of the velocities undergo a one-dimensional collision," which conserves momentum and kinetic energy. There's a Java implementation here.

Upvotes: 2

corsiKa
corsiKa

Reputation: 82579

If you have code for a circle bouncing off a wall, you can approximate it by finding the line that would be tangent to the static circle at the point of contact between the circles and pretending the moving circle bounced off a wall that runs along that line.

Upvotes: 3

Related Questions