Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: how do I rotate about 2 body axes

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2004
    Location
    Mingo Jct., OH, USA
    Posts
    2

    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?
    Daniel Cronin

  2. #2
    Intern Contributor
    Join Date
    Jan 2004
    Location
    Hoboken,NJ,USA
    Posts
    60

    Re: how do I rotate about 2 body axes

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

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2004
    Location
    Mingo Jct., OH, USA
    Posts
    2

    Re: how do I rotate about 2 body axes

    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
    Daniel Cronin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •