Isis 3 Programmer Reference
TgoCassisDistortionMap.cpp
Go to the documentation of this file.
1 
23 #include <cmath>
24 
25 #include <QDebug>
26 
27 #include "IString.h"
28 #include "TgoCassisDistortionMap.h"
29 
30 namespace Isis {
44  int naifIkCode)
45  : CameraDistortionMap(parent) {
46 
47  QString od = "INS" + toString(naifIkCode) + "_OD_";
48 
49  for(int i = 0; i < 6; i++) {
50  m_A1_corr.push_back(p_camera->getDouble(od + "A1_CORR", i));
51  m_A2_corr.push_back(p_camera->getDouble(od + "A2_CORR", i));
52  m_A3_corr.push_back(p_camera->getDouble(od + "A3_CORR", i));
53  m_A1_dist.push_back(p_camera->getDouble(od + "A1_DIST", i));
54  m_A2_dist.push_back(p_camera->getDouble(od + "A2_DIST", i));
55  m_A3_dist.push_back(p_camera->getDouble(od + "A3_DIST", i));
56  }
57  m_pixelPitch = p_camera->getDouble("INS" + toString(naifIkCode) + "_PIXEL_PITCH");
58  m_width = p_camera->getDouble("INS" + toString(naifIkCode) + "_FILTER_SAMPLES");
59  m_height = p_camera->getDouble("INS" + toString(naifIkCode) + "_FILTER_LINES");
60  }
61 
62 
67  }
68 
69 
100  const double dy) {
101 
102  p_focalPlaneX = dx;
103  p_focalPlaneY = dy;
104 
105  // calculate divisor using A3_corr coeffiecients
106  double divider = chiDotA(dx, dy, m_A3_corr);
107  // This distortion model is only valid for values on the CCD:
108  // -1/2 * pixel pitch * CCD width = -10.24 < x < 10.24 = 1/2 * pixel pitch * CCD width
109  // -1/2 * pixel pitch * CCD height = -10.24 < y < 10.24 = 1/2 * pixel pitch * CCD height
110  //
111  // Also, the zeros for the divider variable fall well outside the boundary
112  // of the CCD. (See $ISIS3DATA/tgo/assets/distortion/DistortionModelA3CorrRoots.jpg).
113  //
114  // So, whenever x or y are too far from center or divider is near zero,
115  // return the given inputs
116 
117  if ( dx < -0.5*m_pixelPitch*m_width - 0.2 ||
118  dx > 0.5*m_pixelPitch*m_width + 0.2 ||
119  dy < -0.5*m_pixelPitch*m_height - 0.2 ||
120  dy > 0.5*m_pixelPitch*m_height + 0.2 ) {
123 
124  return true;
125  }
126 
127  // get undistorted ideal (x,y) coordinates
128  double ux = chiDotA(dx, dy, m_A1_corr) / divider;
129  double uy = chiDotA(dx, dy, m_A2_corr) / divider;
130 
133 
134  return true;
135  }
136 
137 
168  const double uy) {
171 
172  // calculate divisor using A3_dist coeffiecients
173  double divider = chiDotA(ux, uy, m_A3_dist);
174  // This distortion model is only valid for values on the CCD:
175  // -1/2 * pixel pitch * CCD width = -10.24 < x < 10.24 = 1/2 * pixel pitch * CCD width
176  // -1/2 * pixel pitch * CCD height = -10.24 < y < 10.24 = 1/2 * pixel pitch * CCD height
177  //
178  // Also, the zeros for the divider variable fall well outside the boundary
179  // of the CCD. (See $ISIS3DATA/tgo/assets/distortion/DistortionModelA3DistRoots.jpg).
180  //
181  // So, whenever x or y are too far from center or divider is near zero,
182  // return the given inputs
183 
184  if ( ux < -0.5*m_pixelPitch*m_width - 0.2 ||
185  ux > 0.5*m_pixelPitch*m_width + 0.2 ||
186  uy < -0.5*m_pixelPitch*m_height - 0.2 ||
187  uy > 0.5*m_pixelPitch*m_height + 0.2 ) {
188  p_focalPlaneX = ux;
189  p_focalPlaneY = uy;
190 
191  return true;
192  }
193 
194  // get undistorted ideal (x,y) coordinates
195  double dx = chiDotA(ux, uy, m_A1_dist) / divider;
196  double dy = chiDotA(ux, uy, m_A2_dist) / divider;
197 
198  p_focalPlaneX = dx;
199  p_focalPlaneY = dy;
200  return true;
201  }
202 
203 
223  double y,
224  QList<double> A) {
225  double x2 = x*x;
226  double y2 = y*y;
227  double xy = x*y;
228 
229  return A[0] * x2
230  + A[1] * xy
231  + A[2] * y2
232  + A[3] * x
233  + A[4] * y
234  + A[5];
235  }
236 }
237 
QList< double > m_A2_dist
Coefficients for rational distortion model used to compute distorted y from ideal y...
double p_focalPlaneX
Distorted focal plane x.
virtual bool SetFocalPlane(const double dx, const double dy)
Compute undistorted focal plane (x,y) coordinate given the distorted (x,y).
double chiDotA(double x, double y, QList< double > A)
Evaluate the value for the multi-variate polynomial, given the list of 6 coefficients.
double m_pixelPitch
The pixel pitch of the camera.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:226
double m_height
The height of the ccd in pixels.
double p_undistortedFocalPlaneX
Undistorted focal plane x.
Camera * p_camera
The camera to distort/undistort.
Distort/undistort focal plane coordinates.
QList< double > m_A1_dist
Coefficients for rational distortion model used to compute distorted x from ideal x...
double p_focalPlaneY
Distorted focal plane y.
virtual bool SetUndistortedFocalPlane(const double ux, const double uy)
Compute distorted focal plane (x,y) given an undistorted focal plane (x,y).
double p_undistortedFocalPlaneY
Undistorted focal plane y.
QList< double > m_A2_corr
Coefficients for rational distortion model used to compute ideal y from distorted y...
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
TgoCassisDistortionMap(Camera *parent, int naifIkCode)
Exomars TGO CaSSIS distortion map constructor.
QList< double > m_A3_dist
Coefficients for rational distortion model used to find scaling factor used when computing distorted ...
double m_width
The width of the ccd in pixels.
QList< double > m_A3_corr
Coefficients for rational distortion model used to find scaling factor used when computing ideal coor...
virtual ~TgoCassisDistortionMap()
Exomars TGO CaSSIS distortion map destructor.
QList< double > m_A1_corr
Coefficients for rational distortion model used to compute ideal x from distorted x...
SpiceDouble getDouble(const QString &key, int index=0)
This returns a value from the NAIF text pool.
Definition: Spice.cpp:963