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

A Naming Scheme for Transform Matrices

In the first section we defined a matrix transform (figures 2 and 3) from reference frame 1 to reference frame 0 by expressing the vectors of frame 1 in frame 0. Let's name it M1to0 to make the reference frames it transforms between explicit. When we start to introduce new reference frames, as in figure 5, this name will be very handy.


Figure 5: Introducing a third reference frame (2) and a point P2 in that frame.

These frames could represent the successive joints of a robot arm or an animation skeleton. Suppose the problem is to find P2 in the space of the zero frame. We'll call this point P0. We can now write out the answer to this problem using our naming scheme for matrices, keeping in mind the order of multiplication between row vectors and matrices and column vectors and matrices.

Column Convention

P1 = M2to1 * P2
P0 = M1to0 * P1

Substituting P1 into the equation for P0:

P0 = M1to0 * M2to1 * P2

We have been consistent with the way column vectors are multiplied with matrices by keeping the column vectors to the right of the transform matrices.

Row Convention

P1 = P2 * M2to1
P0 = P1 * M1to0

P0 = P2 * M2to1 * M1to0

We have been consistent with the way row vectors are multiplied with matrices by keeping the row vectors to the left of the transform matrices.

So the problem has been reduced to finding the transform matrices, and already we have accomplished a lot. We established a convention for naming points in space by the reference frame that they are in (P0, P1). We named matrices for the reference frames that they transform between (M1to0, M2to1). And finally, we leveraged the naming scheme to write out a mathematical expression for the correct answer. There is no ambiguity regarding the order of the matrices or which matrices we need to find.


Figure 6: Reference Frames with T offset vectors shown.

Figure 6 shows the translation vectors between the frames. With the new information in the figure, we can plug into the matrices from figures 1 and 2 to get the needed transform matrices.

Column Convention

P0 = M1to0 * M2to1 * P2

  




Row Convention

P0 = P2 * M2to1 * M1to0

  



Thus we have solved the problem of finding point P0 given P2.

If we reversed the problem and needed to find point P2 given point P0 we could solve it using the same method. We would quickly find that we need the matrices M0to1 and M1to2 and we can get them using matrix inversion.

M0to1 = (M1to0)-1
M1to2 = (M2to1)-1

Again, we write the equation for P2 given P0, M1to0, and M2to1 by allowing the naming scheme to guide the order of the matrix concatenation.

Column Convention
P2 = M1to2 * M0to1 * P0
P2 = (M2to1)-1 * (M1to0)-1 * P0

Row Convention

P2 = P0 * M0to1 * M1to2
P2 = P0 * (M1to0)-1 * (M2to1)-1
Another way to write those equations is by multiplying the matrices first. Matrix multiplication is not communative (meaning you can't switch the order of the factors) but it is associative (meaning you can regroup the factors with parentheses). We can take the row equation:

P2 = P0 * M0to1 * M1to2

And group the matrices together to illustrate the naming scheme for concatenated matrices.

P2 = P0 * (M0to1 * M1to2)

P2 = P0 * M0to2

So when multiplying matrices together using this naming scheme you just chain the reference frame names together.

M0to2 = M0to1 * M1to2

These matrix derivations make excellent comments in the code that can save the person who reads your code lots of time.

______________________________________________________
Simplified Math Notation


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