Isis 3 Programmer Reference
IsisSensor.cpp
1
6/* SPDX-License-Identifier: CC0-1.0 */
7#include "IsisSensor.h"
8
9#include "Angle.h"
10#include "Camera.h"
11#include "Distance.h"
12#include "iTime.h"
13#include "Latitude.h"
14#include "Longitude.h"
15#include "SurfacePoint.h"
16
17using namespace std;
18
19namespace Isis {
24 m_cam = cam;
25 }
26
27
37 SensorUtilities::ObserverState IsisSensor::getState(const SensorUtilities::ImagePt &imagePoint) {
38
39 // These image coordinates are in ISIS pixels; (0.5, 0.5, 1) is the origin.
40 double oldLine = m_cam->Line();
41 double oldSample = m_cam->Sample();
42 int oldBand = m_cam->Band();
43 double newLine = imagePoint.line + 0.5;
44 double newSample = imagePoint.sample + 0.5;
45 int newBand = imagePoint.band + 1;
46
47 bool imagePtChanged = oldLine != newLine ||
48 oldSample != newSample ||
49 (!m_cam->IsBandIndependent() && oldBand != newBand);
50 if (imagePtChanged) {
51 m_cam->SetBand(newBand);
52 m_cam->SetImage(newSample, newLine);
53 }
54
55 vector<double> lookBF = m_cam->lookDirectionBodyFixed();
56 SensorUtilities::Vec lookVec = {lookBF[0], lookBF[1], lookBF[2]};
57
58 vector<double> lookJ2000 = m_cam->lookDirectionJ2000();
59 SensorUtilities::Vec lookVecJ2000 = {lookJ2000[0], lookJ2000[1], lookJ2000[2]};
60
61 vector<double> posBF(3);
62 m_cam->instrumentBodyFixedPosition(&posBF[0]);
63 // Conver to meters from ISIS's Km
64 SensorUtilities::Vec sensorPos = {1000 * posBF[0], 1000 * posBF[1], 1000 * posBF[2]};
65
66 double sensorTime = m_cam->time().Et();
67
68 SensorUtilities::ObserverState sensorState = {
69 lookVec,
70 lookVecJ2000,
71 sensorPos,
72 sensorTime,
73 imagePoint};
74
75 if (imagePtChanged) {
76 m_cam->SetBand(oldBand);
77 m_cam->SetImage(oldSample, oldLine);
78 }
79 return sensorState;
80 }
81
82
90 SensorUtilities::ObserverState IsisSensor::getState(const SensorUtilities::GroundPt3D &groundPt) {
91 SurfacePoint oldGroundPt = m_cam->GetSurfacePoint();
92 SurfacePoint newGroundPt = SurfacePoint(
93 Latitude(groundPt.lat, Angle::Radians),
94 Longitude(groundPt.lon, Angle::Radians),
95 Distance(groundPt.radius, Distance::Meters));
96 // For consistency with ISIS, reset with the image point
97 double oldLine = m_cam->Line();
98 double oldSample = m_cam->Sample();
99 double oldBand = m_cam->Band();
100
101 bool groundPtChanged = !(oldGroundPt == newGroundPt);
102
103 if (groundPtChanged) {
104 m_cam->SetGround(newGroundPt);
105 }
106
107 vector<double> lookBF = m_cam->lookDirectionBodyFixed();
108 SensorUtilities::Vec lookVec = {lookBF[0], lookBF[1], lookBF[2]};
109
110 vector<double> lookJ2000 = m_cam->lookDirectionJ2000();
111 SensorUtilities::Vec lookVecJ2000 = {lookJ2000[0], lookJ2000[1], lookJ2000[2]};
112
113 vector<double> posBF(3);
114 m_cam->instrumentBodyFixedPosition(&posBF[0]);
115 // Conver to meters from ISIS's Km
116 SensorUtilities::Vec sensorPos = {1000 * posBF[0], 1000 * posBF[1], 1000 * posBF[2]};
117
118 double sensorTime = m_cam->time().Et();
119
120 SensorUtilities::ImagePt imagePoint = {
121 m_cam->Line() - 0.5,
122 m_cam->Sample() - 0.5,
123 m_cam->Band() - 1};
124
125 SensorUtilities::ObserverState sensorState = {
126 lookVec,
127 lookVecJ2000,
128 sensorPos,
129 sensorTime,
130 imagePoint};
131
132 if (groundPtChanged) {
133 m_cam->SetBand(oldBand);
134 m_cam->SetImage(oldSample, oldLine);
135 }
136
137 return sensorState;
138 }
139
140}
@ Radians
Radians are generally used in mathematical equations, 0-2*PI is one circle, however these are more di...
Definition Angle.h:63
virtual double Line() const
Returns the current line number.
Definition Camera.cpp:2740
virtual double Sample() const
Returns the current sample number.
Definition Camera.cpp:2720
virtual bool SetImage(const double sample, const double line)
Sets the sample/line values of the image to get the lat/lon values.
Definition Camera.cpp:156
virtual int Band() const
Returns the current band.
Definition Camera.cpp:2730
virtual bool SetGround(Latitude latitude, Longitude longitude)
Sets the lat/lon values to get the sample/line values.
Definition Camera.cpp:403
virtual bool IsBandIndependent()
Virtual method that checks if the band is independent.
Definition Camera.cpp:2679
virtual void SetBand(const int band)
Virtual method that sets the band number.
Definition Camera.cpp:2710
Distance measurement, usually in meters.
Definition Distance.h:34
@ Meters
The distance is being specified in meters.
Definition Distance.h:43
IsisSensor(Camera *cam)
Create an IsisSensor wrapping an ISIS Camera object.
virtual SensorUtilities::ObserverState getState(const SensorUtilities::ImagePt &imagePoint)
Get the sensor state at an image coordinate.
This class is designed to encapsulate the concept of a Latitude.
Definition Latitude.h:51
This class is designed to encapsulate the concept of a Longitude.
Definition Longitude.h:40
virtual SurfacePoint GetSurfacePoint() const
Returns the surface point (most efficient accessor).
Definition Sensor.cpp:257
virtual std::vector< double > lookDirectionBodyFixed() const
Returns the look direction in the body fixed coordinate system.
Definition Sensor.cpp:539
virtual std::vector< double > lookDirectionJ2000() const
Returns the look direction in the camera coordinate system.
Definition Sensor.cpp:553
virtual void instrumentBodyFixedPosition(double p[3]) const
Returns the spacecraft position in body-fixed frame km units.
Definition Spice.cpp:842
virtual iTime time() const
Returns the ephemeris time in seconds which was used to obtain the spacecraft and sun positions.
Definition Spice.cpp:891
This class defines a body-fixed surface point.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
Namespace for the standard library.