Replace two glRotatef() with one glRotatef()?

Hi,me again

I want to know Is there any way to Replace two glRotatef() with one glRotatef()?

for example
there are two glRotatef:

glRotatef(ang1,x1,y1,z1);//a
glRotatef(ang2,x2,y2,z2);//b

Now i want to make another glRotatef:
glRotatef(ang3,x3,y3,z3);//c

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:
glRotatef(45,1,0,0);
glRotatef(25,1,0,0);

But not this:
glRotatef(45,1,0,0);
glRotatef(25,0,1,0);

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.

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)

Oh yea, duah.