11 #include "Chandrayaan1M3DistortionMap.h"
12 #include "CameraFocalPlaneMap.h"
17 Chandrayaan1M3DistortionMap::Chandrayaan1M3DistortionMap(Camera *parent,
19 double k1,
double k2,
double k3,
20 double p1,
double p2) :
21 CameraDistortionMap(parent, 1.0) {
54 double rr = x * x + y * y;
58 double dr = p_k1 + p_k2 * rr +
p_k3 * rr * rr;
62 double dtx = p_p1 * (rr + 2.0 * x * x) + 2.0 *
p_p2 * x * y;
63 double dty = 2.0 * p_p1 * x * y +
p_p2 * (rr + 2 * y * y);
91 double xx, yy, rr, dr;
92 double xdistortion, ydistortion;
93 double xdistorted, ydistorted;
94 double xprevious, yprevious;
99 xprevious = 1000000.0;
100 yprevious = 1000000.0;
102 double tolerance = 0.000001;
104 bool bConverged =
false;
109 for (
int i = 0; i < 50; i++) {
118 dr = p_k1 + p_k2 * rr +
p_k3 * rr * rr;
120 double dtx = p_p1 * (rr + 2.0 * xt * xt) + 2.0 *
p_p2 * xt * yt;
121 double dty = 2.0 * p_p1 * xt * yt +
p_p2 * (rr + 2 * yt * yt);
124 xdistortion = dr * xt + dtx;
125 ydistortion = dr * yt + dty;
128 xt = ux - xdistortion;
129 yt = uy - ydistortion;
132 xdistorted = xt + p_xp;
133 ydistorted = yt +
p_yp;
136 if ((fabs(xt - xprevious) <= tolerance) && (fabs(yt - yprevious) <= tolerance)) {