Advertisement

Quaternion to Euler Angles

Started by April 07, 2003 01:55 AM
0 comments, last by nitzan 21 years, 10 months ago
So I am having some issues converting from a quaternion to euler angles. I converted the Quaternion to a matrix and then used the following equations: angle.x = -atan(matrix[9]/matrix[10]); angle.y = -asin(-matrix[8]); angle.z = -atan(matrix[4]/matrix[0]); Where matrix[16] is a 4-dimensional matrix created from my quaternion. If I rotate my object around the X or Y axis (or both), the angles get converted back correctly. But whenever I rotate around the Z axis AND the X or Y (or both) I get the wrong values back. Any ideas ? Nitzan ------------------------- www.geocities.com/nitzanw www.scorchedearth3d.net -------------------------
Regardless of whether or not your equation is right, you should not use atan(a/b), but atan2(a,b).


[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan

This topic is closed to new replies.

Advertisement