Isis 3 Programmer Reference
DawnFcDistortionMap.cpp
1 #include "DawnFcDistortionMap.h"
2 #include "CameraFocalPlaneMap.h"
3 
4 using namespace std;
5 
6 namespace Isis {
7  DawnFcDistortionMap::DawnFcDistortionMap(Camera *parent, double k1, double zDirection) : CameraDistortionMap(parent, zDirection) {
8  p_k1 = k1;
9  }
10 
11  bool DawnFcDistortionMap::SetUndistortedFocalPlane(const double ux, const double uy) {
12  double offsetSqrd;
13 
16 
17  offsetSqrd = ux * ux + uy * uy;
18 
19  p_focalPlaneX = ux * (1.0 + p_k1 * offsetSqrd);
20  p_focalPlaneY = uy * (1.0 + p_k1 * offsetSqrd);
21  return true;
22  }
23 
24  bool DawnFcDistortionMap::SetFocalPlane(const double dx, const double dy) {
25  double offsetSqrd;
26  int numAttempts;
27  double delta;
28  bool done;
29 
30  p_focalPlaneX = dx;
31  p_focalPlaneY = dy;
32 
33  /****************************************************************************
34  * Pre-loop intializations
35  ****************************************************************************/
36 
37  numAttempts = 1;
38  delta = 0.00001;
39 
40  offsetSqrd = dy * dy + dx * dx;
41  double guess_dx, guess_dy;
42  double guess_ux, guess_uy;
43 
44  /****************************************************************************
45  * Loop ...
46  ****************************************************************************/
47  do {
48  guess_ux = dx / (1.0 + p_k1 * offsetSqrd);
49  guess_uy = dy / (1.0 + p_k1 * offsetSqrd);
50 
51  offsetSqrd = guess_uy * guess_uy + guess_ux * guess_ux;
52 
53  guess_dx = guess_ux * (1.0 + p_k1 * offsetSqrd);
54  guess_dy = guess_uy * (1.0 + p_k1 * offsetSqrd);
55 
56  done = true;
57  if(abs(guess_dy - dy) > delta) {
58  done = false;
59  }
60 
61  if(abs(guess_dx - dx) > delta) {
62  done = false;
63  }
64 
65  /* Not converging so bomb */
66  numAttempts++;
67  if(numAttempts > 20) {
68  return false;
69  }
70  }
71  while(!done);
72 
73  /****************************************************************************
74  * Sucess ...
75  ****************************************************************************/
76 
77  p_undistortedFocalPlaneX = guess_ux;
78  p_undistortedFocalPlaneY = guess_uy;
79  return true;
80  }
81 }
double p_focalPlaneX
Distorted focal plane x.
bool SetFocalPlane(const double ux, const double uy)
Compute undistorted focal plane x/y.
Namespace for the standard library.
double p_undistortedFocalPlaneX
Undistorted focal plane x.
bool SetUndistortedFocalPlane(const double dx, const double dy)
Compute distorted focal plane x/y.
double p_focalPlaneY
Distorted focal plane y.
double p_undistortedFocalPlaneY
Undistorted focal plane y.
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31