diff --git a/src/Math/Quaternion.cpp b/src/Math/Quaternion.cpp index 80d01c33b..c736cbfbf 100644 --- a/src/Math/Quaternion.cpp +++ b/src/Math/Quaternion.cpp @@ -18,9 +18,9 @@ namespace Magnum { namespace Math { #ifndef DOXYGEN_GENERATING_OUTPUT -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Quaternion&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Quaternion&); #ifndef MAGNUM_TARGET_GLES -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Quaternion&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Quaternion&); #endif #endif diff --git a/src/Math/Quaternion.h b/src/Math/Quaternion.h index 8caeb01a6..c1b12c700 100644 --- a/src/Math/Quaternion.h +++ b/src/Math/Quaternion.h @@ -119,7 +119,11 @@ template class Quaternion { return {normalizedAxis*std::sin(angle/2), std::cos(angle/2)}; } - /** @brief Default constructor */ + /** + * @brief Default constructor + * + * %Vector part is set to zero, scalar part to `1`. + */ inline constexpr /*implicit*/ Quaternion(): _scalar(T(1)) {} /** @brief Create quaternion from vector and scalar */ @@ -435,7 +439,7 @@ template inline Quaternion operator/(T scalar, const Quaternion& return {scalar/quaternion.vector(), scalar/quaternion.scalar()}; } -/** @debugoperator{Magnum::Math::Geometry::Rectangle} */ +/** @debugoperator{Magnum::Math::Quaternion} */ template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Quaternion& value) { debug << "Quaternion({"; debug.setFlag(Corrade::Utility::Debug::SpaceAfterEachValue, false); diff --git a/src/Math/Test/CMakeLists.txt b/src/Math/Test/CMakeLists.txt index 1d413def9..5bcc56daa 100644 --- a/src/Math/Test/CMakeLists.txt +++ b/src/Math/Test/CMakeLists.txt @@ -3,16 +3,14 @@ corrade_add_test(MathConstantsTest ConstantsTest.cpp) corrade_add_test(MathFunctionsTest FunctionsTest.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(MathMathTypeTraitsTest MathTypeTraitsTest.cpp) -corrade_add_test(MathRectangularMatrixTest RectangularMatrixTest.cpp LIBRARIES MagnumMathTestLib) - corrade_add_test(MathVectorTest VectorTest.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(MathVector2Test Vector2Test.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(MathVector3Test Vector3Test.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(MathVector4Test Vector4Test.cpp LIBRARIES MagnumMathTestLib) - corrade_add_test(MathPoint2DTest Point2DTest.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(MathPoint3DTest Point3DTest.cpp LIBRARIES MagnumMathTestLib) +corrade_add_test(MathRectangularMatrixTest RectangularMatrixTest.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(MathMatrixTest MatrixTest.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(MathMatrix3Test Matrix3Test.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(MathMatrix4Test Matrix4Test.cpp LIBRARIES MagnumMathTestLib) diff --git a/src/Math/Test/QuaternionTest.cpp b/src/Math/Test/QuaternionTest.cpp index b73b223d8..b2c25688e 100644 --- a/src/Math/Test/QuaternionTest.cpp +++ b/src/Math/Test/QuaternionTest.cpp @@ -29,17 +29,21 @@ class QuaternionTest: public Corrade::TestSuite::Tester { void construct(); void constructDefault(); void constructFromVector(); + void addSubtract(); void negated(); void multiplyDivideScalar(); void multiply(); + void dot(); void dotSelf(); void length(); void normalized(); + void conjugated(); void inverted(); void invertedNormalized(); + void rotation(); void angle(); void matrix(); @@ -58,17 +62,21 @@ QuaternionTest::QuaternionTest() { addTests(&QuaternionTest::construct, &QuaternionTest::constructDefault, &QuaternionTest::constructFromVector, + &QuaternionTest::addSubtract, &QuaternionTest::negated, &QuaternionTest::multiplyDivideScalar, &QuaternionTest::multiply, + &QuaternionTest::dot, &QuaternionTest::dotSelf, &QuaternionTest::length, &QuaternionTest::normalized, + &QuaternionTest::conjugated, &QuaternionTest::inverted, &QuaternionTest::invertedNormalized, + &QuaternionTest::rotation, &QuaternionTest::angle, &QuaternionTest::matrix, @@ -76,6 +84,7 @@ QuaternionTest::QuaternionTest() { &QuaternionTest::slerp, &QuaternionTest::rotateVector, &QuaternionTest::rotateVectorNormalized, + &QuaternionTest::debug); } @@ -86,7 +95,7 @@ void QuaternionTest::construct() { } void QuaternionTest::constructDefault() { - CORRADE_COMPARE(Quaternion(), Quaternion({0.0f, 0.0f, 0.0f}, {1.0f})); + CORRADE_COMPARE(Quaternion(), Quaternion({0.0f, 0.0f, 0.0f}, 1.0f)); } void QuaternionTest::constructFromVector() { @@ -94,12 +103,12 @@ void QuaternionTest::constructFromVector() { } void QuaternionTest::addSubtract() { - Quaternion a({1.0f, 3.0f, -2.0f}, -4.0f); - Quaternion b({-0.5f, 1.4f, 3.0f}, 12.0f); - Quaternion c({0.5f, 4.4f, 1.0f}, 8.0f); + Quaternion a({ 1.0f, 3.0f, -2.0f}, -4.0f); + Quaternion b({-0.5f, 1.4f, 3.0f}, 12.0f); + Quaternion c({ 0.5f, 4.4f, 1.0f}, 8.0f); - CORRADE_COMPARE(a+b, c); - CORRADE_COMPARE(c-b, a); + CORRADE_COMPARE(a + b, c); + CORRADE_COMPARE(c - b, a); } void QuaternionTest::negated() { @@ -107,8 +116,8 @@ void QuaternionTest::negated() { } void QuaternionTest::multiplyDivideScalar() { - Quaternion a({1.0f, 3.0f, -2.0f}, -4.0f); - Quaternion b({-1.5f, -4.5f, 3.0f}, 6.0f); + Quaternion a({ 1.0f, 3.0f, -2.0f}, -4.0f); + Quaternion b({-1.5f, -4.5f, 3.0f}, 6.0f); CORRADE_COMPARE(a*-1.5f, b); CORRADE_COMPARE(-1.5f*a, b); @@ -123,8 +132,8 @@ void QuaternionTest::multiply() { } void QuaternionTest::dot() { - Quaternion a({1.0f, 3.0f, -2.0f}, -4.0f); - Quaternion b({-0.5f, 1.5f, 3.0f}, 12.0f); + Quaternion a({ 1.0f, 3.0f, -2.0f}, -4.0f); + Quaternion b({-0.5f, 1.5f, 3.0f}, 12.0f); CORRADE_COMPARE(Quaternion::dot(a, b), -50.0f); } @@ -144,8 +153,8 @@ void QuaternionTest::normalized() { } void QuaternionTest::conjugated() { - CORRADE_COMPARE(Quaternion({1.0f, 3.0f, -2.0f}, -4.0f).conjugated(), - Quaternion({-1.0f, -3.0f, 2.0f}, -4.0f)); + CORRADE_COMPARE(Quaternion({ 1.0f, 3.0f, -2.0f}, -4.0f).conjugated(), + Quaternion({-1.0f, -3.0f, 2.0f}, -4.0f)); } void QuaternionTest::inverted() {