Game Development Reference
It will be useful at several points in the engine to transpose rather than request a
full inverse when we know the matrix is a rotation matrix only.
There is no point implementing a transpose function for the 3
doesn't have a geometric correlate: transposing a homogeneous matrix doesn't make
sense geometrically. If there is any non-zero element in the fourth column, then it
will be transposed into the fourth row, which we don't have in our matrix.
This makes sense: we will only use transposition to do cheap inverses on rotation
matrices. If the 3
4 were a pure rotation matrix with no translation, then it would
have zeros in its fourth column. If this were the case, we could represent it as a 3
There are other reasons to transpose a matrix, outside of our needs. If you are
working with an existing matrix library with a full 4
4 matrix implementation, it is
likely to have a transpose function.
C ONVERTING A Q UATERNION TO A M ATRIX
In addition to matrix manipulation, we'll need an operation to convert a quaternion
to a matrix. Your graphics engine is likely to need transformations expressed as a
matrix. In order to draw an object we'll need to convert from its position vector and
orientation quaternion into a transform matrix for rendering.
Sometimes we'll want just the rotation matrix in its 3
3 form, and other times
we'll want the full transformation matrix. In each case the conversion from a quater-
nion to a matrix uses the results we saw in sections 9.2.3 and 9.2.4, where both the
quaternion and the rotation matrix were expressed in terms of an axis and an angle.
We could reconstruct the axis and angle from the quaternion and then feed it
into equation 9.3. If we do this, we can simplify out the axes and angles and find an
expression for the matrix purely in terms of the coefficients of the quaternion
( 2 y 2
2 z 2 )
( 2 x 2
2 z 2 )
− ( 2 x 2
2 y 2 )
where w , x , y ,and z are the components of the quaternion