diff --git a/tests/DistortionTests.cpp b/tests/DistortionTests.cpp index d39275b727ba291776d10d83ffe542e20bdae5da..299fd1591a0bb9bfcf5b56ec9d44995229f52a2b 100644 --- a/tests/DistortionTests.cpp +++ b/tests/DistortionTests.cpp @@ -160,8 +160,8 @@ TEST(DawnFc, testApply) { applyDistortion(imagePt.samp, imagePt.line, dx, dy, coeffs, DistortionType::DAWNFC, desiredPrecision); - EXPECT_NEAR(dx, 10.0168, 1e-8); - EXPECT_NEAR(dy, 10.0168, 1e-8); + ASSERT_DOUBLE_EQ(dx, 10.0168); + ASSERT_DOUBLE_EQ(dy, 10.0168); } TEST(DawnFc, testRemove) { @@ -169,11 +169,88 @@ TEST(DawnFc, testRemove) { double ux, uy; double desiredPrecision = 0.0000001; + // Coeffs obtained from file FC21A0039691_15231053805F1E.IMG std::vector<double> coeffs = {8.4e-06}; removeDistortion(imagePt.samp, imagePt.line, ux, uy, coeffs, DistortionType::DAWNFC, desiredPrecision); - EXPECT_NEAR(ux,10.0,1e-8); - EXPECT_NEAR(uy,10.0,1e-8); + EXPECT_NEAR(ux, 10.0, 1e-8); + EXPECT_NEAR(uy, 10.0, 1e-8); +} + +TEST(DawnFc, testZeroCoeffs) { + csm::ImageCoord imagePt(10.0, 10.0); + + double ux, uy, dx, dy; + double desiredPrecision = 0.0000001; + std::vector<double> coeffs = {0}; + + applyDistortion(imagePt.samp, imagePt.line, dx, dy, coeffs, + DistortionType::DAWNFC, desiredPrecision); + + removeDistortion(dx, dy, ux, uy, coeffs, + DistortionType::DAWNFC, desiredPrecision); + + + ASSERT_DOUBLE_EQ(dx, 10.0); + ASSERT_DOUBLE_EQ(dy, 10.0); + ASSERT_DOUBLE_EQ(ux, 10.0); + ASSERT_DOUBLE_EQ(uy, 10.0); +} + +TEST(KaguyaTc, testRemoveCoeffs) { + csm::ImageCoord imagePt(1.0, 1.0); + + double ux, uy; + double desiredPrecision = 0.0000001; + std::vector<double> distortionCoeffs = {1, 2, 3, 4, + 1, 2, 3, 4}; + + removeDistortion(imagePt.samp, imagePt.line, ux, uy, distortionCoeffs, + DistortionType::KAGUYATC, desiredPrecision); + + EXPECT_NEAR(ux, 1 + 1 + 2.828427125 + 6 + 11.313708499, 1e-8); + EXPECT_NEAR(uy, 1 + 1 + 2.828427125 + 6 + 11.313708499, 1e-8); +} + +TEST(KaguyaTc, testCoeffs) { + csm::ImageCoord imagePt(1.0, 1.0); + + double ux, uy, dx, dy; + double desiredPrecision = 0.0000001; + // Coeffs obtained from file TC1W2B0_01_05211N095E3380.img + std::vector<double> coeffs = {-0.0009649900000000001, 0.00098441, 8.5773e-06, -3.7438e-06, + -0.0013796, 1.3502e-05, 2.7251e-06, -6.193800000000001e-06}; + + applyDistortion(imagePt.samp, imagePt.line, dx, dy, coeffs, + DistortionType::KAGUYATC, desiredPrecision); + + removeDistortion(dx, dy, ux, uy, coeffs, + DistortionType::KAGUYATC, desiredPrecision); + + EXPECT_NEAR(dx, 0.999566, 1e-6); + EXPECT_NEAR(dy, 1.00137, 1e-5); + EXPECT_NEAR(ux, 1.0, 1e-8); + EXPECT_NEAR(uy, 1.0, 1e-8); +} + +TEST(KaguyaTc, testZeroCoeffs) { + csm::ImageCoord imagePt(1.0, 1.0); + + double ux, uy, dx, dy; + double desiredPrecision = 0.0000001; + std::vector<double> coeffs = {0, 0, 0, 0, + 0, 0, 0, 0}; + + applyDistortion(imagePt.samp, imagePt.line, dx, dy, coeffs, + DistortionType::KAGUYATC, desiredPrecision); + + removeDistortion(dx, dy, ux, uy, coeffs, + DistortionType::KAGUYATC, desiredPrecision); + + ASSERT_DOUBLE_EQ(dx, 1.0); + ASSERT_DOUBLE_EQ(dy, 1.0); + ASSERT_DOUBLE_EQ(ux, 1.0); + ASSERT_DOUBLE_EQ(uy, 1.0); }