Browse Source

SceneGraph: test that TRS xform recombination works in all cases.

It wasn't broken with large angles because I made scaling() signed,
which was a mistake.
dpi-change-events
Vladimír Vondruš 6 years ago
parent
commit
4a0f843188
  1. 19
      src/Magnum/SceneGraph/Test/TranslationRotationScalingTransformation2DTest.cpp
  2. 19
      src/Magnum/SceneGraph/Test/TranslationRotationScalingTransformation3DTest.cpp

19
src/Magnum/SceneGraph/Test/TranslationRotationScalingTransformation2DTest.cpp

@ -43,6 +43,7 @@ struct TranslationRotationScalingTransformation2DTest: TestSuite::Tester {
void defaults();
void setTransformation();
void setTransformationRotateALot();
void resetTransformation();
void translate();
@ -58,6 +59,7 @@ TranslationRotationScalingTransformation2DTest::TranslationRotationScalingTransf
&TranslationRotationScalingTransformation2DTest::defaults,
&TranslationRotationScalingTransformation2DTest::setTransformation,
&TranslationRotationScalingTransformation2DTest::setTransformationRotateALot,
&TranslationRotationScalingTransformation2DTest::resetTransformation,
&TranslationRotationScalingTransformation2DTest::translate,
@ -123,6 +125,23 @@ void TranslationRotationScalingTransformation2DTest::setTransformation() {
CORRADE_COMPARE(s.transformationMatrix(), Matrix3());
}
void TranslationRotationScalingTransformation2DTest::setTransformationRotateALot() {
Object2D o;
o.setTransformation(
Matrix3::translation({7.0f, -1.0f})*
Matrix3::rotation(225.0_degf)*
Matrix3::scaling({1.5f, 0.5f}));
CORRADE_COMPARE(o.translation(), (Vector2{7.0f, -1.0f}));
/* Rotation of more than 180° causes either the rotation matrix or scaling
to contain negative signs, verify we get a proper matrix back again */
CORRADE_COMPARE(o.rotation(), Complex::rotation(225.0_degf));
CORRADE_COMPARE(o.scaling(), (Vector2{1.5f, 0.5f}));
CORRADE_COMPARE(o.transformationMatrix(),
Matrix3::translation({7.0f, -1.0f})*
Matrix3::rotation(225.0_degf)*
Matrix3::scaling({1.5f, 0.5f}));
}
void TranslationRotationScalingTransformation2DTest::resetTransformation() {
Object2D o;
o.rotate(17.0_degf);

19
src/Magnum/SceneGraph/Test/TranslationRotationScalingTransformation3DTest.cpp

@ -43,6 +43,7 @@ struct TranslationRotationScalingTransformation3DTest: TestSuite::Tester {
void defaults();
void setTransformation();
void setTransformationRotateALot();
void resetTransformation();
void translate();
@ -58,6 +59,7 @@ TranslationRotationScalingTransformation3DTest::TranslationRotationScalingTransf
&TranslationRotationScalingTransformation3DTest::defaults,
&TranslationRotationScalingTransformation3DTest::setTransformation,
&TranslationRotationScalingTransformation3DTest::setTransformationRotateALot,
&TranslationRotationScalingTransformation3DTest::resetTransformation,
&TranslationRotationScalingTransformation3DTest::translate,
@ -123,6 +125,23 @@ void TranslationRotationScalingTransformation3DTest::setTransformation() {
CORRADE_COMPARE(s.transformationMatrix(), Matrix4());
}
void TranslationRotationScalingTransformation3DTest::setTransformationRotateALot() {
Object3D o;
o.setTransformation(
Matrix4::translation({7.0f, -1.0f, 2.2f})*
Matrix4::rotationX(225.0_degf)*
Matrix4::scaling({1.5f, 0.5f, 3.0f}));
CORRADE_COMPARE(o.translation(), (Vector3{7.0f, -1.0f, 2.2f}));
/* Rotation of more than 180° causes either the rotation matrix or scaling
to contain negative signs, verify we get a proper matrix back again */
CORRADE_COMPARE(o.rotation(), Quaternion::rotation(225.0_degf, Vector3::xAxis()));
CORRADE_COMPARE(o.scaling(), (Vector3{1.5f, 0.5f, 3.0f}));
CORRADE_COMPARE(o.transformationMatrix(),
Matrix4::translation({7.0f, -1.0f, 2.2f})*
Matrix4::rotationX(225.0_degf)*
Matrix4::scaling({1.5f, 0.5f, 3.0f}));
}
void TranslationRotationScalingTransformation3DTest::resetTransformation() {
Object3D o;
o.rotateX(17.0_degf);

Loading…
Cancel
Save