Jump to content
  • Advertisement
Sign in to follow this  

What is the global xaxis of an orientation?

This topic is 745 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


1. Take a sheet of paper

2. Take a pencil

3. Take a ruler

4. Put the paper at a flat surface

5. Put the ruler on the paper

6. Draw a line along the ruler with the pencil

7. Remove the ruler from the paper

8. Write "Global x axis" alongside the line

8. Take a pair of scissors

9. Cut out the line and the words, leaving about 1cm or 0.5" (depending whether you use centimeters or inches) white around the line and the words.

10. Get the paper with the line and the words in your hand

11. You've done it! You got the global x axis now




PS In case you meant another global x axis than the one you have now, it would be helpful if you provide some context about what axis in what system using what coordinate systems

Edited by Alberth

Share this post

Link to post
Share on other sites
inline float QuatRotAngleX (const sQuat &q0, const sQuat &q1)
// factor rotation about x axis: sQuat qt = q0.Inversed() * q1; float halfTwistAngle = atan (qt[0] / qt[3]);
    return 2.0f * atan (
        ( ( ( (q0[3] * q1[0]) + (-q0[0] * q1[3]) ) + (-q0[1] * q1[2]) ) - (-q0[2] * q1[1]) ) /
        ( ( ( (q0[3] * q1[3]) - (-q0[0] * q1[0]) ) - (-q0[1] * q1[1]) ) - (-q0[2] * q1[2]) ) );
inline float QuatRotAngleY (const sQuat &q0, const sQuat &q1)
    sQuat qt = q0.Inversed() * q1;
    return 2.0f * atan (qt[1] / qt[3]);
inline float QuatRotAngleZ (const sQuat &q0, const sQuat &q1)
    sQuat qt = q0.Inversed() * q1;
    return 2.0f * atan (qt[2] / qt[3]);

The code for x angle looks different only because i've optimized it.




Another method for better understanding:


Convert the quat to axis and angle.

rotationVector = axis * angle.

float result = dot ( vec(0,1,0), rotationVector )


Works for any normalized directon, does not need to be axis aligned.



Edit: Oh, the code snippets first build the rotation between two inputs.

So for your case it just should be

yAngle = 2 * atan (q.y / q.w)

Edited by JoeJ

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!