Understanding Collision Scenarios in Physics-based Game Development

  • Thread starter Ruddiger
  • Start date
  • Tags
    Collision
In summary, the collision between two objects will result in the objects exchanging momentum and conserving energy. It is possible to calculate the collision between two objects using the laws of physics. If the objects are moving and rotating, the collision will be more complicated to calculate.
  • #1
Ruddiger
7
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
  • #3
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?
 
  • #4
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).
 
  • #5
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)

[tex]u_1,\ m_1,\ u_2,\ m_2[/tex]

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

[tex]v_1,\ v_2[/tex]

by considering momentum conservation parallel to the line of action:

[tex]m_1 u_1 - m_2 u_2 = m_2 v_2 - m_1 v_1[/tex]

this assumes a + velocity component direction directed along [tex]u_1[/tex].

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

[tex] 0 \leq e \leq 1[/tex]

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

[tex]e = \frac{relative\ speed\ of\ separation}{relative\ speed\ of\ approach}[/tex]

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

[tex]v_1,\ v_2[/tex]

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:
  • #6
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!
 
  • #7
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:
  • #8
Made some slight changes to previous post.
 
  • #9
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.
 

1. What is a collision scenario?

A collision scenario is a situation in which two or more objects, such as vehicles or particles, come into contact with each other and transfer energy or momentum.

2. How can I calculate the force of a collision?

The force of a collision can be calculated by using the formula F=ma, where F is the force, m is the mass of the object, and a is the acceleration.

3. What factors can affect the outcome of a collision?

The outcome of a collision can be affected by factors such as the speed and direction of the objects, the mass and size of the objects, and the type of material the objects are made of.

4. How can I reduce the impact of a collision?

To reduce the impact of a collision, you can increase the distance between the objects, decrease the speed of the objects, or use materials that are designed to absorb or deflect the impact.

5. What are the safety measures to take in a collision scenario?

In a collision scenario, it is important to wear appropriate safety gear, follow traffic laws and signals, maintain a safe distance from other objects, and stay alert and focused while operating vehicles or machinery.

Similar threads

  • Introductory Physics Homework Help
Replies
2
Views
1K
  • Introductory Physics Homework Help
Replies
4
Views
1K
  • Introductory Physics Homework Help
Replies
9
Views
1K
  • Introductory Physics Homework Help
Replies
6
Views
2K
  • Introductory Physics Homework Help
Replies
20
Views
2K
  • Introductory Physics Homework Help
Replies
6
Views
727
  • Introductory Physics Homework Help
Replies
3
Views
2K
  • Introductory Physics Homework Help
Replies
17
Views
3K
  • Introductory Physics Homework Help
Replies
25
Views
831
  • Introductory Physics Homework Help
Replies
2
Views
1K
Back
Top