logo back up home forward   further reading more topics »

Physics - Dynamics - Collision response

Results

The results for the one dimentional case (no rotation) are as follows: (see this page for code and derivation)

 

General Case (between Perfectly elastic and Perfectly inelastic)

coefficient of restitution e = (- ) / ( - )
impulse = (e+1)*(- )*
Final velocity of object a= = * +*(e+1)*
Final velocity of object b= = *(e+1)* +

The results for the two dimentional case are as follows: (see this page for code and derivation)

  General Case (between Perfectly elastic and Perfectly inelastic)
impulse =

Jx = (e+1)/k * (Vaix - Vbix)( 1/ma - rax2/Ia + 1/mb - rbx2/Ib) - (e+1)/k * (Vaiy - Vbiy) (rax ray / Ia + rbx rby / Ib)
Jy = - (e+1)/k * (Vaix - Vbix) (rax ray / Ia + rbx rby / Ib) + (e+1)/k * (Vaiy - Vbiy) ( 1/ma - ray2/Ia + 1/mb - rby2/Ib)

where:

k=1/ma2+ 2/ma mb +1/mb2 - rax2/maIa - rbx2/maIb - ray2/maIa - ray2/mbIa - rax2/mbIa - rbx2/mbIb - rby2/maIb - rby2/mbIb + ray2 rbx2/IaIb + rax2 rby2/IaIb - 2 rax ray rbx rby/IaIb

Final velocity of object a=af = Vaix - Jx/Ma
Vaiy - Jy/Ma
Final velocity of object b=bf = Vbix - Jx/Mb
Vbiy - Jy/Mb
Final angular velocity of object a=waf =

waix - (Jx ray - Jy rax) /I
waiy - (Jx ray - Jy rax) /I

Final angular velocity of object b=wbf = wbix - (Jx rby - Jy rbx) /I
wbiy - (Jx rby - Jy rbx) /I

 

The results for the three dimentional case are as follows: (see this page for code and derivation)

  General Case (between Perfectly elastic and Perfectly inelastic)
impulse = |J| = (e+1) * ( - ) / (1/Ma +n•([Ia]-1(n x ra)) x ra + 1/Mb +n•([Ib]-1(n x rb)) x rb)
Final velocity of object a=af = Vai - J/Ma
Final velocity of object b=bf = Vbi - J/Mb
Final angular velocity of object a=waf = wai - [Ia]-1(J x ra)
Final angular velocity of object b=wbf = wbi - [Ib]-1(J x rb)

Collision Response for unconstrained rigid bodies

As already explained here, When unconstrained rigid bodies are floating round in free space, perhaps under the influence of forces, then each object might be represented by a state vector like the following:

Dynamics state vector for an object:

θx
θy
θz
Px
Py
Pz
lx
ly
lz
mvx
mvy
mvz

These values might be gradually changing with time in a way that can be described by simple linear equations. This would go on until two or more objects collide, this produces a step change in these variables, a discontinuity or singularity, when an impulse is transferred between the two objects in an infinitesimally small time. When such a collision occurs we need to calculate the new state vectors for each object. To do this we need to gather the following information which describes the collision:

Collision parameters:

a reference to object a
b reference to object b
sva state vector for object a - 12 dimensional vector as above
svb state vector for object b - 12 dimensional vector as above
Newton-Euler matrix for object a
iaxx iaxy iaxz 0 -haz hay
iayx iayy iayz haz 0 -hax
iazx iazy iazz -hay hax 0
0 haz -hay ma 0 0
-haz 0 hax 0 ma 0
hay -hax 0 0 0 ma

This matrix is explaind here and combines the following information:

  • mass of object a
  • Inertia Tensor for object a (in the global coordinate system - so needs to be computed at the time of the collision)
  • offset of the point of collision from the centre of mass of object a - also needs to be calculated at the time of collision.
Newton-Euler matrix for object b
ibxx ibxy ibxz 0 -hbz hby
ibyx ibyy ibyz hbz 0 -hbx
ibzx ibzy ibzz -hby hbx 0
0 hbz -hby mb 0 0
-hbz 0 hbx 0 Mb 0
hby -hbx 0 0 0 Mb

As above for object b

n A normal vector (dimention 3), this is a normal to the point of collision and shows the direction that the impulse is transferred.
cfa, cfb Optional coefficient of friction for each object

Physics Assumptions

The following is an analytical approach to collisions, it assumes the collision occurs at a point contact between rigid objects. This means that the objects do not break or deform on collision. If these assumptions would cause too many errors, for instance modeling the deformations of a car in a crash, or if the analytical approach produces equations which are too complex then try a numerical approach to collisions.

The dynamics equations for a single object were covered in the previous page. Here we extend this analysis to two objects so that we can calculate the result of a collision between the objects. As explained in the previous page, we need to translate all values (inertia, force, movement, etc.) to world or common coordinates.

Linear momentum, angular momentum and energy is passed between the colliding shapes at the point of collision by means of impulse. Assuming that we know the velocities before the impact, and the point of impact, then one or more of the following might be used to help us calculate the velocities after the collision:

Also there are different outcomes depending on the properties of the objects colliding:

Other concepts:

Impulse is the integral of force over time, it is measured in Newton-seconds. For instance a force of one Newton applied over one second will change the momentum, a force of two Newton's applied over half of a second will have the same effect. For rigid body collisions we take this to its limit and apply an infinite force over an infinitesimally small time. This impulse is equal to the change in momentum of the colliding objects. Because we are talking about forces here, Newton's third law applies, and the impulse on the colliding objects will be equal and opposite.

Rotation

Once we start working in two and three dimensions, there is the possibility of rotation to include. This makes the general solution of a collision very difficult to work out (too difficult for me so far - but I'm working on it, can you help?). Rotation has similar laws to linear collisions, there are equivalents to Newtons laws for rotations and the total angular momentum of a system is conserved in the same way as linear momentum is conserved. However the following issues make the calculation of collision response difficult:

  • Lots more variables. In 3 dimensions there are 12 degrees of freedom, i.e. 12 variables to calculate, 3 linear for each object and 3 angular for each object.
  • When working with linear values in a Newtonian system there is a principal of 'relativity', i.e. velocities are measured relative to something else, or to put it another way, the frame of reference can be set relative to any of the objects in the system and all the rules will work correctly. In fact there are no absolute velocities, no frame of reference is better than any other. So we can travel on one of the traveling objects and calculate the response of the colliding object relative to it. In the case of a system with rotation then, there is an absolute frame of reference for rotation, this is the frame of reference where objects, with no forces acting on them, travel in straight lines. Otherwise, if we have a rotating frame of reference, say from the point of view of a person standing on a rotating planet will see a colliding object appearing to travel in a spiral. So Newtons laws do not appear to work in a rotating frame of reference.
  • There are other complications in a system of mixed linear and rotational movements, for example, the resultant velocities depend on the point of impact, i.e. have the objects collided head on, or is it a glancing collision.

Friction

In a complicated collision, then friction may be involved. However friction (as opposed to elasticity) is only involved if there is a force, such as gravity, pushing the colliding objects together.

 

Collisions in 3 dimensions is quite a complex problem, I'll start with 1 dimension first, then try to build up to 2 and then 3 dimensions.


Implementing this in program

One issue I would like to keep in mind through these pages is, how do we use this theory in the program? It is proposed to include information about these physical properties in the scene graph.

For information about how to use this in the program see dynamics tutorial.


Determining the impact point

We not only need to detect that there has been a collision, we also need to find the point of impact relative to the centres of mass so that we can pass this information on to the collision responce system.


Next Step and Further Reading

This page assumes that the collision has been detected in some way, this is discussed here.

To see how an algorithm for implementing collision responce of a solid object see here.

To see a proposal for a structure to hold this collision responce information see here.

Here is an off topic question, there seems to be 1 way an body can rotate in 2 dimensions and 3 ways that a body can rotate in 3 dimensions. How many ways could a body rotate in 4 dimensions?


metadata block
see also:

go to forces page

Correspondence about this page

Book Shop - Further reading.

Where I can, I have put links to Amazon for books that are relevant to the subject, click on the appropriate country flag to get more details of the book or to buy it from them.

cover Physics for Game Developers - Assumes a knowledge of vectors, Matrix and trigonometry (the book has a one page introduction to quatnions). The book introduces Newtons laws but it does assume a basic knowledge physics. It covers Kinematics, Force, Kinetics, Collision (detection), Projectiles, Aircraft, Ships, Hovercraft, Cars, Real-time, 2D rigid body, Collision Response, Rigid body rotation, 3D rigid body, multiple bodies in 3D and particles. (I cant find a general formula for collision response which combines linear and rotation, but there may be something in the code included?). If you don't have the prerequisite knowledge of Matrices etc. you may want to get the Mathematics for 3D Game programming book first.

cover Classical Dynamics of Particles and Systems - I have not reviewed this book, so I would be interested to hear if it is useful? I would also be interested to hear if there are any other books that may be of interest to readers of this page.

cover Engineering Mechanics - Includes Statics book and dynamics book below..

cover Engineering Mechanics Vol 2: Dynamics - Gives theory for rigid dynamics, aims to allow prediction of effects of force and motion. Includes rotating frame of reference. Lots of colour diagrams, I guess its college / University level.

 

Commercial Software Shop

Where I can, I have put links to Amazon for commercial software, not directly related to the software project, but related to the subject being discussed, click on the appropriate country flag to get more details of the software or to buy it from them.

 

The 3D Gamemaker

Can you help?

Please send me any improvements to here. I would appreciate ideas to make the pages more useful including error correction, ideas for new pages, improvements to wording. It helps if you quote the full URL of the page.

 

progam

I am working on a project which uses these principles, if you would like to help me with this you are welcome to join in, here:

http://sourceforge.net/projects/mjbworld/

This site may have errors. Don't use for critical systems.

Copyright (c) 1998-2008 Martin John Baker - All rights reserved - privacy policy.