Game Development Reference
In-Depth Information
grapple with rotation matrices. We don't expect that everyone will agree
with our assertions, but we hope that every reader will at least appreciate
the value in considering these issues.
Certainly every good math library will have a 3 × 3 matrix class that
can represent any arbitrary transformation, which is to say that it makes
no assumptions about the value of the matrix elements. (Or perhaps it is a
4×4 matrix that can do projection, or a 4×3 which can do translation but
not projection—those distinctions are not important here.) For a matrix
like this, the operations inherently are in terms of some input coordinate
space and an output coordinate space. This is just implicit in the idea of
matrix multiplication. If you need to go from output to input, then you
must obtain the inverse of the matrix.
It is common practice to use the generic transform matrix class to de-
scribe the orientation of an object. In this case, rotation is treated just like
any other transformation. The interface remains in terms of a source and
destination space. Unfortunately, it is our experience that the following
two matrix operations are by far the most commonly used: 2
Take an object-space vector and express it in upright coordinates.
Take an upright-space vector and express it in object coordinates.
Notice that we need to be able to go in both directions. We have no
experience or evidence that either direction is significantly more common
than the other. But more important, the very nature of the operations
and the way programmers think about the operations is in terms of “object
space” and “upright space” (or some other equivalent terminology, such as
“parent space” and “child space”). We do not think of them in terms of a
source space and a destination space. It is in this context that we wish to
consider the question posed at the beginning of this section: Which matrix
should we use?
First, we should back up a bit and remind ourselves of the mathemati-
cally moot but yet conceptually important distinction between orientation
and angular displacement. (See the notes on terminology at the end of
Section 8.1.) If your purpose is to create a matrix that performs a specific
angular displacement (for example, “rotate 30 degrees about the x-axis”),
then the two operations above are not really the ones you probably have
in your head, and using a generic transform matrix with its implied direc-
tion of transformation is no problem, and so this discussion does not apply.
2 We are measuring frequency of use based on how many times the operation is coded,
not how often it is executed at run time. For example, transforming vertices through the
graphics pipeline is certainly an extremely commonly used matrix operation, but there
are relatively few lines of code that do this operation. This has proven to be true in
a wide variety of game genres, such as racing, combat, 3D board games, and shooters,
although, of course, we cannot speak for everyone's work environment.
Search WWH ::




Custom Search