Game Development Reference
In-Depth Information
experiences a drag force that has some (potentially nonlinear) relationship
with the relative velocity of the body and the fluid. Furthermore, the forces
can be the result of interactions between bodies (e.g., four bodies connected
by springs forming a tetrahedron, with one corner submerged in water). In
short, the problem is not trivial.
The mathematical term for this is numerical integration. There are two
main parts to our discussion. This section ignores rotation and discusses
the basic concepts of integration in terms of linear acceleration and velocity.
Section 12.6.4 considers how to integrate angular acceleration and velocity.
Recall that integration is the process of determining a function from
its derivative. In our case, we are working with three different functions
of time: position, velocity, and acceleration. A reader who was not asleep
will remember that velocity is the derivative of position and acceleration
is the derivative of velocity. We are dealing with numerical integration
because we are not symbolically solving the differential equations. Instead,
the derivative function that we know (the acceleration, determined using
Newton's second law from the force) is being sampled only at a discrete
number of time values. To appreciate the di culties, we begin with a naıve
approach and see where it fails.
Let h denote our step size in seconds (1/h is the simulation frequency,
so, for example, if we were running at 60 Hz, h would be 1/60). The
simplest method of integration is to assume that the derivative is constant
during the step. Assume that the current time step is the kth time step.
Then the position for the next time step, k + 1, is determined by
Euler integration of
velocity into position
p k+1 = p k + h v k .
This strategy is known as Euler integration. Although numerical integration
may be an “advanced” subject often taught after calculus, Euler integration
is easier for most people to understand than true (analytic) integration. It is
common practice to use Euler integration to introduce analytic integration,
which is exactly what we did in Figure 11.10 to determine the movement of
a rabbit, although we didn't call the technique by its name. The key point
that was brought out was that simple Euler integration ignores changes in
the derivative during the time step, and this is the source of error. As we
saw, the most obvious way to reduce the error in the answer is to decrease
the step size h. In some cases, we can decrease it to the limit through
symbolic manipulations and arrive at a perfect answer (i.e., we use analytic
integration). But sometimes we have a complicated function and all we can
do is evaluate (“sample”) the function.
Consider three different simulations currently of interest in video games:
hair, cloth, and fluid. In each case, we break up the thing being simulated
into pieces (“discretize” the problem), and then simulate each piece using
Search WWH ::




Custom Search