PDA

Chuffy_345
02-09-2004, 03:10 AM
Hi guys

I'm pretty new to OpenGL and am having problems with a program I'm writing. I'm trying to simulate a 3D collision with 2 spheres and so far I've got the whole detection thing working i.e. the point of contact. Now I need to work out the direction both spheres will go in after the collision. I've got the point of contact, velocity vectors etc but I'm not sure what to do next in regards to the angles and direction they'll travel in.

Any ideas on what to do? Or maybe a book or web site that could help me out?

Cheers

02-09-2004, 02:54 PM
I assume the collision is elastic, ie there is no loss of kinetic energy.

The spheres at this touching position you describe are tangent to the plane which contains the point of contact and is perpendicular to the line connecting the centres of the balls. You can take advantage of the symmetry of the problem here.

This tangent plane defines an axis system. Analyse the velocities of the balls right before the impact on these axes. Each velocity vector then will have two components on the tangent plane and one component along the plane's normal. The collision will only affect whatever lies on this normal axis (joining the two centres as mentioned). I'll call this axis x, don't confuse this with the world's x axis.

Now, you only have to apply 1-d collision using the x-components of the balls' velocities. If the balls have the same mass, this is the easy case, and I'll tell you the answer right away, their velocities will just 'exchange' their x components. Their other two components will remain the same after the collision.

Getting the answer for the case where the masses are different is not difficult, you have to apply conservation of momentum and conservation of kinetic energy.

Any college physics textbook should give you enough on 1-d collisions. Also, google is as always quite revealing, for example
http://www.director-online.com/buildArticle.php?id=460

just popped up in a matter of second, under 'collision 1d physics online'. See also
http://scienceworld.wolfram.com/physics/Collision.html

There are a couple of books out lately presenting physics for games ex.

Physics for Game Developers, Bourg (ed. O'Reilly)

I'm not particularly fond of these books, but I have to admit, they come quite handy sometimes and have enough to get you started. But then again, so do all those online (and free) resources, for instance

http://scienceworld.wolfram.com/ http://www.gamedev.net http://www.flipcode.com

Hope this helps