PDA

View Full Version : Matrix Rotation



ComaWhite
08-01-2008, 01:44 AM
I was wondering how can I be able to perform multiple matrix rotations and get the same effect as doing each individually?
For example

Matrix world, rot;
world = rot.rotateX(56.5) * rot.rotateY(45.5);
glMultMatrixf(world.data();

instead of doing this

Matrix rot;
rot.rotateX(56.5);
glMultMatrixf(rot.data());
rot.rotateY(45.5);
glMultMatrixf(rot.data());

dletozeun
08-01-2008, 02:06 AM
Where is the problem?

And if I understand correctly what you do, you compute twice the same rotation around the X axis, then once a rotation around Y axis and finally multilply the modelview matrix by all these transformations.
Or maybe, I am wrong, and each call matrix.rotate* replace the current matrix.

Zengar
08-01-2008, 10:51 AM
Well, you just have to perform matrix multiplication! If you don't know how, consult google...

ComaWhite
08-01-2008, 08:11 PM
Yeah I know how to do matrix multiplication. But if I do it that way, it rotations but bounces in and out. The only way was to break it into seperate parts