Radian angle to Quaternion
-
Hi, I have a double value describing rotation angle for a text box object. I need to convert it to quaternion. I have searched the web, and all I get is converters that conver Euler angle to Quaternion. I would appreciate any formulae or algorithm. And this double value is the only information I have for rotation. Regards, Shoaib
Its never over !
-
Hi, I have a double value describing rotation angle for a text box object. I need to convert it to quaternion. I have searched the web, and all I get is converters that conver Euler angle to Quaternion. I would appreciate any formulae or algorithm. And this double value is the only information I have for rotation. Regards, Shoaib
Its never over !
shaibee wrote:
I have a double value describing rotation angle for a text box object. I need to convert it to quaternion.
As far as I know, a quaternion is used in 3D. So how can you convert a double which represents an angle into a 3D rotation ? You need to at least have a rotation around an axis...
Cédric Moonen Software developer
Charting control [v1.5] OpenGL game tutorial in C++ -
shaibee wrote:
I have a double value describing rotation angle for a text box object. I need to convert it to quaternion.
As far as I know, a quaternion is used in 3D. So how can you convert a double which represents an angle into a 3D rotation ? You need to at least have a rotation around an axis...
Cédric Moonen Software developer
Charting control [v1.5] OpenGL game tutorial in C++Yes you are right, its to be used in 3D. I am not good in this domain. The docs for that double value say "angle in radians rotated from +ve world x-axis". Does this indicate something ? update: Now I understand that I need a vector, along with the angle for the conversion, but that vector is no where to seen in the information object for the text box. Is ther anything I can use as default for +ve world x-axis as it says above.
Its never over !
-
Yes you are right, its to be used in 3D. I am not good in this domain. The docs for that double value say "angle in radians rotated from +ve world x-axis". Does this indicate something ? update: Now I understand that I need a vector, along with the angle for the conversion, but that vector is no where to seen in the information object for the text box. Is ther anything I can use as default for +ve world x-axis as it says above.
Its never over !
shaibee wrote:
Now I understand that I need a vector, along with the angle for the conversion
If your object is actually existing in 3D space then you should have everything you need. You can create your quaternion as follows:
Quaternion Q; Q.x = x * sin(Angle/2); Q.y = y * sin(Angle/2); Q.z = z * sin(Angle/2); Q.w = cos(Angle/2);
Best Wishes, -David Delaune
-
Hi, I have a double value describing rotation angle for a text box object. I need to convert it to quaternion. I have searched the web, and all I get is converters that conver Euler angle to Quaternion. I would appreciate any formulae or algorithm. And this double value is the only information I have for rotation. Regards, Shoaib
Its never over !
I am reminded of when I told a programmer that OpenGL didn't understand "2D". when you deal with 2D references all you are doing is nulling/zeroing the other rotations. If Z is into the screen (a common reference) then heading is your rotation of a window plane clockwise. All other references would be zero. So you can easily use 3D references to modify 2D parameters. If you write your own window compositing display a flip forward would be pitch and flip left/right is roll. you cand do some pretty cool displays. the hardest part is Euler to quaternion is reference specific. Is +Y out of the screen? is +Z into our out of the screen? so you have to watch your references. in reality you don't need to choose. If you are using only one view, one rotation, you can fake it by choosing an angle and always using that one for window rotation. You might get into trouble when you try to share, but you will find quaternions pretty lie/mistake proof as long as you are carefully consistant. I prefer thinkin in top down 3D where window rotation clockwise is Euler heading. :)
_________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb) John Andrew Holmes "It is well to remember that the entire universe, with one trifling exception, is composed of others."
-
Hi, I have a double value describing rotation angle for a text box object. I need to convert it to quaternion. I have searched the web, and all I get is converters that conver Euler angle to Quaternion. I would appreciate any formulae or algorithm. And this double value is the only information I have for rotation. Regards, Shoaib
Its never over !
Maybe this library[^] could be of use?