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 t开发者_如何学JAVAhe 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?
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.
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.
精彩评论