Isis 3 Programmer Reference
LineScanCameraSkyMap.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 
8 #include "LineScanCameraSkyMap.h"
9 #include "CameraFocalPlaneMap.h"
10 #include "CameraDistortionMap.h"
11 #include "iTime.h"
12 #include "LineScanCameraDetectorMap.h"
13 
14 namespace Isis {
27  bool LineScanCameraSkyMap::SetSky(const double ra, const double dec) {
28  // Get beginning bounding time and offset for iterative loop
29  p_camera->Sensor::setTime(p_camera->Spice::cacheStartTime());
30  p_camera->Sensor::SetRightAscensionDeclination(ra, dec);
31 
32  double lookC[3];
33  p_camera->Sensor::LookDirection(lookC);
34  double ux = p_camera->FocalLength() * lookC[0] / lookC[2];
35  double uy = p_camera->FocalLength() * lookC[1] / lookC[2];
36 
37  CameraDistortionMap *distortionMap = p_camera->DistortionMap();
38  if(!distortionMap->SetUndistortedFocalPlane(ux, uy)) return false;
39  double dx = distortionMap->FocalPlaneX();
40  double dy = distortionMap->FocalPlaneY();
41 
43  if(!focalMap->SetFocalPlane(dx, dy)) return false;
44  double startOffset = focalMap->DetectorLineOffset() -
45  focalMap->DetectorLine();
46 
47  // Get ending bounding time and offset for iterative loop
48  p_camera->Sensor::setTime(p_camera->Spice::cacheEndTime());
49  p_camera->Sensor::SetRightAscensionDeclination(ra, dec);
50 
51  p_camera->Sensor::LookDirection(lookC);
52  ux = p_camera->FocalLength() * lookC[0] / lookC[2];
53  uy = p_camera->FocalLength() * lookC[1] / lookC[2];
54 
55  if(!distortionMap->SetUndistortedFocalPlane(ux, uy)) return false;
56  dx = distortionMap->FocalPlaneX();
57  dy = distortionMap->FocalPlaneY();
58 
59  if(!focalMap->SetFocalPlane(dx, dy)) return false;
60  double endOffset = focalMap->DetectorLineOffset() -
61  focalMap->DetectorLine();
62 
63  // Make sure we are in the image
64  if((startOffset < 0.0) && (endOffset < 0.0)) return false;
65  if((startOffset > 0.0) && (endOffset > 0.0)) return false;
66 
67  // Get everything ordered for iteration
68  double fl, fh, xl, xh;
69  if(startOffset < endOffset) {
70  fl = startOffset;
71  fh = endOffset;
72  xl = p_camera->Spice::cacheStartTime().Et();
73  xh = p_camera->Spice::cacheEndTime().Et();
74  }
75  else {
76  fl = endOffset;
77  fh = startOffset;
78  xl = p_camera->Spice::cacheEndTime().Et();
79  xh = p_camera->Spice::cacheStartTime().Et();
80  }
81 
82  // Iterate to find the time at which the instrument imaged the ground point
83  LineScanCameraDetectorMap *detectorMap =
85  double timeTol = detectorMap->LineRate() / 10.0;
86  for(int j = 0; j < 30; j++) {
87  double etGuess = xl + (xh - xl) * fl / (fl - fh);
88  p_camera->Sensor::setTime(etGuess);
89  p_camera->Sensor::SetRightAscensionDeclination(ra, dec);
90  p_camera->Sensor::LookDirection(lookC);
91  ux = p_camera->FocalLength() * lookC[0] / lookC[2];
92  uy = p_camera->FocalLength() * lookC[1] / lookC[2];
93 
94  if(!distortionMap->SetUndistortedFocalPlane(ux, uy)) return false;
95  dx = distortionMap->FocalPlaneX();
96  dy = distortionMap->FocalPlaneY();
97 
98  if(!focalMap->SetFocalPlane(dx, dy)) return false;
99  double f = focalMap->DetectorLineOffset() -
100  focalMap->DetectorLine();
101 
102  double delTime;
103  if(f < 0.0) {
104  delTime = xl - etGuess;
105  xl = etGuess;
106  fl = f;
107  }
108  else {
109  delTime = xh - etGuess;
110  xh = etGuess;
111  fh = f;
112  }
113 
114  // See if we converged on the point so set up the undistorted
115  // focal plane values and return
116  if(fabs(delTime) < timeTol || f == 0.0) {
117  p_focalPlaneX = ux;
118  p_focalPlaneY = uy;
119  return true;
120  }
121  }
122  return false;
123  }
124 }
Isis::CameraSkyMap::p_focalPlaneX
double p_focalPlaneX
Undistorted x value for the focal plane.
Definition: CameraSkyMap.h:59
Isis::CameraSkyMap::p_camera
Camera * p_camera
The main camera to calculate distortions on.
Definition: CameraSkyMap.h:55
Isis::CameraDistortionMap::SetUndistortedFocalPlane
virtual bool SetUndistortedFocalPlane(double ux, double uy)
Compute distorted focal plane x/y.
Definition: CameraDistortionMap.cpp:130
Isis::CameraDistortionMap::FocalPlaneX
double FocalPlaneX() const
Gets the x-value in the focal plane coordinate system.
Definition: CameraDistortionMap.cpp:215
Isis::CameraFocalPlaneMap::DetectorLine
double DetectorLine() const
Definition: CameraFocalPlaneMap.cpp:263
Isis::CameraDistortionMap::FocalPlaneY
double FocalPlaneY() const
Gets the y-value in the focal plane coordinate system.
Definition: CameraDistortionMap.cpp:226
Isis::Camera::DistortionMap
CameraDistortionMap * DistortionMap()
Returns a pointer to the CameraDistortionMap object.
Definition: Camera.cpp:2826
Isis::LineScanCameraDetectorMap::LineRate
double LineRate() const
Access the time, in seconds, between scan lines.
Definition: LineScanCameraDetectorMap.cpp:70
Isis::CameraSkyMap::p_focalPlaneY
double p_focalPlaneY
Undistorted y value for the focal plane.
Definition: CameraSkyMap.h:60
Isis::CameraFocalPlaneMap::DetectorLineOffset
double DetectorLineOffset() const
Definition: CameraFocalPlaneMap.cpp:334
Isis::CameraFocalPlaneMap::SetFocalPlane
virtual bool SetFocalPlane(const double dx, const double dy)
Compute detector position (sample,line) from focal plane coordinates.
Definition: CameraFocalPlaneMap.cpp:143
Isis::CameraDistortionMap
Distort/undistort focal plane coordinates.
Definition: CameraDistortionMap.h:41
Isis::Camera::FocalPlaneMap
CameraFocalPlaneMap * FocalPlaneMap()
Returns a pointer to the CameraFocalPlaneMap object.
Definition: Camera.cpp:2836
Isis::Camera::FocalLength
double FocalLength() const
Returns the focal length.
Definition: Camera.cpp:2732
Isis::CameraFocalPlaneMap
Convert between distorted focal plane and detector coordinates.
Definition: CameraFocalPlaneMap.h:85
Isis::Camera::DetectorMap
CameraDetectorMap * DetectorMap()
Returns a pointer to the CameraDetectorMap object.
Definition: Camera.cpp:2846
Isis::LineScanCameraSkyMap::SetSky
virtual bool SetSky(const double ra, const double dec)
Compute undistorted focal plane coordinate from ra/dec.
Definition: LineScanCameraSkyMap.cpp:27
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::LineScanCameraDetectorMap
Convert between parent image coordinates and detector coordinates.
Definition: LineScanCameraDetectorMap.h:37