Isis 3 Programmer Reference
Hyb2OncDistortionMap.cpp
Go to the documentation of this file.
1 
24 #include <QDebug>
25 #include <QtGlobal>
26 #include <QtMath>
27 
28 #include "Hyb2OncDistortionMap.h"
29 
30 namespace Isis {
46  : CameraDistortionMap(parent, zDirection) {
47  }
48 
49 
54  }
55 
56 
74  bool Hyb2OncDistortionMap::SetFocalPlane(double dx, double dy) {
75  p_focalPlaneX = dx;
76  p_focalPlaneY = dy;
77 
78  // reducing to principal point offset (xp,yp)
79  double x = dx;// - p_xp;
80  double y = dy;// - p_yp;
81  //
82  // Get the distance from the focal plane center and if we are close
83  // then skip the distortion (this prevents division by zero)
84  double r = (x * x) + (y * y);
85  double r2 = r*r;
86  double r4 = r2*r2;
87  if (r <= 1.0E-6) {
90  return true;
91  }
92 
93  // apply distortion correction
94  // r = x^2 + y^2
95  // rprime = L0*r + L1*r^3 + L2*r^5, where Li are distortion coeffs
96  // "dr" is rprime divided by r, used to reduce operations
97  double dr = p_odk[0] + p_odk[1] * r2 + p_odk[2] * r4;
98  p_undistortedFocalPlaneX = dr * x;
99  p_undistortedFocalPlaneY = dr * y;
100  return true;
101  }
102 
103 
124  const double uy) {
127 
128  // Compute the distance from the focal plane center and if we are
129  // close to the center then no distortion is required
130 
131  bool converged = false;
132  int iteration = 0;
133  double tolMilliMeters = p_camera->PixelPitch() / 100.0;
134  double x = ux;
135  double y = uy;
136  double r = (x * x) + (y * y);
137  if (r <= 1.0E-6) {
138  p_focalPlaneX = ux;
139  p_focalPlaneY = uy;
140  return true;
141  }
142  double rPrevious = r;
143 
144  while (!converged && qAbs(r - rPrevious) > tolMilliMeters) {
145  double r2 = r*r;
146  double r4 = r2*r2;
147  double dr = p_odk[0] + p_odk[1] * r2 + p_odk[2] * r4;
148  rPrevious = r;
149  x = dr * x;
150  y = dr * y;
151  r = x*x + y*y;
152 
153  iteration++;
154  if (iteration > 50) {
155  converged = false;
156  break;
157  }
158  }
159 
160  converged = true;
161  p_focalPlaneX = x;
162  p_focalPlaneY = y;
163 
164  return converged;
165  }
166 
167 }
168 
double p_focalPlaneX
Distorted focal plane x.
virtual bool SetUndistortedFocalPlane(double ux, double uy)
Compute distorted focal plane x/y.
virtual ~Hyb2OncDistortionMap()
Destructor.
double p_undistortedFocalPlaneX
Undistorted focal plane x.
Camera * p_camera
The camera to distort/undistort.
virtual bool SetFocalPlane(double dx, double dy)
Compute undistorted focal plane x/y.
Hyb2OncDistortionMap(Camera *parent, double zDirection=1.0)
Hayabusa 2 ONC Camera distortion map constructor.
Distort/undistort focal plane coordinates.
double PixelPitch() const
Returns the pixel pitch.
Definition: Camera.cpp:2754
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.
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
std::vector< double > p_odk
Vector of distortion coefficients.