Isis 3 Programmer Reference
LoHighDistortionMap.cpp
1
7/* SPDX-License-Identifier: CC0-1.0 */
8
9#include "LoHighDistortionMap.h"
10#include "IString.h"
11
12using namespace std;
13
14namespace Isis {
30
31
84 void LoHighDistortionMap::SetDistortion(const int naifIkCode) {
85 // Get the perspective correction factors for x and y and the distortion
86 // center (point of symmetry of distortion)
87 QString perskey = "INS" + toString(naifIkCode) + "_PERSPECTIVE_FACTORS";
88 QString centkey = "INS" + toString(naifIkCode) + "_POINT_OF_SYMMETRY";
89 p_xPerspective = p_camera->Spice::getDouble(perskey, 0);
90 p_yPerspective = p_camera->Spice::getDouble(perskey, 1);
91 p_x0 = p_camera->Spice::getDouble(centkey, 0);
92 p_y0 = p_camera->Spice::getDouble(centkey, 1);
93
94 // Get the distortion coefficients
96 }
97
98
114 const double dy) {
115 p_focalPlaneX = dx;
116 p_focalPlaneY = dy;
117
118 // Apply perspective correction factors to get perspective corrected x/y
119 double perspectiveFactor = 1. + (p_xPerspective * dx) + (p_yPerspective * dy);
120 double pcx = dx * perspectiveFactor;
121 double pcy = dy * perspectiveFactor;
122
123 // Translate the perspective-corrected x/y coordinate to be relative to the
124 // distortion point of symmetry
125 double distx = pcx - p_x0;
126 double disty = pcy - p_y0;
127
128 // Get the distance from the focal plane center and if we are close
129 // skip the distortion
130 double r2 = distx * distx + disty * disty;
131 if(r2 <= 1.0E-6) {
134 return true;
135 }
136
137 // Otherwise remove distortion
138 double drOverR = p_odk[0] + p_odk[1] * r2;
139 p_undistortedFocalPlaneX = pcx - (drOverR * distx);
140 p_undistortedFocalPlaneY = pcy - (drOverR * disty);
141 return true;
142 }
143
144
164 const double uy) {
165
168
169 // Translate the distorted x/y coordinate to be relative to the
170 // distortion point of symmetry
171 double distux = p_undistortedFocalPlaneX - p_x0;
172 double distuy = p_undistortedFocalPlaneY - p_y0;
173
174 // Compute the distance from the focal plane center and if we are
175 // close to the center then no distortion is required
176 double rp2 = distux * distux + distuy * distuy;
177
178 double pcx, pcy;
179
180 if(rp2 > 1.0E-6) {
181
182 // Add distortion. First compute fractional distortion at rp (r-prime)
183 double drOverR = p_odk[0] + rp2 * p_odk[1];
184
185 // Compute the perspective corrected x/y
186 pcx = p_undistortedFocalPlaneX + (distux * drOverR);
187 pcy = p_undistortedFocalPlaneY + (distuy * drOverR);
188 }
189 else {
192 }
193
194 // Add the perspective error
195 double perspectiveCorrection = 1. - (p_xPerspective * pcx) - (p_yPerspective * pcy);
196 p_focalPlaneX = pcx * perspectiveCorrection;
197 p_focalPlaneY = pcy * perspectiveCorrection;
198 return true;
199 }
200}
Distort/undistort focal plane coordinates.
double p_focalPlaneX
Distorted focal plane x.
double p_undistortedFocalPlaneX
Undistorted focal plane x.
std::vector< double > p_odk
Vector of distortion coefficients.
virtual void SetDistortion(int naifIkCode)
Load distortion coefficients.
double p_undistortedFocalPlaneY
Undistorted focal plane y.
Camera * p_camera
The camera to distort/undistort.
double p_focalPlaneY
Distorted focal plane y.
void SetDistortion(const int naifIkCode)
Load LO High Resolution Camera perspective & distortion coefficients.
double p_yPerspective
Perspective correction factor in y.
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.
double p_y0
Center of distortion on y axis.
LoHighDistortionMap(Camera *parent)
Constructor for LunarOrbiterHighDistortionMap class.
virtual bool SetUndistortedFocalPlane(const double ux, const double uy)
Compute distorted focal plane x/y for Lo High Resolution Camera.
double p_x0
Center of distortion on x axis.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition IString.cpp:211
Namespace for the standard library.