dwcronin

01-30-2004, 03:59 AM

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?

dovkruger

01-30-2004, 05:15 AM

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).]

dwcronin

01-30-2004, 09:17 AM

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 http://www.opengl.org/discussion_boards/ubb/smile.gif

Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.