Game Development Reference
In-Depth Information
expected transformation occurs, and the result is another point-at-infinity
vector of the form [x
′
,y
′
,z
′
,0].
When we transform a point-at-infinity vector by a transformation that
does contain translation, we get the following result:
2
4
r
11
r
12
r
13
0
3
5
Multiplying a “point at
infinity” by a 4 × 4
matrix WITH translation
r
21
r
22
r
23
0
r
31
r
32
r
33
0
∆x ∆y ∆z 1
x y z 0
=
xr
11
+yr
21
+zr
31
xr
12
+yr
22
+zr
32
xr
13
+yr
23
+zr
33
0
.
Notice that the result is the same—that is, no translation occurs.
In other words, the w component of a 4D vector can be used to selec-
tively “switch off” the translation portion of a 4 × 4 matrix. This is useful
because some vectors represent “locations” and should be translated, and
other vectors represent “directions,” such as surface normals, and should
not be translated. In a geometric sense, we can think of the first type of
data, with w = 1, as “points,” and the second type of data, the “points at
infinity” with w = 0, as “vectors.”
So, one reason why 4×4 matrices are useful is that a 4×4 transformation
matrix can contain translation. When we use 4 × 4 matrices solely for this
purpose, the right-most column of the matrix will always be [0,0,0,1]
T
.
Since this is the case, why don't we just drop the column and use a 4 × 3
matrix? According to linear algebra rules, 4 × 3 matrices are undesirable
for several reasons:
•
We cannot multiply a 4 × 3 matrix by another 4 × 3 matrix.
•
We cannot invert a 4 × 3 matrix, since the matrix is not square.
•
When we multiply a 4D vector by a 4 × 3 matrix, the result is a 3D
vector.
Strict adherence to linear algebra rules forces us to add the fourth col-
umn. Of course, in our code, we are not bound by linear algebra rules. It
is a common technique to write a 4 × 3 matrix class that is useful for repre-
senting transformations that contain translation. Basically, such a matrix
is a 4 × 4 matrix, where the right-most column is assumed to be [0,0,0,1]
T
and therefore isn't explicitly stored.
6.4.3 General Affine Transformations
Chapter 5 presented 3 × 3 matrices for many primitive transformations.
Because a 3 × 3 matrix can represent only linear transformations in 3D,
Search WWH ::
Custom Search