Archived

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

fleejay

Angle around an Axis from Quaternion

Recommended Posts

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