Game Development Reference
In-Depth Information
Even though we used the linear equation of motion for a particle, this integration tech‐
nique (and the ones we'll show you later) applies equally well to the angular equations
of motion.
Euler's Method
The preceding explanation of Euler's method was, as we said, informal. To treat Euler's
method in a more mathematically rigorous way, we'll look at the Taylor series expansion
of a general function, y ( x ). Taylor's theorem lets you approximate the value of a function
at some point by knowing something about that function and its derivatives at some
other point. This approximation is expressed as an infinite polynomial series of the
form:
y(x + ∆x) = y(x) + (∆x) y'(x) + ((∆x) 2 / 2!) y''(x) + ((∆x) 3 / 3!)
y'''(x) + · · ·
where y is some function of x , (x + ∆ x ) is the new value of x at which you want to
approximate y , y ' is the first derivative of y , y '' is the second derivative of y , and so on.
In the case of the equation of motion discussed in the preceding section, the function
that you are trying to approximate is the velocity as a function of time. Thus, you can
write v ( t ) instead of y ( x ), which yields the Taylor expansion:
v(t + ∆t) = v(t) + (∆t) v'(t) + ((∆t) 2 / 2!) v''(t) + ((∆t) 3 / 3!) v'''(t)
+ · · ·
Note here that v '( t ) is equal to dv / dt , which equals F / m in the example equation of motion
discussed in the preceding section. Note also that you know the value of v at time t .
What you want to find is the value of v at time t + ∆ t knowing v at time t and its derivative
at time t . As a first approximation, and since you don't know anything about v 's second,
third, or higher derivatives, you can truncate the polynomial series after the term (∆ t )
v '( t ), which yields:
v(t + ∆t) = v(t) + (∆t) v'(t)
This is the Euler integration formula that you saw in the last section. Since Euler's for‐
mula goes out only to the term that includes the first derivative, the rest of the series
that was left off is the truncation error . These terms that were left off are called higher-
order terms , and getting rid of them results in a first-order approximation. The rationale
behind this approximation is that the further you go in the series, the smaller the terms
and the less influence they have on the approximation. Since ∆ t is presumed to be a
small number, ∆ t 2 is even smaller, ∆ t 3 even smaller, and so on, and since these ∆ t terms
appear in the numerators, each successively higher-order term gets smaller and smaller.