Isis 3 Programmer Reference
SpacecraftPosition.cpp
Go to the documentation of this file.
1 
22 #include "SpacecraftPosition.h"
23 
24 #include <cfloat>
25 #include <iomanip>
26 
27 #include <QVector>
28 
29 #include "Constants.h"
30 #include "Distance.h"
31 #include "EndianSwapper.h"
32 #include "FileName.h"
33 #include "IException.h"
34 #include "IString.h"
35 #include "iTime.h"
36 #include "Longitude.h"
37 #include "NaifStatus.h"
38 
39 using namespace std;
40 
41 namespace Isis {
42 
63  SpacecraftPosition::SpacecraftPosition(int targetCode, int observerCode,
64  const LightTimeCorrectionState &ltState,
65  const Distance &radius) :
66  SpicePosition(targetCode, observerCode,
67  ltState.isObserverTargetSwapped()) {
68  m_abcorr = ltState;
69  m_radius = radius;
70  return;
71  }
72 
73 
74 
89  return (m_radius.kilometers()/clight_c());
90  }
91 
103  return (distance.kilometers()/clight_c());
104  }
105 
106 
114  void SpacecraftPosition::SetAberrationCorrection(const QString &correction) {
115  SpicePosition::SetAberrationCorrection(correction); // Checks for validity
116  m_abcorr.setAberrationCorrection(correction);
117  }
118 
119 
127  }
128 
147 
148  // Both light time correction and surface light time correction *must* be requested
149  // in order to invoke the algorithm below, otherwise we can call the pre-existing
150  // implementation as it handles swap and light time adjustments as requested.
151  // The algorithm below only additionally handles light time surface correction.
154  return;
155  }
156 
158  // Proceed with applying light time corrections to surface. The
159  // steps to make this more accurate is as follows:
160  //
161  // 1) Compute vector from observer to target to acquire the light
162  // time correction (in seconds)
163  //
164  // 2) Acquire the vector from the solar system barycenter (SSB) to
165  // the spacecraft at the specified time.
166  //
167  // 3) Acquire the vector from the SSB to the target less the light
168  // time from 1) adding back in the time it takes for light to
169  // travel the radius of the target.
170  //
171  // 4) Compute the vector state of the target from the observer
172  // buy subtracting the result of 2) from 3).
174 
175  SpiceDouble state[6], lt;
176  bool hasVelocity;
177  const SpiceInt ssbCode(0);
178 
179  // 1) get observer/target light time
181  "J2000", GetAberrationCorrection(), state, hasVelocity, lt);
182 
183  // 2) get SSB to s/c
184  SpiceDouble ssbObs[6], ssbObs_lt;
185  bool dummy;
187  "J2000", "NONE", ssbObs, dummy, ssbObs_lt);
188 
189  // 3) get adjusted target position from SSB
190  double ltAdj_et = getAdjustedEphemerisTime() - lt + getRadiusLightTime();
191  SpiceDouble ssbTarg[6], ssbTarg_lt;
192  computeStateVector(ltAdj_et, getTargetCode(), ssbCode,
193  "J2000", "NONE", ssbTarg, dummy, ssbTarg_lt);
194 
195  // 4) compute target to observer
196  (void) vsubg_c(ssbTarg, ssbObs, 6, state);
197 
198  // Store vector and light time correction results
199  setStateVector(state, hasVelocity);
200  setLightTime(ltAdj_et);
201  return;
202  }
203 
204 
213  return (m_abcorr);
214  }
215 
216 
217 } // namespace Isis
int getObserverCode() const
Returns observer code.
static double getDistanceLightTime(const Distance &distance)
Returns the time it takes for light to travel a given distance.
virtual QString GetAberrationCorrection() const
Returns the stellr aberration correction applied.
virtual void SetAberrationCorrection(const QString &correction)
Set the aberration correction (light time)
void setAberrationCorrection(const QString &correction)
Sets the aberration correction directly.
Provides interface to user configurable Light Time correction feature.
Namespace for the standard library.
int getTargetCode() const
Returns target code.
QString getAberrationCorrection() const
Returns the value of the current stellar aberration state.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
double kilometers() const
Get the distance in kilometers.
Definition: Distance.cpp:118
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.
Distance measurement, usually in meters.
Definition: Distance.h:47
bool isLightTimeToSurfaceCorrected() const
Returns state of light time from surface to center body correction.
Distance m_radius
Radius of target.
double getAdjustedEphemerisTime() const
Returns adjusted ephemeris time.
void setStateVector(const double state[6], const bool &hasVelocity)
Sets the state of target relative to observer.
LightTimeCorrectionState m_abcorr
Light time correction state.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
virtual void SetEphemerisTimeSpice()
Determine accurate position of target w.r.t.
const LightTimeCorrectionState & getLightTimeState() const
Return the state of light time correction parameters.
Obtain SPICE position information for a body.
virtual void SetAberrationCorrection(const QString &correction)
Set aberration correction value for determining positions.
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
void setLightTime(const double &lightTime)
Inheritors can set the light time if indicated.
bool isLightTimeCorrected() const
Is light time to target corrected?
double getRadiusLightTime() const
Returns the time it takes for light to travel the radius of the target.
virtual void SetEphemerisTimeSpice()
This is a protected method that is called by SetEphemerisTime() when Source type is Spice...