memecs
August 17, 2009, 2:14pm
1
hello everyone, i got a problem with rotation matrices multiplication and i hope someone could help me tofigure that out…
So say that i want to perform a sequence of rotation in order xyz. Since opengl pre-multiplied it means that it’s multiplying in this way:
Rz * Rx * Ry
now i’ve implemented the matrix Rz * Ry * Rx on my own and it looks exactly like the xyz matrix in the Matrix Table at the bottom of this link:
http://en.wikipedia.org/wiki/Euler_angles
comparing the two rotations i figured out that this matrix perform the following opengl sequence of rotation:
glRotated(az,0,0,1)
glRotated(ay,0,1,0)
glRotated(ax,1,0,0)
How is this possible? Where am I wrong?
thanks a lot
I don’t know, but you can find out for yourself.
Just print it out and see what it looks like:
float M[16];
glGetFloatv( GL_MODELVIEW, M );
memecs:
So say that i want to perform a sequence of rotation in order xyz. Since opengl pre-multiplied it means that it’s multiplying in this way:
Rz * Rx * Ry
now i’ve implemented the matrix Rz * Ry * Rx on my own and it looks exactly like the xyz matrix in the Matrix Table at the bottom of this link … comparing the two rotations i figured out that this matrix perform the following opengl sequence of rotation:
glRotated(az,0,0,1)
glRotated(ay,0,1,0)
glRotated(ax,1,0,0)
How is this possible? Where am I wrong?
Do what sammie381 says and you’ll probably figure it out yourself.
My guess is you’re forgetting OpenGL is column-major storage order and C++ is row-storage order.
Keep in mind that pre-multiply with column-major storage order results in exactly the same resulting matrices as post-multiply with row-major storage order.