diff --git a/src/Utilities.cpp b/src/Utilities.cpp index 50d892f42b92569b7f785e1b79dfee461bfa0956..dec0545f0f915230406c498a8df742c157049c53 100644 --- a/src/Utilities.cpp +++ b/src/Utilities.cpp @@ -87,13 +87,18 @@ void computeDistortedFocalPlaneCoordinates( double t1 = detLine - lineOrigin - iTransL[0]; double t2 = detSample - sampleOrigin - iTransS[0]; double determinant = m11 * m22 - m12 * m21; - double p11 = m11 / determinant; + double p11 = m22 / determinant; double p12 = -m12 / determinant; double p21 = -m21 / determinant; - double p22 = m22 / determinant; + double p22 = m11 / determinant; distortedX = p11 * t1 + p12 * t2; distortedY = p21 * t1 + p22 * t2; + + std::cout << t1 << ", " << t2 << std::endl; + std::cout << p11 << ", " << p12 << std::endl; + std::cout << p21 << ", " << p22 << std::endl; + }; // Compue the image pixel for a distorted focal plane coordinate diff --git a/tests/UtilitiesTests.cpp b/tests/UtilitiesTests.cpp index 4da9a089000541e8e7eac2b2b6d92d5882468a82..19ca11b5db7e7ff3819fd0637e43f491073c7255 100644 --- a/tests/UtilitiesTests.cpp +++ b/tests/UtilitiesTests.cpp @@ -81,6 +81,22 @@ TEST(UtilitiesTests, computeDistortedFocalPlaneCoordinatesSumming) { EXPECT_DOUBLE_EQ(undistortedFocalPlaneY, 0); } +TEST(UtilitiesTests, computeDistortedFocalPlaneCoordinatesAffine) { + double iTransS[] = {-10.0, 0.0, 0.1}; + double iTransL[] = {10.0, -0.1, 0.0}; + double undistortedFocalPlaneX, undistortedFocalPlaneY; + computeDistortedFocalPlaneCoordinates( + 11.0, -9.0, + 0.0, 0.0, + 1.0, 1.0, + 0.0, 0.0, + iTransS, iTransL, + undistortedFocalPlaneX, undistortedFocalPlaneY); + EXPECT_NEAR(undistortedFocalPlaneX, -10.0, 1e-12); + EXPECT_NEAR(undistortedFocalPlaneY, 10.0, 1e-12); +} + + TEST(UtilitiesTests, computeDistortedFocalPlaneCoordinatesStart) { double iTransS[] = {0.0, 0.0, 10.0}; double iTransL[] = {0.0, 10.0, 0.0};