12#include "MarciDistortionMap.h"
28 QString odkkey =
"INS" +
toString(naifIkCode) +
"_DISTORTION_COEFFS";
30 for(
int i = 0; i < 4; i++) {
55 double radialDist2 = (dxPix * dxPix) + (dyPix * dyPix);
57 if(radialDist2 <= 1.0E-3) {
64 double radialDist4 = radialDist2 * radialDist2;
65 double radialDist6 = radialDist4 * radialDist2;
67 double uRadialDist =
p_odk[0] + radialDist2 *
p_odk[1] +
68 radialDist4 *
p_odk[2] +
69 radialDist6 *
p_odk[3];
72 double uxPix = dxPix * uRadialDist;
73 double uyPix = dyPix * uRadialDist;
102 double dxPix = GuessDx(uxPix);
103 double dyPix = uyPix;
107 double Ru = sqrt((uxPix * uxPix) + (uyPix * uyPix));
118 double Rd = sqrt((dxPix * dxPix) + (dyPix * dyPix));
120 while(fabs(delta) > 1
E-9) {
121 if(fabs(delta) > 1E30 || iter > 50) {
125 double Rd2 = Rd * Rd;
126 double Rd3 = Rd2 * Rd;
127 double Rd4 = Rd3 * Rd;
128 double Rd5 = Rd4 * Rd;
129 double Rd6 = Rd5 * Rd;
133 Rd6 *
p_odk[3] - Ru * (1.0 / Rd);
135 double fRd2 = 2 *
p_odk[1] * Rd +
147 dxPix = uxPix * (Rd / Ru);
148 dyPix = uyPix * (Rd / Ru);
156 double MarciDistortionMap::GuessDx(
double uX) {
158 if(fabs(uX) < 1)
return uX;
161 return (1.4101 * log(fabs(uX)));
164 else if(p_filter == 1) {
165 return (1.1039 * log(fabs(uX)));
168 else if(p_filter == 2) {
169 return (0.8963 * log(fabs(uX)) + 2.1644);
172 else if(p_filter == 3) {
173 return (1.1039 * log(fabs(uX)));
176 else if(p_filter == 4) {
177 return (1.4101 * log(fabs(uX)));
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.
double p_undistortedFocalPlaneY
Undistorted focal plane y.
Camera * p_camera
The camera to distort/undistort.
double p_focalPlaneY
Distorted focal plane y.
double PixelPitch() const
Returns the pixel pitch.
virtual bool SetFocalPlane(const double dx, const double dy)
Compute undistorted focal plane x/y.
MarciDistortionMap(Camera *parent, int naifIkCode)
Camera distortion map constructor.
virtual bool SetUndistortedFocalPlane(const double ux, const double uy)
Compute distorted focal plane x/y.
SpiceDouble getDouble(const QString &key, int index=0)
This returns a value from the NAIF text pool.
const double E
Sets some basic constants for use in ISIS programming.
This is free and unencumbered software released into the public domain.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.