Meaningful representation of Quaternions
I am working on an application and I want to store all rotations as Quaternions.
The problem is that I need to present a more meaningful value to the user. So the user might not understand what the values of X,Y,Z,W mean, but they might understand an X Rotation, Y Rotation, Z Rotation or a Yaw, Pitch, Roll Rotation.
How can I convert the Rotation Quaternion into a more meaningful value for presentation to the user? Is there any way to guarantee that the values the user enter can be extracted?
For example if I specify a Yaw, Pitch, Roll of 0, 30, 0 (in degrees), then convert that to a quaternion, is there a way to ensure that I can extract the same 0, 30, 0 back out or could I end up with different values?
My preference would be to work in X,Y,Z rotations but store it in a Quaternion. In understand it is easy to extract Axis/Angle rotations from a Quaternion, however this is problematic because it is more difficult to visualize.
Re: Meaningful representation of Quaternions
Well perhaps some more information would get a response.
First, I am working in C# using DX 9.
I have found the following math:
Code:
yaw = Math.Atan2(2*qt.Y*qt.W - 2* qt.X*qt.Z, 1 - 2*qt.Y*qt.Y - 2*qt.Z*qt.Z);
pitch = Math.Asin(2*qt.X*qt.Y + 2*qt.Z*qt.W);
roll = Math.Atan2(2*qt.X*qt.W-2*qt.Y*qt.Z, 1-2*qt.X*qt.X - 2*qt.Z*qt.Z);
The above works, but there is a problem. The user may enter one set of values in and it will convert them to the quaternion, but then when the quaternion gets converted back into yaw, pitch, roll, the values are different than what the user entered. The values are equivalent (i.e. 180 degrees vs -180 degrees), but ideally I would like them to be the same. I am thinking however that because of the way quaternions work, this is perhaps not possible. Can anyone provide a solution?