Game Development Reference
In-Depth Information
F IGURE 2.1
Three-dimensional coordinates.
as scalars, including multiplication, addition, and subtraction (although the way they
do these is slightly different from scalars, and the result isn't always another vector;
Note that a vector in this sense, and throughout most of this topic, refers only to
this mathematical structure. Many programming languages have a vector data struc-
ture which is some kind of growable array. The name comes from the same source
(a set of values rather than just one), but that's where the similarities stop. In partic-
ular most languages do not have a built-in vector class to represent the kind of vector
we are interested in. On the few occasions in this topic where I need to refer to a grow-
able array, I will call it that, to keep the name “vector” reserved for the mathematical
concept.
One convenient application of vectors is to represent coordinates in space. Fig-
ure 2.1 shows two locations in 3D space. The position can be represented by three
coordinate values, one for the distance from a fixed origin point along three axes at
right angles to one another. This is a Cartesian coordinate system, named for the
mathematician and philosopher Rene Descartes who invented it.
We group the three coordinates together into a vector, written as
x
y
z
=
a
where x , y ,and z are the coordinate values along the X, Y, and Z axes. Note the a
notation. This indicates that a is a vector: we will use this throughout the topic to
make it easy to see what is a vector and what is just a plain number.