Matrix Algebra: Rotation trouble

This question has more to do with math than OpenGL. However, I’ve tried to do a particular rotation now for several days, and couldn’t find a proper way to do it.
I am looking for a mathematical description, rather then how to do it in OpenGL. But I’ll take that too

Here it goes: There are 2 coordinate axis systems: main, and local. I want the object to always rotate around the origin of the local system, but to rotate so the rotation is consistent with the main system.

To clarify:

Suppose, main and local systems are not aligned, that is, X main and x local point in different directions, and so are Y, y, and Z, z.
Right now, when I rotate Theta radians around Y axis, and then do a rotation around X axis, it turns consistent with the local x axis, but NOT with the main X axis.

That is, the rotation is not parallel to the Main X axis, while it is parallel to the local one.

Question: How do I make it parallel to the main X axis ?

I feel this might be some complicated matrix algebra.
Or maybe there is an easier solution, … I feel it may have something to do with pure rotations, that is a rotation matrix that, if inverted and multiplied by the original rotation matrix will give you identity.

Hope I didn’t confuse you yet.

I’ll appreciate any suggestions, Thanks !
Dennis

Everything you want can be accomplished using glRotatef, glTranslatef, the key is order of calls. You can look at bilboarding tutorials, but they should be slower, if done in pure opengl, because you must get matrix, change it and multiply with vector. Whithout that, getmatrix stage is skiped & I think glRotate, glTranslate should be optimized for hw. By the way, rotation, translation matrices look terrible if you want to make them by hand

There are two ways of interpreting your question. Therefore I will attempt to reply to both divisions of your question.

You are trying to rotate your points around a local axis that is rotated around a global axis.

Here you simply need two rotation matrices: one for local rotations (Rl) and one for global rotations (Rg). Then you just rotate your vertex transpose(V)=[x,y,z]:
Vnew=VRgRl
Note: You can multiply by inverse matrix as rotaion matrices are invertible and orthogonal.

  1. You are trying to rotate your points by using Euler (ortho) matrix which turns out to rotate your points fine by the first angle (submatrix) but the rest are rotated around the already rotated axis’.
    This phenomenon is caused by the fact that Euler rotations are done as a structure of rotation manifolds:
    R(alpha)*R(beta)*R(theta)=R
    This yeilds that R(alpha) is independent while R(beta) and R(theta) are dependent to the previous matrices in the manifold.
    These rotations are often used in airplane and spacecraft navigation and are called pitch-roll rotations.

The answer is to use quaternions. Here you can specify a unit vector axis and an angle of rotation (as opposed to fixed-axis rotations). Then you simply multiply the matrices together to get a manifold.

If you need help with quaternions let me know.

Hope this helps