Game Development Reference
In-Depth Information
Notice that it doesn't matter which point we call a and which point we
call b . If we define d to be the vector from b to a instead of from a to b ,
we will derive a slightly different, but mathematically equivalent, equation.
2.11
Vector Dot Product
Section 2.6 showed how to multiply a vector by a scalar. We can also
multiply two vectors together. There are two types of vector products. The
first vector product is the dot product (also known as the inner product),
the subject of this section. We talk about the other vector product, the
cross product, in Section 2.12.
The dot product is ubiquitous in video game programming, useful in
everything from graphics, to simulation, to AI. Following the pattern we
used for the operations, we first discuss the algebraic rules for computing
dot products in Section 2.11.1, followed by some geometric interpretations
in Section 2.11.2.
The dot product formula is one of the few formulas in this topic worth
memorizing. First of all, it's really easy to memorize. Also, if you under-
stand what the dot product does, the formula makes sense. Furthermore,
the dot product has important relationships to many other operations, such
as matrix multiplication, convolution of signals, statistical correlations, and
Fourier transforms. Understanding the formula will make these relation-
ships more apparent.
Even more important than memorizing a formula is to get an intuitive
grasp for what the dot product does. If there is only enough space in your
brain for either the formula or the geometric definition, then we recommend
internalizing the geometry, and getting the formula tattooed on your hand.
You need to understand the geometric definition in order to use the dot
product. When programming in computer languages such as C++, HLSL,
or even Matlab and Maple, you won't need to know the formula anyway,
since you will usually tell the computer to do a dot product calculation not
by typing in the formula, but by invoking a high-level function or overloaded
operator. Furthermore, the geometric definition of the dot product does
not assume any particular coordinate frame or even the use of Cartesian
coordinates.
2.11.1 Official Linear Algebra Rules
The name “dot product” comes from the dot symbol used in the notation:
a
b . Just like scalar-times-vector multiplication, the vector dot product
is performed before addition and subtraction, unless parentheses are used
to override this default order of operations. Note that although we usually
 
Search WWH ::




Custom Search