Game Development Reference
In-Depth Information
vector
v
. The product
vX
results in a new transformed vector
v
.For
example, if
X
represented a 10-unit translation on the x-axis and
v
=
[2, 6, -3, 1], the product
vX
=
v
= [12, 6, -3, 1].
A few things need to be clarified. We use 4
4 matrices because
that particular size can represent all the transformations that we need.
A3
3 may at first seem more suitable to 3D. However, there are many
types of transformations that we would like to use that we cannot
describe with a 3
3 matrix, such as translations, perspective projec-
tions, and reflections. Remember that we are working with a vector-
matrix product, and so we are limited to the rules of matrix
multiplication to perform transformations. Augmenting to a 4
4 matrix
allows us to describe more transformations with a matrix and the
defined vector-matrix multiplication.
We said that we place the coordinates of a point or the components
of a vector into the columns of a 1
4 row vector. But our points and
vectors are 3D! Why are we using 1
4 row vectors? We must augment
our 3D points/vectors to 4D row vectors in order to make the vector-
matrix product defined—the product of a 1
3 row vector and a 4
4
matrix is
not
defined.
So then, what do we use for the fourth component, which, by the
way, we denote as
w
? When placing
points
ina1
4 row vector, we set
the
w
component to 1. This allows translations of points to work cor-
rectly. Because vectors have no location, the translation of vectors is
not defined, and attempting to translate a vector results in a meaning-
less vector. In order to prevent translation on vectors, we set the
w
component to 0 when placing
vectors
into a 1
4 row vector. For exam-
ple, the point
p
=(
p
1
,
p
2
,
p
3
) would be placed in a row vector as
[
p
1
,
p
2
,
p
3
, 1], and the vector
v
=(
v
1
,
v
2
,
v
3
) would be placed in a row
vector as [
v
1
,
v
2
,
v
3
, 0].
Note:
We set
w
= 1 to allow points to be translated correctly, and
we set
w
= 0 to prevent translations on vectors. This is made clear
when we examine the actual translation matrix.
Note:
The augmented 4D vector is called a
homogenous
vector and
because homogeneous vectors can describe points and vectors, we use
the term “vector,” knowing that we may be referring to either points or
vectors.
Sometimes a matrix transformation we define changes the
w
compo-
nent of a vector so that
w
0 and
w
1. Consider the following:
Search WWH ::
Custom Search