Browse Source

Math: test that transformation (dual) complex/quat is normalized.

pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
c019dc7781
  1. 1
      src/Math/Test/ComplexTest.cpp
  2. 2
      src/Math/Test/DualQuaternionTest.cpp
  3. 1
      src/Math/Test/QuaternionTest.cpp

1
src/Math/Test/ComplexTest.cpp

@ -255,6 +255,7 @@ void ComplexTest::angle() {
void ComplexTest::rotation() {
Complex a = Complex::rotation(Deg(120.0f));
CORRADE_COMPARE(a.length(), 1.0f);
CORRADE_COMPARE(a, Complex(-0.5f, 0.8660254f));
CORRADE_COMPARE_AS(a.rotationAngle(), Deg(120.0f), Rad);

2
src/Math/Test/DualQuaternionTest.cpp

@ -190,6 +190,7 @@ void DualQuaternionTest::rotation() {
CORRADE_COMPARE(o.str(), "Math::Quaternion::rotation(): axis must be normalized\n");
DualQuaternion q = DualQuaternion::rotation(Deg(120.0f), axis);
CORRADE_COMPARE(q.length(), 1.0f);
CORRADE_COMPARE(q, DualQuaternion({Vector3(0.5f, 0.5f, 0.5f), 0.5f}, {{}, 0.0f}));
CORRADE_COMPARE_AS(q.rotationAngle(), Deg(120.0f), Deg);
CORRADE_COMPARE(q.rotationAxis(), axis);
@ -198,6 +199,7 @@ void DualQuaternionTest::rotation() {
void DualQuaternionTest::translation() {
Vector3 vec(1.0f, -3.5f, 0.5f);
DualQuaternion q = DualQuaternion::translation(vec);
CORRADE_COMPARE(q.length(), 1.0f);
CORRADE_COMPARE(q, DualQuaternion({}, {{0.5f, -1.75f, 0.25f}, 0.0f}));
CORRADE_COMPARE(q.translation(), vec);
}

1
src/Math/Test/QuaternionTest.cpp

@ -235,6 +235,7 @@ void QuaternionTest::rotation() {
CORRADE_COMPARE(o.str(), "Math::Quaternion::rotation(): axis must be normalized\n");
Quaternion q = Quaternion::rotation(Deg(120.0f), axis);
CORRADE_COMPARE(q.length(), 1.0f);
CORRADE_COMPARE(q, Quaternion(Vector3(0.5f, 0.5f, 0.5f), 0.5f));
CORRADE_COMPARE_AS(q.rotationAngle(), Deg(120.0f), Deg);
CORRADE_COMPARE(q.rotationAxis(), axis);

Loading…
Cancel
Save