Isis 3 Programmer Reference
LineScanCameraSkyMap.cpp
Go to the documentation of this file.
1 
24 #include "LineScanCameraSkyMap.h"
25 #include "CameraFocalPlaneMap.h"
26 #include "CameraDistortionMap.h"
27 #include "iTime.h"
29 
30 namespace Isis {
43  bool LineScanCameraSkyMap::SetSky(const double ra, const double dec) {
44  // Get beginning bounding time and offset for iterative loop
45  p_camera->Sensor::setTime(p_camera->Spice::cacheStartTime());
46  p_camera->Sensor::SetRightAscensionDeclination(ra, dec);
47 
48  double lookC[3];
49  p_camera->Sensor::LookDirection(lookC);
50  double ux = p_camera->FocalLength() * lookC[0] / lookC[2];
51  double uy = p_camera->FocalLength() * lookC[1] / lookC[2];
52 
53  CameraDistortionMap *distortionMap = p_camera->DistortionMap();
54  if(!distortionMap->SetUndistortedFocalPlane(ux, uy)) return false;
55  double dx = distortionMap->FocalPlaneX();
56  double dy = distortionMap->FocalPlaneY();
57 
59  if(!focalMap->SetFocalPlane(dx, dy)) return false;
60  double startOffset = focalMap->DetectorLineOffset() -
61  focalMap->DetectorLine();
62 
63  // Get ending bounding time and offset for iterative loop
64  p_camera->Sensor::setTime(p_camera->Spice::cacheEndTime());
65  p_camera->Sensor::SetRightAscensionDeclination(ra, dec);
66 
67  p_camera->Sensor::LookDirection(lookC);
68  ux = p_camera->FocalLength() * lookC[0] / lookC[2];
69  uy = p_camera->FocalLength() * lookC[1] / lookC[2];
70 
71  if(!distortionMap->SetUndistortedFocalPlane(ux, uy)) return false;
72  dx = distortionMap->FocalPlaneX();
73  dy = distortionMap->FocalPlaneY();
74 
75  if(!focalMap->SetFocalPlane(dx, dy)) return false;
76  double endOffset = focalMap->DetectorLineOffset() -
77  focalMap->DetectorLine();
78 
79  // Make sure we are in the image
80  if((startOffset < 0.0) && (endOffset < 0.0)) return false;
81  if((startOffset > 0.0) && (endOffset > 0.0)) return false;
82 
83  // Get everything ordered for iteration
84  double fl, fh, xl, xh;
85  if(startOffset < endOffset) {
86  fl = startOffset;
87  fh = endOffset;
88  xl = p_camera->Spice::cacheStartTime().Et();
89  xh = p_camera->Spice::cacheEndTime().Et();
90  }
91  else {
92  fl = endOffset;
93  fh = startOffset;
94  xl = p_camera->Spice::cacheEndTime().Et();
95  xh = p_camera->Spice::cacheStartTime().Et();
96  }
97 
98  // Iterate to find the time at which the instrument imaged the ground point
99  LineScanCameraDetectorMap *detectorMap =
101  double timeTol = detectorMap->LineRate() / 10.0;
102  for(int j = 0; j < 30; j++) {
103  double etGuess = xl + (xh - xl) * fl / (fl - fh);
104  p_camera->Sensor::setTime(etGuess);
105  p_camera->Sensor::SetRightAscensionDeclination(ra, dec);
106  p_camera->Sensor::LookDirection(lookC);
107  ux = p_camera->FocalLength() * lookC[0] / lookC[2];
108  uy = p_camera->FocalLength() * lookC[1] / lookC[2];
109 
110  if(!distortionMap->SetUndistortedFocalPlane(ux, uy)) return false;
111  dx = distortionMap->FocalPlaneX();
112  dy = distortionMap->FocalPlaneY();
113 
114  if(!focalMap->SetFocalPlane(dx, dy)) return false;
115  double f = focalMap->DetectorLineOffset() -
116  focalMap->DetectorLine();
117 
118  double delTime;
119  if(f < 0.0) {
120  delTime = xl - etGuess;
121  xl = etGuess;
122  fl = f;
123  }
124  else {
125  delTime = xh - etGuess;
126  xh = etGuess;
127  fh = f;
128  }
129 
130  // See if we converged on the point so set up the undistorted
131  // focal plane values and return
132  if(fabs(delTime) < timeTol || f == 0.0) {
133  p_focalPlaneX = ux;
134  p_focalPlaneY = uy;
135  return true;
136  }
137  }
138  return false;
139  }
140 }
CameraDetectorMap * DetectorMap()
Returns a pointer to the CameraDetectorMap object.
Definition: Camera.cpp:2858
double p_focalPlaneY
Undistorted y value for the focal plane.
Definition: CameraSkyMap.h:77
CameraDistortionMap * DistortionMap()
Returns a pointer to the CameraDistortionMap object.
Definition: Camera.cpp:2838
double LineRate() const
Access the time, in seconds, between scan lines.
virtual bool SetFocalPlane(const double dx, const double dy)
Compute detector position (sample,line) from focal plane coordinates.
double FocalPlaneY() const
Gets the y-value in the focal plane coordinate system.
Convert between distorted focal plane and detector coordinates.
virtual bool SetUndistortedFocalPlane(double ux, double uy)
Compute distorted focal plane x/y.
double FocalLength() const
Returns the focal length.
Definition: Camera.cpp:2744
Distort/undistort focal plane coordinates.
CameraFocalPlaneMap * FocalPlaneMap()
Returns a pointer to the CameraFocalPlaneMap object.
Definition: Camera.cpp:2848
virtual bool SetSky(const double ra, const double dec)
Compute undistorted focal plane coordinate from ra/dec.
double p_focalPlaneX
Undistorted x value for the focal plane.
Definition: CameraSkyMap.h:76
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
Camera * p_camera
The main camera to calculate distortions on.
Definition: CameraSkyMap.h:72
Convert between parent image coordinates and detector coordinates.
double FocalPlaneX() const
Gets the x-value in the focal plane coordinate system.