Commit 7a4c4a4a authored by hybrid's avatar hybrid

Added some test cases for getRotationDegrees submitted by fabietto, also fixed...

Added some test cases for getRotationDegrees submitted by fabietto, also fixed the method to clamp values for asin to [-1,1].

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3228 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 16bb7855
...@@ -854,7 +854,7 @@ namespace core ...@@ -854,7 +854,7 @@ namespace core
const core::vector3d<T> scale = getScale(); const core::vector3d<T> scale = getScale();
const core::vector3d<f64> invScale(core::reciprocal(scale.X),core::reciprocal(scale.Y),core::reciprocal(scale.Z)); const core::vector3d<f64> invScale(core::reciprocal(scale.X),core::reciprocal(scale.Y),core::reciprocal(scale.Z));
f64 Y = -asin(mat[2]*invScale.X); f64 Y = -asin(core::clamp(mat[2]*invScale.X, -1.0, 1.0));
const f64 C = cos(Y); const f64 C = cos(Y);
Y *= RADTODEG64; Y *= RADTODEG64;
......
...@@ -65,6 +65,25 @@ bool transformations(void) ...@@ -65,6 +65,25 @@ bool transformations(void)
core::vector3df newRotation = m.getRotationDegrees(); core::vector3df newRotation = m.getRotationDegrees();
result &= (core::vector3df(30,40,50).equals(newRotation, 0.000004f)); result &= (core::vector3df(30,40,50).equals(newRotation, 0.000004f));
assert(result); assert(result);
m.setRotationDegrees(vector3df(90.0001f, 270.85f, 180.0f));
s.setRotationDegrees(vector3df(0,0, 0.860866));
m *= s;
newRotation = m.getRotationDegrees();
result &= (core::vector3df(0,270,270).equals(newRotation, 0.0001f));
assert(result);
m.setRotationDegrees(vector3df(270.0f, 89.8264f, 0.000100879f));
s.setRotationDegrees(vector3df(0,0, 0.189398));
m *= s;
newRotation = m.getRotationDegrees();
result &= (core::vector3df(0,90,90).equals(newRotation, 0.0001f));
assert(result);
m.setRotationDegrees(vector3df(270.0f, 89.0602f, 359.999f));
s.setRotationDegrees(vector3df(0,0, 0.949104));
m *= s;
newRotation = m.getRotationDegrees();
result &= (core::vector3df(0,90,89.999).equals(newRotation));
assert(result);
return result; return result;
} }
......
Tests finished. 54 tests of 54 passed. Tests finished. 52 tests of 52 passed.
Compiled as DEBUG Compiled as DEBUG
Test suite pass at GMT Sun Feb 07 14:44:37 2010 Test suite pass at GMT Thu Feb 18 11:54:08 2010
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