|
|
|
|
@ -27,6 +27,7 @@ class QuaternionTest: public Corrade::TestSuite::Tester {
|
|
|
|
|
explicit QuaternionTest(); |
|
|
|
|
|
|
|
|
|
void construct(); |
|
|
|
|
void negated(); |
|
|
|
|
void multiplyDivideScalar(); |
|
|
|
|
void multiply(); |
|
|
|
|
void length(); |
|
|
|
|
@ -45,6 +46,7 @@ typedef Math::Vector3<float> Vector3;
|
|
|
|
|
|
|
|
|
|
QuaternionTest::QuaternionTest() { |
|
|
|
|
addTests(&QuaternionTest::construct, |
|
|
|
|
&QuaternionTest::negated, |
|
|
|
|
&QuaternionTest::multiplyDivideScalar, |
|
|
|
|
&QuaternionTest::multiply, |
|
|
|
|
&QuaternionTest::length, |
|
|
|
|
@ -65,6 +67,10 @@ void QuaternionTest::construct() {
|
|
|
|
|
CORRADE_COMPARE(Quaternion(), Quaternion({0.0f, 0.0f, 0.0f}, {1.0f})); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void QuaternionTest::negated() { |
|
|
|
|
CORRADE_COMPARE(-Quaternion({1.0f, 2.0f, -3.0f}, -4.0f), Quaternion({-1.0f, -2.0f, 3.0f}, 4.0f)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void QuaternionTest::multiplyDivideScalar() { |
|
|
|
|
Quaternion a({1.0f, 3.0f, -2.0f}, -4.0f); |
|
|
|
|
Quaternion b({-1.5f, -4.5f, 3.0f}, 6.0f); |
|
|
|
|
@ -141,6 +147,9 @@ void QuaternionTest::matrix() {
|
|
|
|
|
Quaternion q = Quaternion::fromRotation(angle, axis); |
|
|
|
|
Matrix<3, float> expected = Matrix4<float>::rotation(angle, axis).rotationScaling(); |
|
|
|
|
CORRADE_COMPARE(q.matrix(), expected); |
|
|
|
|
|
|
|
|
|
/* Verify that negated quaternion gives the same rotation */ |
|
|
|
|
CORRADE_COMPARE((-q).matrix(), expected); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void QuaternionTest::debug() { |
|
|
|
|
|