diff --git a/src/DebugTools/Test/CapsuleRendererTest.cpp b/src/DebugTools/Test/CapsuleRendererTest.cpp index 4c0f7d762..0ec537c9c 100644 --- a/src/DebugTools/Test/CapsuleRendererTest.cpp +++ b/src/DebugTools/Test/CapsuleRendererTest.cpp @@ -55,9 +55,9 @@ void CapsuleRendererTest::zeroLength2D() { const Vector2 a(0.5f, 3.0f); std::array transformation = Implementation::capsuleRendererTransformation<2>(a, a, 3.5f); - const auto scaling = Math::Matrix<2, Float>::fromDiagonal(Vector2(3.5f)); + const auto scaling = Matrix2x2::fromDiagonal(Vector2(3.5f)); CORRADE_COMPARE(transformation[0].rotationScaling(), scaling); - CORRADE_COMPARE(transformation[1].rotationScaling(), (Math::Matrix<2, Float>::fromDiagonal({3.5f, 0.0f}))); + CORRADE_COMPARE(transformation[1].rotationScaling(), Matrix2x2::fromDiagonal({3.5f, 0.0f})); CORRADE_COMPARE(transformation[2].rotationScaling(), scaling); CORRADE_COMPARE(transformation[0].translation(), a); @@ -94,9 +94,9 @@ void CapsuleRendererTest::zeroLength3D() { const Vector3 a(0.5f, 3.0f, 7.0f); std::array transformation = Implementation::capsuleRendererTransformation<3>(a, a, 3.5f); - const auto scaling = Math::Matrix<3, Float>::fromDiagonal(Vector3(3.5f)); + const auto scaling = Matrix3x3::fromDiagonal(Vector3(3.5f)); CORRADE_COMPARE(transformation[0].rotationScaling(), scaling); - CORRADE_COMPARE(transformation[1].rotationScaling(), (Math::Matrix<3, Float>::fromDiagonal({3.5f, 0.0f, 3.5f}))); + CORRADE_COMPARE(transformation[1].rotationScaling(), Matrix3x3::fromDiagonal({3.5f, 0.0f, 3.5f})); CORRADE_COMPARE(transformation[2].rotationScaling(), scaling); CORRADE_COMPARE(transformation[0].translation(), a); diff --git a/src/DebugTools/Test/CylinderRendererTest.cpp b/src/DebugTools/Test/CylinderRendererTest.cpp index 958003f96..9c18c51fa 100644 --- a/src/DebugTools/Test/CylinderRendererTest.cpp +++ b/src/DebugTools/Test/CylinderRendererTest.cpp @@ -55,7 +55,7 @@ void CylinderRendererTest::zeroLength2D() { const Vector2 a(0.5f, 3.0f); const Matrix3 transformation = Implementation::cylinderRendererTransformation<2>(a, a, 3.5f); - CORRADE_COMPARE(transformation.rotationScaling(), (Math::Matrix<2, Float>::fromDiagonal({3.5f, 0.0f}))); + CORRADE_COMPARE(transformation.rotationScaling(), Matrix2x2::fromDiagonal({3.5f, 0.0f})); CORRADE_COMPARE(transformation.translation(), a); } @@ -76,7 +76,7 @@ void CylinderRendererTest::zeroLength3D() { const Vector3 a(0.5f, 3.0f, 7.0f); const Matrix4 transformation = Implementation::cylinderRendererTransformation<3>(a, a, 3.5f); - CORRADE_COMPARE(transformation.rotationScaling(), (Math::Matrix<3, Float>::fromDiagonal({3.5f, 0.0f, 3.5f}))); + CORRADE_COMPARE(transformation.rotationScaling(), Matrix3x3::fromDiagonal({3.5f, 0.0f, 3.5f})); CORRADE_COMPARE(transformation.translation(), a); } diff --git a/src/Magnum.h b/src/Magnum.h index 30b593c41..0fcece5ab 100644 --- a/src/Magnum.h +++ b/src/Magnum.h @@ -185,15 +185,59 @@ typedef Math::Vector3 Vector3i; /** @brief Four-component signed integer vector */ typedef Math::Vector4 Vector4i; -/** @brief 2x2 float matrix */ -typedef Math::Matrix<2, Float> Matrix2; +/** +@brief 3x3 float transformation matrix -/** @brief 3x3 float matrix */ +@see @ref Matrix3x3 +*/ typedef Math::Matrix3 Matrix3; -/** @brief 4x4 float matrix */ +/** +@brief 4x4 float transformation matrix + +@see @ref Matrix4x4 +*/ typedef Math::Matrix4 Matrix4; +/** @brief 2x2 float matrix */ +#ifndef CORRADE_GCC46_COMPATIBILITY +typedef Math::Matrix2x2 Matrix2x2; +#else +typedef Math::Matrix<2, Float> Matrix2x2; +#endif + +#ifdef MAGNUM_BUILD_DEPRECATED +/** +@copybrief Matrix2x2 +@deprecated Use @ref Magnum::Matrix2x2 "Matrix2x2" instead. +*/ +typedef Math::Matrix<2, Float> Matrix2; +#endif + +/** +@brief 3x3 float matrix + +Note that this is different from @ref Matrix3, which contains additional +functions for transformations in 2D. +*/ +#ifndef CORRADE_GCC46_COMPATIBILITY +typedef Math::Matrix3x3 Matrix3x3; +#else +typedef Math::Matrix<3, Float> Matrix3x3; +#endif + +/** +@brief 4x4 float matrix + +Note that this is different from @ref Matrix4, which contains additional +functions for transformations in 3D. +*/ +#ifndef CORRADE_GCC46_COMPATIBILITY +typedef Math::Matrix4x4 Matrix4x4; +#else +typedef Math::Matrix<4, Float> Matrix4x4; +#endif + /** @brief Float matrix with 2 columns and 3 rows */ #ifndef CORRADE_GCC46_COMPATIBILITY typedef Math::Matrix2x3 Matrix2x3; @@ -284,15 +328,59 @@ typedef Math::Vector3 Vector3d; /** @brief Four-component double vector */ typedef Math::Vector4 Vector4d; -/** @brief 2x2 double matrix */ -typedef Math::Matrix<2, Double> Matrix2d; +/** +@brief 3x3 double transformation matrix -/** @brief 3x3 double matrix */ +@see @ref Matrix3x3d +*/ typedef Math::Matrix3 Matrix3d; -/** @brief 4x4 double matrix */ +/** +@brief 4x4 double transformation matrix + +@see @ref Matrix4x4d +*/ typedef Math::Matrix4 Matrix4d; +/** @brief 2x2 double matrix */ +#ifndef CORRADE_GCC46_COMPATIBILITY +typedef Math::Matrix2x2 Matrix2x2d; +#else +typedef Math::Matrix<2, Double> Matrix2x2d; +#endif + +#ifdef MAGNUM_BUILD_DEPRECATED +/** +@copybrief Matrix2x2d +@deprecated Use @ref Magnum::Matrix2x2d "Matrix2x2d" instead. +*/ +typedef Math::Matrix<2, Double> Matrix2d; +#endif + +/** +@brief 3x3 double matrix + +Note that this is different from @ref Matrix3d, which contains additional +functions for transformations in 2D. +*/ +#ifndef CORRADE_GCC46_COMPATIBILITY +typedef Math::Matrix3x3 Matrix3x3d; +#else +typedef Math::Matrix<3, Double> Matrix3x3d; +#endif + +/** +@brief 4x4 double matrix + +Note that this is different from @ref Matrix4d, which contains additional +functions for transformations in 3D. +*/ +#ifndef CORRADE_GCC46_COMPATIBILITY +typedef Math::Matrix4x4 Matrix4x4d; +#else +typedef Math::Matrix<4, Double> Matrix4x4d; +#endif + /** @brief Double matrix with 2 columns and 3 rows */ #ifndef CORRADE_GCC46_COMPATIBILITY typedef Math::Matrix2x3 Matrix2x3d; diff --git a/src/Math/Algorithms/Test/GaussJordanTest.cpp b/src/Math/Algorithms/Test/GaussJordanTest.cpp index 80ef9c1e5..b20652c18 100644 --- a/src/Math/Algorithms/Test/GaussJordanTest.cpp +++ b/src/Math/Algorithms/Test/GaussJordanTest.cpp @@ -36,7 +36,7 @@ class GaussJordanTest: public Corrade::TestSuite::Tester { void invert(); }; -typedef RectangularMatrix<4, 4, Float> Matrix4; +typedef RectangularMatrix<4, 4, Float> Matrix4x4; typedef Vector<4, Float> Vector4; GaussJordanTest::GaussJordanTest() { @@ -45,32 +45,32 @@ GaussJordanTest::GaussJordanTest() { } void GaussJordanTest::singular() { - Matrix4 a(Vector4(1.0f, 2.0f, 3.0f, 4.0f), - Vector4(2.0f, 3.0f, -7.0f, 11.0f), - Vector4(2.0f, 4.0f, 6.0f, 8.0f), - Vector4(1.0f, 2.0f, 7.0f, 40.0f)); + Matrix4x4 a(Vector4(1.0f, 2.0f, 3.0f, 4.0f), + Vector4(2.0f, 3.0f, -7.0f, 11.0f), + Vector4(2.0f, 4.0f, 6.0f, 8.0f), + Vector4(1.0f, 2.0f, 7.0f, 40.0f)); RectangularMatrix<4, 1, Float> t; CORRADE_VERIFY(!gaussJordanInPlaceTransposed(a, t)); } void GaussJordanTest::invert() { - Matrix4 a(Vector4(3.0f, 5.0f, 8.0f, 4.0f), - Vector4(4.0f, 4.0f, 7.0f, 3.0f), - Vector4(7.0f, -1.0f, 8.0f, 0.0f), - Vector4(9.0f, 4.0f, 5.0f, 9.0f)); - - Matrix4 expectedInverse(Vector4(-60/103.0f, 71/103.0f, -4/103.0f, 3/103.0f), - Vector4(-66/103.0f, 109/103.0f, -25/103.0f, -7/103.0f), - Vector4(177/412.0f, -97/206.0f, 53/412.0f, -7/206.0f), - Vector4(259/412.0f, -185/206.0f, 31/412.0f, 27/206.0f)); - - Matrix4 a2(a); - Matrix4 inverse = Matrix4::fromDiagonal(Vector4(1.0f)); + Matrix4x4 a(Vector4(3.0f, 5.0f, 8.0f, 4.0f), + Vector4(4.0f, 4.0f, 7.0f, 3.0f), + Vector4(7.0f, -1.0f, 8.0f, 0.0f), + Vector4(9.0f, 4.0f, 5.0f, 9.0f)); + + Matrix4x4 expectedInverse(Vector4(-60/103.0f, 71/103.0f, -4/103.0f, 3/103.0f), + Vector4(-66/103.0f, 109/103.0f, -25/103.0f, -7/103.0f), + Vector4(177/412.0f, -97/206.0f, 53/412.0f, -7/206.0f), + Vector4(259/412.0f, -185/206.0f, 31/412.0f, 27/206.0f)); + + Matrix4x4 a2(a); + Matrix4x4 inverse = Matrix4x4::fromDiagonal(Vector4(1.0f)); CORRADE_VERIFY(gaussJordanInPlace(a2, inverse)); CORRADE_COMPARE(inverse, expectedInverse); - CORRADE_COMPARE(a*inverse, Matrix4::fromDiagonal(Vector4(1.0f))); + CORRADE_COMPARE(a*inverse, Matrix4x4::fromDiagonal(Vector4(1.0f))); } }}}} diff --git a/src/Math/Algorithms/Test/GramSchmidtTest.cpp b/src/Math/Algorithms/Test/GramSchmidtTest.cpp index 28700089d..494615329 100644 --- a/src/Math/Algorithms/Test/GramSchmidtTest.cpp +++ b/src/Math/Algorithms/Test/GramSchmidtTest.cpp @@ -36,7 +36,7 @@ class GramSchmidtTest: public Corrade::TestSuite::Tester { void orthonormalize(); }; -typedef RectangularMatrix<3, 3, Float> Matrix3; +typedef RectangularMatrix<3, 3, Float> Matrix3x3; typedef Vector<3, Float> Vector3; GramSchmidtTest::GramSchmidtTest() { @@ -45,11 +45,11 @@ GramSchmidtTest::GramSchmidtTest() { } void GramSchmidtTest::orthogonalize() { - Matrix3 m(Vector3(3.0f, 5.0f, 1.0f), - Vector3(4.0f, 4.0f, 7.0f), - Vector3(7.0f, -1.0f, -3.0f)); + Matrix3x3 m(Vector3(3.0f, 5.0f, 1.0f), + Vector3(4.0f, 4.0f, 7.0f), + Vector3(7.0f, -1.0f, -3.0f)); - Matrix3 orthogonalized = Algorithms::gramSchmidtOrthogonalize(m); + Matrix3x3 orthogonalized = Algorithms::gramSchmidtOrthogonalize(m); /* Verify the first vector is in direction of first original */ CORRADE_COMPARE(orthogonalized[0], m[0]); @@ -62,18 +62,18 @@ void GramSchmidtTest::orthogonalize() { CORRADE_COMPARE(Vector3::dot(orthogonalized[1], orthogonalized[2]), 0.0f); /* Just to be sure */ - Matrix3 expected(Vector3( 3.0f, 5.0f, 1.0f), - Vector3(0.657143f, -1.571429f, 5.885714f), - Vector3(6.086759f, -3.3379f, -1.570777f)); + Matrix3x3 expected(Vector3( 3.0f, 5.0f, 1.0f), + Vector3(0.657143f, -1.571429f, 5.885714f), + Vector3(6.086759f, -3.3379f, -1.570777f)); CORRADE_COMPARE(orthogonalized, expected); } void GramSchmidtTest::orthonormalize() { - Matrix3 m(Vector3(3.0f, 5.0f, 8.0f), - Vector3(4.0f, 4.0f, 7.0f), - Vector3(7.0f, -1.0f, 8.0f)); + Matrix3x3 m(Vector3(3.0f, 5.0f, 8.0f), + Vector3(4.0f, 4.0f, 7.0f), + Vector3(7.0f, -1.0f, 8.0f)); - Matrix3 orthonormalized = Algorithms::gramSchmidtOrthonormalize(m); + Matrix3x3 orthonormalized = Algorithms::gramSchmidtOrthonormalize(m); /* Verify the first vector is in direction of first original */ CORRADE_COMPARE(orthonormalized[0], m[0].normalized()); @@ -89,9 +89,9 @@ void GramSchmidtTest::orthonormalize() { CORRADE_COMPARE(Vector3::dot(orthonormalized[1], orthonormalized[2]), 0.0f); /* Just to be sure */ - Matrix3 expected(Vector3( 0.303046f, 0.505076f, 0.808122f), - Vector3( 0.928316f, -0.348119f, -0.130544f), - Vector3(-0.215388f, -0.789754f, 0.574367f)); + Matrix3x3 expected(Vector3( 0.303046f, 0.505076f, 0.808122f), + Vector3( 0.928316f, -0.348119f, -0.130544f), + Vector3(-0.215388f, -0.789754f, 0.574367f)); CORRADE_COMPARE(orthonormalized, expected); } diff --git a/src/Math/Math.h b/src/Math/Math.h index ea5f9c59c..ab239d11b 100644 --- a/src/Math/Math.h +++ b/src/Math/Math.h @@ -44,6 +44,12 @@ template class DualComplex; template class DualQuaternion; template class Matrix; +#ifndef CORRADE_GCC46_COMPATIBILITY +template using Matrix2x2 = Matrix<2, T>; +template using Matrix3x3 = Matrix<3, T>; +template using Matrix4x4 = Matrix<4, T>; +#endif + template class Matrix3; template class Matrix4; diff --git a/src/Math/Matrix.h b/src/Math/Matrix.h index edcbaaf5c..0a4165e21 100644 --- a/src/Math/Matrix.h +++ b/src/Math/Matrix.h @@ -44,7 +44,7 @@ namespace Implementation { See @ref matrix-vector for brief introduction. @configurationvalueref{Magnum::Math::Matrix} -@see Magnum::Matrix2, Magnum::Matrix2d +@see @ref Matrix2x2, @ref Matrix3x3, @ref Matrix4x4 */ template class Matrix: public RectangularMatrix { public: @@ -89,9 +89,9 @@ template class Matrix: public RectangularMatrix floatingPoint({1.3f, 2.7f}, + * Matrix2x2 floatingPoint({1.3f, 2.7f}, * {-15.0f, 7.0f}); - * Matrix<2, Byte> integral(floatingPoint); + * Matrix2x2 integral(floatingPoint); * // integral == {{1, 2}, {-15, 7}} * @endcode */ @@ -180,6 +180,40 @@ template class Matrix: public RectangularMatrix%Matrix<2, T>. See @ref Matrix for more +information. +@note Not available on GCC < 4.7. Use %Matrix<2, T> instead. +@see @ref Magnum::Matrix2x2, @ref Magnum::Matrix2x2d +*/ +template using Matrix2x2 = Matrix<2, T>; + +/** +@brief 3x3 matrix + +Convenience alternative to %Matrix<3, T>. See @ref Matrix for more +information. Note that this is different from @ref Matrix3, which contains +additional functions for transformations in 2D. +@note Not available on GCC < 4.7. Use %Matrix<3, T> instead. +@see @ref Magnum::Matrix3x3, @ref Magnum::Matrix3x3d +*/ +template using Matrix3x3 = Matrix<3, T>; + +/** +@brief 4x4 matrix + +Convenience alternative to %Matrix<4, T>. See @ref Matrix for more +information. Note that this is different from @ref Matrix4, which contains +additional functions for transformations in 3D. +@note Not available on GCC < 4.7. Use %Matrix<3, T> instead. +@see @ref Magnum::Matrix4x4, @ref Magnum::Matrix4x4d +*/ +template using Matrix4x4 = Matrix<4, T>; +#endif + MAGNUM_MATRIX_OPERATOR_IMPLEMENTATION(Matrix) /** @debugoperator{Magnum::Math::Matrix} */ diff --git a/src/Math/Test/ComplexTest.cpp b/src/Math/Test/ComplexTest.cpp index 1942d1a5d..181f3a780 100644 --- a/src/Math/Test/ComplexTest.cpp +++ b/src/Math/Test/ComplexTest.cpp @@ -100,7 +100,7 @@ typedef Math::Rad Rad; typedef Math::Complex Complex; typedef Math::Vector2 Vector2; typedef Math::Matrix3 Matrix3; -typedef Math::Matrix<2, Float> Matrix2; +typedef Math::Matrix<2, Float> Matrix2x2; void ComplexTest::construct() { constexpr Complex a(0.5f, -3.7f); @@ -275,7 +275,7 @@ void ComplexTest::rotation() { void ComplexTest::matrix() { Complex a = Complex::rotation(Deg(37.0f)); - Matrix2 m = Matrix3::rotation(Deg(37.0f)).rotationScaling(); + Matrix2x2 m = Matrix3::rotation(Deg(37.0f)).rotationScaling(); CORRADE_COMPARE(a.toMatrix(), m); diff --git a/src/Math/Test/Matrix3Test.cpp b/src/Math/Test/Matrix3Test.cpp index 2cf0d8b2a..3349e6dcb 100644 --- a/src/Math/Test/Matrix3Test.cpp +++ b/src/Math/Test/Matrix3Test.cpp @@ -90,7 +90,7 @@ class Matrix3Test: public Corrade::TestSuite::Tester { typedef Math::Deg Deg; typedef Math::Matrix3 Matrix3; typedef Math::Matrix3 Matrix3i; -typedef Math::Matrix<2, Float> Matrix2; +typedef Math::Matrix<2, Float> Matrix2x2; typedef Math::Vector3 Vector3; typedef Math::Vector2 Vector2; @@ -269,8 +269,8 @@ void Matrix3Test::projection() { } void Matrix3Test::fromParts() { - constexpr Matrix2 rotationScaling(Vector2(3.0f, 5.0f), - Vector2(4.0f, 4.0f)); + constexpr Matrix2x2 rotationScaling(Vector2(3.0f, 5.0f), + Vector2(4.0f, 4.0f)); constexpr Vector2 translation(7.0f, -1.0f); constexpr Matrix3 a = Matrix3::from(rotationScaling, translation); @@ -283,10 +283,10 @@ void Matrix3Test::rotationScalingPart() { constexpr Matrix3 a({3.0f, 5.0f, 8.0f}, {4.0f, 4.0f, 7.0f}, {7.0f, -1.0f, 8.0f}); - constexpr Matrix2 b = a.rotationScaling(); + constexpr Matrix2x2 b = a.rotationScaling(); - CORRADE_COMPARE(b, Matrix2(Vector2(3.0f, 5.0f), - Vector2(4.0f, 4.0f))); + CORRADE_COMPARE(b, Matrix2x2(Vector2(3.0f, 5.0f), + Vector2(4.0f, 4.0f))); } void Matrix3Test::rotationNormalizedPart() { @@ -303,34 +303,34 @@ void Matrix3Test::rotationNormalizedPart() { Matrix3 b({ 0.965926f, 0.258819f, 1.0f}, {-0.258819f, 0.965926f, 3.0f}, { 0.0f, 0.0f, 1.0f}); - CORRADE_COMPARE(b.rotationNormalized(), Matrix2(Vector2( 0.965926f, 0.258819f), - Vector2(-0.258819f, 0.965926f))); + CORRADE_COMPARE(b.rotationNormalized(), Matrix2x2(Vector2( 0.965926f, 0.258819f), + Vector2(-0.258819f, 0.965926f))); } void Matrix3Test::rotationPart() { Matrix3 rotation = Matrix3::rotation(Deg(15.0f)); - Matrix2 expectedRotationPart(Vector2( 0.965926f, 0.258819f), - Vector2(-0.258819f, 0.965926f)); + Matrix2x2 expectedRotationPart(Vector2( 0.965926f, 0.258819f), + Vector2(-0.258819f, 0.965926f)); /* For rotation and translation this is the same as rotationScaling() */ Matrix3 rotationTranslation = rotation*Matrix3::translation({2.0f, 5.0f}); - Matrix2 rotationTranslationPart = rotationTranslation.rotation(); + Matrix2x2 rotationTranslationPart = rotationTranslation.rotation(); CORRADE_COMPARE(rotationTranslationPart, rotationTranslation.rotationScaling()); CORRADE_COMPARE(rotationTranslationPart, expectedRotationPart); /* Test uniform scaling */ Matrix3 rotationScaling = rotation*Matrix3::scaling(Vector2(3.0f)); - Matrix2 rotationScalingPart = rotationScaling.rotation(); + Matrix2x2 rotationScalingPart = rotationScaling.rotation(); CORRADE_COMPARE(rotationScalingPart.determinant(), 1.0f); - CORRADE_COMPARE(rotationScalingPart*rotationScalingPart.transposed(), Matrix2()); + CORRADE_COMPARE(rotationScalingPart*rotationScalingPart.transposed(), Matrix2x2()); CORRADE_COMPARE(rotationScalingPart, expectedRotationPart); /* Fails on non-uniform scaling */ std::ostringstream o; Error::setOutput(&o); - Matrix2 rotationScaling2 = (rotation*Matrix3::scaling(Vector2::yScale(3.5f))).rotation(); + Matrix2x2 rotationScaling2 = (rotation*Matrix3::scaling(Vector2::yScale(3.5f))).rotation(); CORRADE_COMPARE(o.str(), "Math::Matrix3::rotation(): the matrix doesn't have uniform scaling\n"); - CORRADE_COMPARE(rotationScaling2, Matrix2()); + CORRADE_COMPARE(rotationScaling2, Matrix2x2()); } void Matrix3Test::uniformScalingPart() { diff --git a/src/Math/Test/Matrix4Test.cpp b/src/Math/Test/Matrix4Test.cpp index 066a4715d..106f6d4ad 100644 --- a/src/Math/Test/Matrix4Test.cpp +++ b/src/Math/Test/Matrix4Test.cpp @@ -98,7 +98,7 @@ typedef Math::Deg Deg; typedef Math::Rad Rad; typedef Math::Matrix4 Matrix4; typedef Math::Matrix4 Matrix4i; -typedef Math::Matrix<3, Float> Matrix3; +typedef Math::Matrix<3, Float> Matrix3x3; typedef Math::Vector3 Vector3; Matrix4Test::Matrix4Test() { @@ -348,9 +348,9 @@ void Matrix4Test::perspectiveProjectionFov() { } void Matrix4Test::fromParts() { - constexpr Matrix3 rotationScaling(Vector3(3.0f, 5.0f, 8.0f), - Vector3(4.0f, 4.0f, 7.0f), - Vector3(7.0f, -1.0f, 8.0f)); + constexpr Matrix3x3 rotationScaling(Vector3(3.0f, 5.0f, 8.0f), + Vector3(4.0f, 4.0f, 7.0f), + Vector3(7.0f, -1.0f, 8.0f)); constexpr Vector3 translation(9.0f, 4.0f, 5.0f); constexpr Matrix4 a = Matrix4::from(rotationScaling, translation); @@ -365,11 +365,11 @@ void Matrix4Test::rotationScalingPart() { {4.0f, 4.0f, 7.0f, 3.0f}, {7.0f, -1.0f, 8.0f, 0.0f}, {9.0f, 4.0f, 5.0f, 9.0f}); - constexpr Matrix3 b = a.rotationScaling(); + constexpr Matrix3x3 b = a.rotationScaling(); - CORRADE_COMPARE(b, Matrix3(Vector3(3.0f, 5.0f, 8.0f), - Vector3(4.0f, 4.0f, 7.0f), - Vector3(7.0f, -1.0f, 8.0f))); + CORRADE_COMPARE(b, Matrix3x3(Vector3(3.0f, 5.0f, 8.0f), + Vector3(4.0f, 4.0f, 7.0f), + Vector3(7.0f, -1.0f, 8.0f))); } void Matrix4Test::rotationNormalizedPart() { @@ -387,36 +387,36 @@ void Matrix4Test::rotationNormalizedPart() { { 0.47987163f, 0.59757638f, 0.6423595f, 3.0f}, {-0.80181062f, 0.0015183985f, 0.59757638f, 4.0f}, { 0.0f, 0.0f, 0.0f, 1.0f}); - CORRADE_COMPARE(b.rotationNormalized(), Matrix3(Vector3( 0.35612214f, -0.80181062f, 0.47987163f), - Vector3( 0.47987163f, 0.59757638f, 0.6423595f), - Vector3(-0.80181062f, 0.0015183985f, 0.59757638f))); + CORRADE_COMPARE(b.rotationNormalized(), Matrix3x3(Vector3( 0.35612214f, -0.80181062f, 0.47987163f), + Vector3( 0.47987163f, 0.59757638f, 0.6423595f), + Vector3(-0.80181062f, 0.0015183985f, 0.59757638f))); } void Matrix4Test::rotationPart() { Matrix4 rotation = Matrix4::rotation(Deg(-74.0f), Vector3(-1.0f, 2.0f, 2.0f).normalized()); - Matrix3 expectedRotationPart(Vector3( 0.35612214f, -0.80181062f, 0.47987163f), - Vector3( 0.47987163f, 0.59757638f, 0.6423595f), - Vector3(-0.80181062f, 0.0015183985f, 0.59757638f)); + Matrix3x3 expectedRotationPart(Vector3( 0.35612214f, -0.80181062f, 0.47987163f), + Vector3( 0.47987163f, 0.59757638f, 0.6423595f), + Vector3(-0.80181062f, 0.0015183985f, 0.59757638f)); /* For rotation and translation this is the same as rotationScaling() */ Matrix4 rotationTranslation = rotation*Matrix4::translation({2.0f, 5.0f, -3.0f}); - Matrix3 rotationTranslationPart = rotationTranslation.rotation(); + Matrix3x3 rotationTranslationPart = rotationTranslation.rotation(); CORRADE_COMPARE(rotationTranslationPart, rotationTranslation.rotationScaling()); CORRADE_COMPARE(rotationTranslationPart, expectedRotationPart); /* Test uniform scaling */ Matrix4 rotationScaling = rotation*Matrix4::scaling(Vector3(3.0f)); - Matrix3 rotationScalingPart = rotationScaling.rotation(); + Matrix3x3 rotationScalingPart = rotationScaling.rotation(); CORRADE_COMPARE(rotationScalingPart.determinant(), 1.0f); - CORRADE_COMPARE(rotationScalingPart*rotationScalingPart.transposed(), Matrix3()); + CORRADE_COMPARE(rotationScalingPart*rotationScalingPart.transposed(), Matrix3x3()); CORRADE_COMPARE(rotationScalingPart, expectedRotationPart); /* Fails on non-uniform scaling */ std::ostringstream o; Error::setOutput(&o); - Matrix3 rotationScaling2 = (rotation*Matrix4::scaling(Vector3::yScale(3.5f))).rotation(); + Matrix3x3 rotationScaling2 = (rotation*Matrix4::scaling(Vector3::yScale(3.5f))).rotation(); CORRADE_COMPARE(o.str(), "Math::Matrix4::rotation(): the matrix doesn't have uniform scaling\n"); - CORRADE_COMPARE(rotationScaling2, Matrix3()); + CORRADE_COMPARE(rotationScaling2, Matrix3x3()); } void Matrix4Test::uniformScalingPart() { diff --git a/src/Math/Test/MatrixTest.cpp b/src/Math/Test/MatrixTest.cpp index a8c160de3..875c4ff98 100644 --- a/src/Math/Test/MatrixTest.cpp +++ b/src/Math/Test/MatrixTest.cpp @@ -82,9 +82,9 @@ class MatrixTest: public Corrade::TestSuite::Tester { void configuration(); }; -typedef Matrix<4, Float> Matrix4; -typedef Matrix<4, Int> Matrix4i; -typedef Matrix<3, Float> Matrix3; +typedef Matrix<4, Float> Matrix4x4; +typedef Matrix<4, Int> Matrix4x4i; +typedef Matrix<3, Float> Matrix3x3; typedef Vector<4, Float> Vector4; typedef Vector<4, Int> Vector4i; typedef Vector<3, Float> Vector3; @@ -115,30 +115,30 @@ MatrixTest::MatrixTest() { } void MatrixTest::construct() { - constexpr Matrix4 a = {Vector4(3.0f, 5.0f, 8.0f, -3.0f), - Vector4(4.5f, 4.0f, 7.0f, 2.0f), - Vector4(1.0f, 2.0f, 3.0f, -1.0f), - Vector4(7.9f, -1.0f, 8.0f, -1.5f)}; - CORRADE_COMPARE(a, Matrix4(Vector4(3.0f, 5.0f, 8.0f, -3.0f), - Vector4(4.5f, 4.0f, 7.0f, 2.0f), - Vector4(1.0f, 2.0f, 3.0f, -1.0f), - Vector4(7.9f, -1.0f, 8.0f, -1.5f))); + constexpr Matrix4x4 a = {Vector4(3.0f, 5.0f, 8.0f, -3.0f), + Vector4(4.5f, 4.0f, 7.0f, 2.0f), + Vector4(1.0f, 2.0f, 3.0f, -1.0f), + Vector4(7.9f, -1.0f, 8.0f, -1.5f)}; + CORRADE_COMPARE(a, Matrix4x4(Vector4(3.0f, 5.0f, 8.0f, -3.0f), + Vector4(4.5f, 4.0f, 7.0f, 2.0f), + Vector4(1.0f, 2.0f, 3.0f, -1.0f), + Vector4(7.9f, -1.0f, 8.0f, -1.5f))); } void MatrixTest::constructIdentity() { - Matrix4 identity; - Matrix4 identity2(Matrix4::Identity); - Matrix4 identity3(Matrix4::Identity, 4.0f); + Matrix4x4 identity; + Matrix4x4 identity2(Matrix4x4::Identity); + Matrix4x4 identity3(Matrix4x4::Identity, 4.0f); - Matrix4 identityExpected(Vector4(1.0f, 0.0f, 0.0f, 0.0f), - Vector4(0.0f, 1.0f, 0.0f, 0.0f), - Vector4(0.0f, 0.0f, 1.0f, 0.0f), - Vector4(0.0f, 0.0f, 0.0f, 1.0f)); + Matrix4x4 identityExpected(Vector4(1.0f, 0.0f, 0.0f, 0.0f), + Vector4(0.0f, 1.0f, 0.0f, 0.0f), + Vector4(0.0f, 0.0f, 1.0f, 0.0f), + Vector4(0.0f, 0.0f, 0.0f, 1.0f)); - Matrix4 identity3Expected(Vector4(4.0f, 0.0f, 0.0f, 0.0f), - Vector4(0.0f, 4.0f, 0.0f, 0.0f), - Vector4(0.0f, 0.0f, 4.0f, 0.0f), - Vector4(0.0f, 0.0f, 0.0f, 4.0f)); + Matrix4x4 identity3Expected(Vector4(4.0f, 0.0f, 0.0f, 0.0f), + Vector4(0.0f, 4.0f, 0.0f, 0.0f), + Vector4(0.0f, 0.0f, 4.0f, 0.0f), + Vector4(0.0f, 0.0f, 0.0f, 4.0f)); CORRADE_COMPARE(identity, identityExpected); CORRADE_COMPARE(identity2, identityExpected); @@ -146,30 +146,30 @@ void MatrixTest::constructIdentity() { } void MatrixTest::constructZero() { - constexpr Matrix4 a(Matrix4::Zero); - CORRADE_COMPARE(a, Matrix4(Vector4(0.0f, 0.0f, 0.0f, 0.0f), - Vector4(0.0f, 0.0f, 0.0f, 0.0f), - Vector4(0.0f, 0.0f, 0.0f, 0.0f), - Vector4(0.0f, 0.0f, 0.0f, 0.0f))); + constexpr Matrix4x4 a(Matrix4x4::Zero); + CORRADE_COMPARE(a, Matrix4x4(Vector4(0.0f, 0.0f, 0.0f, 0.0f), + Vector4(0.0f, 0.0f, 0.0f, 0.0f), + Vector4(0.0f, 0.0f, 0.0f, 0.0f), + Vector4(0.0f, 0.0f, 0.0f, 0.0f))); } void MatrixTest::constructConversion() { - constexpr Matrix4 a(Vector4(3.0f, 5.0f, 8.0f, -3.0f), - Vector4(4.5f, 4.0f, 7.0f, 2.0f), - Vector4(1.0f, 2.0f, 3.0f, -1.0f), - Vector4(7.9f, -1.0f, 8.0f, -1.5f)); + constexpr Matrix4x4 a(Vector4(3.0f, 5.0f, 8.0f, -3.0f), + Vector4(4.5f, 4.0f, 7.0f, 2.0f), + Vector4(1.0f, 2.0f, 3.0f, -1.0f), + Vector4(7.9f, -1.0f, 8.0f, -1.5f)); #ifndef CORRADE_GCC46_COMPATIBILITY - constexpr Matrix4i b(a); + constexpr Matrix4x4i b(a); #else Matrix4i b(a); /* Not constexpr under GCC < 4.7 */ #endif - CORRADE_COMPARE(b, Matrix4i(Vector4i(3, 5, 8, -3), - Vector4i(4, 4, 7, 2), - Vector4i(1, 2, 3, -1), - Vector4i(7, -1, 8, -1))); + CORRADE_COMPARE(b, Matrix4x4i(Vector4i(3, 5, 8, -3), + Vector4i(4, 4, 7, 2), + Vector4i(1, 2, 3, -1), + Vector4i(7, -1, 8, -1))); /* Implicit conversion is not allowed */ - CORRADE_VERIFY(!(std::is_convertible::value)); + CORRADE_VERIFY(!(std::is_convertible::value)); } void MatrixTest::constructCopy() { @@ -177,22 +177,22 @@ void MatrixTest::constructCopy() { Vector4(4.5f, 4.0f, 7.0f, 2.0f), Vector4(1.0f, 2.0f, 3.0f, -1.0f), Vector4(7.9f, -1.0f, 8.0f, -1.5f)); - constexpr Matrix4 b(a); - CORRADE_COMPARE(b, Matrix4(Vector4(3.0f, 5.0f, 8.0f, -3.0f), - Vector4(4.5f, 4.0f, 7.0f, 2.0f), - Vector4(1.0f, 2.0f, 3.0f, -1.0f), - Vector4(7.9f, -1.0f, 8.0f, -1.5f))); + constexpr Matrix4x4 b(a); + CORRADE_COMPARE(b, Matrix4x4(Vector4(3.0f, 5.0f, 8.0f, -3.0f), + Vector4(4.5f, 4.0f, 7.0f, 2.0f), + Vector4(1.0f, 2.0f, 3.0f, -1.0f), + Vector4(7.9f, -1.0f, 8.0f, -1.5f))); } void MatrixTest::convert() { constexpr Mat3 a{{1.5f, 2.0f, -3.5f, 2.0f, -3.1f, 0.4f, 9.5f, -1.5f, 0.1f}}; - constexpr Matrix3 b(Vector3(1.5f, 2.0f, -3.5f), - Vector3(2.0f, -3.1f, 0.4f), - Vector3(9.5f, -1.5f, 0.1f)); + constexpr Matrix3x3 b(Vector3(1.5f, 2.0f, -3.5f), + Vector3(2.0f, -3.1f, 0.4f), + Vector3(9.5f, -1.5f, 0.1f)); - constexpr Matrix3 c(b); + constexpr Matrix3x3 c(b); CORRADE_COMPARE(c, b); #ifndef CORRADE_GCC46_COMPATIBILITY @@ -203,20 +203,20 @@ void MatrixTest::convert() { CORRADE_COMPARE(d.a[i], a.a[i]); /* Implicit conversion is not allowed */ - CORRADE_VERIFY(!(std::is_convertible::value)); - CORRADE_VERIFY(!(std::is_convertible::value)); + CORRADE_VERIFY(!(std::is_convertible::value)); + CORRADE_VERIFY(!(std::is_convertible::value)); } void MatrixTest::isOrthogonal() { - CORRADE_VERIFY(!Matrix3(Vector3(1.0f, 0.0f, 0.0f), - Vector3(0.0f, 1.0f, 0.0f), - Vector3(0.0f, 0.1f, 1.0f)).isOrthogonal()); - CORRADE_VERIFY(!Matrix3(Vector3(1.0f, 0.0f, 0.0f), - Vector3(0.0f, 1.0f, 0.0f), - Vector3(0.0f, 1.0f, 0.0f)).isOrthogonal()); - CORRADE_VERIFY(Matrix3(Vector3(1.0f, 0.0f, 0.0f), - Vector3(0.0f, 1.0f, 0.0f), - Vector3(0.0f, 0.0f, 1.0f)).isOrthogonal()); + CORRADE_VERIFY(!Matrix3x3(Vector3(1.0f, 0.0f, 0.0f), + Vector3(0.0f, 1.0f, 0.0f), + Vector3(0.0f, 0.1f, 1.0f)).isOrthogonal()); + CORRADE_VERIFY(!Matrix3x3(Vector3(1.0f, 0.0f, 0.0f), + Vector3(0.0f, 1.0f, 0.0f), + Vector3(0.0f, 1.0f, 0.0f)).isOrthogonal()); + CORRADE_VERIFY(Matrix3x3(Vector3(1.0f, 0.0f, 0.0f), + Vector3(0.0f, 1.0f, 0.0f), + Vector3(0.0f, 0.0f, 1.0f)).isOrthogonal()); } void MatrixTest::trace() { @@ -232,14 +232,14 @@ void MatrixTest::trace() { } void MatrixTest::ij() { - Matrix4 original(Vector4( 0.0f, 1.0f, 2.0f, 3.0f), - Vector4( 4.0f, 5.0f, 6.0f, 7.0f), - Vector4( 8.0f, 9.0f, 10.0f, 11.0f), - Vector4(12.0f, 13.0f, 14.0f, 15.0f)); + Matrix4x4 original(Vector4( 0.0f, 1.0f, 2.0f, 3.0f), + Vector4( 4.0f, 5.0f, 6.0f, 7.0f), + Vector4( 8.0f, 9.0f, 10.0f, 11.0f), + Vector4(12.0f, 13.0f, 14.0f, 15.0f)); - Matrix3 skipped(Vector3( 0.0f, 1.0f, 3.0f), - Vector3( 8.0f, 9.0f, 11.0f), - Vector3(12.0f, 13.0f, 15.0f)); + Matrix3x3 skipped(Vector3( 0.0f, 1.0f, 3.0f), + Vector3( 8.0f, 9.0f, 11.0f), + Vector3(12.0f, 13.0f, 15.0f)); CORRADE_COMPARE(original.ij(1, 2), skipped); } @@ -257,33 +257,33 @@ void MatrixTest::determinant() { } void MatrixTest::inverted() { - Matrix4 m(Vector4(3.0f, 5.0f, 8.0f, 4.0f), - Vector4(4.0f, 4.0f, 7.0f, 3.0f), - Vector4(7.0f, -1.0f, 8.0f, 0.0f), - Vector4(9.0f, 4.0f, 5.0f, 9.0f)); + Matrix4x4 m(Vector4(3.0f, 5.0f, 8.0f, 4.0f), + Vector4(4.0f, 4.0f, 7.0f, 3.0f), + Vector4(7.0f, -1.0f, 8.0f, 0.0f), + Vector4(9.0f, 4.0f, 5.0f, 9.0f)); - Matrix4 inverse(Vector4(-60/103.0f, 71/103.0f, -4/103.0f, 3/103.0f), - Vector4(-66/103.0f, 109/103.0f, -25/103.0f, -7/103.0f), - Vector4(177/412.0f, -97/206.0f, 53/412.0f, -7/206.0f), - Vector4(259/412.0f, -185/206.0f, 31/412.0f, 27/206.0f)); + Matrix4x4 inverse(Vector4(-60/103.0f, 71/103.0f, -4/103.0f, 3/103.0f), + Vector4(-66/103.0f, 109/103.0f, -25/103.0f, -7/103.0f), + Vector4(177/412.0f, -97/206.0f, 53/412.0f, -7/206.0f), + Vector4(259/412.0f, -185/206.0f, 31/412.0f, 27/206.0f)); - Matrix4 _inverse = m.inverted(); + Matrix4x4 _inverse = m.inverted(); CORRADE_COMPARE(_inverse, inverse); - CORRADE_COMPARE(_inverse*m, Matrix4()); + CORRADE_COMPARE(_inverse*m, Matrix4x4()); } void MatrixTest::invertedOrthogonal() { std::ostringstream o; Error::setOutput(&o); - Matrix3 a(Vector3(Constants::sqrt3()/2.0f, 0.5f, 0.0f), - Vector3(-0.5f, Constants::sqrt3()/2.0f, 0.0f), - Vector3(0.0f, 0.0f, 1.0f)); + Matrix3x3 a(Vector3(Constants::sqrt3()/2.0f, 0.5f, 0.0f), + Vector3(-0.5f, Constants::sqrt3()/2.0f, 0.0f), + Vector3(0.0f, 0.0f, 1.0f)); (a*2).invertedOrthogonal(); CORRADE_COMPARE(o.str(), "Math::Matrix::invertedOrthogonal(): the matrix is not orthogonal\n"); - CORRADE_COMPARE(a.invertedOrthogonal()*a, Matrix3()); + CORRADE_COMPARE(a.invertedOrthogonal()*a, Matrix3x3()); CORRADE_COMPARE(a.invertedOrthogonal(), a.inverted()); } @@ -344,10 +344,10 @@ void MatrixTest::subclass() { } void MatrixTest::debug() { - Matrix4 m(Vector4(3.0f, 5.0f, 8.0f, 4.0f), - Vector4(4.0f, 4.0f, 7.0f, 3.0f), - Vector4(7.0f, -1.0f, 8.0f, 0.0f), - Vector4(9.0f, 4.0f, 5.0f, 9.0f)); + Matrix4x4 m(Vector4(3.0f, 5.0f, 8.0f, 4.0f), + Vector4(4.0f, 4.0f, 7.0f, 3.0f), + Vector4(7.0f, -1.0f, 8.0f, 0.0f), + Vector4(9.0f, 4.0f, 5.0f, 9.0f)); std::ostringstream o; Debug(&o) << m; @@ -357,7 +357,7 @@ void MatrixTest::debug() { " 4, 3, 0, 9)\n"); o.str({}); - Debug(&o) << "a" << Matrix4() << "b" << Matrix4(); + Debug(&o) << "a" << Matrix4x4() << "b" << Matrix4x4(); CORRADE_COMPARE(o.str(), "a Matrix(1, 0, 0, 0,\n" " 0, 1, 0, 0,\n" " 0, 0, 1, 0,\n" @@ -370,15 +370,15 @@ void MatrixTest::debug() { void MatrixTest::configuration() { Corrade::Utility::Configuration c; - Matrix4 m(Vector4(3.0f, 5.0f, 8.0f, 4.0f), - Vector4(4.0f, 4.0f, 7.0f, 3.125f), - Vector4(7.0f, -1.0f, 8.0f, 0.0f), - Vector4(9.0f, 4.0f, 5.0f, 9.55f)); + Matrix4x4 m(Vector4(3.0f, 5.0f, 8.0f, 4.0f), + Vector4(4.0f, 4.0f, 7.0f, 3.125f), + Vector4(7.0f, -1.0f, 8.0f, 0.0f), + Vector4(9.0f, 4.0f, 5.0f, 9.55f)); std::string value("3 4 7 9 5 4 -1 4 8 7 8 5 4 3.125 0 9.55"); c.setValue("matrix", m); CORRADE_COMPARE(c.value("matrix"), value); - CORRADE_COMPARE(c.value("matrix"), m); + CORRADE_COMPARE(c.value("matrix"), m); } }}} diff --git a/src/Math/Test/QuaternionTest.cpp b/src/Math/Test/QuaternionTest.cpp index 1ab42012f..1d4413861 100644 --- a/src/Math/Test/QuaternionTest.cpp +++ b/src/Math/Test/QuaternionTest.cpp @@ -69,7 +69,7 @@ class QuaternionTest: public Corrade::TestSuite::Tester { typedef Math::Deg Deg; typedef Math::Rad Rad; -typedef Math::Matrix<3, Float> Matrix3; +typedef Math::Matrix<3, Float> Matrix3x3; typedef Math::Matrix4 Matrix4; typedef Math::Quaternion Quaternion; typedef Math::Vector3 Vector3; @@ -283,7 +283,7 @@ void QuaternionTest::matrix() { Vector3 axis = Vector3(1.0f, -3.0f, 5.0f).normalized(); Quaternion q = Quaternion::rotation(Deg(37.0f), axis); - Matrix3 m = Matrix4::rotation(Deg(37.0f), axis).rotationScaling(); + Matrix3x3 m = Matrix4::rotation(Deg(37.0f), axis).rotationScaling(); /* Verify that negated quaternion gives the same rotation */ CORRADE_COMPARE(q.toMatrix(), m); @@ -299,7 +299,7 @@ void QuaternionTest::matrix() { CORRADE_COMPARE(Quaternion::fromMatrix(m), q); /* Trace < 0 */ - Matrix3 m2 = Matrix4::rotation(Deg(130.0f), axis).rotationScaling(); + Matrix3x3 m2 = Matrix4::rotation(Deg(130.0f), axis).rotationScaling(); Quaternion q2 = Quaternion::rotation(Deg(130.0f), axis); CORRADE_VERIFY(m2.trace() < 0.0f); CORRADE_COMPARE(Quaternion::fromMatrix(m2), q2); diff --git a/src/Math/Test/RectangularMatrixTest.cpp b/src/Math/Test/RectangularMatrixTest.cpp index b1104fa1b..d77e97289 100644 --- a/src/Math/Test/RectangularMatrixTest.cpp +++ b/src/Math/Test/RectangularMatrixTest.cpp @@ -90,8 +90,8 @@ class RectangularMatrixTest: public Corrade::TestSuite::Tester { typedef RectangularMatrix<4, 3, Float> Matrix4x3; typedef RectangularMatrix<3, 4, Float> Matrix3x4; -typedef RectangularMatrix<2, 2, Float> Matrix2; -typedef RectangularMatrix<2, 2, Int> Matrix2i; +typedef RectangularMatrix<2, 2, Float> Matrix2x2; +typedef RectangularMatrix<2, 2, Int> Matrix2x2i; typedef Vector<4, Float> Vector4; typedef Vector<3, Float> Vector3; typedef Vector<2, Float> Vector2; @@ -152,19 +152,19 @@ void RectangularMatrixTest::constructDefault() { } void RectangularMatrixTest::constructConversion() { - constexpr Matrix2 a(Vector2( 1.3f, 2.7f), - Vector2(-15.0f, 7.0f)); + constexpr Matrix2x2 a(Vector2( 1.3f, 2.7f), + Vector2(-15.0f, 7.0f)); #ifndef CORRADE_GCC46_COMPATIBILITY - constexpr Matrix2i b(a); + constexpr Matrix2x2i b(a); #else - Matrix2i b(a); /* Not constexpr under GCC < 4.7 */ + Matrix2x2i b(a); /* Not constexpr under GCC < 4.7 */ #endif - CORRADE_COMPARE(b, Matrix2i(Vector2i( 1, 2), - Vector2i(-15, 7))); + CORRADE_COMPARE(b, Matrix2x2i(Vector2i( 1, 2), + Vector2i(-15, 7))); /* Implicit conversion is not allowed */ - CORRADE_VERIFY(!(std::is_convertible::value)); + CORRADE_VERIFY(!(std::is_convertible::value)); } void RectangularMatrixTest::constructFromData() { @@ -268,28 +268,28 @@ void RectangularMatrixTest::row() { } void RectangularMatrixTest::compare() { - Matrix2 a(Vector2(1.0f, -3.0f), - Vector2(5.0f, -10.0f)); - Matrix2 b(Vector2(1.0f + TypeTraits::epsilon()/2, -3.0f), - Vector2(5.0f, -10.0f)); - Matrix2 c(Vector2(1.0f, -1.0f + TypeTraits::epsilon()*2), - Vector2(5.0f, -10.0f)); + Matrix2x2 a(Vector2(1.0f, -3.0f), + Vector2(5.0f, -10.0f)); + Matrix2x2 b(Vector2(1.0f + TypeTraits::epsilon()/2, -3.0f), + Vector2(5.0f, -10.0f)); + Matrix2x2 c(Vector2(1.0f, -1.0f + TypeTraits::epsilon()*2), + Vector2(5.0f, -10.0f)); CORRADE_VERIFY(a == b); CORRADE_VERIFY(a != c); - Matrix2i ai(Vector2i(1, -3), - Vector2i(5, -10)); - Matrix2i bi(Vector2i(1, -2), - Vector2i(5, -10)); + Matrix2x2i ai(Vector2i(1, -3), + Vector2i(5, -10)); + Matrix2x2i bi(Vector2i(1, -2), + Vector2i(5, -10)); CORRADE_VERIFY(ai == ai); CORRADE_VERIFY(ai != bi); } void RectangularMatrixTest::negative() { - Matrix2 matrix(Vector2(1.0f, -3.0f), - Vector2(5.0f, -10.0f)); - Matrix2 negated(Vector2(-1.0f, 3.0f), - Vector2(-5.0f, 10.0f)); + Matrix2x2 matrix(Vector2(1.0f, -3.0f), + Vector2(5.0f, -10.0f)); + Matrix2x2 negated(Vector2(-1.0f, 3.0f), + Vector2(-5.0f, 10.0f)); CORRADE_COMPARE(-matrix, negated); } @@ -312,20 +312,20 @@ void RectangularMatrixTest::addSubtract() { } void RectangularMatrixTest::multiplyDivide() { - Matrix2 matrix(Vector2(1.0f, 2.0f), - Vector2(3.0f, 4.0f)); - Matrix2 multiplied(Vector2(-1.5f, -3.0f), - Vector2(-4.5f, -6.0f)); + Matrix2x2 matrix(Vector2(1.0f, 2.0f), + Vector2(3.0f, 4.0f)); + Matrix2x2 multiplied(Vector2(-1.5f, -3.0f), + Vector2(-4.5f, -6.0f)); CORRADE_COMPARE(matrix*-1.5f, multiplied); CORRADE_COMPARE(-1.5f*matrix, multiplied); CORRADE_COMPARE(multiplied/-1.5f, matrix); /* Divide vector with number and inverse */ - Matrix2 divisor(Vector2( 1.0f, 2.0f), - Vector2(-4.0f, 8.0f)); - Matrix2 result(Vector2( 1.0f, 0.5f), - Vector2(-0.25f, 0.125f)); + Matrix2x2 divisor(Vector2( 1.0f, 2.0f), + Vector2(-4.0f, 8.0f)); + Matrix2x2 result(Vector2( 1.0f, 0.5f), + Vector2(-0.25f, 0.125f)); CORRADE_COMPARE(1.0f/divisor, result); } diff --git a/src/Shaders/Phong.h b/src/Shaders/Phong.h index 801c585ef..493599586 100644 --- a/src/Shaders/Phong.h +++ b/src/Shaders/Phong.h @@ -167,7 +167,7 @@ class MAGNUM_SHADERS_EXPORT Phong: public AbstractShaderProgram { * @brief Set normal matrix * @return Reference to self (for method chaining) */ - Phong& setNormalMatrix(const Math::Matrix<3, Float>& matrix) { + Phong& setNormalMatrix(const Matrix3x3& matrix) { setUniform(normalMatrixUniform, matrix); return *this; }