Commit 044cb4de authored by bitplane's avatar bitplane

fixed NaNs returned by toEuler, rounding errors caused acos to be passed > 1 or < -1.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@779 dfc29bdd-3216-0410-991c-e03cc46cb475
parent abe0cf6e
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define __IRR_QUATERNION_H_INCLUDED__ #define __IRR_QUATERNION_H_INCLUDED__
#include "irrTypes.h" #include "irrTypes.h"
#include "irrMath.h"
#include "matrix4.h" #include "matrix4.h"
#include "vector3d.h" #include "vector3d.h"
...@@ -503,7 +504,7 @@ inline void quaternion::toEuler(vector3df& euler) const ...@@ -503,7 +504,7 @@ inline void quaternion::toEuler(vector3df& euler) const
euler.X = (f32) (atan2(2.0 * (Y*Z +X*W),(-sqx - sqy + sqz + sqw))); euler.X = (f32) (atan2(2.0 * (Y*Z +X*W),(-sqx - sqy + sqz + sqw)));
// attitude = rotation about y-axis // attitude = rotation about y-axis
euler.Y = (f32) (asin(-2.0 * (X*Z - Y*W))); euler.Y = (f32) (asin( clamp(-2.0 * (X*Z - Y*W), -1.0, 1.0) ));
} }
inline vector3df quaternion::operator* (const vector3df& v) const inline vector3df quaternion::operator* (const vector3df& v) const
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment