638 12. Collision and Rigid Body Dynamics
12.4.4.1. Explicit Euler
One of the simplest numerical solutions to an ODE is known as the explicit
Euler method. This is the intuitive approach oft en taken by new game program-
mers. Let’s assume for the moment that we already know the current velocity
and that we wish to solve the following ODE to fi nd the body’s position on
the next frame:
vr()t=().t (12.4)
Using the explicit Euler method, we simply convert the velocity from meters
per second into meters per frame by multiplying by the time delta, and then
we add “one frame’s worth” of velocity onto the current position in order to
fi nd the new position on the next frame. This yields the following approxi-
mate solution to the ODE given by Equation (12.4):
r rv() () () .tt^211 =+t^ Δt (12.5)
We can take an analogous approach to fi nd the body’s velocity next frame
given the net force acting this frame. Hence, the approximate explicit Euler
solution to the ODE
is as follows:
(12.6)
Interpretations of Explicit Euler
What we’re really doing in Equation (12.5) is assuming that the velocity of the
body is constant during the time step. Therefore, we can use the current velocity
to predict the body’s position on the next frame. The change in position Δr be-
tween times t 1 and t 2 is hence Δr = v(t 1 ) Δt. Graphically, if we imagine a plot of the
position of the body versus time, we are taking the slope of the function at time
Δr
Δt
t
r(t 1 )
rapprox(t 2 )
r(t 2 )
r(t)
t 1 t 2
slope
ΔΔrt= v(t 1 )
Figure 12.23. In the explicit Euler method, the slope of r(t) at time t 1 is used to linearly
extrapolate from r(t 1 ) to an estimate of the true value of r(t 2 ).
a()t F ()t v()
m
==net t
vv() ()t 21 =+t Fnetm()t^1 Δt.