Game Development Reference
In-Depth Information
vectors won't matter. However, in Section 4.1.7 we discuss why in certain
circumstances the distinction is critical.
When we wish to refer to the individual components in a vector, we use
subscript notation. In math literature, integer indices are used to access
the elements. For example v 1 refers to the first element in v . However, we
are specifically interested in 2D, 3D, and 4D vectors rather than vectors of
arbitrary dimension n, so we rarely use this notation. Instead, we use x
and y to refer to the elements in a 2D vector; x, y, and z to refer to the
elements in a 3D vector; and x, y, z, and w to refer to the elements in a
4D vector. This notation is shown in Equation (2.1).
1
2
a 1 = a x = 1
a 2 = a y = 2
Vector subscript
notation
a =
2
3
3
4
5
b 1 = b x = 3
b 2 = b y = 4
b 3 = b z = 5
4
5
b =
(2.1)
2
4 6
3
c 1 = c x = 6
c 2 = c y = 7
c 3 = c z = 8
c 4 = c w = 9
5
7
8
9
c =
Notice that the components of a 4D vector are not in alphabetical order.
The fourth value is w. (Hey, they ran out of letters in the alphabet!)
Now let's talk about some important typeface conventions that are used
in this topic. As you know, variables are placeholder symbols used to stand
for unknown quantities. In 3D math, we work with scalar, vector, and
(later) matrix quantities. In the same way that it's important in a C++
or Java program to specify what type of data is stored by a variable, it
is important when working with vectors to be clear what type of data is
represented by a particular variable. In this topic, we use different fonts for
variables of different types:
Scalar variables are represented by lowercase Roman or Greek letters
in italics: a, b, x, y, z, θ, α, ω, γ.
Vector variables of any dimension are represented by lowercase letters
in boldface: a , b , u , v , q , r .
Matrix variables are represented using uppercase letters in boldface:
A , B , M , R .
Search WWH ::




Custom Search