What is the global xaxis of an orientation?

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

Recommended Posts

And the global y-axis of an orientation (Quaternion)
How do I get them?

Thanks
Jack

Share on other sites

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

Albert

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

1. 1
Rutin
24
2. 2
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 19
• 11
• 11
• 9
• Forum Statistics

• Total Topics
631762
• Total Posts
3002180
×