Game Development Reference
In-Depth Information
The standard example of a force is gravity, F grav = m g , which draws us to
the Earth. There is also the normal force that counteracts gravity and keeps us
from sinking through the ground. The thrust of a rocket, an engine moving a car
along—these are all forces.
There can be multiple forces acting on an object. To manage these, we take
the sum of all forces on an object and treat the result as a single force in our
equations:
F =
j
F j .
1.6.2 Nonconstant Forces
Equation (1.4) is suitable when our forces are constant across the time interval we
are considering. However, in many cases, our forces are dependent on position or
velocity. For example, we can represent a spring force based on position,
F spring =
k x ,
or a drag force based on velocity,
F drag =
v .
And as position and velocity will be changing across our time interval, our forces
will as well.
One solution is to try and find a closed analytical solution, but (a) such a
solution may not be possible to find and (b) the solution may be so complex
that it is impractical to compute every frame. In addition, this constrains us to a
single set of forces for that solution, and we would like the flexibility to apply and
remove forces at will.
Instead, we will use a numerical solution. The problem we are trying to solve
is this: we have a physical simulation with a total force dependent generally on
time, position, and velocity, which we will represent as F ( t, x , v ).Wehavea
position x ( t )= x 0 and a starting velocity v ( t )= v 0 . The question is, what is
x ( t + h )?
One solution to this problem is to look at the definition of a derivative. Recall
that
x ( t + h )
x ( t )
x ( t ) = lim
h→ 0
.
h
For the moment, we will assume that h is sufficiently small and obtain an approx-
imation by treating h as our time step.
Rearranging terms, we get
= x ( t )+ h x ( t ) ,
x ( t + h )