SolarSystem.cpp
Go to the documentation of this file.
1 //==============================================================================
2 //
3 // This file is part of GNSSTk, the ARL:UT GNSS Toolkit.
4 //
5 // The GNSSTk is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published
7 // by the Free Software Foundation; either version 3.0 of the License, or
8 // any later version.
9 //
10 // The GNSSTk is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with GNSSTk; if not, write to the Free Software Foundation,
17 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
18 //
19 // This software was developed by Applied Research Laboratories at the
20 // University of Texas at Austin.
21 // Copyright 2004-2022, The Board of Regents of The University of Texas System
22 //
23 //==============================================================================
24 
25 //==============================================================================
26 //
27 // This software was developed by Applied Research Laboratories at the
28 // University of Texas at Austin, under contract to an agency or agencies
29 // within the U.S. Department of Defense. The U.S. Government retains all
30 // rights to use, duplicate, distribute, disclose, or release this software.
31 //
32 // Pursuant to DoD Directive 523024
33 //
34 // DISTRIBUTION STATEMENT A: This software has been approved for public
35 // release, distribution is unlimited.
36 //
37 //==============================================================================
38 
66 //------------------------------------------------------------------------------------
67 #include "SolarSystem.hpp"
68 
69 //------------------------------------------------------------------------------------
70 using namespace std;
71 
72 namespace gnsstk
73 {
74  //---------------------------------------------------------------------------------
75  /* Compute the ECEF (terrestrial frame, relative to Earth's center) position
76  of a Solar System body at the input time, with units meters. param body
77  SolarSystem::Planet of interest (input) param time Time of interest
78  (input) return ECEF Position of the body in meters. */
79  Position SolarSystem::ECEFPosition(const SolarSystemEphemeris::Planet body,
80  const EphTime& time)
81  {
82  try
83  {
84  Position Pos, Vel;
85  ECEFPositionVelocity(body, time, Pos, Vel);
86  return Pos;
87  }
88  catch (Exception& e)
89  {
90  GNSSTK_RETHROW(e);
91  }
92  }
93 
94  //---------------------------------------------------------------------------------
95  /* Compute the ECEF (terrestrial frame, relative to Earth's center) position
96  and velocity of a Solar System body at the input time, with units meters
97  and m/s. param body SolarSystem::Planet of interest (input) param time
98  Time of interest, in system TDB (input) return double PV[6] containing
99  position XYZ components (PV[0-2]) in meters
100  and velocity XYZ components (PV[3-5]) in m/sec. */
101  void
102  SolarSystem::ECEFPositionVelocity(const SolarSystemEphemeris::Planet body,
103  const EphTime& time, Position& Pos,
104  Position& Vel)
105  {
106  try
107  {
108  int i;
109  double PV[6];
110 
111  // get inertial frame position and velocity relative to Earth
112  EphTime ttag(time);
113  ttag.convertSystemTo(TimeSystem::TDB);
114  relativeInertialPositionVelocity(ttag.dMJD(), body, idEarth,
115  PV); // km,km/day
116 
117  // copy into 3-vectors
118  Vector<double> iPos(3), iVel(3), tPos(3), tVel(3);
119  for (i = 0; i < 3; i++)
120  {
121  iPos(i) = PV[i];
122  iVel(i) = PV[i + 3];
123  }
124 
125  // get EOP at time
126  ttag.convertSystemTo(TimeSystem::UTC);
127  EarthOrientation eo = EOPStore::getEOP(ttag.dMJD(), iersconv);
128 
129  // get transformation i-to-t = transpose(terrestrial-to-inertial)
131 
132  // transform inertial to terrestrial
133  tPos = Rot * iPos;
134  tVel = Rot * iVel;
135 
136  // change units
137  tPos *= 1000.0; // convert km to meters
138  tVel *= 1000.0 / 86400.0; // convert km/day to m/s
139 
140  // copy out
141  Pos = Position(tPos(0), tPos(1), tPos(2), Position::Cartesian);
142  Vel = Position(tVel(0), tVel(1), tVel(2), Position::Cartesian);
143 
144  return;
145  }
146  catch (Exception& e)
147  {
148  GNSSTK_RETHROW(e);
149  }
150  catch (exception& e)
151  {
152  Exception E("std except: " + string(e.what()));
153  GNSSTK_THROW(E);
154  }
155  catch (...)
156  {
157  Exception e("Unknown exception");
158  GNSSTK_THROW(e);
159  }
160  }
161 
162 } // end namespace gnsstk
gnsstk::EphTime::convertSystemTo
void convertSystemTo(const TimeSystem &ts)
Definition: EphTime.hpp:96
gnsstk
For Sinex::InputHistory.
Definition: BasicFramework.cpp:50
gnsstk::Exception
Definition: Exception.hpp:151
gnsstk::transpose
SparseMatrix< T > transpose(const SparseMatrix< T > &M)
transpose
Definition: SparseMatrix.hpp:829
gnsstk::SolarSystemEphemeris::Planet
Planet
These are indexes used by the caller of inertialPositionVelocity().
Definition: SolarSystemEphemeris.hpp:110
gnsstk::Matrix< double >
example4.time
time
Definition: example4.py:103
gnsstk::EphTime
Definition: EphTime.hpp:67
GNSSTK_RETHROW
#define GNSSTK_RETHROW(exc)
Definition: Exception.hpp:369
gnsstk::Vector< double >
SolarSystem.hpp
std
Definition: Angle.hpp:142
gnsstk::EarthOrientation::ECEFtoInertial
Matrix< double > ECEFtoInertial(const EphTime &t, bool reduced=false)
Definition: EarthOrientation.cpp:1247
gnsstk::Position
Definition: Position.hpp:136
GNSSTK_THROW
#define GNSSTK_THROW(exc)
Definition: Exception.hpp:366
gnsstk::EphTime::dMJD
double dMJD() const
Definition: EphTime.hpp:171
gnsstk::EarthOrientation
Definition: EarthOrientation.hpp:93


gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:41