Commit 214170e4 authored by acpaquette's avatar acpaquette Committed by Jesse Mapel
Browse files

Added tests for cahvor distortion

parent b277c09b
Loading
Loading
Loading
Loading
+4 −7
Original line number Diff line number Diff line
@@ -204,14 +204,11 @@ void removeDistortion(double dx, double dy, double &ux, double &uy,
      double r = sqrt(r2);
      double r3 = r2 * r;

      int xPointer = 0;
      int yPointer = 5;

      double dr_x = odkx[0] + odkx[1] * r + odkx[2] * r2 + odkx[3] * r3;
      double dr_y = odky[0] + odky[1] * r + odky[2] * r2 + odky[3] * r3;

      ux = dx + dr_x + boresightX;
      uy = dy + dr_y + boresightY;
      ux += dr_x + boresightX;
      uy += dr_y + boresightY;
    } break;

    // The dawn distortion model is "reversed" from other distortion models so
@@ -593,8 +590,8 @@ void applyDistortion(double ux, double uy, double &dx, double &dy,
          iteration++;
        } while (fabs(r - r_prev) > desiredPrecision);

        dx = ux / (1.0 - drOverR);
        dy = uy / (1.0 - drOverR);
        dx = shiftedUx / (1.0 - drOverR);
        dy = shiftedUy / (1.0 - drOverR);
        dx += opticalDistCoeffs[3];
        dy += opticalDistCoeffs[4];
      }
+56 −0
Original line number Diff line number Diff line
@@ -324,3 +324,59 @@ TEST(LroLrocNac, testZeroCoeffs) {
  ASSERT_DOUBLE_EQ(ux, 0.0);
  ASSERT_DOUBLE_EQ(uy, 0.0);
}

INSTANTIATE_TEST_SUITE_P(CahvorTest, CoeffOffsetParameterizedTest,
                         ::testing::Values(std::vector<double>(2, 0),
                                           std::vector<double>(2, 1)));

TEST_P(CoeffOffsetParameterizedTest, RemoveDistortionCahvorTest)
{
  csm::ImageCoord imagePt(0.0, 4.0);

  double ux, uy;
  std::vector<double> offsets = GetParam();
  std::vector<double> coeffs = {0, 0, 0};
  coeffs.insert(coeffs.end(), offsets.begin(), offsets.end());

  removeDistortion(imagePt.samp, imagePt.line, ux, uy, coeffs,
                   DistortionType::CAHVOR);

  EXPECT_NEAR(ux, 4, 1e-8);
  EXPECT_NEAR(uy, 0, 1e-8);
}

// If coeffs are 0 then this will have the same result as removeDistortion
// with 0 distortion coefficients
TEST_P(CoeffOffsetParameterizedTest, InverseDistortionCahvorTest)
{
  csm::ImageCoord imagePt(0.0, 4.0);

  double dx, dy;
  double desiredPrecision = 0.01;
  std::vector<double> offsets = GetParam();
  std::vector<double> coeffs = {0, 0, 0};
  coeffs.insert(coeffs.end(), offsets.begin(), offsets.end());

  applyDistortion(imagePt.samp, imagePt.line, dx, dy, coeffs,
                  DistortionType::CAHVOR, desiredPrecision);

  EXPECT_NEAR(dx, 4, 1e-8);
  EXPECT_NEAR(dy, 0, 1e-8);
}

TEST_P(CoeffOffsetParameterizedTest, InverseOnesCoeffsCahvorTest)
{
  csm::ImageCoord imagePt(0.0, 4.0);

  double dx, dy;
  double desiredPrecision = 0.01;
  std::vector<double> offsets = GetParam();
  std::vector<double> coeffs = {1, 1, 1};
  coeffs.insert(coeffs.end(), offsets.begin(), offsets.end());

  applyDistortion(imagePt.samp, imagePt.line, dx, dy, coeffs,
                  DistortionType::CAHVOR, desiredPrecision);

  EXPECT_NEAR(dx, 4, 1e-8);
  EXPECT_NEAR(dy, 0, 1e-8);
}
+3 −0
Original line number Diff line number Diff line
@@ -177,6 +177,9 @@ class ConstVelLineScanIsdTest : public ::testing::Test {
class ImageCoordParameterizedTest
    : public ::testing::TestWithParam<csm::ImageCoord> {};

class CoeffOffsetParameterizedTest
    : public ::testing::TestWithParam<std::vector<double>> {};

class FramerParameterizedTest
    : public ::testing::TestWithParam<csm::ImageCoord> {
 protected: