Game Engine Architecture

(Ben Green) #1

154 4. 3D Math for Games


Not all matrices have inverses. However, all affi ne matri-
ces (combinations of pure rotations, translations, scales, and shears) do have
inverses. Gaussian elimination or LU decomposition can be used to fi nd the
inverse, if one exists.
Since we’ll be dealing with matrix multiplication a lot, it’s important to
note here that the inverse of a sequence of concatenated matrices can be writt en
as the reverse concatenation of the individual matrices’ inverses. For example,
(ABC)–1 = C–1^ B–1^ A–1.

4.3.5. Transposition
The transpose of a matrix M is denoted MT. It is obtained by refl ecting the en-
tries of the original matrix across its diagonal. In other words, the rows of the
original matrix become the columns of the transposed matrix, and vice-versa:

The transpose is useful for a number of reasons. For one thing, the inverse
of an orthonormal (pure rotation) matrix is exactly equal to its transpose—
which is good news, because it’s much cheaper to transpose a matrix than it is
to fi nd its inverse in general. Transposition can also be important when mov-
ing data from one math library to another, because some libraries use column
vectors while others expect row vectors. The matrices used by a row-vector-
based library will be transposed relative to those used by a library that employs
the column vector convention.
As with the inverse, the transpose of a sequence of concatenated matrices
can be rewritt en as the reverse concatenation of the individual matrices’ trans-
poses. For example,
(ABC)T = CT^ BT^ AT.
This will prove useful when we consider how to apply transformation matri-
ces to points and vectors.

4.3.6. Homogeneous Coordinates
You may recall from high-school algebra that a 2 × 2 matrix can represent a
rotation in two dimensions. To rotate a vector r through an angle of φ degrees
(where positive rotations are counter-clockwise), we can write

AA()() .−−^11 ≡≡A A I


cos sin
[][]rr rrxy xysin cos.

⎡⎤φφ
′′= ⎢⎥−φ φ
⎣⎦

T

.

abc adg
de f
g h i c f i

⎡ ⎤⎡ ⎤


⎢ ⎥⎢= ⎥


⎢ ⎥⎢ ⎥


⎢⎣ ⎥⎢⎦⎣ ⎥⎦


b eh
Free download pdf