View Full Version : matrix normalization?

SebastianB

03-08-2003, 06:48 AM

hi!

once again a matrix problem http://www.opengl.org/discussion_boards/ubb/smile.gif

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??

http://www.opengl.org/discussion_boards/ubb/smile.gif

sebastian

Miguel_dup1

03-08-2003, 08:12 AM

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

mikael_aronsson

03-08-2003, 09:00 AM

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

SebastianB

03-08-2003, 09:30 AM

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

seb

shinpaughp

03-08-2003, 10:54 AM

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.

SebastianB

03-08-2003, 11:01 AM

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

shinpaughp

03-08-2003, 12:12 PM

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).]

Miguel_dup1

03-08-2003, 01:12 PM

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:

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

Powered by vBulletin® Version 4.2.5 Copyright © 2018 vBulletin Solutions Inc. All rights reserved.