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 Repesentation 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

Matrix transforms are a ubiquitous aspect of 3D game programming. Yet it is surprising that game programmers do not often use a rigorous method for creating them or a common way of discussing them. Practitioners in the field of Robotics have mastered them long ago but these methods haven't made their way into daily practice among game programmers. Some of the many symptoms include models that import the wrong way and characters that rotate left when they are told to rotate right. So after a review of matrix conventions and notation, we'll introduce a useful naming scheme, a shorthand notation for transforms and tips for debugging them that will allow you to create concatenated matrix transforms correctly in much shorter time.

Matrix Representation of Transforms

Matrices represent transforms by storing the vectors that represent one reference frame in another reference frame. Figure 1 shows two 2D reference frames offset by a vector T and rotated relative to each. To represent frame one in the space of frame zero , we need the translation vector T, and the unit axis vectors X1 and Y1 expressed in the zero frame.





Figure 1: 2D Reference Frames offset and rotated from each other


We know that we need to store vectors in a matrix but now we have to decide how. We can either store them in a square matrix as rows or as columns. Each convention is shown below with the vectors expanded into their x and y components.


Figure 2: 2D Transform Stored as Columns

Figure 3: 2D Transform Stored as Rows

Each stores the same information so the question of which one is better will not be discussed. The difference only matters when you use them in a multiplication. Matrix multiplication is a set of dot products between the rows of the left matrix and columns of the right matrix. Figure 4 below shows the multiplication of two 3x3 matrices, A and B.


Figure 4: The First Dot Product in a Matrix Multiply

The first element in the product A times B is the row (a00, a01, a02) dotted with the column (b00, b10, b20). The dot product is valid because the row and the column each have three components. This dictates how a row vector and a column vector are each multiplied by a matrix.

A column vector must go on the right of the matrix.

A row vector must go on the left of the matrix.

In each convention, the vectors are represented consistently as rows or columns as one might expect but it is important to realize that the order changes. Again, we must switch the order because the rows on the left must be the same size as the columns on the right in order for the matrix multiplication to be defined.

You can convert between row and column matrices by taking the matrix transpose of either matrix. Here we show that the transpose of a column matrix is a row matrix.

______________________________________________________

Naming Scheme for Transform Matrices


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