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
14namespace 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}
virtual double LineRate() const
Return the line collection rate (0 for framing cameras)
Distort/undistort focal plane coordinates.
double FocalPlaneX() const
Gets the x-value in the focal plane coordinate system.
Convert between distorted focal plane and detector coordinates.
CameraDetectorMap * DetectorMap()
Returns a pointer to the CameraDetectorMap object.
Definition Camera.cpp:2876
double FocalLength() const
Returns the focal length.
Definition Camera.cpp:2762
CameraDistortionMap * DistortionMap()
Returns a pointer to the CameraDistortionMap object.
Definition Camera.cpp:2856
CameraFocalPlaneMap * FocalPlaneMap()
Returns a pointer to the CameraFocalPlaneMap object.
Definition Camera.cpp:2866
Camera * p_camera
The main camera to calculate distortions on.
double p_focalPlaneY
Undistorted y value for the focal plane.
double p_focalPlaneX
Undistorted x value for the focal plane.
Convert between parent image coordinates and detector coordinates.
virtual bool SetSky(const double ra, const double dec)
Compute undistorted focal plane coordinate from ra/dec.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16