Monday, March 5, 2007

How To Name Transformation Matrices

A transformation matrix is a function for converting a point or vector from one coordinate system to another. Unfortunately people tend to name matrices after only the source or the destination coordinate system which only tells half the story.

Matrices come in two forms depending on whether they are multiplied by row or column vectors. Naturally, both are commonly used.

Direct3D uses the row-vector form, which means the vector is multiplied on the left of the matrix. In this case, name your matrices source-to-destination, where source is the input vector’s coordinate system and destination is the output vector’s coordinate system. For instance, a typical render pipeline might have matrices named modelToWorld, worldToView, and viewToScreen.

OpenGL uses the column-vector form, which means the vector is multiplied on the right of the matrix. In this case, name your matrices destination-from-source, where destination is the output vector’s coordinate system and source is the input vector’s coordinate system. For instance, a typical render pipeline might have matrices named screenFromView, viewFromWorld, and worldFromModel.

Once matrices are named in this manner, multiplying them together in the correct order is a simple matter of connecting matching coordinate systems. Concatenations of the matrices listed above would look like this:

Row-vector form: modelToScreen = modelToWorld * worldToView * viewToScreen;

Column-vector form: screenFromModel = screenFromView * viewFromWorld * worldFromModel;

2 comments:

Anonymous said...

thanks

Anonymous said...

Genial post and this mail helped me alot in my college assignement. Say thank you you seeking your information.