Skip to content

Commit

Permalink
Fix failing 3D transformation tests on Ubuntu Bionic
Browse files Browse the repository at this point in the history
  • Loading branch information
boxanm committed Jan 23, 2024
1 parent 1a3a4b3 commit 1942a77
Showing 1 changed file with 97 additions and 101 deletions.
198 changes: 97 additions & 101 deletions utest/ui/Transformations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,46 +258,44 @@ TEST(Transformation, ComputeRigidTransformDataPoints2D)
}
}

//// (CRITICAL) ToDo: investigate unit-test failure (ref task NMO-301)
//TEST(Transformation, ComputeRigidTransformDataPoints3D)
//{
// std::shared_ptr<PM::Transformation> transformator = PM::get().REG(Transformation).create("RigidTransformation");
//
// // Identity.
// {
// const Eigen::Matrix<NumericType, 3, 1> translation{ 0, 0, 0 };
// const Eigen::Quaternion<NumericType> rotation{ 1, 0, 0, 0 };
// const Eigen::Transform<NumericType, 3, Eigen::Affine> transformation = buildUpTransformation3D(translation, rotation);
// // Transform and assert on the result.
// assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator);
// }
//
// // Pure translation.
// {
// const Eigen::Matrix<NumericType, 3, 1> translation{ -1.0001, 5, -12321.234 };
// const Eigen::Quaternion<NumericType> rotation{ 1, 0, 0, 0 };
// const Eigen::Transform<NumericType, 3, Eigen::Affine> transformation = buildUpTransformation3D(translation, rotation);
// // Transform and assert on the result.
// assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator);
// }
// // Pure rotation.
// {
// const Eigen::Matrix<NumericType, 3, 1> translation{ 0, 0, 0 };
// const Eigen::Quaternion<NumericType> rotation{ 1, -5, 23, 0.5 };
// const Eigen::Transform<NumericType, 3, Eigen::Affine> 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<NumericType, 3, 1> translation{ 1, -3, -4 };
// const Eigen::Quaternion<NumericType> rotation{ 0, -2.54, 0, 0.5 };
// const Eigen::Transform<NumericType, 3, Eigen::Affine> transformation = buildUpTransformation3D(translation, rotation);
// // Transform and assert on the result.
// assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator, kEpsilonNumericalError);
// }
//}
TEST(Transformation, ComputeRigidTransformDataPoints3D)
{
std::shared_ptr<PM::Transformation> transformator = PM::get().REG(Transformation).create("RigidTransformation");

// Identity.
{
const Eigen::Matrix<NumericType, 3, 1> translation{ 0, 0, 0 };
const Eigen::Quaternion<NumericType> rotation{ 1, 0, 0, 0 };
const Eigen::Transform<NumericType, 3, Eigen::Affine> transformation = buildUpTransformation3D(translation, rotation);
// Transform and assert on the result.
assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator);
}

// Pure translation.
{
const Eigen::Matrix<NumericType, 3, 1> translation{ -1.0001, 5, -12321.234 };
const Eigen::Quaternion<NumericType> rotation{ 1, 0, 0, 0 };
const Eigen::Transform<NumericType, 3, Eigen::Affine> transformation = buildUpTransformation3D(translation, rotation);
// Transform and assert on the result.
assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator);
}
// Pure rotation.
{
const Eigen::Matrix<NumericType, 3, 1> translation{ 0, 0, 0 };
const Eigen::Quaternion<NumericType> rotation{ 1, -5, 23, 0.5 };
const Eigen::Transform<NumericType, 3, Eigen::Affine> transformation = buildUpTransformation3D(translation, rotation);
// Transform and assert on the result.
assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator, 1e-7);
}
// Translation + rotation.
{
const Eigen::Matrix<NumericType, 3, 1> translation{ 1, -3, -4 };
const Eigen::Quaternion<NumericType> rotation{ 0, -2.54, 0, 0.5 };
const Eigen::Transform<NumericType, 3, Eigen::Affine> transformation = buildUpTransformation3D(translation, rotation);
// Transform and assert on the result.
assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator, 1e-7);
}
}

TEST(Transformation, ComputeSimilarityTransformDataPoints2D)
{
Expand Down Expand Up @@ -359,64 +357,62 @@ TEST(Transformation, ComputeSimilarityTransformDataPoints2D)
}
}

//// (CRITICAL) ToDo: investigate unit-test failure (ref task NMO-301)
//TEST(Transformation, ComputeSimilarityTransformDataPoints3D)
//{
// std::shared_ptr<PM::Transformation> transformator = PM::get().REG(Transformation).create("SimilarityTransformation");
//
// // Identity.
// {
// const Eigen::Matrix<NumericType, 3, 1> translation{ 0, 0, 0 };
// const Eigen::Quaternion<NumericType> rotation{ 1, 0, 0, 0 };
// const NumericType scale{ 1.0 };
// const Eigen::Transform<NumericType, 3, Eigen::Affine> transformation = buildUpTransformation3D(translation, rotation, scale);
// // Transform and assert on the result.
// assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator);
// }
// // Pure Upscaling.
// {
// const Eigen::Matrix<NumericType, 3, 1> translation{ 0, 0, 0 };
// const Eigen::Quaternion<NumericType> rotation{ 1, 0, 0, 0 };
// const NumericType scale{ 5.0 };
// const Eigen::Transform<NumericType, 3, Eigen::Affine> transformation = buildUpTransformation3D(translation, rotation, scale);
// // Transform and assert on the result.
// assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator);
// }
// // Pure Downscaling.
// {
// const Eigen::Matrix<NumericType, 3, 1> translation{ 0, 0, 0 };
// const Eigen::Quaternion<NumericType> rotation{ 1, 0, 0, 0 };
// const NumericType scale{ 0.1 };
// const Eigen::Transform<NumericType, 3, Eigen::Affine> transformation = buildUpTransformation3D(translation, rotation, scale);
// // Transform and assert on the result.
// assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator);
// }
// // Pure translation + Downscaling.
// {
// const Eigen::Matrix<NumericType, 3, 1> translation{ -1.0001, 5, -12321.234 };
// const Eigen::Quaternion<NumericType> rotation{ 1, 0, 0, 0 };
// const NumericType scale{ 0.5 };
// const Eigen::Transform<NumericType, 3, Eigen::Affine> transformation = buildUpTransformation3D(translation, rotation, scale);
// // Transform and assert on the result.
// assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator);
// }
// // Pure rotation + Upscaling.
// {
// const Eigen::Matrix<NumericType, 3, 1> translation{ 0, 0, 0 };
// const Eigen::Quaternion<NumericType> rotation{ 1, -5, 23, 0.5 };
// const NumericType scale{ 1.9 };
// const Eigen::Transform<NumericType, 3, Eigen::Affine> 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<NumericType, 3, 1> translation{ 1, -3, -4 };
// const Eigen::Quaternion<NumericType> rotation{ 0, -2.54, 0, 0.5 };
// const NumericType scale{ 1.9 };
// const Eigen::Transform<NumericType, 3, Eigen::Affine> transformation = buildUpTransformation3D(translation, rotation, scale);
// // Transform and assert on the result.
// assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator, kEpsilonNumericalError);
// }
//}
TEST(Transformation, ComputeSimilarityTransformDataPoints3D)
{
std::shared_ptr<PM::Transformation> transformator = PM::get().REG(Transformation).create("SimilarityTransformation");

// Identity.
{
const Eigen::Matrix<NumericType, 3, 1> translation{ 0, 0, 0 };
const Eigen::Quaternion<NumericType> rotation{ 1, 0, 0, 0 };
const NumericType scale{ 1.0 };
const Eigen::Transform<NumericType, 3, Eigen::Affine> transformation = buildUpTransformation3D(translation, rotation, scale);
// Transform and assert on the result.
assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator);
}
// Pure Upscaling.
{
const Eigen::Matrix<NumericType, 3, 1> translation{ 0, 0, 0 };
const Eigen::Quaternion<NumericType> rotation{ 1, 0, 0, 0 };
const NumericType scale{ 5.0 };
const Eigen::Transform<NumericType, 3, Eigen::Affine> transformation = buildUpTransformation3D(translation, rotation, scale);
// Transform and assert on the result.
assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator);
}
// Pure Downscaling.
{
const Eigen::Matrix<NumericType, 3, 1> translation{ 0, 0, 0 };
const Eigen::Quaternion<NumericType> rotation{ 1, 0, 0, 0 };
const NumericType scale{ 0.1 };
const Eigen::Transform<NumericType, 3, Eigen::Affine> transformation = buildUpTransformation3D(translation, rotation, scale);
// Transform and assert on the result.
assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator);
}
// Pure translation + Downscaling.
{
const Eigen::Matrix<NumericType, 3, 1> translation{ -1.0001, 5, -12321.234 };
const Eigen::Quaternion<NumericType> rotation{ 1, 0, 0, 0 };
const NumericType scale{ 0.5 };
const Eigen::Transform<NumericType, 3, Eigen::Affine> transformation = buildUpTransformation3D(translation, rotation, scale);
// Transform and assert on the result.
assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator);
}
// Pure rotation + Upscaling.
{
const Eigen::Matrix<NumericType, 3, 1> translation{ 0, 0, 0 };
const Eigen::Quaternion<NumericType> rotation{ 1, -5, 23, 0.5 };
const NumericType scale{ 1.9 };
const Eigen::Transform<NumericType, 3, Eigen::Affine> transformation = buildUpTransformation3D(translation, rotation, scale);
// Transform and assert on the result.
assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator, 1e-7);
}
// Translation + rotation + Upscaling.
{
const Eigen::Matrix<NumericType, 3, 1> translation{ 1, -3, -4 };
const Eigen::Quaternion<NumericType> rotation{ 0, -2.54, 0, 0.5 };
const NumericType scale{ 1.9 };
const Eigen::Transform<NumericType, 3, Eigen::Affine> transformation = buildUpTransformation3D(translation, rotation, scale);
// Transform and assert on the result.
assertOnDataPointsTransformation(data3D, transformation.matrix(), transformator, 1e-7);
}
}

0 comments on commit 1942a77

Please sign in to comment.