how do I rotate about 2 body axes

Put your left hand out. Point your thumb in the air (z), your index finger forward (y), and your middle finger to the right (x). I want to rotate around my thumb (yaw) and then rotate around my middle finger (pitch). What is the math that will make me rotate around my middle finger (body x) and not around the world x axis?

Perhaps I’m misunderstanding the question, but matrix manipulation is cumulative, and affects subsequent manipulation.

If you rotate around the y-axis first, your whole frame of reference does in fact change, so the next rotate is not about the original z-axis, but the new locally rotated one, vis:

glRotated(30,0,1,0); // thumb?
glRotated(20,1,0,0); // middle?

etc.

Oh, by the way, everyone uses the righthand rule in physics because it’s a righthanded universe, so conventions are typically that directions are positive for cross product if you reverse hands when making that description!

[This message has been edited by dovkruger (edited 01-30-2004).]

That’s what I thought also. Here is some code that I wrote in Mathematica. If you have trouble reading it, just tell me and I’ll translate.

pitch[theta_]:={{1,0,0,0},{0,ct,-st,0},{0,st,ct,0},{0,0,0,1}}/.{ct->Cos[theta], st->Sin[theta]}

yaw[theta_]:={{ct,-st,0,0},{st,ct,0,0},{0,0,1,0},{0,0,0,1}}/.{ct->Cos[theta], st->Sin[theta]}

pitch[Pi/4].yaw[-Pi/2].{0,1,0,0}

Out[20]={1,0,0,0}

I think that yaw[-Pi/2].{0,1,0,0}

should turn the unit vector in the y-direction so that it is pointing in the x-direction. Then I think that pitch[Pi/4] should point it {sqrt[2]/2,0,sqrt[2]/2,0}.

It doesn’t though. Out[20] says it just points it in the x-direction as if it is rotating around the old x-axis.

Do you see what’s going on?

p.s. my coordinate system is right handed. I’m left handed though so I explain everything that way