|
|
|
@ -56,23 +56,23 @@ MatrixTransformation3DTest::MatrixTransformation3DTest() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MatrixTransformation3DTest::fromMatrix() { |
|
|
|
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); |
|
|
|
CORRADE_COMPARE(MatrixTransformation3D<>::fromMatrix(m), m); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MatrixTransformation3DTest::toMatrix() { |
|
|
|
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); |
|
|
|
CORRADE_COMPARE(MatrixTransformation3D<>::toMatrix(m), m); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MatrixTransformation3DTest::compose() { |
|
|
|
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}); |
|
|
|
Matrix4 child = Matrix4::translation({1.0f, -0.3f, 2.3f}); |
|
|
|
CORRADE_COMPARE(MatrixTransformation3D<>::compose(parent, child), parent*child); |
|
|
|
CORRADE_COMPARE(MatrixTransformation3D<>::compose(parent, child), parent*child); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MatrixTransformation3DTest::inverted() { |
|
|
|
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()); |
|
|
|
CORRADE_COMPARE(MatrixTransformation3D<>::inverted(m)*m, Matrix4()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -81,15 +81,15 @@ void MatrixTransformation3DTest::setTransformation() { |
|
|
|
Object3D o; |
|
|
|
Object3D o; |
|
|
|
o.setClean(); |
|
|
|
o.setClean(); |
|
|
|
CORRADE_VERIFY(!o.isDirty()); |
|
|
|
CORRADE_VERIFY(!o.isDirty()); |
|
|
|
o.setTransformation(Matrix4::rotationX(deg(17.0f))); |
|
|
|
o.setTransformation(Matrix4::rotationX(Deg(17.0f))); |
|
|
|
CORRADE_VERIFY(o.isDirty()); |
|
|
|
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 */ |
|
|
|
/* Scene cannot be transformed */ |
|
|
|
Scene3D s; |
|
|
|
Scene3D s; |
|
|
|
s.setClean(); |
|
|
|
s.setClean(); |
|
|
|
CORRADE_VERIFY(!s.isDirty()); |
|
|
|
CORRADE_VERIFY(!s.isDirty()); |
|
|
|
s.setTransformation(Matrix4::rotationX(deg(17.0f))); |
|
|
|
s.setTransformation(Matrix4::rotationX(Deg(17.0f))); |
|
|
|
CORRADE_VERIFY(!s.isDirty()); |
|
|
|
CORRADE_VERIFY(!s.isDirty()); |
|
|
|
CORRADE_COMPARE(s.transformationMatrix(), Matrix4()); |
|
|
|
CORRADE_COMPARE(s.transformationMatrix(), Matrix4()); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -97,28 +97,28 @@ void MatrixTransformation3DTest::setTransformation() { |
|
|
|
void MatrixTransformation3DTest::transform() { |
|
|
|
void MatrixTransformation3DTest::transform() { |
|
|
|
{ |
|
|
|
{ |
|
|
|
Object3D o; |
|
|
|
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})); |
|
|
|
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; |
|
|
|
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); |
|
|
|
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() { |
|
|
|
void MatrixTransformation3DTest::translate() { |
|
|
|
{ |
|
|
|
{ |
|
|
|
Object3D o; |
|
|
|
Object3D o; |
|
|
|
o.setTransformation(Matrix4::rotationX(deg(17.0f))); |
|
|
|
o.setTransformation(Matrix4::rotationX(Deg(17.0f))); |
|
|
|
o.translate({1.0f, -0.3f, 2.3f}); |
|
|
|
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; |
|
|
|
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); |
|
|
|
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; |
|
|
|
Object3D o; |
|
|
|
o.setTransformation(Matrix4::translation({1.0f, -0.3f, 2.3f})); |
|
|
|
o.setTransformation(Matrix4::translation({1.0f, -0.3f, 2.3f})); |
|
|
|
o.rotateX(deg(17.0f)) |
|
|
|
o.rotateX(Deg(17.0f)) |
|
|
|
->rotateY(deg(25.0f)) |
|
|
|
->rotateY(Deg(25.0f)) |
|
|
|
->rotateZ(deg(-23.0f)) |
|
|
|
->rotateZ(Deg(-23.0f)) |
|
|
|
->rotate(deg(96.0f), Vector3(1.0f/Constants::sqrt3())); |
|
|
|
->rotate(Deg(96.0f), Vector3(1.0f/Constants::sqrt3())); |
|
|
|
CORRADE_COMPARE(o.transformationMatrix(), |
|
|
|
CORRADE_COMPARE(o.transformationMatrix(), |
|
|
|
Matrix4::rotation(deg(96.0f), Vector3(1.0f/Constants::sqrt3()))* |
|
|
|
Matrix4::rotation(Deg(96.0f), Vector3(1.0f/Constants::sqrt3()))* |
|
|
|
Matrix4::rotationZ(deg(-23.0f))* |
|
|
|
Matrix4::rotationZ(Deg(-23.0f))* |
|
|
|
Matrix4::rotationY(deg(25.0f))* |
|
|
|
Matrix4::rotationY(Deg(25.0f))* |
|
|
|
Matrix4::rotationX(deg(17.0f))* |
|
|
|
Matrix4::rotationX(Deg(17.0f))* |
|
|
|
Matrix4::translation({1.0f, -0.3f, 2.3f})); |
|
|
|
Matrix4::translation({1.0f, -0.3f, 2.3f})); |
|
|
|
} { |
|
|
|
} { |
|
|
|
Object3D o; |
|
|
|
Object3D o; |
|
|
|
o.setTransformation(Matrix4::translation({1.0f, -0.3f, 2.3f})); |
|
|
|
o.setTransformation(Matrix4::translation({1.0f, -0.3f, 2.3f})); |
|
|
|
o.rotateX(deg(17.0f), TransformationType::Local) |
|
|
|
o.rotateX(Deg(17.0f), TransformationType::Local) |
|
|
|
->rotateY(deg(25.0f), TransformationType::Local) |
|
|
|
->rotateY(Deg(25.0f), TransformationType::Local) |
|
|
|
->rotateZ(deg(-23.0f), TransformationType::Local) |
|
|
|
->rotateZ(Deg(-23.0f), TransformationType::Local) |
|
|
|
->rotate(deg(96.0f), Vector3(1.0f/Constants::sqrt3()), TransformationType::Local); |
|
|
|
->rotate(Deg(96.0f), Vector3(1.0f/Constants::sqrt3()), TransformationType::Local); |
|
|
|
CORRADE_COMPARE(o.transformationMatrix(), |
|
|
|
CORRADE_COMPARE(o.transformationMatrix(), |
|
|
|
Matrix4::translation({1.0f, -0.3f, 2.3f})* |
|
|
|
Matrix4::translation({1.0f, -0.3f, 2.3f})* |
|
|
|
Matrix4::rotationX(deg(17.0f))* |
|
|
|
Matrix4::rotationX(Deg(17.0f))* |
|
|
|
Matrix4::rotationY(deg(25.0f))* |
|
|
|
Matrix4::rotationY(Deg(25.0f))* |
|
|
|
Matrix4::rotationZ(deg(-23.0f))* |
|
|
|
Matrix4::rotationZ(Deg(-23.0f))* |
|
|
|
Matrix4::rotation(deg(96.0f), Vector3(1.0f/Constants::sqrt3()))); |
|
|
|
Matrix4::rotation(Deg(96.0f), Vector3(1.0f/Constants::sqrt3()))); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void MatrixTransformation3DTest::scale() { |
|
|
|
void MatrixTransformation3DTest::scale() { |
|
|
|
{ |
|
|
|
{ |
|
|
|
Object3D o; |
|
|
|
Object3D o; |
|
|
|
o.setTransformation(Matrix4::rotationX(deg(17.0f))); |
|
|
|
o.setTransformation(Matrix4::rotationX(Deg(17.0f))); |
|
|
|
o.scale({1.0f, -0.3f, 2.3f}); |
|
|
|
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; |
|
|
|
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); |
|
|
|
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() { |
|
|
|
void MatrixTransformation3DTest::reflect() { |
|
|
|
{ |
|
|
|
{ |
|
|
|
Object3D o; |
|
|
|
Object3D o; |
|
|
|
o.setTransformation(Matrix4::rotationX(deg(17.0f))); |
|
|
|
o.setTransformation(Matrix4::rotationX(Deg(17.0f))); |
|
|
|
o.reflect(Vector3(-1.0f/Constants::sqrt3())); |
|
|
|
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; |
|
|
|
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); |
|
|
|
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()))); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|