637
As we saw in Equation (12.3), force is a function of time, position, and velocity
in general:
r()t Fr r, (), ().
m
=^1 ()t^ t t (12.18)
This clearly qualifi es as an ODE. We wish to solve this ODE in order to fi nd
v(t) and r(t).
12.4.3.3. Analytical Solutions
In some rare situations, the diff erential equations of motion can be solved ana-
lytically , meaning that a simple, closed-form function can be found that de-
scribes the body’s position for all possible values of time t. A common example
is the vertical motion of a projectile under the infl uence of a constant accelera-
tion due to gravity, a(t) = [ 0, g, 0 ], where g = –9.8 m/s^2. In this case, the ODE
of motion boils down to
yt()=g.
Integrating once yields
y t()=+gt v 0 ,
where v 0 is the vertical velocity at time t = 0. Integrating a second time yields
the familiar solution
y t()= ++^12 gt^2 v t 00 y,
where y 0 is the initial vertical position of the object.
However, analytical solutions are almost never possible in game physics.
This is due in part to the fact that closed-form solutions to some diff erential
equations are simply not known. Moreover, a game is an interactive simula-
tion, so we cannot predict how the forces in a game will behave over time. This
makes it impossible to fi nd simple, closed-form expressions for the positions
and velocities of the objects in the game as functions of time.
12.4.4. Numerical Integration
For the reasons cited above, game physics engines turn to a technique known
as numerical integration. With this technique, we solve our diff erential equa-
tions in a time-stepped manner—using the solution from a previous time step
to arrive at the solution for the next time step. The duration of the time step is
usually taken to be (roughly) constant and is denoted by the symbol Δt. Given
that we know the body’s position and velocity at the current time t 1 and that
the force is known as a function of time, position, and/or velocity, we wish to
fi nd the position and velocity at the next time step t 2 = t 1 + Δt. In other words,
given r(t 1 ), v(t 1 ), and F(t, r, v), the problem is to fi nd r(t 2 ) and v(t 2 ).
12.4. Rigid Body Dynamics