It's free to join Gamasutra!|Have a question? Want to know who runs this site? Here you go.|Targeting the game development market with your product or service? Get info on advertising here.||For altering your contact information or changing email subscription preferences.
Registered members can log in here.Back to the home page.

Search articles, jobs, buyers guide, and more.

By Scott Johnson
Gamasutra
[Author's Bio]
May 17, 2002

Matrix Representation of Transforms

Naming Scheme for Transform Matrices

Simplified Math Notation

Interpreting Concatenated Matrix Transforms

Printer Friendly Version
   


Game Developer Magazine Back Issues 3 CD-ROM Set. Every issue from 1994 to April 2001.
Price: $149.00 + S&H

Letters to the Editor:
Write a letter
View all letters


Features

Complex Matrix Transformations

Simplified Math Notation for Matrix Concatenations

The following is the component wise matrix multiplication for two 3x3 matrices and it is big.

The multiplication of two 4x4 matrices is even bigger. It is already a large bulky expression with just two matrices. No one ever gained any insight into matrix concatenation of transform matrices by looking at the product expressed by each component. Instead we'll substitute algebraic variables for the sections of a transform in order to come up with a much more intuitive notation.

These are the components of a 4x4 column transform matrix:

The upper left 3x3 portion is a rotation and the far right column forms the translation. Let's simplify the matrix by making some definitions.




Now we can represent the 4x4 matrix as a 2x2 matrix:


Working with 2x2 matrix multiplication is much easier.

It is easy enough to do by hand. It is just four dot products between the rows on the left and the columns on the right. In the coming notation, many of the multiplications will be with one or zero so that will make it even easier.

Up to this point, we haven't dealt with scale but it is easy enough to add.

This new notation allows us to study the effects of combining rotation, translation, and scale by combining building blocks for each one. Figure 7 defines a 2x2 rotation matrix that is really a representation of a 4x4 transform matrix. Likewise, Figure 8 defines a 2x2 scale matrix that represents a 4x4 transform matrix.

Figure 7: A 2x2 rotation matrix that represent a 4x4 transform

Figure 8: A 2x2 scale matrix that represents a 4x4 transform

This notation is not concerned with whether R has rows or columns in it so the R matrix (Figure 7) is the same in both row and column conventions. S is a diagonal matrix so its 2x2 matrix (Figure 8) is the same in both row and column conventions. The 2x2 matrix for translation must change based on the row/column convention to reflect the location of the translation in the full 4x4 transform.

Column Convention (T is a column):


Row Convention (T is a row):


Figure 9: 2x2 Translation matrix that represents a 4x4 transform


Now we have the building blocks and we can start combining them. Let's start with a simple translation and rotation, change the order of multiplication and see what we can learn from it.

Column Convention

With translation on the left and rotation on the right we get the familiar M1to0 matrix, represented as a 2x2.



Switching the factors yields an entirely different result. The rotation, R, is the same, but the translation portion of the right hand side shows that R has rotated the translation.

Row Convention

In order to get the familiar M1to0 row matrix, we need to put rotation on the left of the translation.

The other way around results in a rotated translation.

Now that the differences in the notation between row and column conventions have been shown, we'll only show the column convention to avoid repeating the same point.

The column transform for figure 6 is shown below. The change is that we have to distinguish between the different rotations and translations by naming them differently with subscripts.

Now we experiment with scale. If we tack a scale matrix factor on the right of the product we get:

Right away you can see that the scale does not affect the translation (upper right portion of the product) at all because S doesn't appear in it. This makes sense because with columns, the full transform equation with points P0 and P5 included would look like this,

and it is just as though P5 was scaled and then the rest of the transform occurred afterwards. The given point was named P5 because each matrix is considered a transform from one space to another.

If the scale is introduced on the left,

then every term in the result is scaled, as you might expect. There are countless combinations to explore. The notation makes it easier to form a complex transform from intuitive simple pieces.

It is easy to multiply 2x2 matrices by hand but it gets very tedious to repeat. Instead, you can enter any of the above symbolic expressions into Mathematica, MathCad, or Maple V and the product is computed for you. Math programs take some effort to learn but your investment will be paid back many times over.

______________________________________________________
Interpreting Concatenated Matrix Transforms


join | contact us | advertise | write | my profile
news | features | companies | jobs | resumes | education | product guide | projects | store



Copyright © 2003 CMP Media LLC

privacy policy
| terms of service