Game Development Reference

In-Depth Information

chapter up with several showing you how to implement both 2D and 3D rigid-body

simulations.

Integrating the Equations of Motion

By now you should have a thorough understanding of the dynamic equations of motion

for particles and rigid bodies. If not, you may want to go back and review
Chapter 1

through
Chapter 4
before reading this one. The next aspect of dealing with the equations

of motion is actually solving them in your simulation. The equations of motion that

we've been discussing can be classified as ordinary differential equations. In
Chap‐

ter 2
and
Chapter 4
, you were able to solve these differential equations explicitly since

you were dealing with simple functions for acceleration, velocity, and displacement.

This won't be the case for your simulations. As you'll see in later chapters, force and

moment calculations for your system can get pretty complicated and may even rely on

tabulated empirical data, which will prevent you from writing simple mathematical

functions that can be easily integrated. This means that you have to use numerical in‐

tegration techniques to approximately integrate the equations of motion. We say
ap‐

proximately
because solutions based on numerical integration won't be exact and will

have a certain amount of error depending on the chosen method.

We're going to start with a rather informal explanation of how we'll apply numerical

integration because it will be easier to grasp. Later we'll get into some of the formal

mathematics. Take a look at the differential equation of linear motion for a particle (or

rigid body's center of mass):

F = m dv/dt

Recall that this equation is a statement of force equals mass times acceleration, where
F

is force,
m
is mass, and
dv
/
dt
is the time derivative of velocity, which is acceleration. In

the simple examples of the earlier chapters of this topic, we rewrote this equation in the

following form so it could be integrated explicitly:

dv/dt = F/m

dv = (F/m) dt

One way to interpret this equation is that an infinitesimally small change in velocity,

dv
, is equal to (
F
/
m
) times an infinitesimally small change in time. In earlier examples,

we integrated explicitly by taking the definite integral of the left side of this equation

with respect to velocity and the right side with respect to time. In numerical integration

you have to take finite steps in time, thus
dt
goes from being infinitely small to some

discrete time increment, ∆
t
, and you end up with a discrete change in velocity, ∆
v
:

∆v = (F/m) ∆t