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

Robert Osfield robert.osfield at gmail.com
Thu Sep 4 07:34:09 PDT 2008


HI Matthias,

On Thu, Sep 4, 2008 at 12:36 PM, Matthias Bindernagel
<matthias.bindernagel at gmx.de> wrote:
> On the page is stated that one should load a column-major-matrix with
> glLoadMatrixf(). And then there's this example given:
>
>  | cosA  -sinA   0    0 |
>  | sinA   cosA   0    0 |
>  | 0        0    1    0 |
>  | 0        0    0    1 |
>
> GLfloat ZrotateMatrix[][4] = {
>       { cosA, -sinA, 0, 0 },
>       { sinA,  cosA, 0, 0 },
>       {    0,  0,    1, 0 },
>       {    0,  0,    0, 1 }
> };
>
> Which is, in fact, a row-major-matrix (to make it column-major one must swap
> sinA and -sinA). Afterwards is it argumented that the actual outcome does
> not match the desired one - which cannot happen, if you pretend to pass a
> column-major-matrix, but actually pass a row-major-matrix.
>
> My problem with this erroneous example is that its assumed correctness is
> the foundation for the whole following argumentation.

OK, re-reading the C code, yes it does look wrong - this is where the
documented OpenGL column major convention is confusing... because in
memory it's not column major at all, its row major in memory.  The
code you highlight is correct for the OSG - where the C array ordering
is exactly the same as the way you'd write the matrix.  The same is
true for vectors - in C you'd write them float v[3]={x,y,z};  But of
course the OpenGL documentation would have this vector transposed into
a column vector.

It might be best to have this page re-written.  I'm not the original
author, and if fact this is the first time I've read this particular
page.  Perhaps others with better teaching skills can dive in a fix
this page.

Robert.



More information about the osg-users mailing list