Isis 3 Programmer Reference
LoHighDistortionMap.cpp
Go to the documentation of this file.
1 
20 #include "LoHighDistortionMap.h"
21 #include "IString.h"
22 
23 using namespace std;
24 
25 namespace Isis {
38  LoHighDistortionMap::LoHighDistortionMap(Camera *parent) :
39  CameraDistortionMap(parent, -1) {
40  }
41 
42 
95  void LoHighDistortionMap::SetDistortion(const int naifIkCode) {
96  // Get the perspective correction factors for x and y and the distortion
97  // center (point of symmetry of distortion)
98  QString perskey = "INS" + toString(naifIkCode) + "_PERSPECTIVE_FACTORS";
99  QString centkey = "INS" + toString(naifIkCode) + "_POINT_OF_SYMMETRY";
100  p_xPerspective = p_camera->Spice::getDouble(perskey, 0);
101  p_yPerspective = p_camera->Spice::getDouble(perskey, 1);
102  p_x0 = p_camera->Spice::getDouble(centkey, 0);
103  p_y0 = p_camera->Spice::getDouble(centkey, 1);
104 
105  // Get the distortion coefficients
107  }
108 
109 
125  const double dy) {
126  p_focalPlaneX = dx;
127  p_focalPlaneY = dy;
128 
129  // Apply perspective correction factors to get perspective corrected x/y
130  double perspectiveFactor = 1. + (p_xPerspective * dx) + (p_yPerspective * dy);
131  double pcx = dx * perspectiveFactor;
132  double pcy = dy * perspectiveFactor;
133 
134  // Translate the perspective-corrected x/y coordinate to be relative to the
135  // distortion point of symmetry
136  double distx = pcx - p_x0;
137  double disty = pcy - p_y0;
138 
139  // Get the distance from the focal plane center and if we are close
140  // skip the distortion
141  double r2 = distx * distx + disty * disty;
142  if(r2 <= 1.0E-6) {
145  return true;
146  }
147 
148  // Otherwise remove distortion
149  double drOverR = p_odk[0] + p_odk[1] * r2;
150  p_undistortedFocalPlaneX = pcx - (drOverR * distx);
151  p_undistortedFocalPlaneY = pcy - (drOverR * disty);
152  return true;
153  }
154 
155 
175  const double uy) {
176 
179 
180  // Translate the distorted x/y coordinate to be relative to the
181  // distortion point of symmetry
182  double distux = p_undistortedFocalPlaneX - p_x0;
183  double distuy = p_undistortedFocalPlaneY - p_y0;
184 
185  // Compute the distance from the focal plane center and if we are
186  // close to the center then no distortion is required
187  double rp2 = distux * distux + distuy * distuy;
188 
189  double pcx, pcy;
190 
191  if(rp2 > 1.0E-6) {
192 
193  // Add distortion. First compute fractional distortion at rp (r-prime)
194  double drOverR = p_odk[0] + rp2 * p_odk[1];
195 
196  // Compute the perspective corrected x/y
197  pcx = p_undistortedFocalPlaneX + (distux * drOverR);
198  pcy = p_undistortedFocalPlaneY + (distuy * drOverR);
199  }
200  else {
203  }
204 
205  // Add the perspective error
206  double perspectiveCorrection = 1. - (p_xPerspective * pcx) - (p_yPerspective * pcy);
207  p_focalPlaneX = pcx * perspectiveCorrection;
208  p_focalPlaneY = pcy * perspectiveCorrection;
209  return true;
210  }
211 }
double p_focalPlaneX
Distorted focal plane x.
void SetDistortion(const int naifIkCode)
Load LO High Resolution Camera perspective & distortion coefficients.
Namespace for the standard library.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:226
virtual void SetDistortion(int naifIkCode)
Load distortion coefficients.
double p_undistortedFocalPlaneX
Undistorted focal plane x.
Camera * p_camera
The camera to distort/undistort.
virtual bool SetUndistortedFocalPlane(const double ux, const double uy)
Compute distorted focal plane x/y for Lo High Resolution Camera.
double p_y0
Center of distortion on y axis.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
double p_yPerspective
Perspective correction factor in y.
Distort/undistort focal plane coordinates.
const double E
Sets some basic constants for use in ISIS programming.
Definition: Constants.h:55
double p_focalPlaneY
Distorted focal plane y.
double p_undistortedFocalPlaneY
Undistorted focal plane y.
double p_x0
Center of distortion on x axis.
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
std::vector< double > p_odk
Vector of distortion coefficients.
double p_xPerspective
Perspective correction factor in x.
virtual bool SetFocalPlane(const double dx, const double dy)
Compute undistorted focal plane x/y for Lo High Resolution Camera.