Game Development Reference
In-Depth Information
and finally the bank. As before, the object (and its points) are moving in
space, and we are using upright coordinates to measure everything. The
only difference is that we are starting with upright coordinates this time.
At the end of these rotations, the objects' body axes are aligned with the
upright axes, and the resulting coordinates are the object-space coordinates:
−1 P
−1 B
−1 = R y (−h) R x (−p) R z (−b)
M upright→object = H
Upright-to-object
rotation matrix from
Euler angles
2
3
chcb + shspsb −chsb + shspcb shcp
sbcp cbcp −sp
−shcb + chspsb sbsh + chspcb chcp
4
5
=
.
(8.15)
When we compare Equations (8.14) and (8.15), we see that the object-
to-upright matrix is indeed the transpose of the upright-to-object matrix,
as expected.
Also notice that we can think of the rotation matrices H
−1 , P
−1 , and
−1 either as the inverse matrices of their counterparts or as regular rota-
tion matrices using the opposite rotation angles.
B
8.7.2 Converting a Matrix to Euler angles
Converting an angular displacement from matrix form to Euler angle rep-
resentation entails several considerations:
We must know which rotation the matrix performs: either object-to-
upright, or upright-to-object. This section develops a technique using
the object-to-upright matrix. The process of converting an upright-
to-object matrix to Euler angles is very similar, since the two matrices
are transposes of each other.
For any given angular displacement, there are an infinite number
of Euler angle representations, due to Euler angle aliasing (see Sec-
tion 8.3.4) . The technique we present here always returns canonical
Euler angles, with heading and bank in the range ±180 o and pitch in
the range ±90 o .
Some matrices may be ill-formed, and so we must be tolerant of float-
ing point precision errors. Some matrices contain transformations
other than rotation, such as scale, mirroring, or skew. The technique
described here works only on proper rotation matrices, perhaps with
the usual floating point imprecision but nothing grossly out of or-
thogonality. If this technique is used on a non-orthogonal matrix, the
results are unpredictable.
 
Search WWH ::




Custom Search