650 12. Collision and Rigid Body Dynamics
The orientation quaternion q(t) should be renormalized periodically to reverse
the eff ects of the inevitable accumulation of fl oating-point error.
As always, the explicit Euler method is being used here just as an ex-
ample. In a real engine, we would employ velocity Verlet, RK4, or some other
more-stable and more-accurate numerical method.
12.4.7. Collision Response
Everything we’ve discussed so far assumes that our rigid bodies are neither
colliding with anything, nor is their motion constrained in any other way.
When bodies collide with one another, the dynamics simulation must take
steps to ensure that they respond realistically to the collision and that they
are never left in a state of interpenetration aft er the simulation step has been
completed. This is known as collision response.
12.4.7.1. Energy
Before we discuss collision response, we must understand the concept of en-
ergy. When a force moves a body over a distance, we say that the force does
work. Work represents a change in energy—that is, a force either adds energy
to a system of rigid bodies (e.g., an explosion) or it removes energy from the
system (e.g., friction). Energy comes in two forms. The potential energy V of a
body is the energy it has simply because of where it is relative to a force fi eld
such as a gravitational or a magnetic fi eld. (For example, the higher up a body
is above the surface of the Earth, the more gravitational potential energy it
has.) The kinetic energy of a body T represents the energy arising from the
fact that it is moving relative to other bodies in a system. The total energy
E = V + T of an isolated system of bodies is a conserved quantity, meaning that
it remains constant unless energy is being drained from the system or added
from outside the system.
The kinetic energy arising from linear motion can be writt en
Tlinear=^12 mv^2 ,
or in terms of the linear momentum and velocity vectors:
Tlinear=⋅^12 pv.
Analogously, the kinetic energy arising from a body’s rotational motion is as
follows:
Energy and its conservation can be extremely useful concepts when solving
all sorts of physics problems. We’ll see the role that energy plays in the deter-
mination of collision responses in the following section.
Tangular=⋅^12 Lω.