Game Development Reference
In-Depth Information
useful, calculations. For example, in dynamics you'll often have to find a vector per‐
pendicular, or normal , to a plane or contacting surface; you use the cross-product op‐
eration for this task. Another common calculation involves finding the shortest distance
from a point to a plane in space; you use the dot-product operation here. Both of these
tasks are described in Appendix A , which we encourage you to review before delving
too deeply into the example code presented throughout the remainder of this topic.
Derivatives and Integrals
If you're not familiar with calculus, or The Calculus, don't let the use of derivatives and
integrals in this text worry you. While we'll write equations using derivatives and inte‐
grals, we'll show you explicitly how to deal with them computationally throughout this
book. Without going into a dissertation on all the properties and applications of deriv‐
atives and integrals, let's touch on their physical significance as they relate to the material
we'll cover.
You can think of a derivative as the rate of change in one variable with respect to another
variable, or in other words, derivatives tells you how fast one variable changes as some
other variable changes. Take speed, for example. A car travels at a certain speed covering
some distance in a certain period of time. Its speed, on average, is the distance traveled
over a specific time interval. If it travels a distance of 60 kilometers in one hour, then
its average speed is 60 kilometers an hour. When we're doing simulations, the ones you'll
see later in this topic, we're interested in what the car is doing over very short time
intervals. As the time interval gets really small and we consider the distance traveled
over that very short period of time, we're looking at instantaneous speed. We usually
write such relations using symbols like the following:
|v| = ds/dt
where v is the speed, ds is a small distance (a differential distance), and dt is a small,
differential, period of time. In reality, for our simulations, we'll never deal with infinitely
small numbers; we'll use small numbers, such as time intervals of 1 millisecond, but not
infinitely small numbers.
For our purposes, you can think of integrals as the reverse, or the inverse, of derivatives;
integration is the inverse of differentiation. The symbol ∫ represents integration. You
can think of integration as a process of adding up a bunch of infinitely small chunks of
some variable. Here again, we are not going to deal with infinitely small pieces of any‐
thing, but instead will consider small, discrete parcels of some variable—for example,
a small, discrete amount of time, area, or mass. In these cases, we'll use the ∑ symbol
instead of the integration symbol. Consider a loaf of bread that's sliced into uniformly
thick slices along its whole length. If you wanted to compute the volume of that loaf of
bread, you can approximate it by starting at one end and computing the volume of the
first slice, approximating its volume as though it were a very short, square cylinder; then