Understanding Collision Scenarios in Physics-based Game Development

  • Thread starter Thread starter Ruddiger
  • Start date Start date
  • Tags Tags
    Collision
AI Thread Summary
Understanding collision scenarios in physics-based game development involves grasping concepts like elastic and inelastic collisions, which dictate how momentum is transferred between colliding objects. In elastic collisions, objects exchange momentum, while inelastic collisions result in objects sticking together and moving at a reduced speed. The coefficient of restitution, which varies based on the materials involved, determines the elasticity of the collision and influences how momentum is transferred. For 3D scenarios, velocity vectors should be split into parallel and perpendicular components to calculate momentum transfer accurately. Incorporating rotation adds complexity, and resources like "Physics for Game Developers" by David M. Bourg can provide deeper insights into these calculations.
Ruddiger
Messages
7
Reaction score
0
I'm trying to implement some physics in a game I'm coding and need help with understanding some basic concepts. I have two ships in space of different size and mass. Can somebody please explain to me how to determine what happens when the two ships collide? How do I know if when A collides with B: A might stop completely and move B, or A might move B and keep moving at a slower rate, or A might move B and bounce in the opposite direction?

I don't know if this seems like a silly question or not but I would appreciate any help anyone can give. Thanks!
 
Physics news on Phys.org
So, if I undertand this right, in an elastic collision the two objects basically exchange each others momentum so that no matter how massive object A is, if it hits a stationary object B, A will become stationary and launch B with its momentum? But in an inelastic collision the two objects will always "stick" and travel together at a lesser speed? I'm guessing my scenario is inelastic?
 
The collision will conserve momentum. However, you have to choose yourself how quickly the ships separate from one another after the collision, by saying for example whether the ship's shields crumple to absorb some of the impact energy (sticking together in the most extreme case) or whether they explode releasing further energy (or neither, which is the elastic case).
 
The maths can become a little challeging, but (barely) manageable.

If you model the ships as two balls and consider their velocity components parallel to the line of action (line connecting their centers at point of impact)

u_1,\ m_1,\ u_2,\ m_2

assuming no friction. You could set up two equations to solve for their final parallel velocity components

v_1,\ v_2

by considering momentum conservation parallel to the line of action:

m_1 u_1 - m_2 u_2 = m_2 v_2 - m_1 v_1

this assumes a + velocity component direction directed along u_1.

Another equation is obtained by assuming a coefficient of restitution between the two ships

0 \leq e \leq 1

where 0 will give you an inelastic collision and 1 a perfectly elastic collision. To set up the equation you use the fact that

e = \frac{relative\ speed\ of\ separation}{relative\ speed\ of\ approach}

which again will involve just the velocity components parallel to the line of action. Between these two equations you can then solve for

v_1,\ v_2

The velocity components of the ships perpendicular to the line of action will then not be changed as a result of the collision.
 
Last edited:
Ok, this is starting to make some sense now. So the coefficient of restitution controls the elasticity of a collision. Is it safe to say that it represents a ratio dictating how much the mass of the objects will influence the transfer of momentum? Is this coefficient constant between two objects, or does it vary based on other factors?

Also, for a 3D scenario, do I split the velocity vectors into parallel and perpendicular components (to the line of action, right?), perform these calculations to transfer momentum on the parallel components and then add back the unmodified perpendicular components?

And finally (sorry if I'm asking too much), how drastically do things change if the ships are moving AND rotating around their centers of mass? Is there some preliminary way of adding the rotation to the translation of the ships and still perform the same calculations?

Thanks a lot for your help thus far guys!
 
The coeff of restitution is determined by the two materials and descibes how much the relative motion of the two colliding objects will be altered.

Yes the procedure will be the same for 3D. The velocity components (and therefore the momentum) in a plane perpendicular to the line of action will be unaltered by the collision.

If you consider rotation also things gets more complicated.

Maybe you should try and get "Physics for game developers" by David M. Bourg. His book is mathematically advanced (with DirectX collision simulations in 3D). Although I did find some errors in his maths, but the simulations look realistic. The first chapter can put one off a bit since he discusses things like inertia tensors, but the maths are very neat and not that bad at all. I bought a secondhand copy from Amazon (it was brand new - I guess the game programmer gave it one look and was totally overwhelmed by the maths and send it back, but as I said it is really not that bad and quite understandable if you put the effort in and work through it).

The example code is available at

http://examples.oreilly.com/physicsgame/"
 
Last edited by a moderator:
Made some slight changes to previous post.
 
Thanks andrevdh, that might be the best way to go about it. I'll look through the sample programs and maybe get the book you suggested.
 
  • #10
As soon as one moves into 3D the maths gets quite advanced. But Bourg keeps it quite neat and organized - even his C++ programming is clear. Work through the book and post here for some help.
 
Back
Top