How does glRotatef() relate to a direction vector?

Hi, strange question, I know. I hope that somene will indulge me.

If I am rotating about (0,0,0), how does a direction vector relate to the rotation? i.e. I have a direction vector and I want to set up the rotation of an object.

Obviously, I can convert the vector to longitude and latitude and that would give me rotation in the xz and xy plane. Could I then do something like…


Is that right, or a complete miss?

Any help appreciated.



The direction vector is the vector you want to rotate about. Stick your thumb in the air, and curl your fingers. Your thumb is the direction vector, your fingers are the direction of the rotation (or opposite direction, depends upon the hand you choose).

Sorry to be a pain, but I’m not sure that answers my question. It’s entirely my fault for the way that I asked it. Or maybe I’m too stupid to realise your response is actually the answer…

If I have a cylinder whose direction vector is aligned with the centroid along its length, and I want to change the direction of that vector interactively, then I want to drag the mouse to do that.

Only, the simplest way to do that is to glPushMatrix(), glRotate() then glPopMatrix(). The base of the vector is (0,0,0), and my dilema is how do I derive the new vector components from the rotation that I just applied?

This is what I’ve use so far to rotate the object…

glRotatef(m_ObjectRotationY, 1.0, 0.0, 0.0);
glRotatef(m_ObjectRotationX, 0.0, 1.0, 0.0);

I’m in a bit of a muddle at the moment. Does the previous response still apply?



rotates around the vector givern by the angle givern