From 1942a77d995c9fc661b93c53b3589baea3b5aaa2 Mon Sep 17 00:00:00 2001 From: boxanm Date: Tue, 23 Jan 2024 10:08:19 -0500 Subject: [PATCH] Fix failing 3D transformation tests on Ubuntu Bionic --- utest/ui/Transformations.cpp | 198 +++++++++++++++++------------------ 1 file changed, 97 insertions(+), 101 deletions(-) diff --git a/utest/ui/Transformations.cpp b/utest/ui/Transformations.cpp index 6e4f97c4..c29ea40a 100644 --- a/utest/ui/Transformations.cpp +++ b/utest/ui/Transformations.cpp @@ -258,46 +258,44 @@ TEST(Transformation, ComputeRigidTransformDataPoints2D) } } -//// (CRITICAL) ToDo: investigate unit-test failure (ref task NMO-301) -//TEST(Transformation, ComputeRigidTransformDataPoints3D) -//{ -// std::shared_ptr transformator = PM::get().REG(Transformation).create("RigidTransformation"); -// -// // Identity. -// { -// const Eigen::Matrix translation{ 0, 0, 0 }; -// const Eigen::Quaternion rotation{ 1, 0, 0, 0 }; -// const Eigen::Transform transformation = buildUpTransformation3D(translation, rotation); -// // Transform and assert on the result. -// assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator); -// } -// -// // Pure translation. -// { -// const Eigen::Matrix translation{ -1.0001, 5, -12321.234 }; -// const Eigen::Quaternion rotation{ 1, 0, 0, 0 }; -// const Eigen::Transform transformation = buildUpTransformation3D(translation, rotation); -// // Transform and assert on the result. -// assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator); -// } -// // Pure rotation. -// { -// const Eigen::Matrix translation{ 0, 0, 0 }; -// const Eigen::Quaternion rotation{ 1, -5, 23, 0.5 }; -// const Eigen::Transform transformation = buildUpTransformation3D(translation, rotation); -// // Transform and assert on the result. -// assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator); -// } -// // Translation + rotation. -// { -// const NumericType kEpsilonNumericalError = 1e-6; -// const Eigen::Matrix translation{ 1, -3, -4 }; -// const Eigen::Quaternion rotation{ 0, -2.54, 0, 0.5 }; -// const Eigen::Transform transformation = buildUpTransformation3D(translation, rotation); -// // Transform and assert on the result. -// assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator, kEpsilonNumericalError); -// } -//} +TEST(Transformation, ComputeRigidTransformDataPoints3D) +{ + std::shared_ptr transformator = PM::get().REG(Transformation).create("RigidTransformation"); + + // Identity. + { + const Eigen::Matrix translation{ 0, 0, 0 }; + const Eigen::Quaternion rotation{ 1, 0, 0, 0 }; + const Eigen::Transform transformation = buildUpTransformation3D(translation, rotation); + // Transform and assert on the result. + assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator); + } + + // Pure translation. + { + const Eigen::Matrix translation{ -1.0001, 5, -12321.234 }; + const Eigen::Quaternion rotation{ 1, 0, 0, 0 }; + const Eigen::Transform transformation = buildUpTransformation3D(translation, rotation); + // Transform and assert on the result. + assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator); + } + // Pure rotation. + { + const Eigen::Matrix translation{ 0, 0, 0 }; + const Eigen::Quaternion rotation{ 1, -5, 23, 0.5 }; + const Eigen::Transform transformation = buildUpTransformation3D(translation, rotation); + // Transform and assert on the result. + assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator, 1e-7); + } + // Translation + rotation. + { + const Eigen::Matrix translation{ 1, -3, -4 }; + const Eigen::Quaternion rotation{ 0, -2.54, 0, 0.5 }; + const Eigen::Transform transformation = buildUpTransformation3D(translation, rotation); + // Transform and assert on the result. + assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator, 1e-7); + } +} TEST(Transformation, ComputeSimilarityTransformDataPoints2D) { @@ -359,64 +357,62 @@ TEST(Transformation, ComputeSimilarityTransformDataPoints2D) } } -//// (CRITICAL) ToDo: investigate unit-test failure (ref task NMO-301) -//TEST(Transformation, ComputeSimilarityTransformDataPoints3D) -//{ -// std::shared_ptr transformator = PM::get().REG(Transformation).create("SimilarityTransformation"); -// -// // Identity. -// { -// const Eigen::Matrix translation{ 0, 0, 0 }; -// const Eigen::Quaternion rotation{ 1, 0, 0, 0 }; -// const NumericType scale{ 1.0 }; -// const Eigen::Transform transformation = buildUpTransformation3D(translation, rotation, scale); -// // Transform and assert on the result. -// assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator); -// } -// // Pure Upscaling. -// { -// const Eigen::Matrix translation{ 0, 0, 0 }; -// const Eigen::Quaternion rotation{ 1, 0, 0, 0 }; -// const NumericType scale{ 5.0 }; -// const Eigen::Transform transformation = buildUpTransformation3D(translation, rotation, scale); -// // Transform and assert on the result. -// assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator); -// } -// // Pure Downscaling. -// { -// const Eigen::Matrix translation{ 0, 0, 0 }; -// const Eigen::Quaternion rotation{ 1, 0, 0, 0 }; -// const NumericType scale{ 0.1 }; -// const Eigen::Transform transformation = buildUpTransformation3D(translation, rotation, scale); -// // Transform and assert on the result. -// assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator); -// } -// // Pure translation + Downscaling. -// { -// const Eigen::Matrix translation{ -1.0001, 5, -12321.234 }; -// const Eigen::Quaternion rotation{ 1, 0, 0, 0 }; -// const NumericType scale{ 0.5 }; -// const Eigen::Transform transformation = buildUpTransformation3D(translation, rotation, scale); -// // Transform and assert on the result. -// assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator); -// } -// // Pure rotation + Upscaling. -// { -// const Eigen::Matrix translation{ 0, 0, 0 }; -// const Eigen::Quaternion rotation{ 1, -5, 23, 0.5 }; -// const NumericType scale{ 1.9 }; -// const Eigen::Transform transformation = buildUpTransformation3D(translation, rotation, scale); -// // Transform and assert on the result. -// assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator); -// } -// // Translation + rotation + Upscaling. -// { -// const NumericType kEpsilonNumericalError = 1e-6; -// const Eigen::Matrix translation{ 1, -3, -4 }; -// const Eigen::Quaternion rotation{ 0, -2.54, 0, 0.5 }; -// const NumericType scale{ 1.9 }; -// const Eigen::Transform transformation = buildUpTransformation3D(translation, rotation, scale); -// // Transform and assert on the result. -// assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator, kEpsilonNumericalError); -// } -//} +TEST(Transformation, ComputeSimilarityTransformDataPoints3D) +{ + std::shared_ptr transformator = PM::get().REG(Transformation).create("SimilarityTransformation"); + + // Identity. + { + const Eigen::Matrix translation{ 0, 0, 0 }; + const Eigen::Quaternion rotation{ 1, 0, 0, 0 }; + const NumericType scale{ 1.0 }; + const Eigen::Transform transformation = buildUpTransformation3D(translation, rotation, scale); + // Transform and assert on the result. + assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator); + } + // Pure Upscaling. + { + const Eigen::Matrix translation{ 0, 0, 0 }; + const Eigen::Quaternion rotation{ 1, 0, 0, 0 }; + const NumericType scale{ 5.0 }; + const Eigen::Transform transformation = buildUpTransformation3D(translation, rotation, scale); + // Transform and assert on the result. + assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator); + } + // Pure Downscaling. + { + const Eigen::Matrix translation{ 0, 0, 0 }; + const Eigen::Quaternion rotation{ 1, 0, 0, 0 }; + const NumericType scale{ 0.1 }; + const Eigen::Transform transformation = buildUpTransformation3D(translation, rotation, scale); + // Transform and assert on the result. + assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator); + } + // Pure translation + Downscaling. + { + const Eigen::Matrix translation{ -1.0001, 5, -12321.234 }; + const Eigen::Quaternion rotation{ 1, 0, 0, 0 }; + const NumericType scale{ 0.5 }; + const Eigen::Transform transformation = buildUpTransformation3D(translation, rotation, scale); + // Transform and assert on the result. + assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator); + } + // Pure rotation + Upscaling. + { + const Eigen::Matrix translation{ 0, 0, 0 }; + const Eigen::Quaternion rotation{ 1, -5, 23, 0.5 }; + const NumericType scale{ 1.9 }; + const Eigen::Transform transformation = buildUpTransformation3D(translation, rotation, scale); + // Transform and assert on the result. + assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator, 1e-7); + } + // Translation + rotation + Upscaling. + { + const Eigen::Matrix translation{ 1, -3, -4 }; + const Eigen::Quaternion rotation{ 0, -2.54, 0, 0.5 }; + const NumericType scale{ 1.9 }; + const Eigen::Transform transformation = buildUpTransformation3D(translation, rotation, scale); + // Transform and assert on the result. + assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator, 1e-7); + } +}