Isis 3 Programmer Reference
Hyb2OncDistortionMap.cpp
1 
7 /* SPDX-License-Identifier: CC0-1.0 */
8 
9 #include <QDebug>
10 #include <QtGlobal>
11 #include <QtMath>
12 
13 #include "Hyb2OncDistortionMap.h"
14 
15 namespace Isis {
31  : CameraDistortionMap(parent, zDirection) {
32  }
33 
34 
39  }
40 
41 
59  bool Hyb2OncDistortionMap::SetFocalPlane(double dx, double dy) {
60  p_focalPlaneX = dx;
61  p_focalPlaneY = dy;
62 
63  // reducing to principal point offset (xp,yp)
64  double x = dx;// - p_xp;
65  double y = dy;// - p_yp;
66  //
67  // Get the distance from the focal plane center and if we are close
68  // then skip the distortion (this prevents division by zero)
69  double r = (x * x) + (y * y);
70  double r2 = r*r;
71  double r4 = r2*r2;
72  if (r <= 1.0E-6) {
75  return true;
76  }
77 
78  // apply distortion correction
79  // r = x^2 + y^2
80  // rprime = L0*r + L1*r^3 + L2*r^5, where Li are distortion coeffs
81  // "dr" is rprime divided by r, used to reduce operations
82  double dr = p_odk[0] + p_odk[1] * r2 + p_odk[2] * r4;
83  p_undistortedFocalPlaneX = dr * x;
84  p_undistortedFocalPlaneY = dr * y;
85  return true;
86  }
87 
88 
109  const double uy) {
112 
113  // Compute the distance from the focal plane center and if we are
114  // close to the center then no distortion is required
115 
116  bool converged = false;
117  int iteration = 0;
118  double tolMilliMeters = p_camera->PixelPitch() / 100.0;
119  double x = ux;
120  double y = uy;
121  double r = (x * x) + (y * y);
122  if (r <= 1.0E-6) {
123  p_focalPlaneX = ux;
124  p_focalPlaneY = uy;
125  return true;
126  }
127  double rPrevious = r;
128 
129  while (!converged && qAbs(r - rPrevious) > tolMilliMeters) {
130  double r2 = r*r;
131  double r4 = r2*r2;
132  double dr = p_odk[0] + p_odk[1] * r2 + p_odk[2] * r4;
133  rPrevious = r;
134  x = dr * x;
135  y = dr * y;
136  r = x*x + y*y;
137 
138  iteration++;
139  if (iteration > 50) {
140  converged = false;
141  break;
142  }
143  }
144 
145  converged = true;
146  p_focalPlaneX = x;
147  p_focalPlaneY = y;
148 
149  return converged;
150  }
151 
152 }
Isis::Hyb2OncDistortionMap::~Hyb2OncDistortionMap
virtual ~Hyb2OncDistortionMap()
Destructor.
Definition: Hyb2OncDistortionMap.cpp:38
Isis::CameraDistortionMap::p_focalPlaneX
double p_focalPlaneX
Distorted focal plane x.
Definition: CameraDistortionMap.h:65
Isis::Hyb2OncDistortionMap::Hyb2OncDistortionMap
Hyb2OncDistortionMap(Camera *parent, double zDirection=1.0)
Hayabusa 2 ONC Camera distortion map constructor.
Definition: Hyb2OncDistortionMap.cpp:30
Isis::CameraDistortionMap::p_undistortedFocalPlaneY
double p_undistortedFocalPlaneY
Undistorted focal plane y.
Definition: CameraDistortionMap.h:68
Isis::CameraDistortionMap::p_undistortedFocalPlaneX
double p_undistortedFocalPlaneX
Undistorted focal plane x.
Definition: CameraDistortionMap.h:67
Isis::Camera
Definition: Camera.h:236
Isis::Hyb2OncDistortionMap::SetFocalPlane
virtual bool SetFocalPlane(double dx, double dy)
Compute undistorted focal plane x/y.
Definition: Hyb2OncDistortionMap.cpp:59
Isis::CameraDistortionMap::p_camera
Camera * p_camera
The camera to distort/undistort.
Definition: CameraDistortionMap.h:63
Isis::CameraDistortionMap
Distort/undistort focal plane coordinates.
Definition: CameraDistortionMap.h:41
Isis::Hyb2OncDistortionMap::SetUndistortedFocalPlane
virtual bool SetUndistortedFocalPlane(double ux, double uy)
Compute distorted focal plane x/y.
Definition: Hyb2OncDistortionMap.cpp:108
Isis::Camera::PixelPitch
double PixelPitch() const
Returns the pixel pitch.
Definition: Camera.cpp:2742
Isis::E
const double E
Sets some basic constants for use in ISIS programming.
Definition: Constants.h:39
Isis::CameraDistortionMap::p_odk
std::vector< double > p_odk
Vector of distortion coefficients.
Definition: CameraDistortionMap.h:71
Isis::CameraDistortionMap::p_focalPlaneY
double p_focalPlaneY
Distorted focal plane y.
Definition: CameraDistortionMap.h:66
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16