Game Development Reference
In-Depth Information
Calculation of the inverse of an arbitrary matrix is a somewhat advanced topic, so
itis not covered in this topic.However,itisimportant toknowthatnotallmatrices
have an inverse, but in games a matrix with no inverse typically means a calcula-
tion has gone awry. Thankfully, the transformation matrices covered in Chapter 4
have inverses that are relatively straightforward to compute.
Transpose
A transpose of a matrix, denoted by T , takes each row of a matrix and converts it
to a corresponding column. So the first row becomes the first column, the second
row becomes the second column, and so on. Here is the transpose of a 3×3 matrix:
For certain types of matrices known as orthonormal matrices, the inverse of the
matrix is its transpose. Rotation matrices are one example of this type of matrix.
Transforming 3D Vectors by Matrices
In order to apply a matrix transformation to a vector, the two must be multiplied
together. But before multiplication can occur, the vector must first be represented
as a matrix. It turns out there are two potential ways to represent a vector as a mat-
rix: It could be a matrix with a single row or a matrix with a single column. These
representations are referred to as row-major and column-major , respectively.
Given the vector = 1, 2, 3, , the row-major matrix representation would be this:
Whereas the column-major representation would be this:
If you have a matrix that is intended to be multiplied with row-major vectors, but
instead want to multiply it by a column-major one, the matrix must be transposed.
Take a look at how a 3D vector is multiplied by a 3×3 matrix first in row-major
form and then in column-major form:
Search WWH ::




Custom Search