File failed to load: https://isis.astrogeology.usgs.gov/6.0.0/Object/assets/jax/output/NativeMML/config.js
Isis 3 Programmer Reference
PushFrameCameraGroundMap.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 #include "PushFrameCameraGroundMap.h"
8 
9 #include <QDebug>
10 
11 #include "CameraDistortionMap.h"
12 #include "CameraFocalPlaneMap.h"
13 #include "Distance.h"
14 #include "Latitude.h"
15 #include "Longitude.h"
16 #include "PushFrameCameraDetectorMap.h"
17 #include "SurfacePoint.h"
18 
19 namespace Isis {
29  const Longitude &lon) {
31 
32  SurfacePoint surfacePoint(lat, lon, p_camera->LocalRadius(lat, lon));
33 
34  // Get ending bounding framelets and distances for iterative loop to minimize the spacecraft distance
35  int startFramelet = 1;
36  double startDist = FindSpacecraftDistance(1, surfacePoint);
37 
38  int endFramelet = detectorMap->TotalFramelets();
39  double endDist = FindSpacecraftDistance(endFramelet, surfacePoint);
40 
41  bool minimizedSpacecraftDist = false;
42 
43  for (int j = 0; j < 30 && !minimizedSpacecraftDist;j++) {
44  int deltaX = abs(startFramelet - endFramelet) / 2;
45 
46  // start + deltaX = middle framelet.
47  // We're able to optimize this modified binary search
48  // because the 'V' shape -- it's mostly parallel. Meaning,
49  // if the left side is higher than the right, then the
50  // solution is closer to the right. The bias factor will
51  // determine how much closer, and then back off a little so
52  // we dont overshoot it.
53  double biasFactor = startDist / endDist;
54 
55  if (biasFactor < 1.0) {
56  biasFactor = -1.0 / biasFactor;
57  biasFactor = -(biasFactor + 1) / biasFactor;
58 
59  // The bias is about 50% unsure... sometimes our V is a U
60  biasFactor = std::min(biasFactor + 0.50, 0.0);
61  }
62  else {
63  biasFactor = (biasFactor - 1) / biasFactor;
64 
65  // The bias is about 50% unsure... sometimes our V is a U
66  biasFactor = std::max(biasFactor - 0.50, 0.0);
67  }
68 
69  int middleFramelet = startFramelet + (int)(deltaX + biasFactor * deltaX);
70  double middleDist = FindSpacecraftDistance(middleFramelet, surfacePoint);
71 
72  if (startDist > endDist) {
73  // This makes sure we don't get stuck halfway between framelets
74  if (startFramelet == middleFramelet) middleFramelet++;
75  startFramelet = middleFramelet;
76  startDist = middleDist;
77  }
78  else {
79  endFramelet = middleFramelet;
80  endDist = middleDist;
81  }
82 
83  if (startFramelet == endFramelet) {
84  minimizedSpacecraftDist = true;
85  }
86  }
87 
88  if (!minimizedSpacecraftDist) {
89  return false;
90  }
91 
92  int realFramelet = startFramelet;
93  bool frameletEven = (realFramelet % 2 == 0);
94  bool timeAscendingFramelets = detectorMap->timeAscendingFramelets();
95 
96  // Do we need to find a neighboring framelet? Get the closest (minimize distance)
97  if ((timeAscendingFramelets && frameletEven != p_evenFramelets) ||
98  (!timeAscendingFramelets && frameletEven == p_evenFramelets)) {
99  realFramelet++; // this direction doesnt really matter... it's simply a guess
100  }
101 
102  int direction = 2;
103 
104  double realDist = FindDistance(realFramelet, surfacePoint);
105  int guessFramelet = realFramelet + direction;
106  double guessDist = FindDistance(guessFramelet, surfacePoint);
107 
108  if (guessDist > realDist) {
109  direction = -1 * direction; // reverse the search direction
110  guessFramelet = realFramelet + direction;
111  guessDist = FindDistance(guessFramelet, surfacePoint);
112  }
113 
114  for (int j = 0; (realDist >= guessDist) && (j < 30);j++) {
115  realFramelet = guessFramelet;
116  realDist = guessDist;
117 
118  guessFramelet = realFramelet + direction;
119  guessDist = FindDistance(guessFramelet, surfacePoint);
120 
121  if (realFramelet <= 0 || realFramelet > detectorMap->TotalFramelets()) {
122  return false;
123  }
124  }
125 
126  detectorMap->SetFramelet(realFramelet);
127 
128  return CameraGroundMap::SetGround(surfacePoint);
129  }
130 
131 
133  return SetGround(surfacePt.GetLatitude(), surfacePt.GetLongitude());
134  }
135 
136 
148  const SurfacePoint &surfacePoint) {
151 
152  detectorMap->SetFramelet(framelet);
153  if(!p_camera->Sensor::SetGround(surfacePoint, false)) return DBL_MAX;
154 
155  double lookC[3];
156  p_camera->Sensor::LookDirection(lookC);
157  double ux = p_camera->FocalLength() * lookC[0] / lookC[2];
158  double uy = p_camera->FocalLength() * lookC[1] / lookC[2];
159 
160  if(!distortionMap->SetUndistortedFocalPlane(ux, uy)) return DBL_MAX;
161 
162  double dx = distortionMap->FocalPlaneX();
163  double dy = distortionMap->FocalPlaneY();
164 
166  if(!focalMap->SetFocalPlane(dx, dy)) return DBL_MAX;
167 
168  detectorMap->SetDetector(focalMap->DetectorSample(), focalMap->DetectorLine());
169 
170  double actualFrameletHeight = detectorMap->frameletHeight() / detectorMap->LineScaleFactor();
171  double frameletDeltaY = detectorMap->frameletLine() - (actualFrameletHeight / 2.0);
172 
173  return frameletDeltaY * frameletDeltaY;
174  }
175 
187  const SurfacePoint &surfacePoint) {
189 
190  detectorMap->SetFramelet(framelet);
191  if(!p_camera->Sensor::SetGround(surfacePoint, false)) return DBL_MAX;
192 
193  return p_camera->SlantDistance();
194  }
195 }
Isis::PushFrameCameraGroundMap::FindDistance
double FindDistance(int framelet, const SurfacePoint &surfacePoint)
This method finds the distance from the center of the framelet to the lat,lon.
Definition: PushFrameCameraGroundMap.cpp:147
Isis::Latitude
This class is designed to encapsulate the concept of a Latitude.
Definition: Latitude.h:51
Isis::PushFrameCameraDetectorMap::TotalFramelets
int TotalFramelets() const
Return the total number of framelets including padding.
Definition: PushFrameCameraDetectorMap.cpp:381
Isis::PushFrameCameraDetectorMap::SetFramelet
void SetFramelet(int framelet, const double deltaT=0)
This method changes the current framelet.
Definition: PushFrameCameraDetectorMap.cpp:182
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::SurfacePoint::GetLatitude
Latitude GetLatitude() const
Return the body-fixed latitude for the surface point.
Definition: SurfacePoint.cpp:1665
Isis::CameraFocalPlaneMap::DetectorSample
double DetectorSample() const
Definition: CameraFocalPlaneMap.cpp:255
Isis::PushFrameCameraGroundMap::SetGround
virtual bool SetGround(const Latitude &lat, const Longitude &lon)
Compute undistorted focal plane coordinate from ground position.
Definition: PushFrameCameraGroundMap.cpp:28
Isis::Longitude
This class is designed to encapsulate the concept of a Longitude.
Definition: Longitude.h:40
Isis::PushFrameCameraDetectorMap::frameletHeight
int frameletHeight() const
This returns how many lines are considered a single framelet.
Definition: PushFrameCameraDetectorMap.cpp:414
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::PushFrameCameraDetectorMap::SetDetector
virtual bool SetDetector(const double sample, const double line)
Compute parent position from a detector coordinate.
Definition: PushFrameCameraDetectorMap.cpp:59
Isis::PushFrameCameraDetectorMap::frameletLine
double frameletLine() const
This returns the calculated framelet line.
Definition: PushFrameCameraDetectorMap.cpp:403
Isis::CameraGroundMap::p_camera
Camera * p_camera
Camera.
Definition: CameraGroundMap.h:131
Isis::CameraDistortionMap
Distort/undistort focal plane coordinates.
Definition: CameraDistortionMap.h:41
Isis::CameraDetectorMap::LineScaleFactor
virtual double LineScaleFactor() const
Return scaling factor for computing line resolution.
Definition: CameraDetectorMap.cpp:183
Isis::SurfacePoint::GetLongitude
Longitude GetLongitude() const
Return the body-fixed longitude for the surface point.
Definition: SurfacePoint.cpp:1685
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::PushFrameCameraGroundMap::FindSpacecraftDistance
double FindSpacecraftDistance(int framelet, const SurfacePoint &surfacePoint)
This method finds the distance from the point on the ground to the spacecraft at the time the specifi...
Definition: PushFrameCameraGroundMap.cpp:186
Isis::PushFrameCameraDetectorMap
Convert between parent image coordinates and detector coordinates.
Definition: PushFrameCameraDetectorMap.h:45
Isis::SurfacePoint
This class defines a body-fixed surface point.
Definition: SurfacePoint.h:132
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::Sensor::SlantDistance
virtual double SlantDistance() const
Return the distance between the spacecraft and surface point in kmv.
Definition: Sensor.cpp:637
Isis::Sensor::LocalRadius
Distance LocalRadius() const
Returns the local radius at the intersection point.
Definition: Sensor.cpp:267
Isis::PushFrameCameraGroundMap::p_evenFramelets
bool p_evenFramelets
True if the file contains even framelets.
Definition: PushFrameCameraGroundMap.h:58
Isis::CameraGroundMap::SetGround
virtual bool SetGround(const Latitude &lat, const Longitude &lon)
Compute undistorted focal plane coordinate from ground position.
Definition: CameraGroundMap.cpp:76
Isis::PushFrameCameraDetectorMap::timeAscendingFramelets
bool timeAscendingFramelets()
Returns if the framelets are reversed from top-to-bottom.
Definition: PushFrameCameraDetectorMap.cpp:425

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the USGS Astrogeology Discussion Board
To report a bug, or suggest a feature go to: ISIS Github
File Modified: 07/13/2023 15:17:06