collision response with spin in 2D

Started by
0 comments, last by orbano 19 years, 2 months ago
Hello I'm writing a simple 2D ball bouncing simulation with gravity and the ability to bounce off any line segments drawn on the screen. I'm hoping to develop it into a bounce juggling simulator once a get the basic physics right. Here's the exe and source code (Delphi) http://atlas.walagata.com/w/peterbone/ball_bounce.zip . The ball can be thrown by dragging with the left mouse button and surfaces can be drawn by dragging with the right mouse button. I worked out how to do the collision detection and physics myself so I'm not sure it's the best way of doing it but it seems to work well. Here's how it works (skip this paragraph and go to the question at the end if you don't care). It loops through all the surfaces and works out if it's moving towards the surface by doing a dot product with the surface normal and the ball velocity direction. If it's going towards the surface it then works out if it has crossed the surface, since the balls previous position, by using a fast line crossing test (the 2 lines being the surface and the line connecting the ball to its previous position). If it has collided with the surface it calculates the new velocity by reversing the component of the velocity perpendicular to the surface and multiplies it by the restitution. The *position* of the ball is also updated since it has gone beyond the surface. This is done by calculating the intersection and reversing the overshoot in the same way the velocity was updated. Sorry for the long explaination, but does that sound anything like the way it should be done? My main question is, how can I incorporate the spin of the ball into the collision response? I think it must be fairly complex because the spin effects the direction of the ball after the collision and the collision effects the spin. Thanks for any help and sorry if this question has been asked numerous times before. Peter Bone
Advertisement
Hi there!

Your collision detection seems to be ok. Simulating the effect of the spin on the collision is quite complex. Of yourse you can cheat. In your system, the collision takes no time (it takes 0 secs). In the real world the balls sticks to the surface, and becouse of its spin, it applies a force to the surface, perpendicular to the contact (now the surface) normal. It depends on a lot of things. The balls mass, speed, elasticity, a contact coefficient (i dont know physics terms in english). Becouse your simulation does not take these values into count, you have to cheat, if you dont want to deal with ball friction. You have to add an extra vector to the velocity. This one is parallel to the surface, its sign is the same as te velocity vector's parallel component, and propotional to the relative speed of the ball and the surface, elasticity, mass and the so called contact coefficient. If you apply gravity, you have to take it into count too (the bigger the contact force between the ball and the surface is, the bigger the influence of the spin will be).
I think you will have to work it out yourself.
Hope i could help :)
"Knowledge is no more expensive than ignorance, and at least as satisfying." -Barrin

This topic is closed to new replies.

Advertisement