From 830ce69da07e968e0534f324ae72e92898fc3a92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 20 Feb 2013 21:06:09 +0100 Subject: [PATCH] Math: using Rad in Matrix*::rotation*(). Also updated dependent functions and tests. --- doc/matrix-vector.dox | 4 +- doc/scenegraph.dox | 2 +- src/Math/Matrix3.h | 11 ++- src/Math/Matrix4.h | 51 ++++++------ src/Math/Test/Matrix3Test.cpp | 11 +-- src/Math/Test/Matrix4Test.cpp | 26 ++++--- src/Math/Vector3.h | 2 +- src/Physics/Test/CapsuleTest.cpp | 2 +- src/Physics/Test/LineTest.cpp | 2 +- src/Physics/Test/PlaneTest.cpp | 2 +- src/Physics/Test/SphereTest.cpp | 2 +- .../AbstractTranslationRotation2D.h | 6 +- .../AbstractTranslationRotation3D.h | 22 +++--- src/SceneGraph/Animable.h | 2 +- src/SceneGraph/Drawable.h | 2 +- .../EuclideanMatrixTransformation2D.h | 8 +- .../EuclideanMatrixTransformation3D.h | 39 ++++++---- src/SceneGraph/MatrixTransformation2D.h | 2 +- src/SceneGraph/MatrixTransformation3D.h | 17 ++-- src/SceneGraph/Test/CameraTest.cpp | 2 +- .../EuclideanMatrixTransformation2DTest.cpp | 40 +++++----- .../EuclideanMatrixTransformation3DTest.cpp | 64 +++++++-------- .../Test/MatrixTransformation2DTest.cpp | 54 ++++++------- .../Test/MatrixTransformation3DTest.cpp | 78 +++++++++---------- src/SceneGraph/Test/ObjectTest.cpp | 36 ++++----- 25 files changed, 245 insertions(+), 242 deletions(-) diff --git a/doc/matrix-vector.dox b/doc/matrix-vector.dox index 5f5afec45..115e13991 100644 --- a/doc/matrix-vector.dox +++ b/doc/matrix-vector.dox @@ -74,7 +74,7 @@ Vectors are commonly used to specify various axes and scaling coefficients in transformations, you can use convenience functions instead of typing out all other elements: @code -Matrix4::rotation(deg(5.0f), Vector3::xAxis()); // {1.0f, 0.0f, 0.0f} +Matrix4::rotation(5.0_degf, Vector3::xAxis()); // {1.0f, 0.0f, 0.0f} Matrix3::translation(Vector2::yAxis(2.0f)); // {0.0f, 2.0f} Matrix4::scaling(Vector3::zScale(-10.0f)); // {1.0f, 1.0f, -10.0f} @endcode @@ -144,7 +144,7 @@ transformation: Matrix4 a = Matrix4::translation(Vector3::yAxis(4.0f)); Vector3 translation = a.translation(); -Matrix3 b = Matrix3::rotation(deg(15.f)); +Matrix3 b = Matrix3::rotation(15.0_degf)); Matrix<2, float> rotationScaling = b.rotationScaling(); Vector2 up = b.up(); @endcode diff --git a/doc/scenegraph.dox b/doc/scenegraph.dox index 4c478397b..28fec624d 100644 --- a/doc/scenegraph.dox +++ b/doc/scenegraph.dox @@ -88,7 +88,7 @@ transformation. For convenience you can use method chaining: Object3D* next = new Object3D; next->setParent(another) ->translate(Vector3::yAxis(3.0f)) - ->rotateY(deg(35.0f)); + ->rotateY(35.0_degf); @endcode @section scenegraph-features Object features diff --git a/src/Math/Matrix3.h b/src/Math/Matrix3.h index 86862bc39..a67efd47f 100644 --- a/src/Math/Matrix3.h +++ b/src/Math/Matrix3.h @@ -62,14 +62,13 @@ template class Matrix3: public Matrix<3, T> { /** * @brief 2D rotation matrix - * @param angle Rotation angle (counterclockwise, in radians) + * @param angle Rotation angle (counterclockwise) * - * @see rotation() const, Matrix4::rotation(T, const Vector3&), deg(), - * rad() + * @see rotation() const, Matrix4::rotation(Rad, const Vector3&) */ - static Matrix3 rotation(T angle) { - T sine = std::sin(angle); - T cosine = std::cos(angle); + static Matrix3 rotation(Rad angle) { + T sine = std::sin(T(angle)); + T cosine = std::cos(T(angle)); return {{ cosine, sine, T(0)}, { -sine, cosine, T(0)}, diff --git a/src/Math/Matrix4.h b/src/Math/Matrix4.h index 8799c05cd..c72dc52a9 100644 --- a/src/Math/Matrix4.h +++ b/src/Math/Matrix4.h @@ -70,21 +70,21 @@ template class Matrix4: public Matrix<4, T> { /** * @brief 3D rotation around arbitrary axis - * @param angle Rotation angle (counterclockwise, in radians) + * @param angle Rotation angle (counterclockwise) * @param normalizedAxis Normalized rotation axis * * Expects that the rotation axis is normalized. If possible, use * faster alternatives like rotationX(), rotationY() and rotationZ(). * @see rotation() const, DualQuaternion::rotation(), - * Quaternion::rotation(), Matrix3::rotation(T), Vector3::xAxis(), - * Vector3::yAxis(), Vector3::zAxis(), deg(), rad() + * Quaternion::rotation(), Matrix3::rotation(Rad), Vector3::xAxis(), + * Vector3::yAxis(), Vector3::zAxis() */ - static Matrix4 rotation(T angle, const Vector3& normalizedAxis) { + static Matrix4 rotation(Rad angle, const Vector3& normalizedAxis) { CORRADE_ASSERT(MathTypeTraits::equals(normalizedAxis.dot(), T(1)), "Math::Matrix4::rotation(): axis must be normalized", {}); - T sine = std::sin(angle); - T cosine = std::cos(angle); + T sine = std::sin(T(angle)); + T cosine = std::cos(T(angle)); T oneMinusCosine = T(1) - cosine; T xx = normalizedAxis.x()*normalizedAxis.x(); @@ -113,16 +113,15 @@ template class Matrix4: public Matrix<4, T> { /** * @brief 3D rotation around X axis - * @param angle Rotation angle (counterclockwise, in radians) + * @param angle Rotation angle (counterclockwise) * * Faster than calling `Matrix4::rotation(angle, Vector3::xAxis())`. - * @see rotation(T, const Vector3&), rotationY(), rotationZ(), - * rotation() const, Quaternion::rotation(), Matrix3::rotation(T), - * deg(), rad() + * @see rotation(Rad, const Vector3&), rotationY(), rotationZ(), + * rotation() const, Quaternion::rotation(), Matrix3::rotation(Rad) */ - static Matrix4 rotationX(T angle) { - T sine = std::sin(angle); - T cosine = std::cos(angle); + static Matrix4 rotationX(Rad angle) { + T sine = std::sin(T(angle)); + T cosine = std::cos(T(angle)); return {{T(1), T(0), T(0), T(0)}, {T(0), cosine, sine, T(0)}, @@ -132,16 +131,15 @@ template class Matrix4: public Matrix<4, T> { /** * @brief 3D rotation around Y axis - * @param angle Rotation angle (counterclockwise, in radians) + * @param angle Rotation angle (counterclockwise) * * Faster than calling `Matrix4::rotation(angle, Vector3::yAxis())`. - * @see rotation(T, const Vector3&), rotationX(), rotationZ(), - * rotation() const, Quaternion::rotation(), Matrix3::rotation(T), - * deg(), rad() + * @see rotation(Rad, const Vector3&), rotationX(), rotationZ(), + * rotation() const, Quaternion::rotation(), Matrix3::rotation(Rad) */ - static Matrix4 rotationY(T angle) { - T sine = std::sin(angle); - T cosine = std::cos(angle); + static Matrix4 rotationY(Rad angle) { + T sine = std::sin(T(angle)); + T cosine = std::cos(T(angle)); return {{cosine, T(0), -sine, T(0)}, { T(0), T(1), T(0), T(0)}, @@ -151,16 +149,15 @@ template class Matrix4: public Matrix<4, T> { /** * @brief 3D rotation matrix around Z axis - * @param angle Rotation angle (counterclockwise, in radians) + * @param angle Rotation angle (counterclockwise) * * Faster than calling `Matrix4::rotation(angle, Vector3::zAxis())`. - * @see rotation(T, const Vector3&), rotationX(), rotationY(), - * rotation() const, Quaternion::rotation(), Matrix3::rotation(T), - * deg(), rad() + * @see rotation(Rad, const Vector3&), rotationX(), rotationY(), + * rotation() const, Quaternion::rotation(), Matrix3::rotation(Rad) */ - static Matrix4 rotationZ(T angle) { - T sine = std::sin(angle); - T cosine = std::cos(angle); + static Matrix4 rotationZ(Rad angle) { + T sine = std::sin(T(angle)); + T cosine = std::cos(T(angle)); return {{cosine, sine, T(0), T(0)}, { -sine, cosine, T(0), T(0)}, diff --git a/src/Math/Test/Matrix3Test.cpp b/src/Math/Test/Matrix3Test.cpp index 5f61137ca..f0126f04f 100644 --- a/src/Math/Test/Matrix3Test.cpp +++ b/src/Math/Test/Matrix3Test.cpp @@ -44,6 +44,7 @@ class Matrix3Test: public Corrade::TestSuite::Tester { void configuration(); }; +typedef Math::Deg Deg; typedef Math::Matrix3 Matrix3; typedef Math::Matrix<2, float> Matrix2; typedef Math::Vector2 Vector2; @@ -107,7 +108,7 @@ void Matrix3Test::rotation() { {-0.258819f, 0.965926f, 0.0f}, { 0.0f, 0.0f, 1.0f}); - CORRADE_COMPARE(Matrix3::rotation(deg(15.0f)), matrix); + CORRADE_COMPARE(Matrix3::rotation(Deg(15.0f)), matrix); } void Matrix3Test::reflection() { @@ -165,7 +166,7 @@ void Matrix3Test::rotationPart() { Matrix2 expectedRotationPart(Vector2( 0.965926f, 0.258819f), Vector2(-0.258819f, 0.965926f)); - Matrix3 rotation = Matrix3::rotation(deg(15.0f)); + Matrix3 rotation = Matrix3::rotation(Deg(15.0f)); CORRADE_COMPARE(rotation.rotation(), expectedRotationPart); Matrix3 rotationTransformed = Matrix3::translation({2.0f, 5.0f})*rotation*Matrix3::scaling(Vector2(9.0f)); @@ -196,19 +197,19 @@ void Matrix3Test::invertedEuclidean() { CORRADE_COMPARE(Matrix3::scaling(Vector2(2.0f)).invertedEuclidean(), Matrix3()); CORRADE_COMPARE(o.str(), "Math::Matrix3::invertedEuclidean(): the matrix doesn't represent Euclidean transformation\n"); - Matrix3 actual = Matrix3::rotation(deg(-74.0f))* + Matrix3 actual = Matrix3::rotation(Deg(-74.0f))* Matrix3::reflection(Vector2(0.5f, -2.0f).normalized())* Matrix3::translation({2.0f, -3.0f}); Matrix3 expected = Matrix3::translation({-2.0f, 3.0f})* Matrix3::reflection(Vector2(0.5f, -2.0f).normalized())* - Matrix3::rotation(deg(74.0f)); + Matrix3::rotation(Deg(74.0f)); CORRADE_COMPARE(actual.invertedEuclidean(), expected); CORRADE_COMPARE(actual.invertedEuclidean(), actual.inverted()); } void Matrix3Test::transform() { - Matrix3 a = Matrix3::translation({1.0f, -5.0f})*Matrix3::rotation(deg(90.0f)); + Matrix3 a = Matrix3::translation({1.0f, -5.0f})*Matrix3::rotation(Deg(90.0f)); Vector2 v(1.0f, -2.0f); CORRADE_COMPARE(a.transformVector(v), Vector2(2.0f, 1.0f)); diff --git a/src/Math/Test/Matrix4Test.cpp b/src/Math/Test/Matrix4Test.cpp index b9c68eee3..c1d815587 100644 --- a/src/Math/Test/Matrix4Test.cpp +++ b/src/Math/Test/Matrix4Test.cpp @@ -49,6 +49,8 @@ class Matrix4Test: public Corrade::TestSuite::Tester { void configuration(); }; +typedef Math::Deg Deg; +typedef Math::Rad Rad; typedef Math::Matrix4 Matrix4; typedef Math::Matrix<3, float> Matrix3; typedef Math::Vector3 Vector3; @@ -120,14 +122,14 @@ void Matrix4Test::rotation() { std::ostringstream o; Error::setOutput(&o); - CORRADE_COMPARE(Matrix4::rotation(deg(-74.0f), {-1.0f, 2.0f, 2.0f}), Matrix4()); + CORRADE_COMPARE(Matrix4::rotation(Deg(-74.0f), {-1.0f, 2.0f, 2.0f}), Matrix4()); CORRADE_COMPARE(o.str(), "Math::Matrix4::rotation(): axis must be normalized\n"); Matrix4 matrix({ 0.35612214f, -0.80181062f, 0.47987163f, 0.0f}, { 0.47987163f, 0.59757638f, 0.6423595f, 0.0f}, {-0.80181062f, 0.0015183985f, 0.59757638f, 0.0f}, { 0.0f, 0.0f, 0.0f, 1.0f}); - CORRADE_COMPARE(Matrix4::rotation(deg(-74.0f), Vector3(-1.0f, 2.0f, 2.0f).normalized()), matrix); + CORRADE_COMPARE(Matrix4::rotation(Deg(-74.0f), Vector3(-1.0f, 2.0f, 2.0f).normalized()), matrix); } void Matrix4Test::rotationX() { @@ -135,8 +137,8 @@ void Matrix4Test::rotationX() { {0.0f, 0.90096887f, 0.43388374f, 0.0f}, {0.0f, -0.43388374f, 0.90096887f, 0.0f}, {0.0f, 0.0f, 0.0f, 1.0f}); - CORRADE_COMPARE(Matrix4::rotation(rad(Math::Constants::pi()/7), Vector3::xAxis()), matrix); - CORRADE_COMPARE(Matrix4::rotationX(rad(Math::Constants::pi()/7)), matrix); + CORRADE_COMPARE(Matrix4::rotation(Rad(Math::Constants::pi()/7), Vector3::xAxis()), matrix); + CORRADE_COMPARE(Matrix4::rotationX(Rad(Math::Constants::pi()/7)), matrix); } void Matrix4Test::rotationY() { @@ -144,8 +146,8 @@ void Matrix4Test::rotationY() { { 0.0f, 1.0f, 0.0f, 0.0f}, {0.43388374f, 0.0f, 0.90096887f, 0.0f}, { 0.0f, 0.0f, 0.0f, 1.0f}); - CORRADE_COMPARE(Matrix4::rotation(rad(Math::Constants::pi()/7), Vector3::yAxis()), matrix); - CORRADE_COMPARE(Matrix4::rotationY(rad(Math::Constants::pi()/7)), matrix); + CORRADE_COMPARE(Matrix4::rotation(Rad(Math::Constants::pi()/7), Vector3::yAxis()), matrix); + CORRADE_COMPARE(Matrix4::rotationY(Rad(Math::Constants::pi()/7)), matrix); } void Matrix4Test::rotationZ() { @@ -153,8 +155,8 @@ void Matrix4Test::rotationZ() { {-0.43388374f, 0.90096887f, 0.0f, 0.0f}, { 0.0f, 0.0f, 1.0f, 0.0f}, { 0.0f, 0.0f, 0.0f, 1.0f}); - CORRADE_COMPARE(Matrix4::rotation(rad(Math::Constants::pi()/7), Vector3::zAxis()), matrix); - CORRADE_COMPARE(Matrix4::rotationZ(rad(Math::Constants::pi()/7)), matrix); + CORRADE_COMPARE(Matrix4::rotation(Rad(Math::Constants::pi()/7), Vector3::zAxis()), matrix); + CORRADE_COMPARE(Matrix4::rotationZ(Rad(Math::Constants::pi()/7)), matrix); } void Matrix4Test::reflection() { @@ -232,7 +234,7 @@ void Matrix4Test::rotationPart() { Vector3( 0.47987163f, 0.59757638f, 0.6423595f), Vector3(-0.80181062f, 0.0015183985f, 0.59757638f)); - Matrix4 rotation = Matrix4::rotation(deg(-74.0f), Vector3(-1.0f, 2.0f, 2.0f).normalized()); + Matrix4 rotation = Matrix4::rotation(Deg(-74.0f), Vector3(-1.0f, 2.0f, 2.0f).normalized()); CORRADE_COMPARE(rotation.rotation().determinant(), 1.0f); CORRADE_COMPARE(rotation.rotation()*rotation.rotation().transposed(), Matrix3()); CORRADE_COMPARE(rotation.rotation(), expectedRotationPart); @@ -270,19 +272,19 @@ void Matrix4Test::invertedEuclidean() { CORRADE_COMPARE(Matrix4::scaling(Vector3(2.0f)).invertedEuclidean(), Matrix4()); CORRADE_COMPARE(o.str(), "Math::Matrix4::invertedEuclidean(): the matrix doesn't represent Euclidean transformation\n"); - Matrix4 actual = Matrix4::rotation(deg(-74.0f), Vector3(-1.0f, 0.5f, 2.0f).normalized())* + Matrix4 actual = Matrix4::rotation(Deg(-74.0f), Vector3(-1.0f, 0.5f, 2.0f).normalized())* Matrix4::reflection(Vector3(0.5f, -2.0f, 2.0f).normalized())* Matrix4::translation({1.0f, 2.0f, -3.0f}); Matrix4 expected = Matrix4::translation({-1.0f, -2.0f, 3.0f})* Matrix4::reflection(Vector3(0.5f, -2.0f, 2.0f).normalized())* - Matrix4::rotation(deg(74.0f), Vector3(-1.0f, 0.5f, 2.0f).normalized()); + Matrix4::rotation(Deg(74.0f), Vector3(-1.0f, 0.5f, 2.0f).normalized()); CORRADE_COMPARE(actual.invertedEuclidean(), expected); CORRADE_COMPARE(actual.invertedEuclidean(), actual.inverted()); } void Matrix4Test::transform() { - Matrix4 a = Matrix4::translation({1.0f, -5.0f, 3.5f})*Matrix4::rotation(deg(90.0f), Vector3::zAxis()); + Matrix4 a = Matrix4::translation({1.0f, -5.0f, 3.5f})*Matrix4::rotation(Deg(90.0f), Vector3::zAxis()); Vector3 v(1.0f, -2.0f, 5.5f); CORRADE_COMPARE(a.transformVector(v), Vector3(2.0f, 1.0f, 5.5f)); diff --git a/src/Math/Vector3.h b/src/Math/Vector3.h index 9c1996bab..d54f96f37 100644 --- a/src/Math/Vector3.h +++ b/src/Math/Vector3.h @@ -41,7 +41,7 @@ template class Vector3: public Vector<3, T> { * Usable for translation or rotation along given axis, for example: * @code * Matrix4::translation(Vector3::xAxis(5.0f)); // same as Matrix4::translation({5.0f, 0.0f, 0.0f}); - * Matrix4::rotation(deg(30.0f), Vector3::xAxis()); // same as Matrix::rotation(deg(30.0f), {1.0f, 0.0f, 0.0f}); + * Matrix4::rotation(30.0_degf, Vector3::xAxis()); // same as Matrix::rotation(30.0_degf, {1.0f, 0.0f, 0.0f}); * @endcode * @see yAxis(), zAxis(), xScale(), Matrix4::right() */ diff --git a/src/Physics/Test/CapsuleTest.cpp b/src/Physics/Test/CapsuleTest.cpp index 60636bf5e..a3b0f9c16 100644 --- a/src/Physics/Test/CapsuleTest.cpp +++ b/src/Physics/Test/CapsuleTest.cpp @@ -39,7 +39,7 @@ CapsuleTest::CapsuleTest() { void CapsuleTest::applyTransformation() { Physics::Capsule3D capsule({1.0f, 2.0f, 3.0f}, {-1.0f, -2.0f, -3.0f}, 7.0f); - capsule.applyTransformationMatrix(Matrix4::rotation(deg(90.0f), Vector3::zAxis())); + capsule.applyTransformationMatrix(Matrix4::rotation(Deg(90.0f), Vector3::zAxis())); CORRADE_COMPARE(capsule.transformedA(), Vector3(-2.0f, 1.0f, 3.0f)); CORRADE_COMPARE(capsule.transformedB(), Vector3(2.0f, -1.0f, -3.0f)); CORRADE_COMPARE(capsule.radius(), 7.0f); diff --git a/src/Physics/Test/LineTest.cpp b/src/Physics/Test/LineTest.cpp index 2b9c8be2c..6f67631b8 100644 --- a/src/Physics/Test/LineTest.cpp +++ b/src/Physics/Test/LineTest.cpp @@ -34,7 +34,7 @@ LineTest::LineTest() { void LineTest::applyTransformation() { Physics::Line3D line({1.0f, 2.0f, 3.0f}, {-1.0f, -2.0f, -3.0f}); - line.applyTransformationMatrix(Matrix4::rotation(deg(90.0f), Vector3::zAxis())); + line.applyTransformationMatrix(Matrix4::rotation(Deg(90.0f), Vector3::zAxis())); CORRADE_COMPARE(line.transformedA(), Vector3(-2.0f, 1.0f, 3.0f)); CORRADE_COMPARE(line.transformedB(), Vector3(2.0f, -1.0f, -3.0f)); } diff --git a/src/Physics/Test/PlaneTest.cpp b/src/Physics/Test/PlaneTest.cpp index d3af840e0..14962e1de 100644 --- a/src/Physics/Test/PlaneTest.cpp +++ b/src/Physics/Test/PlaneTest.cpp @@ -40,7 +40,7 @@ PlaneTest::PlaneTest() { void PlaneTest::applyTransformation() { Physics::Plane plane({1.0f, 2.0f, 3.0f}, {Constants::sqrt2(), -Constants::sqrt2(), 0}); - plane.applyTransformationMatrix(Matrix4::rotation(deg(90.0f), Vector3::xAxis())); + plane.applyTransformationMatrix(Matrix4::rotation(Deg(90.0f), Vector3::xAxis())); CORRADE_COMPARE(plane.transformedPosition(), Vector3(1.0f, -3.0f, 2.0f)); CORRADE_COMPARE(plane.transformedNormal(), Vector3(Constants::sqrt2(), 0, -Constants::sqrt2())); diff --git a/src/Physics/Test/SphereTest.cpp b/src/Physics/Test/SphereTest.cpp index f53057f6d..a19477ac4 100644 --- a/src/Physics/Test/SphereTest.cpp +++ b/src/Physics/Test/SphereTest.cpp @@ -44,7 +44,7 @@ SphereTest::SphereTest() { void SphereTest::applyTransformation() { Physics::Sphere3D sphere({1.0f, 2.0f, 3.0f}, 7.0f); - sphere.applyTransformationMatrix(Matrix4::rotation(deg(90.0f), Vector3::yAxis())); + sphere.applyTransformationMatrix(Matrix4::rotation(Deg(90.0f), Vector3::yAxis())); CORRADE_COMPARE(sphere.transformedPosition(), Vector3(3.0f, 2.0f, -1.0f)); CORRADE_COMPARE(sphere.transformedRadius(), 7.0f); diff --git a/src/SceneGraph/AbstractTranslationRotation2D.h b/src/SceneGraph/AbstractTranslationRotation2D.h index 215be0d49..33b178d47 100644 --- a/src/SceneGraph/AbstractTranslationRotation2D.h +++ b/src/SceneGraph/AbstractTranslationRotation2D.h @@ -49,13 +49,11 @@ class AbstractTranslationRotation2D: public AbstractTransformation<2, T> { /** * @brief Rotate object - * @param angle Angle in radians, counterclockwise + * @param angle Angle (counterclockwise) * @param type Transformation type * @return Pointer to self (for method chaining) - * - * @see deg(), rad() */ - virtual AbstractTranslationRotation2D* rotate(T angle, TransformationType type = TransformationType::Global) = 0; + virtual AbstractTranslationRotation2D* rotate(Math::Rad angle, TransformationType type = TransformationType::Global) = 0; }; }} diff --git a/src/SceneGraph/AbstractTranslationRotation3D.h b/src/SceneGraph/AbstractTranslationRotation3D.h index bfc63943d..d0f49b47b 100644 --- a/src/SceneGraph/AbstractTranslationRotation3D.h +++ b/src/SceneGraph/AbstractTranslationRotation3D.h @@ -50,54 +50,52 @@ class AbstractTranslationRotation3D: public AbstractTransformation<3, T> { /** * @brief Rotate object - * @param angle Angle in radians, counterclockwise + * @param angle Angle (counterclockwise) * @param normalizedAxis Normalized rotation axis * @param type Transformation type * @return Pointer to self (for method chaining) * - * @see deg(), rad(), Vector3::xAxis(), Vector3::yAxis(), Vector3::zAxis() + * @see rotateX(), rotateY(), rotateZ(), Vector3::xAxis(), + * Vector3::yAxis(), Vector3::zAxis() */ - virtual AbstractTranslationRotation3D* rotate(T angle, const Math::Vector3& normalizedAxis, TransformationType type = TransformationType::Global) = 0; + virtual AbstractTranslationRotation3D* rotate(Math::Rad angle, const Math::Vector3& normalizedAxis, TransformationType type = TransformationType::Global) = 0; /** * @brief Rotate object around X axis - * @param angle Angle in radians, counterclockwise + * @param angle Angle (counterclockwise) * @param type Transformation type * @return Pointer to self (for method chaining) * * In some implementations faster than calling * `rotate(angle, Vector3::xAxis())`. - * @see deg(), rad() */ - virtual AbstractTranslationRotation3D* rotateX(T angle, TransformationType type = TransformationType::Global) { + virtual AbstractTranslationRotation3D* rotateX(Math::Rad angle, TransformationType type = TransformationType::Global) { return rotate(angle, Math::Vector3::xAxis(), type); } /** * @brief Rotate object around Y axis - * @param angle Angle in radians, counterclockwise + * @param angle Angle (counterclockwise) * @param type Transformation type * @return Pointer to self (for method chaining) * * In some implementations faster than calling * `rotate(angle, Vector3::yAxis())`. - * @see deg(), rad() */ - virtual AbstractTranslationRotation3D* rotateY(T angle, TransformationType type = TransformationType::Global) { + virtual AbstractTranslationRotation3D* rotateY(Math::Rad angle, TransformationType type = TransformationType::Global) { return rotate(angle, Math::Vector3::yAxis(), type); } /** * @brief Rotate object around Z axis - * @param angle Angle in radians, counterclockwise + * @param angle Angle (counterclockwise) * @param type Transformation type * @return Pointer to self (for method chaining) * * In some implementations faster than calling * `rotate(angle, Vector3::zAxis())`. - * @see deg(), rad() */ - virtual AbstractTranslationRotation3D* rotateZ(T angle, TransformationType type = TransformationType::Global) { + virtual AbstractTranslationRotation3D* rotateZ(Math::Rad angle, TransformationType type = TransformationType::Global) { return rotate(angle, Math::Vector3::zAxis(), type); } }; diff --git a/src/SceneGraph/Animable.h b/src/SceneGraph/Animable.h index 3b21555e6..a58dbfea3 100644 --- a/src/SceneGraph/Animable.h +++ b/src/SceneGraph/Animable.h @@ -75,7 +75,7 @@ class AnimableObject: public Object3D, SceneGraph::Animable3D<> { } void animationStep(GLfloat time, GLfloat delta) override { - rotateX(deg(15.0f)*delta); // rotate at 15 degrees per second + rotateX(15.0_degf*delta); // rotate at 15 degrees per second } } @endcode diff --git a/src/SceneGraph/Drawable.h b/src/SceneGraph/Drawable.h index 702d3d60c..daad699c9 100644 --- a/src/SceneGraph/Drawable.h +++ b/src/SceneGraph/Drawable.h @@ -59,7 +59,7 @@ SceneGraph::DrawableGroup3D<> drawables; (new DrawableObject(&scene, &drawables)) ->translate(Vector3::yAxis(-0.3f)) - ->rotateX(deg(30.0f)); + ->rotateX(30.0_degf); (new AnotherDrawableObject(&scene, &drawables)) ->translate(Vector3::zAxis(0.5f)); // ... diff --git a/src/SceneGraph/EuclideanMatrixTransformation2D.h b/src/SceneGraph/EuclideanMatrixTransformation2D.h index 3b497cf40..12fe4749c 100644 --- a/src/SceneGraph/EuclideanMatrixTransformation2D.h +++ b/src/SceneGraph/EuclideanMatrixTransformation2D.h @@ -98,13 +98,13 @@ class EuclideanMatrixTransformation2D: public AbstractTranslationRotation2D { /** * @brief Rotate object - * @param angle Angle in radians, counterclockwise + * @param angle Angle (counterclockwise) * @param type Transformation type * @return Pointer to self (for method chaining) * - * @see deg(), rad(), normalizeRotation() + * @see normalizeRotation(), Matrix3::rotation() */ - inline EuclideanMatrixTransformation2D* rotate(T angle, TransformationType type = TransformationType::Global) override { + inline EuclideanMatrixTransformation2D* rotate(Math::Rad angle, TransformationType type = TransformationType::Global) override { transform(Math::Matrix3::rotation(angle), type); return this; } @@ -115,6 +115,8 @@ class EuclideanMatrixTransformation2D: public AbstractTranslationRotation2D { * (normalized) * @param type Transformation type * @return Pointer to self (for method chaining) + * + * @see Matrix3::reflection() */ inline EuclideanMatrixTransformation2D* reflect(const Math::Vector2& normal, TransformationType type = TransformationType::Global) { transform(Math::Matrix3::reflection(normal), type); diff --git a/src/SceneGraph/EuclideanMatrixTransformation3D.h b/src/SceneGraph/EuclideanMatrixTransformation3D.h index 693b2b6c1..35cda398e 100644 --- a/src/SceneGraph/EuclideanMatrixTransformation3D.h +++ b/src/SceneGraph/EuclideanMatrixTransformation3D.h @@ -90,7 +90,15 @@ class EuclideanMatrixTransformation3D: public AbstractTranslationRotation3D { return this; } - /** @copydoc AbstractTranslationRotation3D::translate() */ + /** + * @brief Translate object + * @param vector Translation vector + * @param type Transformation type + * @return Pointer to self (for method chaining) + * + * @see Vector3::xAxis(), Vector3::yAxis(), Vector3::zAxis(), + * Matrix4::translation() + */ inline EuclideanMatrixTransformation3D* translate(const Math::Vector3& vector, TransformationType type = TransformationType::Global) override { transform(Math::Matrix4::translation(vector), type); return this; @@ -98,54 +106,55 @@ class EuclideanMatrixTransformation3D: public AbstractTranslationRotation3D { /** * @brief Rotate object - * @param angle Angle in radians, counterclockwise + * @param angle Angle (counterclockwise) * @param normalizedAxis Normalized rotation axis * @param type Transformation type * @return Pointer to self (for method chaining) * - * @see deg(), rad(), Vector3::xAxis(), Vector3::yAxis(), - * Vector3::zAxis(), normalizeRotation() + * @see rotateX(), rotateY(), rotateZ(), Vector3::xAxis(), + * Vector3::yAxis(), Vector3::zAxis(), normalizeRotation(), + * Matrix4::rotation() */ - inline EuclideanMatrixTransformation3D* rotate(T angle, const Math::Vector3& normalizedAxis, TransformationType type = TransformationType::Global) override { + inline EuclideanMatrixTransformation3D* rotate(Math::Rad angle, const Math::Vector3& normalizedAxis, TransformationType type = TransformationType::Global) override { transform(Math::Matrix4::rotation(angle, normalizedAxis), type); return this; } /** * @brief Rotate object around X axis - * @param angle Angle in radians, counterclockwise + * @param angle Angle (counterclockwise) * @param type Transformation type * @return Pointer to self (for method chaining) * - * @see deg(), rad(), normalizeRotation() + * @see normalizeRotation(), Matrix4::rotationX() */ - inline EuclideanMatrixTransformation3D* rotateX(T angle, TransformationType type = TransformationType::Global) override { + inline EuclideanMatrixTransformation3D* rotateX(Math::Rad angle, TransformationType type = TransformationType::Global) override { transform(Math::Matrix4::rotationX(angle), type); return this; } /** * @brief Rotate object around Y axis - * @param angle Angle in radians, counterclockwise + * @param angle Angle (counterclockwise) * @param type Transformation type * @return Pointer to self (for method chaining) * - * @see deg(), rad(), normalizeRotation() + * @see normalizeRotation(), Matrix4::rotationY() */ - inline EuclideanMatrixTransformation3D* rotateY(T angle, TransformationType type = TransformationType::Global) override { + inline EuclideanMatrixTransformation3D* rotateY(Math::Rad angle, TransformationType type = TransformationType::Global) override { transform(Math::Matrix4::rotationY(angle), type); return this; } /** * @brief Rotate object around Z axis - * @param angle Angle in radians, counterclockwise + * @param angle Angle (counterclockwise) * @param type Transformation type * @return Pointer to self (for method chaining) * - * @see deg(), rad(), normalizeRotation() + * @see normalizeRotation(), Matrix4::rotationZ() */ - inline EuclideanMatrixTransformation3D* rotateZ(T angle, TransformationType type = TransformationType::Global) override { + inline EuclideanMatrixTransformation3D* rotateZ(Math::Rad angle, TransformationType type = TransformationType::Global) override { transform(Math::Matrix4::rotationZ(angle), type); return this; } @@ -157,7 +166,7 @@ class EuclideanMatrixTransformation3D: public AbstractTranslationRotation3D { * @param type Transformation type * @return Pointer to self (for method chaining) * - * Same as calling transform() with Matrix4::reflection(). + * @see Matrix4::reflection() */ inline EuclideanMatrixTransformation3D* reflect(const Math::Vector3& normal, TransformationType type = TransformationType::Global) { transform(Math::Matrix4::reflection(normal), type); diff --git a/src/SceneGraph/MatrixTransformation2D.h b/src/SceneGraph/MatrixTransformation2D.h index 08f1fdbd0..87cb449fc 100644 --- a/src/SceneGraph/MatrixTransformation2D.h +++ b/src/SceneGraph/MatrixTransformation2D.h @@ -104,7 +104,7 @@ class MatrixTransformation2D: public AbstractTranslationRotationScaling2D { * @copydoc AbstractTranslationRotationScaling2D::rotate() * Same as calling transform() with Matrix3::rotation(). */ - inline MatrixTransformation2D* rotate(T angle, TransformationType type = TransformationType::Global) override { + inline MatrixTransformation2D* rotate(Math::Rad angle, TransformationType type = TransformationType::Global) override { transform(Math::Matrix3::rotation(angle), type); return this; } diff --git a/src/SceneGraph/MatrixTransformation3D.h b/src/SceneGraph/MatrixTransformation3D.h index c5018a684..0c613cacb 100644 --- a/src/SceneGraph/MatrixTransformation3D.h +++ b/src/SceneGraph/MatrixTransformation3D.h @@ -104,49 +104,46 @@ class MatrixTransformation3D: public AbstractTranslationRotationScaling3D { * @copydoc AbstractTranslationRotationScaling3D::rotate() * Same as calling transform() with Matrix4::rotation(). */ - inline MatrixTransformation3D* rotate(T angle, const Math::Vector3& normalizedAxis, TransformationType type = TransformationType::Global) override { + inline MatrixTransformation3D* rotate(Math::Rad angle, const Math::Vector3& normalizedAxis, TransformationType type = TransformationType::Global) override { transform(Math::Matrix4::rotation(angle, normalizedAxis), type); return this; } /** * @brief Rotate object around X axis - * @param angle Angle in radians, counterclockwise + * @param angle Angle (counterclockwise) * @param type Transformation type * @return Pointer to self (for method chaining) * * Same as calling transform() with Matrix4::rotationX(). - * @see deg(), rad() */ - inline MatrixTransformation3D* rotateX(T angle, TransformationType type = TransformationType::Global) override { + inline MatrixTransformation3D* rotateX(Math::Rad angle, TransformationType type = TransformationType::Global) override { transform(Math::Matrix4::rotationX(angle), type); return this; } /** * @brief Rotate object around Y axis - * @param angle Angle in radians, counterclockwise + * @param angle Angle (counterclockwise) * @param type Transformation type * @return Pointer to self (for method chaining) * * Same as calling transform() with Matrix4::rotationY(). - * @see deg(), rad() */ - inline MatrixTransformation3D* rotateY(T angle, TransformationType type = TransformationType::Global) override { + inline MatrixTransformation3D* rotateY(Math::Rad angle, TransformationType type = TransformationType::Global) override { transform(Math::Matrix4::rotationY(angle), type); return this; } /** * @brief Rotate object around Z axis - * @param angle Angle in radians, counterclockwise + * @param angle Angle (counterclockwise) * @param type Transformation type * @return Pointer to self (for method chaining) * * Same as calling transform() with Matrix4::rotationZ(). - * @see deg(), rad() */ - inline MatrixTransformation3D* rotateZ(T angle, TransformationType type = TransformationType::Global) override { + inline MatrixTransformation3D* rotateZ(Math::Rad angle, TransformationType type = TransformationType::Global) override { transform(Math::Matrix4::rotationZ(angle), type); return this; } diff --git a/src/SceneGraph/Test/CameraTest.cpp b/src/SceneGraph/Test/CameraTest.cpp index 07d42dfc3..61f52a5cd 100644 --- a/src/SceneGraph/Test/CameraTest.cpp +++ b/src/SceneGraph/Test/CameraTest.cpp @@ -132,7 +132,7 @@ void CameraTest::projectionSizeOrthographic() { void CameraTest::projectionSizePerspective() { Object3D o; Camera3D camera(&o); - camera.setPerspective(deg(27.0f), 2.35f, 32.0f, 100); + camera.setPerspective(Deg(27.0f), 2.35f, 32.0f, 100); CORRADE_COMPARE(camera.projectionSize(), Vector2(0.48015756f, 0.204322f)); } diff --git a/src/SceneGraph/Test/EuclideanMatrixTransformation2DTest.cpp b/src/SceneGraph/Test/EuclideanMatrixTransformation2DTest.cpp index d772b969e..6ae1df500 100644 --- a/src/SceneGraph/Test/EuclideanMatrixTransformation2DTest.cpp +++ b/src/SceneGraph/Test/EuclideanMatrixTransformation2DTest.cpp @@ -54,23 +54,23 @@ EuclideanMatrixTransformation2DTest::EuclideanMatrixTransformation2DTest() { } void EuclideanMatrixTransformation2DTest::fromMatrix() { - Matrix3 m = Matrix3::rotation(deg(17.0f))*Matrix3::translation({1.0f, -0.3f}); + Matrix3 m = Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f}); CORRADE_COMPARE(EuclideanMatrixTransformation2D<>::fromMatrix(m), m); } void EuclideanMatrixTransformation2DTest::toMatrix() { - Matrix3 m = Matrix3::rotation(deg(17.0f))*Matrix3::translation({1.0f, -0.3f}); + Matrix3 m = Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f}); CORRADE_COMPARE(EuclideanMatrixTransformation2D<>::toMatrix(m), m); } void EuclideanMatrixTransformation2DTest::compose() { - Matrix3 parent = Matrix3::rotation(deg(17.0f)); + Matrix3 parent = Matrix3::rotation(Deg(17.0f)); Matrix3 child = Matrix3::translation({1.0f, -0.3f}); CORRADE_COMPARE(EuclideanMatrixTransformation2D<>::compose(parent, child), parent*child); } void EuclideanMatrixTransformation2DTest::inverted() { - Matrix3 m = Matrix3::rotation(deg(17.0f))*Matrix3::translation({1.0f, -0.3f}); + Matrix3 m = Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f}); CORRADE_COMPARE(EuclideanMatrixTransformation2D<>::inverted(m)*m, Matrix3()); } @@ -78,13 +78,13 @@ void EuclideanMatrixTransformation2DTest::setTransformation() { /* Dirty after setting transformation */ Object2D o; o.setClean(); - o.rotate(deg(17.0f)); + o.rotate(Deg(17.0f)); CORRADE_VERIFY(o.isDirty()); /* Scene cannot be transformed */ Scene2D s; s.setClean(); - s.rotate(deg(17.0f)); + s.rotate(Deg(17.0f)); CORRADE_VERIFY(!s.isDirty()); CORRADE_COMPARE(s.transformationMatrix(), Matrix3()); } @@ -92,14 +92,14 @@ void EuclideanMatrixTransformation2DTest::setTransformation() { void EuclideanMatrixTransformation2DTest::translate() { { Object2D o; - o.rotate(deg(17.0f)); + o.rotate(Deg(17.0f)); o.translate({1.0f, -0.3f}); - CORRADE_COMPARE(o.transformationMatrix(), Matrix3::translation({1.0f, -0.3f})*Matrix3::rotation(deg(17.0f))); + CORRADE_COMPARE(o.transformationMatrix(), Matrix3::translation({1.0f, -0.3f})*Matrix3::rotation(Deg(17.0f))); } { Object2D o; - o.rotate(deg(17.0f)); + o.rotate(Deg(17.0f)); o.translate({1.0f, -0.3f}, TransformationType::Local); - CORRADE_COMPARE(o.transformationMatrix(), Matrix3::rotation(deg(17.0f))*Matrix3::translation({1.0f, -0.3f})); + CORRADE_COMPARE(o.transformationMatrix(), Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f})); } } @@ -107,35 +107,35 @@ void EuclideanMatrixTransformation2DTest::rotate() { { Object2D o; o.translate({1.0f, -0.3f}); - o.rotate(deg(17.0f)); - CORRADE_COMPARE(o.transformationMatrix(), Matrix3::rotation(deg(17.0f))*Matrix3::translation({1.0f, -0.3f})); + o.rotate(Deg(17.0f)); + CORRADE_COMPARE(o.transformationMatrix(), Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f})); } { Object2D o; o.translate({1.0f, -0.3f}); - o.rotate(deg(17.0f), TransformationType::Local); - CORRADE_COMPARE(o.transformationMatrix(), Matrix3::translation({1.0f, -0.3f})*Matrix3::rotation(deg(17.0f))); + o.rotate(Deg(17.0f), TransformationType::Local); + CORRADE_COMPARE(o.transformationMatrix(), Matrix3::translation({1.0f, -0.3f})*Matrix3::rotation(Deg(17.0f))); } } void EuclideanMatrixTransformation2DTest::reflect() { { Object2D o; - o.rotate(deg(17.0f)); + o.rotate(Deg(17.0f)); o.reflect(Vector2(-1.0f/Constants::sqrt2())); - CORRADE_COMPARE(o.transformationMatrix(), Matrix3::reflection(Vector2(-1.0f/Constants::sqrt2()))*Matrix3::rotation(deg(17.0f))); + CORRADE_COMPARE(o.transformationMatrix(), Matrix3::reflection(Vector2(-1.0f/Constants::sqrt2()))*Matrix3::rotation(Deg(17.0f))); } { Object2D o; - o.rotate(deg(17.0f)); + o.rotate(Deg(17.0f)); o.reflect(Vector2(-1.0f/Constants::sqrt2()), TransformationType::Local); - CORRADE_COMPARE(o.transformationMatrix(), Matrix3::rotation(deg(17.0f))*Matrix3::reflection(Vector2(-1.0f/Constants::sqrt2()))); + CORRADE_COMPARE(o.transformationMatrix(), Matrix3::rotation(Deg(17.0f))*Matrix3::reflection(Vector2(-1.0f/Constants::sqrt2()))); } } void EuclideanMatrixTransformation2DTest::normalizeRotation() { Object2D o; - o.rotate(deg(17.0f)); + o.rotate(Deg(17.0f)); o.normalizeRotation(); - CORRADE_COMPARE(o.transformationMatrix(), Matrix3::rotation(deg(17.0f))); + CORRADE_COMPARE(o.transformationMatrix(), Matrix3::rotation(Deg(17.0f))); } }}} diff --git a/src/SceneGraph/Test/EuclideanMatrixTransformation3DTest.cpp b/src/SceneGraph/Test/EuclideanMatrixTransformation3DTest.cpp index ee1e79e0e..207b0d832 100644 --- a/src/SceneGraph/Test/EuclideanMatrixTransformation3DTest.cpp +++ b/src/SceneGraph/Test/EuclideanMatrixTransformation3DTest.cpp @@ -54,23 +54,23 @@ EuclideanMatrixTransformation3DTest::EuclideanMatrixTransformation3DTest() { } void EuclideanMatrixTransformation3DTest::fromMatrix() { - Matrix4 m = Matrix4::rotationX(deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f}); + Matrix4 m = Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f}); CORRADE_COMPARE(EuclideanMatrixTransformation3D<>::fromMatrix(m), m); } void EuclideanMatrixTransformation3DTest::toMatrix() { - Matrix4 m = Matrix4::rotationX(deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f}); + Matrix4 m = Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f}); CORRADE_COMPARE(EuclideanMatrixTransformation3D<>::toMatrix(m), m); } void EuclideanMatrixTransformation3DTest::compose() { - Matrix4 parent = Matrix4::rotationX(deg(17.0f)); + Matrix4 parent = Matrix4::rotationX(Deg(17.0f)); Matrix4 child = Matrix4::translation({1.0f, -0.3f, 2.3f}); CORRADE_COMPARE(EuclideanMatrixTransformation3D<>::compose(parent, child), parent*child); } void EuclideanMatrixTransformation3DTest::inverted() { - Matrix4 m = Matrix4::rotationX(deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f}); + Matrix4 m = Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f}); CORRADE_COMPARE(EuclideanMatrixTransformation3D<>::inverted(m)*m, Matrix4()); } @@ -78,13 +78,13 @@ void EuclideanMatrixTransformation3DTest::setTransformation() { /* Dirty after setting transformation */ Object3D o; o.setClean(); - o.rotateX(deg(17.0f)); + o.rotateX(Deg(17.0f)); CORRADE_VERIFY(o.isDirty()); /* Scene cannot be transformed */ Scene3D s; s.setClean(); - s.rotateX(deg(17.0f)); + s.rotateX(Deg(17.0f)); CORRADE_VERIFY(!s.isDirty()); CORRADE_COMPARE(s.transformationMatrix(), Matrix4()); } @@ -92,14 +92,14 @@ void EuclideanMatrixTransformation3DTest::setTransformation() { void EuclideanMatrixTransformation3DTest::translate() { { Object3D o; - o.rotateX(deg(17.0f)); + o.rotateX(Deg(17.0f)); o.translate({1.0f, -0.3f, 2.3f}); - CORRADE_COMPARE(o.transformationMatrix(), Matrix4::translation({1.0f, -0.3f, 2.3f})*Matrix4::rotationX(deg(17.0f))); + CORRADE_COMPARE(o.transformationMatrix(), Matrix4::translation({1.0f, -0.3f, 2.3f})*Matrix4::rotationX(Deg(17.0f))); } { Object3D o; - o.rotateX(deg(17.0f)); + o.rotateX(Deg(17.0f)); o.translate({1.0f, -0.3f, 2.3f}, TransformationType::Local); - CORRADE_COMPARE(o.transformationMatrix(), Matrix4::rotationX(deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f})); + CORRADE_COMPARE(o.transformationMatrix(), Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f})); } } @@ -107,51 +107,51 @@ void EuclideanMatrixTransformation3DTest::rotate() { { Object3D o; o.translate({1.0f, -0.3f, 2.3f}); - o.rotateX(deg(17.0f)) - ->rotateY(deg(25.0f)) - ->rotateZ(deg(-23.0f)) - ->rotate(deg(96.0f), Vector3(1.0f/Constants::sqrt3())); + o.rotateX(Deg(17.0f)) + ->rotateY(Deg(25.0f)) + ->rotateZ(Deg(-23.0f)) + ->rotate(Deg(96.0f), Vector3(1.0f/Constants::sqrt3())); CORRADE_COMPARE(o.transformationMatrix(), - Matrix4::rotation(deg(96.0f), Vector3(1.0f/Constants::sqrt3()))* - Matrix4::rotationZ(deg(-23.0f))* - Matrix4::rotationY(deg(25.0f))* - Matrix4::rotationX(deg(17.0f))* + Matrix4::rotation(Deg(96.0f), Vector3(1.0f/Constants::sqrt3()))* + Matrix4::rotationZ(Deg(-23.0f))* + Matrix4::rotationY(Deg(25.0f))* + Matrix4::rotationX(Deg(17.0f))* Matrix4::translation({1.0f, -0.3f, 2.3f})); } { Object3D o; o.translate({1.0f, -0.3f, 2.3f}); - o.rotateX(deg(17.0f), TransformationType::Local) - ->rotateY(deg(25.0f), TransformationType::Local) - ->rotateZ(deg(-23.0f), TransformationType::Local) - ->rotate(deg(96.0f), Vector3(1.0f/Constants::sqrt3()), TransformationType::Local); + o.rotateX(Deg(17.0f), TransformationType::Local) + ->rotateY(Deg(25.0f), TransformationType::Local) + ->rotateZ(Deg(-23.0f), TransformationType::Local) + ->rotate(Deg(96.0f), Vector3(1.0f/Constants::sqrt3()), TransformationType::Local); CORRADE_COMPARE(o.transformationMatrix(), Matrix4::translation({1.0f, -0.3f, 2.3f})* - Matrix4::rotationX(deg(17.0f))* - Matrix4::rotationY(deg(25.0f))* - Matrix4::rotationZ(deg(-23.0f))* - Matrix4::rotation(deg(96.0f), Vector3(1.0f/Constants::sqrt3()))); + Matrix4::rotationX(Deg(17.0f))* + Matrix4::rotationY(Deg(25.0f))* + Matrix4::rotationZ(Deg(-23.0f))* + Matrix4::rotation(Deg(96.0f), Vector3(1.0f/Constants::sqrt3()))); } } void EuclideanMatrixTransformation3DTest::reflect() { { Object3D o; - o.rotateX(deg(17.0f)); + o.rotateX(Deg(17.0f)); o.reflect(Vector3(-1.0f/Constants::sqrt3())); - CORRADE_COMPARE(o.transformationMatrix(), Matrix4::reflection(Vector3(-1.0f/Constants::sqrt3()))*Matrix4::rotationX(deg(17.0f))); + CORRADE_COMPARE(o.transformationMatrix(), Matrix4::reflection(Vector3(-1.0f/Constants::sqrt3()))*Matrix4::rotationX(Deg(17.0f))); } { Object3D o; - o.rotateX(deg(17.0f)); + o.rotateX(Deg(17.0f)); o.reflect(Vector3(-1.0f/Constants::sqrt3()), TransformationType::Local); - CORRADE_COMPARE(o.transformationMatrix(), Matrix4::rotationX(deg(17.0f))*Matrix4::reflection(Vector3(-1.0f/Constants::sqrt3()))); + CORRADE_COMPARE(o.transformationMatrix(), Matrix4::rotationX(Deg(17.0f))*Matrix4::reflection(Vector3(-1.0f/Constants::sqrt3()))); } } void EuclideanMatrixTransformation3DTest::normalizeRotation() { Object3D o; - o.rotateX(deg(17.0f)); + o.rotateX(Deg(17.0f)); o.normalizeRotation(); - CORRADE_COMPARE(o.transformationMatrix(), Matrix4::rotationX(deg(17.0f))); + CORRADE_COMPARE(o.transformationMatrix(), Matrix4::rotationX(Deg(17.0f))); } }}} diff --git a/src/SceneGraph/Test/MatrixTransformation2DTest.cpp b/src/SceneGraph/Test/MatrixTransformation2DTest.cpp index 1960ad713..9b67c6fbf 100644 --- a/src/SceneGraph/Test/MatrixTransformation2DTest.cpp +++ b/src/SceneGraph/Test/MatrixTransformation2DTest.cpp @@ -56,23 +56,23 @@ MatrixTransformation2DTest::MatrixTransformation2DTest() { } void MatrixTransformation2DTest::fromMatrix() { - Matrix3 m = Matrix3::rotation(deg(17.0f))*Matrix3::translation({1.0f, -0.3f}); + Matrix3 m = Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f}); CORRADE_COMPARE(MatrixTransformation2D<>::fromMatrix(m), m); } void MatrixTransformation2DTest::toMatrix() { - Matrix3 m = Matrix3::rotation(deg(17.0f))*Matrix3::translation({1.0f, -0.3f}); + Matrix3 m = Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f}); CORRADE_COMPARE(MatrixTransformation2D<>::toMatrix(m), m); } void MatrixTransformation2DTest::compose() { - Matrix3 parent = Matrix3::rotation(deg(17.0f)); + Matrix3 parent = Matrix3::rotation(Deg(17.0f)); Matrix3 child = Matrix3::translation({1.0f, -0.3f}); CORRADE_COMPARE(MatrixTransformation2D<>::compose(parent, child), parent*child); } void MatrixTransformation2DTest::inverted() { - Matrix3 m = Matrix3::rotation(deg(17.0f))*Matrix3::translation({1.0f, -0.3f}); + Matrix3 m = Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f}); CORRADE_COMPARE(MatrixTransformation2D<>::inverted(m)*m, Matrix3()); } @@ -81,15 +81,15 @@ void MatrixTransformation2DTest::setTransformation() { Object2D o; o.setClean(); CORRADE_VERIFY(!o.isDirty()); - o.setTransformation(Matrix3::rotation(deg(17.0f))); + o.setTransformation(Matrix3::rotation(Deg(17.0f))); CORRADE_VERIFY(o.isDirty()); - CORRADE_COMPARE(o.transformationMatrix(), Matrix3::rotation(deg(17.0f))); + CORRADE_COMPARE(o.transformationMatrix(), Matrix3::rotation(Deg(17.0f))); /* Scene cannot be transformed */ Scene2D s; s.setClean(); CORRADE_VERIFY(!s.isDirty()); - s.setTransformation(Matrix3::rotation(deg(17.0f))); + s.setTransformation(Matrix3::rotation(Deg(17.0f))); CORRADE_VERIFY(!s.isDirty()); CORRADE_COMPARE(s.transformationMatrix(), Matrix3()); } @@ -97,28 +97,28 @@ void MatrixTransformation2DTest::setTransformation() { void MatrixTransformation2DTest::transform() { { Object2D o; - o.setTransformation(Matrix3::rotation(deg(17.0f))); + o.setTransformation(Matrix3::rotation(Deg(17.0f))); o.transform(Matrix3::translation({1.0f, -0.3f})); - CORRADE_COMPARE(o.transformationMatrix(), Matrix3::translation({1.0f, -0.3f})*Matrix3::rotation(deg(17.0f))); + CORRADE_COMPARE(o.transformationMatrix(), Matrix3::translation({1.0f, -0.3f})*Matrix3::rotation(Deg(17.0f))); } { Object2D o; - o.setTransformation(Matrix3::rotation(deg(17.0f))); + o.setTransformation(Matrix3::rotation(Deg(17.0f))); o.transform(Matrix3::translation({1.0f, -0.3f}), TransformationType::Local); - CORRADE_COMPARE(o.transformationMatrix(), Matrix3::rotation(deg(17.0f))*Matrix3::translation({1.0f, -0.3f})); + CORRADE_COMPARE(o.transformationMatrix(), Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f})); } } void MatrixTransformation2DTest::translate() { { Object2D o; - o.setTransformation(Matrix3::rotation(deg(17.0f))); + o.setTransformation(Matrix3::rotation(Deg(17.0f))); o.translate({1.0f, -0.3f}); - CORRADE_COMPARE(o.transformationMatrix(), Matrix3::translation({1.0f, -0.3f})*Matrix3::rotation(deg(17.0f))); + CORRADE_COMPARE(o.transformationMatrix(), Matrix3::translation({1.0f, -0.3f})*Matrix3::rotation(Deg(17.0f))); } { Object2D o; - o.setTransformation(Matrix3::rotation(deg(17.0f))); + o.setTransformation(Matrix3::rotation(Deg(17.0f))); o.translate({1.0f, -0.3f}, TransformationType::Local); - CORRADE_COMPARE(o.transformationMatrix(), Matrix3::rotation(deg(17.0f))*Matrix3::translation({1.0f, -0.3f})); + CORRADE_COMPARE(o.transformationMatrix(), Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f})); } } @@ -126,41 +126,41 @@ void MatrixTransformation2DTest::rotate() { { Object2D o; o.setTransformation(Matrix3::translation({1.0f, -0.3f})); - o.rotate(deg(17.0f)); - CORRADE_COMPARE(o.transformationMatrix(), Matrix3::rotation(deg(17.0f))*Matrix3::translation({1.0f, -0.3f})); + o.rotate(Deg(17.0f)); + CORRADE_COMPARE(o.transformationMatrix(), Matrix3::rotation(Deg(17.0f))*Matrix3::translation({1.0f, -0.3f})); } { Object2D o; o.setTransformation(Matrix3::translation({1.0f, -0.3f})); - o.rotate(deg(17.0f), TransformationType::Local); - CORRADE_COMPARE(o.transformationMatrix(), Matrix3::translation({1.0f, -0.3f})*Matrix3::rotation(deg(17.0f))); + o.rotate(Deg(17.0f), TransformationType::Local); + CORRADE_COMPARE(o.transformationMatrix(), Matrix3::translation({1.0f, -0.3f})*Matrix3::rotation(Deg(17.0f))); } } void MatrixTransformation2DTest::scale() { { Object2D o; - o.setTransformation(Matrix3::rotation(deg(17.0f))); + o.setTransformation(Matrix3::rotation(Deg(17.0f))); o.scale({1.0f, -0.3f}); - CORRADE_COMPARE(o.transformationMatrix(), Matrix3::scaling({1.0f, -0.3f})*Matrix3::rotation(deg(17.0f))); + CORRADE_COMPARE(o.transformationMatrix(), Matrix3::scaling({1.0f, -0.3f})*Matrix3::rotation(Deg(17.0f))); } { Object2D o; - o.setTransformation(Matrix3::rotation(deg(17.0f))); + o.setTransformation(Matrix3::rotation(Deg(17.0f))); o.scale({1.0f, -0.3f}, TransformationType::Local); - CORRADE_COMPARE(o.transformationMatrix(), Matrix3::rotation(deg(17.0f))*Matrix3::scaling({1.0f, -0.3f})); + CORRADE_COMPARE(o.transformationMatrix(), Matrix3::rotation(Deg(17.0f))*Matrix3::scaling({1.0f, -0.3f})); } } void MatrixTransformation2DTest::reflect() { { Object2D o; - o.setTransformation(Matrix3::rotation(deg(17.0f))); + o.setTransformation(Matrix3::rotation(Deg(17.0f))); o.reflect(Vector2(-1.0f/Constants::sqrt2())); - CORRADE_COMPARE(o.transformationMatrix(), Matrix3::reflection(Vector2(-1.0f/Constants::sqrt2()))*Matrix3::rotation(deg(17.0f))); + CORRADE_COMPARE(o.transformationMatrix(), Matrix3::reflection(Vector2(-1.0f/Constants::sqrt2()))*Matrix3::rotation(Deg(17.0f))); } { Object2D o; - o.setTransformation(Matrix3::rotation(deg(17.0f))); + o.setTransformation(Matrix3::rotation(Deg(17.0f))); o.reflect(Vector2(-1.0f/Constants::sqrt2()), TransformationType::Local); - CORRADE_COMPARE(o.transformationMatrix(), Matrix3::rotation(deg(17.0f))*Matrix3::reflection(Vector2(-1.0f/Constants::sqrt2()))); + CORRADE_COMPARE(o.transformationMatrix(), Matrix3::rotation(Deg(17.0f))*Matrix3::reflection(Vector2(-1.0f/Constants::sqrt2()))); } } diff --git a/src/SceneGraph/Test/MatrixTransformation3DTest.cpp b/src/SceneGraph/Test/MatrixTransformation3DTest.cpp index a3dcf35a8..8f664a80b 100644 --- a/src/SceneGraph/Test/MatrixTransformation3DTest.cpp +++ b/src/SceneGraph/Test/MatrixTransformation3DTest.cpp @@ -56,23 +56,23 @@ MatrixTransformation3DTest::MatrixTransformation3DTest() { } void MatrixTransformation3DTest::fromMatrix() { - Matrix4 m = Matrix4::rotationX(deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f})*Matrix4::scaling({2.0f, 1.4f, -2.1f}); + Matrix4 m = Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f})*Matrix4::scaling({2.0f, 1.4f, -2.1f}); CORRADE_COMPARE(MatrixTransformation3D<>::fromMatrix(m), m); } void MatrixTransformation3DTest::toMatrix() { - Matrix4 m = Matrix4::rotationX(deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f})*Matrix4::scaling({2.0f, 1.4f, -2.1f}); + Matrix4 m = Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f})*Matrix4::scaling({2.0f, 1.4f, -2.1f}); CORRADE_COMPARE(MatrixTransformation3D<>::toMatrix(m), m); } void MatrixTransformation3DTest::compose() { - Matrix4 parent = Matrix4::rotationX(deg(17.0f)); + Matrix4 parent = Matrix4::rotationX(Deg(17.0f)); Matrix4 child = Matrix4::translation({1.0f, -0.3f, 2.3f}); CORRADE_COMPARE(MatrixTransformation3D<>::compose(parent, child), parent*child); } void MatrixTransformation3DTest::inverted() { - Matrix4 m = Matrix4::rotationX(deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f})*Matrix4::scaling({2.0f, 1.4f, -2.1f}); + Matrix4 m = Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f})*Matrix4::scaling({2.0f, 1.4f, -2.1f}); CORRADE_COMPARE(MatrixTransformation3D<>::inverted(m)*m, Matrix4()); } @@ -81,15 +81,15 @@ void MatrixTransformation3DTest::setTransformation() { Object3D o; o.setClean(); CORRADE_VERIFY(!o.isDirty()); - o.setTransformation(Matrix4::rotationX(deg(17.0f))); + o.setTransformation(Matrix4::rotationX(Deg(17.0f))); CORRADE_VERIFY(o.isDirty()); - CORRADE_COMPARE(o.transformationMatrix(), Matrix4::rotationX(deg(17.0f))); + CORRADE_COMPARE(o.transformationMatrix(), Matrix4::rotationX(Deg(17.0f))); /* Scene cannot be transformed */ Scene3D s; s.setClean(); CORRADE_VERIFY(!s.isDirty()); - s.setTransformation(Matrix4::rotationX(deg(17.0f))); + s.setTransformation(Matrix4::rotationX(Deg(17.0f))); CORRADE_VERIFY(!s.isDirty()); CORRADE_COMPARE(s.transformationMatrix(), Matrix4()); } @@ -97,28 +97,28 @@ void MatrixTransformation3DTest::setTransformation() { void MatrixTransformation3DTest::transform() { { Object3D o; - o.setTransformation(Matrix4::rotationX(deg(17.0f))); + o.setTransformation(Matrix4::rotationX(Deg(17.0f))); o.transform(Matrix4::translation({1.0f, -0.3f, 2.3f})); - CORRADE_COMPARE(o.transformationMatrix(), Matrix4::translation({1.0f, -0.3f, 2.3f})*Matrix4::rotationX(deg(17.0f))); + CORRADE_COMPARE(o.transformationMatrix(), Matrix4::translation({1.0f, -0.3f, 2.3f})*Matrix4::rotationX(Deg(17.0f))); } { Object3D o; - o.setTransformation(Matrix4::rotationX(deg(17.0f))); + o.setTransformation(Matrix4::rotationX(Deg(17.0f))); o.transform(Matrix4::translation({1.0f, -0.3f, 2.3f}), TransformationType::Local); - CORRADE_COMPARE(o.transformationMatrix(), Matrix4::rotationX(deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f})); + CORRADE_COMPARE(o.transformationMatrix(), Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f})); } } void MatrixTransformation3DTest::translate() { { Object3D o; - o.setTransformation(Matrix4::rotationX(deg(17.0f))); + o.setTransformation(Matrix4::rotationX(Deg(17.0f))); o.translate({1.0f, -0.3f, 2.3f}); - CORRADE_COMPARE(o.transformationMatrix(), Matrix4::translation({1.0f, -0.3f, 2.3f})*Matrix4::rotationX(deg(17.0f))); + CORRADE_COMPARE(o.transformationMatrix(), Matrix4::translation({1.0f, -0.3f, 2.3f})*Matrix4::rotationX(Deg(17.0f))); } { Object3D o; - o.setTransformation(Matrix4::rotationX(deg(17.0f))); + o.setTransformation(Matrix4::rotationX(Deg(17.0f))); o.translate({1.0f, -0.3f, 2.3f}, TransformationType::Local); - CORRADE_COMPARE(o.transformationMatrix(), Matrix4::rotationX(deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f})); + CORRADE_COMPARE(o.transformationMatrix(), Matrix4::rotationX(Deg(17.0f))*Matrix4::translation({1.0f, -0.3f, 2.3f})); } } @@ -126,57 +126,57 @@ void MatrixTransformation3DTest::rotate() { { Object3D o; o.setTransformation(Matrix4::translation({1.0f, -0.3f, 2.3f})); - o.rotateX(deg(17.0f)) - ->rotateY(deg(25.0f)) - ->rotateZ(deg(-23.0f)) - ->rotate(deg(96.0f), Vector3(1.0f/Constants::sqrt3())); + o.rotateX(Deg(17.0f)) + ->rotateY(Deg(25.0f)) + ->rotateZ(Deg(-23.0f)) + ->rotate(Deg(96.0f), Vector3(1.0f/Constants::sqrt3())); CORRADE_COMPARE(o.transformationMatrix(), - Matrix4::rotation(deg(96.0f), Vector3(1.0f/Constants::sqrt3()))* - Matrix4::rotationZ(deg(-23.0f))* - Matrix4::rotationY(deg(25.0f))* - Matrix4::rotationX(deg(17.0f))* + Matrix4::rotation(Deg(96.0f), Vector3(1.0f/Constants::sqrt3()))* + Matrix4::rotationZ(Deg(-23.0f))* + Matrix4::rotationY(Deg(25.0f))* + Matrix4::rotationX(Deg(17.0f))* Matrix4::translation({1.0f, -0.3f, 2.3f})); } { Object3D o; o.setTransformation(Matrix4::translation({1.0f, -0.3f, 2.3f})); - o.rotateX(deg(17.0f), TransformationType::Local) - ->rotateY(deg(25.0f), TransformationType::Local) - ->rotateZ(deg(-23.0f), TransformationType::Local) - ->rotate(deg(96.0f), Vector3(1.0f/Constants::sqrt3()), TransformationType::Local); + o.rotateX(Deg(17.0f), TransformationType::Local) + ->rotateY(Deg(25.0f), TransformationType::Local) + ->rotateZ(Deg(-23.0f), TransformationType::Local) + ->rotate(Deg(96.0f), Vector3(1.0f/Constants::sqrt3()), TransformationType::Local); CORRADE_COMPARE(o.transformationMatrix(), Matrix4::translation({1.0f, -0.3f, 2.3f})* - Matrix4::rotationX(deg(17.0f))* - Matrix4::rotationY(deg(25.0f))* - Matrix4::rotationZ(deg(-23.0f))* - Matrix4::rotation(deg(96.0f), Vector3(1.0f/Constants::sqrt3()))); + Matrix4::rotationX(Deg(17.0f))* + Matrix4::rotationY(Deg(25.0f))* + Matrix4::rotationZ(Deg(-23.0f))* + Matrix4::rotation(Deg(96.0f), Vector3(1.0f/Constants::sqrt3()))); } } void MatrixTransformation3DTest::scale() { { Object3D o; - o.setTransformation(Matrix4::rotationX(deg(17.0f))); + o.setTransformation(Matrix4::rotationX(Deg(17.0f))); o.scale({1.0f, -0.3f, 2.3f}); - CORRADE_COMPARE(o.transformationMatrix(), Matrix4::scaling({1.0f, -0.3f, 2.3f})*Matrix4::rotationX(deg(17.0f))); + CORRADE_COMPARE(o.transformationMatrix(), Matrix4::scaling({1.0f, -0.3f, 2.3f})*Matrix4::rotationX(Deg(17.0f))); } { Object3D o; - o.setTransformation(Matrix4::rotationX(deg(17.0f))); + o.setTransformation(Matrix4::rotationX(Deg(17.0f))); o.scale({1.0f, -0.3f, 2.3f}, TransformationType::Local); - CORRADE_COMPARE(o.transformationMatrix(), Matrix4::rotationX(deg(17.0f))*Matrix4::scaling({1.0f, -0.3f, 2.3f})); + CORRADE_COMPARE(o.transformationMatrix(), Matrix4::rotationX(Deg(17.0f))*Matrix4::scaling({1.0f, -0.3f, 2.3f})); } } void MatrixTransformation3DTest::reflect() { { Object3D o; - o.setTransformation(Matrix4::rotationX(deg(17.0f))); + o.setTransformation(Matrix4::rotationX(Deg(17.0f))); o.reflect(Vector3(-1.0f/Constants::sqrt3())); - CORRADE_COMPARE(o.transformationMatrix(), Matrix4::reflection(Vector3(-1.0f/Constants::sqrt3()))*Matrix4::rotationX(deg(17.0f))); + CORRADE_COMPARE(o.transformationMatrix(), Matrix4::reflection(Vector3(-1.0f/Constants::sqrt3()))*Matrix4::rotationX(Deg(17.0f))); } { Object3D o; - o.setTransformation(Matrix4::rotationX(deg(17.0f))); + o.setTransformation(Matrix4::rotationX(Deg(17.0f))); o.reflect(Vector3(-1.0f/Constants::sqrt3()), TransformationType::Local); - CORRADE_COMPARE(o.transformationMatrix(), Matrix4::rotationX(deg(17.0f))*Matrix4::reflection(Vector3(-1.0f/Constants::sqrt3()))); + CORRADE_COMPARE(o.transformationMatrix(), Matrix4::rotationX(Deg(17.0f))*Matrix4::reflection(Vector3(-1.0f/Constants::sqrt3()))); } } diff --git a/src/SceneGraph/Test/ObjectTest.cpp b/src/SceneGraph/Test/ObjectTest.cpp index 322d4014b..14d241fbc 100644 --- a/src/SceneGraph/Test/ObjectTest.cpp +++ b/src/SceneGraph/Test/ObjectTest.cpp @@ -119,9 +119,9 @@ void ObjectTest::absoluteTransformation() { CORRADE_COMPARE(o.transformation(), Matrix4::translation(Vector3::xAxis(2.0f))); CORRADE_COMPARE(o.transformation(), o.transformationMatrix()); Object3D o2(&o); - o2.rotateY(deg(90.0f)); + o2.rotateY(Deg(90.0f)); CORRADE_COMPARE(o2.absoluteTransformation(), - Matrix4::translation(Vector3::xAxis(2.0f))*Matrix4::rotationY(deg(90.0f))); + Matrix4::translation(Vector3::xAxis(2.0f))*Matrix4::rotationY(Deg(90.0f))); CORRADE_COMPARE(o2.absoluteTransformation(), o2.absoluteTransformationMatrix()); /* Transformation of root object */ @@ -133,7 +133,7 @@ void ObjectTest::absoluteTransformation() { void ObjectTest::transformations() { Scene3D s; - Matrix4 initial = Matrix4::rotationX(deg(90.0f)).inverted(); + Matrix4 initial = Matrix4::rotationX(Deg(90.0f)).inverted(); /* Empty list */ CORRADE_COMPARE(s.transformations(std::vector(), initial), std::vector()); @@ -143,16 +143,16 @@ void ObjectTest::transformations() { /* One object */ Object3D first(&s); - first.rotateZ(deg(30.0f)); + first.rotateZ(Deg(30.0f)); Object3D second(&first); second.scale(Vector3(0.5f)); CORRADE_COMPARE(s.transformations({&second}, initial), std::vector{ - initial*Matrix4::rotationZ(deg(30.0f))*Matrix4::scaling(Vector3(0.5f)) + initial*Matrix4::rotationZ(Deg(30.0f))*Matrix4::scaling(Vector3(0.5f)) }); /* One object and scene */ CORRADE_COMPARE(s.transformations({&second, &s}, initial), (std::vector{ - initial*Matrix4::rotationZ(deg(30.0f))*Matrix4::scaling(Vector3(0.5f)), + initial*Matrix4::rotationZ(Deg(30.0f))*Matrix4::scaling(Vector3(0.5f)), initial })); @@ -160,15 +160,15 @@ void ObjectTest::transformations() { Object3D third(&first); third.translate(Vector3::xAxis(5.0f)); CORRADE_COMPARE(s.transformations({&second, &third}, initial), (std::vector{ - initial*Matrix4::rotationZ(deg(30.0f))*Matrix4::scaling(Vector3(0.5f)), - initial*Matrix4::rotationZ(deg(30.0f))*Matrix4::translation(Vector3::xAxis(5.0f)), + initial*Matrix4::rotationZ(Deg(30.0f))*Matrix4::scaling(Vector3(0.5f)), + initial*Matrix4::rotationZ(Deg(30.0f))*Matrix4::translation(Vector3::xAxis(5.0f)), })); /* Three objects with joint as one of them */ CORRADE_COMPARE(s.transformations({&second, &third, &first}, initial), (std::vector{ - initial*Matrix4::rotationZ(deg(30.0f))*Matrix4::scaling(Vector3(0.5f)), - initial*Matrix4::rotationZ(deg(30.0f))*Matrix4::translation(Vector3::xAxis(5.0f)), - initial*Matrix4::rotationZ(deg(30.0f)), + initial*Matrix4::rotationZ(Deg(30.0f))*Matrix4::scaling(Vector3(0.5f)), + initial*Matrix4::rotationZ(Deg(30.0f))*Matrix4::translation(Vector3::xAxis(5.0f)), + initial*Matrix4::rotationZ(Deg(30.0f)), })); } @@ -177,7 +177,7 @@ void ObjectTest::transformationsRelative() { Scene3D s; Object3D first(&s); - first.rotateZ(deg(30.0f)); + first.rotateZ(Deg(30.0f)); Object3D second(&first); second.scale(Vector3(0.5f)); Object3D third(&first); @@ -190,7 +190,7 @@ void ObjectTest::transformationsRelative() { /* Transformation relative to another object, not part of any scene (but should work) */ Object3D orphanParent1; - orphanParent1.rotate(deg(31.0f), Vector3(1.0f).normalized()); + orphanParent1.rotate(Deg(31.0f), Vector3(1.0f).normalized()); Object3D orphanParent(&orphanParent1); Object3D orphan1(&orphanParent); orphan1.scale(Vector3::xScale(3.0f)); @@ -215,15 +215,15 @@ void ObjectTest::transformationsOrphan() { void ObjectTest::transformationsDuplicate() { Scene3D s; Object3D first(&s); - first.rotateZ(deg(30.0f)); + first.rotateZ(Deg(30.0f)); Object3D second(&first); second.scale(Vector3(0.5f)); Object3D third(&first); third.translate(Vector3::xAxis(5.0f)); - Matrix4 firstExpected = Matrix4::rotationZ(deg(30.0f)); - Matrix4 secondExpected = Matrix4::rotationZ(deg(30.0f))*Matrix4::scaling(Vector3(0.5f)); - Matrix4 thirdExpected = Matrix4::rotationZ(deg(30.0f))*Matrix4::translation(Vector3::xAxis(5.0f)); + Matrix4 firstExpected = Matrix4::rotationZ(Deg(30.0f)); + Matrix4 secondExpected = Matrix4::rotationZ(Deg(30.0f))*Matrix4::scaling(Vector3(0.5f)); + Matrix4 thirdExpected = Matrix4::rotationZ(Deg(30.0f))*Matrix4::translation(Vector3::xAxis(5.0f)); CORRADE_COMPARE(s.transformations({&second, &third, &second, &first, &third}), (std::vector{ secondExpected, thirdExpected, secondExpected, firstExpected, thirdExpected })); @@ -267,7 +267,7 @@ void ObjectTest::setClean() { CachingInvertedFeature* childTwoFeature2 = new CachingInvertedFeature(childTwo); CachingObject* childThree = new CachingObject(childTwo); - childThree->rotate(deg(90.0f), Vector3::yAxis()); + childThree->rotate(Deg(90.0f), Vector3::yAxis()); /* Object is dirty at the beginning */ CORRADE_VERIFY(scene.isDirty());