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