diff --git a/src/Magnum/SceneGraph/Test/TranslationRotationScalingTransformation2DTest.cpp b/src/Magnum/SceneGraph/Test/TranslationRotationScalingTransformation2DTest.cpp index 0d0333a25..793846793 100644 --- a/src/Magnum/SceneGraph/Test/TranslationRotationScalingTransformation2DTest.cpp +++ b/src/Magnum/SceneGraph/Test/TranslationRotationScalingTransformation2DTest.cpp @@ -42,6 +42,7 @@ struct TranslationRotationScalingTransformation2DTest: TestSuite::Tester { template void defaults(); template void setTransformation(); template void setTransformationRotateALot(); + template void setTransformationReflection(); template void resetTransformation(); template void translate(); @@ -66,6 +67,8 @@ TranslationRotationScalingTransformation2DTest::TranslationRotationScalingTransf &TranslationRotationScalingTransformation2DTest::setTransformation, &TranslationRotationScalingTransformation2DTest::setTransformationRotateALot, &TranslationRotationScalingTransformation2DTest::setTransformationRotateALot, + &TranslationRotationScalingTransformation2DTest::setTransformationReflection, + &TranslationRotationScalingTransformation2DTest::setTransformationReflection, &TranslationRotationScalingTransformation2DTest::resetTransformation, &TranslationRotationScalingTransformation2DTest::resetTransformation, @@ -169,6 +172,25 @@ template void TranslationRotationScalingTransformation2DTest::setTransf Math::Matrix3::scaling({T(1.5), T(0.5)})); } +template void TranslationRotationScalingTransformation2DTest::setTransformationReflection() { + setTestCaseTemplateName(Math::TypeTraits::name()); + + Object2D o; + o.setTransformation( + Math::Matrix3::translation({T(7.0), T(-1.0)})* + Math::Matrix3::rotation(Math::Deg{T(17.0)})* + Math::Matrix3::scaling({T(-1.5), T(0.5)})); + CORRADE_COMPARE(o.translation(), (Math::Vector2{T(7.0), T(-1.0)})); + /* The negative scaling should get properly extracted from the rotation + without getting lost */ + CORRADE_COMPARE(o.rotation(), Math::Complex::rotation(Math::Deg{T(17.0)})); + CORRADE_COMPARE(o.scaling(), (Math::Vector2{T(-1.5), T(0.5)})); + CORRADE_COMPARE(o.transformationMatrix(), + Math::Matrix3::translation({T(7.0), T(-1.0)})* + Math::Matrix3::rotation(Math::Deg{T(17.0)})* + Math::Matrix3::scaling({T(-1.5), T(0.5)})); +} + template void TranslationRotationScalingTransformation2DTest::resetTransformation() { setTestCaseTemplateName(Math::TypeTraits::name()); diff --git a/src/Magnum/SceneGraph/Test/TranslationRotationScalingTransformation3DTest.cpp b/src/Magnum/SceneGraph/Test/TranslationRotationScalingTransformation3DTest.cpp index e23a7777c..cd1a7d837 100644 --- a/src/Magnum/SceneGraph/Test/TranslationRotationScalingTransformation3DTest.cpp +++ b/src/Magnum/SceneGraph/Test/TranslationRotationScalingTransformation3DTest.cpp @@ -42,6 +42,7 @@ struct TranslationRotationScalingTransformation3DTest: TestSuite::Tester { template void defaults(); template void setTransformation(); template void setTransformationRotateALot(); + template void setTransformationReflection(); template void resetTransformation(); template void translate(); @@ -66,6 +67,8 @@ TranslationRotationScalingTransformation3DTest::TranslationRotationScalingTransf &TranslationRotationScalingTransformation3DTest::setTransformation, &TranslationRotationScalingTransformation3DTest::setTransformationRotateALot, &TranslationRotationScalingTransformation3DTest::setTransformationRotateALot, + &TranslationRotationScalingTransformation3DTest::setTransformationReflection, + &TranslationRotationScalingTransformation3DTest::setTransformationReflection, &TranslationRotationScalingTransformation3DTest::resetTransformation, &TranslationRotationScalingTransformation3DTest::resetTransformation, @@ -169,6 +172,27 @@ template void TranslationRotationScalingTransformation3DTest::setTransf Math::Matrix4::scaling({T(1.5), T(0.5), T(3.0)})); } +template void TranslationRotationScalingTransformation3DTest::setTransformationReflection() { + setTestCaseTemplateName(Math::TypeTraits::name()); + + Object3D o; + o.setTransformation( + Math::Matrix4::translation({T(7.0), T(-1.0), T(2.2)})* + Math::Matrix4::rotationX(Math::Deg{T(17.0)})* + Math::Matrix4::scaling({T(1.5), T(-0.5), T(3.0)})); + CORRADE_COMPARE(o.translation(), (Math::Vector3{T(7.0), T(-1.0), T(2.2)})); + /* The negative scaling should get properly extracted from the rotation + without causing the rotation to go crazy. Well, some equivalent representation of it. */ + CORRADE_COMPARE(o.rotation(), Math::Quaternion::rotation(Math::Deg{T(180.0)}, {T(0.0), T(-0.147809411129611), T(0.989015863361917)})); + CORRADE_COMPARE(o.scaling(), (Math::Vector3{T(-1.5), T(0.5), T(3.0)})); + /* The combineúd matrix is however the same as if we'd have the Y axis + reflected */ + CORRADE_COMPARE(o.transformationMatrix(), + Math::Matrix4::translation({T(7.0), T(-1.0), T(2.2)})* + Math::Matrix4::rotationX(Math::Deg{T(17.0)})* + Math::Matrix4::scaling({T(1.5), T(-0.5), T(3.0)})); +} + template void TranslationRotationScalingTransformation3DTest::resetTransformation() { setTestCaseTemplateName(Math::TypeTraits::name());