Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

fleejay

Angle around an Axis from Quaternion

This topic is 5360 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

Hi, Does anyone know how to get an angle around an abitrary axis from a quaternion? (Does anyone know if this is possible?) Cheers Fleejay

Share this post


Link to post
Share on other sites
Advertisement
It is practically the easiest thing to do with a quaternion.

Angle: acos(w * 2);
Axis = q[x y z] / sqrt(1 - w*w)

As easily provided by google....

Share this post


Link to post
Share on other sites
Thanks for your reply but that''s not exactly what I meant.

What I want to be able to do is pass in a vector and get the angle around that vector.

For example to get the angle a character is facing in the world I''d want to pass in the Y-axis, (0, 1, 0), and get out the angle.

I know this can be done for all the primary axis(es?) by converting the quaternion into a matrix and then getting the rotation from that matrix, but I''d like to be able to do it for any given vector.

Fleejay

Share this post


Link to post
Share on other sites
The simplest method is probably to convert the quaternion to an axis/angle, find the dot product of the axis and your target axis, and multiply the resultant scalar by the angle. But it''s fairly late, so I could be talking out of my ass. Anyone with some lucidity wanna chime in?


How appropriate. You fight like a cow.

Share this post


Link to post
Share on other sites
I''ve finally had chance to test this method and unfortunately it doesn''t give the correct results. I tested it against a GetAngleAroundYFromQuat() function which I know provides the right angle and although most of the values where close none of them were exactly right.

Any other ideas would be greatfully received!

Fleejay

Share this post


Link to post
Share on other sites
Every thing that you need is descreaben in the Ken Shoemake tutorial availible on the net:

ftp://ftp.cis.upenn.edu/pub/graphics/shoemake/quatut.ps.Z

There in the end of tutorial provided the calculation of rotation about arbitrary axis.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!