Isis 3 Programmer Reference
NewHorizonsLorriDistortionMap.cpp
Go to the documentation of this file.
1 
22 #include "CameraFocalPlaneMap.h"
23 
24 using namespace std;
25 
26 namespace Isis {
27 
42  NewHorizonsLorriDistortionMap::NewHorizonsLorriDistortionMap(Camera *parent, double e2, double e5,
43  double e6, double zDirection) : CameraDistortionMap(parent, zDirection) {
44  p_e2 = e2;
45  p_e5 = e5;
46  p_e6 = e6;
47  }
48 
49 
62  bool NewHorizonsLorriDistortionMap::SetFocalPlane(const double dx, const double dy) {
63 
64  p_focalPlaneX = dx;
65  p_focalPlaneY = dy;
66 
67  // Reducing to the principle point offset (xp,yp)
68  double x = dx;
69  double y = dy;
70 
71  // r is the distance between the principal point and the measured point on the image
72  double rr = x * x + y * y;
73 
74  // dr is the radial distortion contribution
75  // The equation below was changed from all + to all - to adjust the distortion model to fit
76  // the definition of the LORRI distortion. The original version with +, was defined from Bill
77  // Owen's paper with an assumption the xs and ys in the equations were distorted x,ys. After
78  // meeting with the LORRI team +s were changed to -s to account for the x,ys actually being
79  // undistorted focal plane positions. That is, the undistorted focal plane positions are
80  // closer to the center of the image than the distorted focal plane positions.
81  // NOTE: The discussions showed the Ky and e5 values needed to be negated. The e5 value has
82  // now been negated in the LORRI IK, and the y is now negated in the equation below.
83  // NOTE: The Y and Line values can not be negated in the transY and transL affines because
84  // this would cause the p_xxxxx class member variables to be in a flipped (top to bottom)
85  // coordinate system relative to the SPICE defined focal plane coordinate system.
86  double dr = 1.0 - rr * p_e2 - y * p_e5 - x * p_e6;
87 
88  // Image coordinates corrected for distortion
89  p_undistortedFocalPlaneX = x * dr;
90  p_undistortedFocalPlaneY = y * dr;
91 
92  return true;
93 
94  }
95 
96 
109  bool NewHorizonsLorriDistortionMap::SetUndistortedFocalPlane(const double ux, const double uy) {
110 
111  // Image coordinates prior to introducing distortion
114 
115  double xt = ux;
116  double yt = uy;
117 
118  double xx, yy, xy, rr;
119  double xdistortion, ydistortion;
120  double xdistorted, ydistorted;
121  double xprevious, yprevious;
122 
123  xprevious = 1000000.0;
124  yprevious = 1000000.0;
125 
126  double tolerance = 0.000001;
127 
128  bool bConverged = false;
129 
130  // Iterating to introduce distortion...
131  // We stop when the difference between distorted coordinates
132  // in successive iterations is at or below the given tolerance
133  for (int i = 0; i < 50; i++) {
134  xx = xt * xt;
135  yy = yt * yt;
136  xy = xt * yt;
137  rr = xx + yy;
138 
139  // Distortion at the current point location
140  xdistortion = xt * rr * p_e2 + xy * p_e5 + xx * p_e6;
141  ydistortion = yt * rr * p_e2 + yy * p_e5 + xy * p_e6;
142 
143  // Updated image coordinates
144  // Changed to + instead of -. See comment in SetFocalPlane above
145  xt = ux + xdistortion;
146  yt = uy + ydistortion;
147 
148  // Distorted point corrected for principal point
149  xdistorted = xt; // No PP for LORRI
150  ydistorted = yt; // No PP for LORRI
151 
152  // Check for convergence
153  if ((fabs(xt - xprevious) <= tolerance) && (fabs(yt - yprevious) <= tolerance)) {
154  bConverged = true;
155  break;
156  }
157 
158  xprevious = xt;
159  yprevious = yt;
160  }
161 
162  if (bConverged) {
163  p_focalPlaneX = xdistorted;
164  p_focalPlaneY = ydistorted;
165  }
166 
167  return bConverged;
168 
169  }
170 }
double p_focalPlaneX
Distorted focal plane x.
Namespace for the standard library.
bool SetUndistortedFocalPlane(const double dx, const double dy)
Compute distorted focal plane x/y.
double p_undistortedFocalPlaneX
Undistorted focal plane x.
Distort/undistort focal plane coordinates.
double p_focalPlaneY
Distorted focal plane y.
double p_undistortedFocalPlaneY
Undistorted focal plane y.
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
bool SetFocalPlane(const double ux, const double uy)
Compute undistorted focal plane x/y.