Isis 3 Programmer Reference
MocWideAngleDistortionMap.cpp
1
7/* SPDX-License-Identifier: CC0-1.0 */
8
9#include "MocWideAngleDistortionMap.h"
10
11using namespace std;
12namespace Isis {
30 CameraDistortionMap(parent, 1.0) {
31 // Set up distortion coefficients
32 if(red) {
33 p_coefs.push_back(0.9993258);
34 p_coefs.push_back(0.4655529);
35 p_coefs.push_back(-0.1548756);
36 p_coefs.push_back(1.827967);
37 p_coefs.push_back(-3.057435);
38 p_coefs.push_back(2.226331);
39 p_scale = 1.0;
40 p_icoefs.push_back(0.9995458);
41 p_icoefs.push_back(-0.4237090);
42 p_icoefs.push_back(0.2810857);
43 p_icoefs.push_back(-0.1697522);
44 p_icoefs.push_back(0.068131536);
45 p_icoefs.push_back(-0.012665644);
46 }
47 else {
48 p_coefs.push_back(1.000246);
49 p_coefs.push_back(0.4612695);
50 p_coefs.push_back(0.2352545);
51 p_coefs.push_back(0.3535922);
52 p_coefs.push_back(-0.2853861);
53 p_coefs.push_back(0.5574971);
54 p_scale = 1.000452;
55 p_icoefs.push_back(0.9994557);
56 p_icoefs.push_back(-0.4515307);
57 p_icoefs.push_back(0.3152195);
58 p_icoefs.push_back(-0.1993053);
59 p_icoefs.push_back(0.081707217);
60 p_icoefs.push_back(-0.014814299);
61 }
62 p_numCoefs = 6;
63 }
64
65
67 const double dy) {
68 // Apply scale factor
69 p_focalPlaneX = dx;
70 p_focalPlaneY = dy;
71 double sdy = dy / p_scale;
72
73 // See if we are close to the boresight which implies no distortion
74 double s2 = dx * dx + sdy * sdy;
75 if(s2 <= 1.0E-6) {
78 return true;
79 }
80
81 // Remove distortion
82 double s = sqrt(s2);
83 double ang = atan(s / p_camera->FocalLength());
84 double ang2 = ang * ang;
85 double angp = p_coefs[p_numCoefs-1];
86 for(int i = p_numCoefs - 2; i >= 0; i--) {
87 angp = angp * ang2 + p_coefs[i];
88 }
89 angp = angp * ang;
90 double sp = p_camera->FocalLength() * tan(angp);
91 p_undistortedFocalPlaneX = dx * sp / s;
92 p_undistortedFocalPlaneY = sdy * sp / s;
93 return true;
94 }
95
97 const double uy) {
100
101 // See if we are close to boresight
102 double sp2 = ux * ux + uy * uy;
103 if(sp2 <= 1.0E-6) {
104 p_focalPlaneX = ux;
105 p_focalPlaneY = uy * p_scale;
106 return true;
107 }
108
109 // Add distortion
110 double sp = sqrt(sp2);
111 double angp = atan(sp / p_camera->FocalLength());
112 double angp2 = angp * angp;
113 double ang = p_icoefs[p_numCoefs-1];
114 for(int i = p_numCoefs - 2; i >= 0; i--) {
115 ang = ang * angp2 + p_icoefs[i];
116 }
117 ang = ang * angp;
118 double s = p_camera->FocalLength() * tan(ang);
119 p_focalPlaneX = ux * s / sp;
120 p_focalPlaneY = uy * s / sp * p_scale;
121 return true;
122 }
123}
Distort/undistort focal plane coordinates.
double p_focalPlaneX
Distorted focal plane x.
double p_undistortedFocalPlaneX
Undistorted focal plane x.
double p_undistortedFocalPlaneY
Undistorted focal plane y.
Camera * p_camera
The camera to distort/undistort.
double p_focalPlaneY
Distorted focal plane y.
double FocalLength() const
Returns the focal length.
Definition Camera.cpp:2762
virtual bool SetUndistortedFocalPlane(const double ux, const double uy)
Compute distorted focal plane x/y.
virtual bool SetFocalPlane(const double dx, const double dy)
Compute undistorted focal plane x/y.
MocWideAngleDistortionMap(Camera *parent, bool red)
Constructor for MocWideAngleDistortionMap class.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
Namespace for the standard library.