Hi, I’d like to know if it’s possible to combine a sequence of successive glRotate calls into one glRotate call.

Let’s assume I’ve stored the parameters used for each call and the order in which the calls are to be made.

Is there an algorithm or formula that achieves this?

Thanks in advance.

Hi !

You will have to keep you own matrix and put the rotations in there, a matrix can contain any number of transformations (translate,rotate,scale) and you can then use glMultMatrix to get the combined transformation into OpenGL.

OpenGl itself does not have any suuport for this, but there are tons of tutorials and also lbraries available for this, try google.

Mikael

You want quaternions!

Usually only rotations on the same axis can combined together, and they needed to be successive, without other transformations between them.

[ul][li] Rotate x pi/2[*] Rotate x pi/6[*] Rotate y pi/12[*] Rotate x pi/2[*] Rotate z -pi/16[*] Rotate z pi/3[*] Rotate x pi/2[/ul][/li]This can be combined into

[ul][li] Rotate x 2pi/3[*] Rotate y pi/12[*] Rotate x pi/2[*] Rotate z 13pi/48[*] Rotate x pi/2[/ul][/li]

If you would like to convert the rotations into quaternions, you can combine all the rotations into a single quaternion. Which the above can be reduced to

[ul][li] Quaternion (.65, .6, .7, 0.01)[/ul][/li]

then equivalently,

[ul][li]glRotate(167, .65, .6, .7)[/ul][/li]

The number above aren’t perfect, but the procedure is sound.

Perhaps I should make clear what exactly I’m trying to achieve. I have a plane which the user can rotate, translate, zoom, etc. Once the user is done, I need to be able to indicate the new orientation. This is important because the plane is such that it’s easy to mix up the right and left sides, and I can’t allow that. Also, I don’t want to display the markers while the user plays around with the orientation.

Will it be enough to simply retrieve the Modelview matrix once the user is done, and then use glMultMatrix to determine where on the screen my markers need to be placed?

Will it be enough to simply retrieve the Modelview matrix once the user is done, and then use glMultMatrix to determine where on the screen my markers need to be placed?

Yes, get the final matrix :

glGetDoublev(GL_MODELVIEW_MATRIX,double*);

And multmatrix it.