[osg-users] Correction of wikipage Support/Maths/MatrixTransformations

Matthias Bindernagel matthias.bindernagel at gmx.de
Wed Sep 3 11:19:47 PDT 2008


on the page
is stated that one should

>pass this matrix
>GLfloat ZrotateMatrix[][4] = {
>      { cosA, -sinA, 0, 0 },
>      { sinA,  cosA, 0, 0 },
>      {    0,  0,    1, 0 },
>      {    0,  0,    0, 1 }
>to glLoadMatrixf(): and see what happens (g'ahead try it, don't take my word 
for it).
>Your rotations will be the opposite of what you expect.

Well, the correctness of the result depends on what you expect: OpenGL's 
glLoadMatrixf() and its variants expect a column-major-matrix as parameter 
(see http://www.opengl.org/sdk/docs/man/xhtml/glLoadMatrix.xml); passing a 
row-major-matrix (like done in this example) to glLoadMatrixf() results in a 
transformation described by the transposed matrix-argument. Same holds true 
for the translation described later on the wiki page.

So the results of the allegedly erroneous examples are actually correct, 
regarding the OpenGL documentation and standard maths.

Another point I want to mention here is my surprise about the argumentation of 
the matrix-vector-product in OSG:
Almost every book or website I've read about computer graphics in general and 
some DSL's in particular uses 
V' = M * V
on a broad basis, where V' is the transformed vector, V is the original vector 
and M descibes the trafo. 

One could - like the documentation did - replace this commonly used matrix 
product with W' = W * N, but (at least in my opinion) _must_ mention that:
1. W' and W are transposed vectors (that is, they are row vectors, instead of 
widely used column vectors)
2. N must not be a common transformation matrix (like the ones mentioned on 
wikipedia or mathworld.wolfram.com), but the transpose of such a matrix.

IMHO, the documentation found on that wiki page does need some slight 
corrections, but also a lot of additions to clearly state when to use 
original or transposed transformation matrices.

Regards, Matthias Bindernagel

More information about the osg-users mailing list