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