Angle around an Axis from Quaternion
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
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....
Angle: acos(w * 2);
Axis = q[x y z] / sqrt(1 - w*w)
As easily provided by google....
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
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
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.
How appropriate. You fight like a cow.
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
Any other ideas would be greatfully received!
Fleejay
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement