USGS

Isis 3.0 Object Programmers' Reference

Home

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) {
143  p_undistortedFocalPlaneX = pcx;
144  p_undistortedFocalPlaneY = pcy;
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 
177  p_undistortedFocalPlaneX = ux;
178  p_undistortedFocalPlaneY = uy;
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 {
201  pcx = p_undistortedFocalPlaneX;
202  pcy = p_undistortedFocalPlaneY;
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 }