Isis 3 Programmer Reference
SpacecraftPosition.cpp
1
6/* SPDX-License-Identifier: CC0-1.0 */
7#include "SpacecraftPosition.h"
8
9#include <cfloat>
10#include <iomanip>
11
12#include <QVector>
13
14#include "Constants.h"
15#include "Distance.h"
16#include "EndianSwapper.h"
17#include "FileName.h"
18#include "IException.h"
19#include "IString.h"
20#include "iTime.h"
21#include "Longitude.h"
22#include "NaifStatus.h"
23
24using namespace std;
25
26namespace Isis {
27
48 SpacecraftPosition::SpacecraftPosition(int targetCode, int observerCode,
49 const LightTimeCorrectionState &ltState,
50 const Distance &radius) :
51 SpicePosition(targetCode, observerCode,
52 ltState.isObserverTargetSwapped()) {
53 m_abcorr = ltState;
54 m_radius = radius;
55 return;
56 }
57
58
59
74 return (m_radius.kilometers()/clight_c());
75 }
76
88 return (distance.kilometers()/clight_c());
89 }
90
91
99 void SpacecraftPosition::SetAberrationCorrection(const QString &correction) {
100 SpicePosition::SetAberrationCorrection(correction); // Checks for validity
102 }
103
104
113
132
133 // Both light time correction and surface light time correction *must* be requested
134 // in order to invoke the algorithm below, otherwise we can call the pre-existing
135 // implementation as it handles swap and light time adjustments as requested.
136 // The algorithm below only additionally handles light time surface correction.
139 return;
140 }
141
143 // Proceed with applying light time corrections to surface. The
144 // steps to make this more accurate is as follows:
145 //
146 // 1) Compute vector from observer to target to acquire the light
147 // time correction (in seconds)
148 //
149 // 2) Acquire the vector from the solar system barycenter (SSB) to
150 // the spacecraft at the specified time.
151 //
152 // 3) Acquire the vector from the SSB to the target less the light
153 // time from 1) adding back in the time it takes for light to
154 // travel the radius of the target.
155 //
156 // 4) Compute the vector state of the target from the observer
157 // buy subtracting the result of 2) from 3).
159
160 SpiceDouble state[6], lt;
161 bool hasVelocity;
162 const SpiceInt ssbCode(0);
163
164 // 1) get observer/target light time
166 "J2000", GetAberrationCorrection(), state, hasVelocity, lt);
167
168 // 2) get SSB to s/c
169 SpiceDouble ssbObs[6], ssbObs_lt;
170 bool dummy;
172 "J2000", "NONE", ssbObs, dummy, ssbObs_lt);
173
174 // 3) get adjusted target position from SSB
175 double ltAdj_et = getAdjustedEphemerisTime() - lt + getRadiusLightTime();
176 SpiceDouble ssbTarg[6], ssbTarg_lt;
177 computeStateVector(ltAdj_et, getTargetCode(), ssbCode,
178 "J2000", "NONE", ssbTarg, dummy, ssbTarg_lt);
179
180 // 4) compute target to observer
181 (void) vsubg_c(ssbTarg, ssbObs, 6, state);
182
183 // Store vector and light time correction results
184 setStateVector(state, hasVelocity);
185 setLightTime(ltAdj_et);
186 return;
187 }
188
189
200
201
202} // namespace Isis
Distance measurement, usually in meters.
Definition Distance.h:34
double kilometers() const
Get the distance in kilometers.
Definition Distance.cpp:106
Provides interface to user configurable Light Time correction feature.
bool isLightTimeToSurfaceCorrected() const
Returns state of light time from surface to center body correction.
QString getAberrationCorrection() const
Returns the value of the current stellar aberration state.
void setAberrationCorrection(const QString &correction)
Sets the aberration correction directly.
bool isLightTimeCorrected() const
Is light time to target corrected?
LightTimeCorrectionState m_abcorr
Light time correction state.
const LightTimeCorrectionState & getLightTimeState() const
Return the state of light time correction parameters.
virtual void SetAberrationCorrection(const QString &correction)
Set aberration correction value for determining positions.
double getRadiusLightTime() const
Returns the time it takes for light to travel the radius of the target.
virtual void SetEphemerisTimeSpice()
Determine accurate position of target w.r.t.
SpacecraftPosition(int targetCode, int observerCode, const LightTimeCorrectionState &ltState=LightTimeCorrectionState(), const Distance &radius=Distance(0.0, Distance::Meters))
constructor for swapping observer/target parameters
static double getDistanceLightTime(const Distance &distance)
Returns the time it takes for light to travel a given distance.
Distance m_radius
Radius of target.
virtual QString GetAberrationCorrection() const
Returns the stellr aberration correction applied.
Obtain SPICE position information for a body.
virtual void SetEphemerisTimeSpice()
This is a protected method that is called by SetEphemerisTime() when Source type is Spice.
void setLightTime(const double &lightTime)
Inheritors can set the light time if indicated.
void setStateVector(const double state[6], const bool &hasVelocity)
Sets the state of target relative to observer.
int getTargetCode() const
Returns target code.
double getAdjustedEphemerisTime() const
Returns adjusted ephemeris time.
int getObserverCode() const
Returns observer code.
void computeStateVector(double et, int target, int observer, const QString &refFrame, const QString &abcorr, double state[6], bool &hasVelocity, double &lightTime) const
Computes the state vector of the target w.r.t observer.
virtual void SetAberrationCorrection(const QString &correction)
Set the aberration correction (light time)
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
Namespace for the standard library.