Isis 3 Programmer Reference
TgoCassisDistortionMap.cpp
1 
7 /* SPDX-License-Identifier: CC0-1.0 */
8 
9 #include <cmath>
10 
11 #include <QDebug>
12 
13 #include "IString.h"
14 #include "TgoCassisDistortionMap.h"
15 
16 namespace Isis {
30  int naifIkCode)
31  : CameraDistortionMap(parent) {
32 
33  QString od = "INS" + toString(naifIkCode) + "_OD_";
34 
35  for(int i = 0; i < 6; i++) {
36  m_A1_corr.push_back(p_camera->getDouble(od + "A1_CORR", i));
37  m_A2_corr.push_back(p_camera->getDouble(od + "A2_CORR", i));
38  m_A3_corr.push_back(p_camera->getDouble(od + "A3_CORR", i));
39  m_A1_dist.push_back(p_camera->getDouble(od + "A1_DIST", i));
40  m_A2_dist.push_back(p_camera->getDouble(od + "A2_DIST", i));
41  m_A3_dist.push_back(p_camera->getDouble(od + "A3_DIST", i));
42  }
43  m_pixelPitch = p_camera->getDouble("INS" + toString(naifIkCode) + "_PIXEL_PITCH");
44  m_width = p_camera->getDouble("INS" + toString(naifIkCode) + "_FILTER_SAMPLES");
45  m_height = p_camera->getDouble("INS" + toString(naifIkCode) + "_FILTER_LINES");
46  }
47 
48 
53  }
54 
55 
86  const double dy) {
87 
88  p_focalPlaneX = dx;
89  p_focalPlaneY = dy;
90 
91  // calculate divisor using A3_corr coeffiecients
92  double divider = chiDotA(dx, dy, m_A3_corr);
93  // This distortion model is only valid for values on the CCD:
94  // -1/2 * pixel pitch * CCD width = -10.24 < x < 10.24 = 1/2 * pixel pitch * CCD width
95  // -1/2 * pixel pitch * CCD height = -10.24 < y < 10.24 = 1/2 * pixel pitch * CCD height
96  //
97  // Also, the zeros for the divider variable fall well outside the boundary
98  // of the CCD. (See $ISISDATA/tgo/assets/distortion/DistortionModelA3CorrRoots.jpg).
99  //
100  // So, whenever x or y are too far from center or divider is near zero,
101  // return the given inputs
102 
103  if ( dx < -0.5*m_pixelPitch*m_width - 0.2 ||
104  dx > 0.5*m_pixelPitch*m_width + 0.2 ||
105  dy < -0.5*m_pixelPitch*m_height - 0.2 ||
106  dy > 0.5*m_pixelPitch*m_height + 0.2 ) {
109 
110  return true;
111  }
112 
113  // get undistorted ideal (x,y) coordinates
114  double ux = chiDotA(dx, dy, m_A1_corr) / divider;
115  double uy = chiDotA(dx, dy, m_A2_corr) / divider;
116 
119 
120  return true;
121  }
122 
123 
154  const double uy) {
157 
158  // calculate divisor using A3_dist coeffiecients
159  double divider = chiDotA(ux, uy, m_A3_dist);
160  // This distortion model is only valid for values on the CCD:
161  // -1/2 * pixel pitch * CCD width = -10.24 < x < 10.24 = 1/2 * pixel pitch * CCD width
162  // -1/2 * pixel pitch * CCD height = -10.24 < y < 10.24 = 1/2 * pixel pitch * CCD height
163  //
164  // Also, the zeros for the divider variable fall well outside the boundary
165  // of the CCD. (See $ISISDATA/tgo/assets/distortion/DistortionModelA3DistRoots.jpg).
166  //
167  // So, whenever x or y are too far from center or divider is near zero,
168  // return the given inputs
169 
170  if ( ux < -0.5*m_pixelPitch*m_width - 0.2 ||
171  ux > 0.5*m_pixelPitch*m_width + 0.2 ||
172  uy < -0.5*m_pixelPitch*m_height - 0.2 ||
173  uy > 0.5*m_pixelPitch*m_height + 0.2 ) {
174  p_focalPlaneX = ux;
175  p_focalPlaneY = uy;
176 
177  return true;
178  }
179 
180  // get undistorted ideal (x,y) coordinates
181  double dx = chiDotA(ux, uy, m_A1_dist) / divider;
182  double dy = chiDotA(ux, uy, m_A2_dist) / divider;
183 
184  p_focalPlaneX = dx;
185  p_focalPlaneY = dy;
186  return true;
187  }
188 
189 
209  double y,
210  QList<double> A) {
211  double x2 = x*x;
212  double y2 = y*y;
213  double xy = x*y;
214 
215  return A[0] * x2
216  + A[1] * xy
217  + A[2] * y2
218  + A[3] * x
219  + A[4] * y
220  + A[5];
221  }
222 }
Isis::TgoCassisDistortionMap::m_A1_corr
QList< double > m_A1_corr
Coefficients for rational distortion model used to compute ideal x from distorted x.
Definition: TgoCassisDistortionMap.h:58
Isis::TgoCassisDistortionMap::m_width
double m_width
The width of the ccd in pixels.
Definition: TgoCassisDistortionMap.h:72
Isis::CameraDistortionMap::p_focalPlaneX
double p_focalPlaneX
Distorted focal plane x.
Definition: CameraDistortionMap.h:65
QList< double >
Isis::TgoCassisDistortionMap::m_A2_dist
QList< double > m_A2_dist
Coefficients for rational distortion model used to compute distorted y from ideal y.
Definition: TgoCassisDistortionMap.h:66
Isis::CameraDistortionMap::p_undistortedFocalPlaneY
double p_undistortedFocalPlaneY
Undistorted focal plane y.
Definition: CameraDistortionMap.h:68
Isis::CameraDistortionMap::p_undistortedFocalPlaneX
double p_undistortedFocalPlaneX
Undistorted focal plane x.
Definition: CameraDistortionMap.h:67
Isis::TgoCassisDistortionMap::m_height
double m_height
The height of the ccd in pixels.
Definition: TgoCassisDistortionMap.h:74
Isis::Camera
Definition: Camera.h:236
Isis::toString
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:211
Isis::TgoCassisDistortionMap::m_pixelPitch
double m_pixelPitch
The pixel pitch of the camera.
Definition: TgoCassisDistortionMap.h:70
Isis::TgoCassisDistortionMap::chiDotA
double chiDotA(double x, double y, QList< double > A)
Evaluate the value for the multi-variate polynomial, given the list of 6 coefficients.
Definition: TgoCassisDistortionMap.cpp:208
Isis::TgoCassisDistortionMap::m_A1_dist
QList< double > m_A1_dist
Coefficients for rational distortion model used to compute distorted x from ideal x.
Definition: TgoCassisDistortionMap.h:64
Isis::CameraDistortionMap::p_camera
Camera * p_camera
The camera to distort/undistort.
Definition: CameraDistortionMap.h:63
Isis::CameraDistortionMap
Distort/undistort focal plane coordinates.
Definition: CameraDistortionMap.h:41
Isis::TgoCassisDistortionMap::m_A3_dist
QList< double > m_A3_dist
Coefficients for rational distortion model used to find scaling factor used when computing distorted ...
Definition: TgoCassisDistortionMap.h:68
Isis::TgoCassisDistortionMap::TgoCassisDistortionMap
TgoCassisDistortionMap(Camera *parent, int naifIkCode)
Exomars TGO CaSSIS distortion map constructor.
Definition: TgoCassisDistortionMap.cpp:29
Isis::TgoCassisDistortionMap::m_A2_corr
QList< double > m_A2_corr
Coefficients for rational distortion model used to compute ideal y from distorted y.
Definition: TgoCassisDistortionMap.h:60
Isis::TgoCassisDistortionMap::SetUndistortedFocalPlane
virtual bool SetUndistortedFocalPlane(const double ux, const double uy)
Compute distorted focal plane (x,y) given an undistorted focal plane (x,y).
Definition: TgoCassisDistortionMap.cpp:153
Isis::Spice::getDouble
SpiceDouble getDouble(const QString &key, int index=0)
This returns a value from the NAIF text pool.
Definition: Spice.cpp:1039
Isis::TgoCassisDistortionMap::SetFocalPlane
virtual bool SetFocalPlane(const double dx, const double dy)
Compute undistorted focal plane (x,y) coordinate given the distorted (x,y).
Definition: TgoCassisDistortionMap.cpp:85
Isis::TgoCassisDistortionMap::~TgoCassisDistortionMap
virtual ~TgoCassisDistortionMap()
Exomars TGO CaSSIS distortion map destructor.
Definition: TgoCassisDistortionMap.cpp:52
Isis::CameraDistortionMap::p_focalPlaneY
double p_focalPlaneY
Distorted focal plane y.
Definition: CameraDistortionMap.h:66
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::TgoCassisDistortionMap::m_A3_corr
QList< double > m_A3_corr
Coefficients for rational distortion model used to find scaling factor used when computing ideal coor...
Definition: TgoCassisDistortionMap.h:62