matrix normalization?

hi!

once again a matrix problem

i am multiplying lots of rotation matrices, and after a
while my rotations dont look as i think they should!

i once read somewhere, matrices should be normalized every
once in a while when multiplying them with each other …
is that true? and could that be the reason for my problems?

and, if i have to do that, does anyone have a link
on HOW to normalize a 4x4 matrix??


sebastian

I see no reason to normalize a matrix every so often…

What kind of a problem do you get that you think it is unexpected??? Post some code and explain a bit of the problem.

Miguel Castillo

Hi !

One possibility is that you do a lot of incremental rotations and a matrix, if the matrix is also using floats, then you might get some pretty severe errors after a while.

The other thing is that you mess up the matrix, if rotate around one axis, then a little around another axis, and then again a little on the first axis, it’s not the old axis any longer and you start to get unpected results.

Mikael

very nice hints, thats what i seem to experience. but what could i do against it??

seb

Originally posted by mancha:
What kind of a problem do you get that you think it is unexpected??? Post some code and explain a bit of the problem.

its a conceptional question, no code needed here.

the problems i experience are that i rotate around x, then around y, then try to rotate back into original position, but when i am back in original orientation, my angles ares not 0/0.

seb

Best to use glPushMatrix and glPopMatrix.

glMatrixMode(GL_MODELVIEW);
glPushMatrix();//matrix pushed onto stack - saved
glRotate(…);
glTranslate(…);
glRotate(…);

draw something

glPopMatrix();//saved matrix popped off stack exactly as it was

And there is a limit to the number of matrices pushed onto stack. Use glGet with GL_MODELVIEW_STACK_DEPTH for modelview stack and GL_PROJECTION_STACK_DEPTH for projection stack to find the limits. There are many other useful state variables (100s maybe - takes up 30 pages in the blue book) that you can get information about through glGet.

[This message has been edited by shinpaughp (edited 03-08-2003).]

Floating point is a b-atch at times… As shinpaughp said, use glPush() and glPop().
Regardless, always expect floating point error, it is normal.

Originally posted by SebastianB:
[b]its a conceptional question, no code needed here.

the problems i experience are that i rotate around x, then around y, then try to rotate back into original position, but when i am back in original orientation, my angles ares not 0/0.

seb[/b]