Game Development Reference

In-Depth Information

In this case, the first truncated term, ((∆
t
)
2
/
2
!)
v
''(
t
), dominates the truncation error,

and this method is said to have an error of order (∆
t
)
2
.

Geometrically, Euler's method approximates a new value, at the current step, for the

function under consideration by extrapolating in the direction of the derivative of the

function at the previous step. This is illustrated in
Figure 7-1
.

Figure 7-1. Euler integration step

Figure 7-1
illustrates the truncation error and shows that Euler's method will result in

a polygonal approximation of the smooth function under consideration. Clearly, if you

decrease the step size, you increase the number of polygonal segments and better ap‐

proximate the function. As we said before, though, this isn't always efficient to do since

the number of computations in your simulation will increase and round-off error will

accumulate more rapidly.

To illustrate Euler's method in practice, let's examine the linear equation of motion for

the ship example of
Chapter 4
:

T - (C v) = ma

where
T
is the propeller's thrust,
C
is a drag coefficient,
v
is the ship's velocity,
m
its mass,

and
a
its acceleration.

Figure 7-2
shows the Euler integration solution, using a 0.5s time step, superimposed

over the exact solution derived in
Chapter 4
for the ship's speed over time.