Download tests/src/Base/Rotation.cpp from AbdulElahGwaith/FreeCAD: direct link, hf CLI and curl.
- Browser
- Download file 1.89 kB
-
https://huggingface.co/AbdulElahGwaith/FreeCAD/resolve/main/tests/src/Base/Rotation.cpp
- Command line
-
hf download hf://AbdulElahGwaith/FreeCAD/tests/src/Base/Rotation.cpp
-
curl -L -o Rotation.cpp https://huggingface.co/AbdulElahGwaith/FreeCAD/resolve/main/tests/src/Base/Rotation.cpp
1.89 kB
| // NOLINTBEGIN(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) | |
| TEST(Rotation, TestNonUniformScaleLeft) | |
| { | |
| Base::Rotation rot; | |
| rot.setYawPitchRoll(45.0, 0.0, 0.0); | |
| Base::Matrix4D mat; | |
| rot.getValue(mat); | |
| Base::Matrix4D scale; | |
| 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); | |
| } | |
| TEST(Rotation, TestNonUniformScaleRight) | |
| { | |
| Base::Rotation rot; | |
| rot.setYawPitchRoll(20.0, 0.0, 0.0); | |
| Base::Matrix4D mat; | |
| rot.getValue(mat); | |
| Base::Matrix4D scale; | |
| scale.scale(2.0, 3.0, 4.0); | |
| Base::Rotation scaled_rot(mat * scale); | |
| EXPECT_EQ(scaled_rot.isSame(rot, 1.0e-7), true); | |
| EXPECT_EQ(rot.isSame(scaled_rot, 1.0e-7), true); | |
| } | |
| TEST(Rotation, TestUniformScaleGT1) | |
| { | |
| Base::Rotation rot; | |
| rot.setYawPitchRoll(20.0, 0.0, 0.0); | |
| Base::Matrix4D mat; | |
| rot.getValue(mat); | |
| Base::Matrix4D scale; | |
| scale.scale(3.0, 3.0, 3.0); | |
| Base::Rotation scaled_rot(mat * scale); | |
| EXPECT_EQ(scaled_rot.isSame(rot, 1.0e-7), true); | |
| EXPECT_EQ(rot.isSame(scaled_rot, 1.0e-7), true); | |
| } | |
| TEST(Rotation, TestUniformScaleLT1) | |
| { | |
| Base::Matrix4D mat; | |
| mat.scale(0.5); | |
| Base::Rotation scaled_rot(mat); | |
| EXPECT_EQ(scaled_rot.isSame(scaled_rot, 1.0e-7), true); | |
| } | |
| TEST(Rotation, TestRotationDecompose) | |
| { | |
| 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}); | |
| // decompose rotation part | |
| EXPECT_TRUE(Base::Rotation {mat}.isIdentity()); | |
| } | |
| // NOLINTEND(cppcoreguidelines-avoid-magic-numbers,readability-magic-numbers) | |