View Full Version : Replace two glRotatef() with one glRotatef()?
Hi,me again http://www.opengl.org/discussion_boards/ubb/smile.gif
I want to know Is there any way to Replace two glRotatef() with one glRotatef()?
there are two glRotatef:
Now i want to make another glRotatef:
And c will take the function of a and b.
but how to get the ang3,x3,y3,z3?
[This message has been edited by tgtt (edited 02-24-2004).]
02-24-2004, 04:46 AM
No, if you have diffent axis of rotations in the two statments.
These two could be made into one:
But not this:
because you would not get the same results by combining them.
yes there is: you have to find the rotation axis and angle which will turn the current orientation of the object to the wished orientation of the object.
a common way to solve this is to compute the resulting rotation matrix or quaternion of all axis rotations and to derive the "new" single axis rotation out of it (various math libraries around provide code to convert between different rotation types)
02-24-2004, 10:04 AM
mw: I could be wrong, but I think you are. Consider glRotate(180, 1,0,0); glRotate(90,0,1,0); There is no way you can get that result from a single glRotate() call, is there?
Like you say, though, you could make a matrix that combines those transformations.
Originally posted by endash:
Consider glRotate(180, 1,0,0); glRotate(90,0,1,0); There is no way you can get that result from a single glRotate() call, is there?
glRotate(180, 1, 0, 1) http://www.opengl.org/discussion_boards/ubb/rolleyes.gif
02-24-2004, 02:33 PM
Oh yea, duah.
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.