Create rotation from any matrix

To help find a matrix components a decompose method is added to Matrix class
This commit is contained in:
Jolbas
2023-03-23 01:03:07 +01:00
committed by Chris Hennes
parent d7fcbc79a8
commit 2d8c280528
7 changed files with 111 additions and 76 deletions

View File

@@ -8,16 +8,17 @@
TEST(Rotation, TestNonUniformScaleLeft)
{
Base::Rotation rot;
rot.setYawPitchRoll(20.0, 0.0, 0.0);
rot.setYawPitchRoll(45.0, 0.0, 0.0);
Base::Matrix4D mat;
rot.getValue(mat);
Base::Matrix4D scale;
scale.scale(2.0, 3.0, 4.0);
scale.scale(1.0, std::sqrt(3.0), 1.0);
Base::Rotation scaled_rot(scale * mat);
rot.setYawPitchRoll(60.0, 0.0, 0.0);
EXPECT_EQ(scaled_rot.isSame(rot, 1.0e-7), true);
EXPECT_EQ(rot.isSame(scaled_rot, 1.0e-7), true);
}
@@ -66,13 +67,4 @@ TEST(Rotation, TestUniformScaleLT1)
EXPECT_EQ(scaled_rot.isSame(scaled_rot, 1.0e-7), true);
}
TEST(Rotation, TestRotationFailure)
{
Base::Matrix4D mat;
mat.setCol(0, Base::Vector3d {1, 0, 0});
mat.setCol(1, Base::Vector3d {1, 1, 0});
mat.setCol(2, Base::Vector3d {0, 0, 1});
EXPECT_THROW(Base::Rotation {mat}, Base::ValueError);
}
// NOLINTEND(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers)