# Physics - Dynamics - Collision response

Here we are looking at the collision of rigid objects and how to calculate the response. There are a number of theoretical and practical issues that we need to consider, on this page we will start looking at the equations we get in collisions with combined rotation and linear motion, subpages look at the two and three dimensional cases in more detail. The way that momentum is transferred by an impulse is discussed on this page.

On this page we discuss more about the practical factors such as:

• Whether we model the deformation of the objects or whether we assume solid body collisions.
• What assumptions we make about elasticity coefficient and energy converted to heat.
• What assumptions we make about friction and how objects slide.
• How we handle multiple points of contact and simultaneous collisions.

There is no right answer to these questions, it depends on factors like: what we want to do, what accuracy do we need, how much computer power do we have, how stable must the simulation be and what type of materials are we dealing with.

## Combined Rotation and Movement with a Linear Motion

It is difficult to analyse the situation when the colliding objects are free to both rotate and move with a linear motion. The main method we will use to do this involves the following stages.

1. Determine the collision point and the normal direction at this point.
2. Calculate the minimum impulse to prevent the objects intersecting, or to
reverse the approach velocity, depending on the coefficient of friction.
3. Calculate the effect of this impulse on the rotation and linear motion
separately.

This involves a lot of assumptions and approximations that may not always be valid, we need to understand what is going on to be sure that our simulations or programs are making the correct assumptions and that the results will be stable and accurate enough.

This method is based on the concept of an 'impulse' which is an instantaneous transfer of momentum between the objects. This is not intuitively obvious and I think its worth taking some time to rid ourselves of our natural misconceptions. The collision may involve an exchange of energy between the objects but the impulse is about momentum not energy, this distinction means:

• Momentum is a vector quantity in which all the dimensions are independent and the linear dimensions are independent of the rotational dimensions.
• Linear momentum and rotational momentum for a closed system are conserved independently, that is, linear momentum cannot be converted to rotational momentum and visa versa. Energy can be converted into other forms.
• The component of momentum in each dimension for a closed system is conserved independently, that is, the x component of momentum cannot be converted to, or from, the y component of momentum. Again energy can be converted into other forms.
• The whole of the impulse causes changes the linear momentum and rotational momentum, it is not that part of the impulse applies to linear momentum and the rest applies to rotational, all the impulse applies to both. In the case of energy we can ascribe part of the energy to the linear motion and another part to the rotational motion and energy can be transferred between them.

This last point is difficult for people to understand, it took me a long time for me to realise this and I have found that many other people have problems with it. This seems like something for nothing, the same impulse doing two jobs, but its not. The impulse just exchanges momentum between two objects and the same impulse can transfer the two types of momentum. Its not the same as energy and it works completely differently.

If you would like to see a practical example of this see this page (sent to me by Kevin Pegrume) which demonstrates this and highlights some of the counter intuitive issues.

## Results

Here are equations for calculating the components of impulse (J) then the equations to use this to calculate the new velocities. This is just an overview, the definitions and derivations are given on the individual pages for the one, two and three cases:

The results for the one dimensional 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 dimensional 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 dimensional case are as follows: (see this page for code and derivation)

General Case (between Perfectly elastic and Perfectly inelastic)
impulse J =
 -(1+e) (va-vb)•n + (ra×n)•ωa - (rb×n)•ωb 1/ma+1/mb+(ra×n)•([Ia]-1(ra×n))+(rb×n)•([Ib]-1(rb×n))
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

Until now we have kept the rotation and linear components separate, it would be good if we could combine them into a single set of equations, I can think of two approaches: here we combine them using vectors and matrices. I would also like to try an approach using geometric algebra and conformal space but I have not made any progress with yet.

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 (dimension 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:

• Conservation of momentum - The total momentum of the whole system will be conserved. The momentum is a vector quantity so in the 3D case it is conserved in whatever x,y and z axis we choose.
• Conservation of energy - The total energy of the whole system will be conserved, but energy may be converted between kinetic energy and other types of energy. So we need to make assumptions about this. In a perfectly elastic collision then the kinetic energy is conserved, in an inelastic collision some of the energy associated with the approaching objects may be converted to heat.
• Calculation of Impulse - The impulse could be calculated which would allow us to work out the change in velocity of both objects.

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

• If the objects are perfectly elastic, they will absorb the kinetic energy of the collision as potential energy (like a spring) and then instantly convert it back to kinetic energy, so that the objects bounce off each other with a separating velocity equal and opposite to the approaching velocity.
• If the objects are perfectly inelastic, they will stick together and the final velocities of the two objects will be equal. In this case the total kinetic energy will be reduced and some energy will be converted into heat or other forms of energy.
• The objects may be somewhere in-between these two extremes. So we could introduce an elasticity factor for each colliding object which would give final velocities somewhere between these two extremes. Another complication is that this factor might be different in different dimensions, for instance objects may collide and slide against each other, so friction may also need to be taken into account.

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 response 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 response of a solid object see here.

To see a proposal for a structure to hold this collision response 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: 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. 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. 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. Engineering Mechanics - Includes Statics book and dynamics book below.. 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

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

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