44  bool Chandrayaan1M3DistortionMap::SetFocalPlane(
const double dx, 
const double dy) {
 
   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);
 
   67    p_undistortedFocalPlaneX = dx + x * dr + dtx;
 
   68    p_undistortedFocalPlaneY = dy + y * dr + dty;
 
 
   86  bool Chandrayaan1M3DistortionMap::SetUndistortedFocalPlane(
const double ux, 
const double uy) {
 
   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)) {
 
  146      p_undistortedFocalPlaneX = ux;
 
  147      p_undistortedFocalPlaneY = uy;
 
  149      p_focalPlaneX = xdistorted;
 
  150      p_focalPlaneY = ydistorted;