COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
Collaboration diagram for Ephemeris functions:

Functions

int32_t jpllib (double utc, rmatrix *rm, rmatrix *drm)
 Librations from JPL Ephemeris. More...
 
int32_t jpllib (double utc, rmatrix &rm, rmatrix &drm)
 
int32_t jplnut (double utc, double nuts[])
 Nutations from JPL Ephemeris. More...
 
int32_t jplpos (long from, long to, double utc, cartpos *pos)
 Position from JPL Ephemeris. More...
 
int32_t jplpos (long from, long to, double utc, cartpos &pos)
 
int32_t jplopen ()
 

Detailed Description

Function Documentation

int32_t jpllib ( double  utc,
rmatrix rm,
rmatrix drm 
)

Librations from JPL Ephemeris.

Position and Velocity values for Lunar Libration from the JPL Ephemeris

Parameters
utcModified julian day of position
rmPointer to the rotation matrix that represents Libration motion from Selenocentric (Principal Axis) to ICRF.
drmPointer to the rotation matrix that represents derivative Libration motion
55 {
56  return jpllib(utc, *rm, *drm);
57 }
int32_t jpllib(double utc, rmatrix *rm, rmatrix *drm)
Librations from JPL Ephemeris.
Definition: ephemlib.cpp:54
int32_t jpllib ( double  utc,
rmatrix rm,
rmatrix drm 
)
60  {
61  double pvec[6];
62  int32_t iretn;
63 
64  iretn = jplopen();
65  if (iretn < 0)
66  {
67  return iretn;
68  }
69 
70  eph_mutex.lock();
71  iretn = jpl_pleph(jplephem,utc + JD_MJD_OFFSET,15,0,pvec,1);
72  eph_mutex.unlock();
73  if (iretn < 0)
74  {
75  return iretn;
76  }
77 
79  drm = rm_mmult(rm_change_around_z(pvec[0]+pvec[3]/86400.),rm_mmult(rm_change_around_x(pvec[1]+pvec[4]/86400.),rm_change_around_z(pvec[2]+pvec[5]/86400.)));
80  drm = rm_sub(drm,rm);
81 
82  return 0;
83 }
static void * jplephem
Definition: ephemlib.cpp:40
static std::mutex eph_mutex
Definition: ephemlib.cpp:42
int iretn
Definition: rw_test.cpp:37
int32_t jplopen()
Definition: ephemlib.cpp:183
#define JD_MJD_OFFSET
Definition: timelib.h:74
rmatrix rm_sub(rmatrix a, rmatrix b)
rmatrix subtraction. Subtract two rmatrix values.
Definition: matrix.cpp:294
int DLL_FUNC jpl_pleph(void *ephem, const double et, const int ntarg, const int ncent, double rrd[], const int calc_velocity)
Definition: jpleph.cpp:128
rmatrix rm_change_around_x(double angle)
Rotation matrix for X axis.
Definition: matrix.cpp:358
rmatrix rm_mmult(rmatrix a, rmatrix b)
rmatrix Matrix Product
Definition: matrix.cpp:198
rmatrix rm_change_around_z(double angle)
Rotation matrix for Z axis.
Definition: matrix.cpp:382
int32_t jplnut ( double  utc,
double  nuts[] 
)

Nutations from JPL Ephemeris.

Longitude and obliquity values and rates.

Parameters
utcModified julian day of nutations
nutsStorage for nutations: psi, epsilon, dpsi, depsilon
91 {
92  double pvec[6];
93 
94  if (!std::isfinite(utc))
95  {
97  }
98 
99  int32_t iretn = jplopen();
100  if (iretn < 0)
101  {
102  return iretn;
103  }
104 
105  eph_mutex.lock();
106  iretn = jpl_pleph(jplephem,utc + JD_MJD_OFFSET,static_cast<int>(JPL_NUTATIONS),0,pvec,1);
107  eph_mutex.unlock();
108  if (iretn < 0)
109  {
110  return iretn;
111  }
112 
113  nuts[0] = pvec[0];
114  nuts[1] = pvec[1];
115  nuts[2] = pvec[2] / 86400.;
116  nuts[3] = pvec[3] / 86400.;
117 
118  return 0;
119 }
static void * jplephem
Definition: ephemlib.cpp:40
static std::mutex eph_mutex
Definition: ephemlib.cpp:42
int iretn
Definition: rw_test.cpp:37
int32_t jplopen()
Definition: ephemlib.cpp:183
#define JPL_NUTATIONS
Definition: convertdef.h:123
#define JD_MJD_OFFSET
Definition: timelib.h:74
int DLL_FUNC jpl_pleph(void *ephem, const double et, const int ntarg, const int ncent, double rrd[], const int calc_velocity)
Definition: jpleph.cpp:128
#define JPLEPHEM_ERROR_OUTOFRANGE
Definition: cosmos-errno.h:242
int32_t jplpos ( long  from,
long  to,
double  utc,
cartpos pos 
)

Position from JPL Ephemeris.

Position, velocity and acceleration vectors from one solar system object to another in J2000 coordinates.

Parameters
fromStarting object for vectors.
toEnding object for vectors.
posStorage from returned vectors
utcModified julian day of position
129 {
130  return jplpos(from, to, utc, *pos);
131 }
int32_t jplpos(long from, long to, double utc, cartpos *pos)
Position from JPL Ephemeris.
Definition: ephemlib.cpp:128
int32_t jplpos ( long  from,
long  to,
double  utc,
cartpos pos 
)
134  {
135  static double pvec[3][6];
136 
137  pos.s = pos.v = pos.a = rv_zero();
138 
139  int32_t iretn = jplopen();
140  if (iretn < 0)
141  {
142  return iretn;
143  }
144 
145  eph_mutex.lock();
146  iretn = jpl_pleph(jplephem,utc + JD_MJD_OFFSET - .05/86400., static_cast<int>(to), static_cast<int>(from) ,pvec[0],1);
147  eph_mutex.unlock();
148  if (iretn < 0)
149  {
150  return iretn;
151  }
152 
153  eph_mutex.lock();
154  iretn = jpl_pleph(jplephem,utc + JD_MJD_OFFSET, static_cast<int>(to), static_cast<int>(from) ,pvec[1],1);
155  eph_mutex.unlock();
156  if (iretn < 0)
157  {
158  return iretn;
159  }
160 
161  eph_mutex.lock();
162  iretn = jpl_pleph(jplephem,utc + JD_MJD_OFFSET + .05/86400., static_cast<int>(to), static_cast<int>(from) ,pvec[2],1);
163  eph_mutex.unlock();
164  if (iretn < 0)
165  {
166  return iretn;
167  }
168 
169  pos.s.col[0] = pvec[1][0] * 1000.;
170  pos.s.col[1] = pvec[1][1] * 1000.;
171  pos.s.col[2] = pvec[1][2] * 1000.;
172  pos.v.col[0] = pvec[1][3] * 1000.;
173  pos.v.col[1] = pvec[1][4] * 1000.;
174  pos.v.col[2] = pvec[1][5] * 1000.;
175  pos.a.col[0] = (pvec[2][3] - pvec[0][3]) * 10000.;
176  pos.a.col[1] = (pvec[2][4] - pvec[0][4]) * 10000.;
177  pos.a.col[2] = (pvec[2][5] - pvec[0][5]) * 10000.;
178  pos.utc = utc;
179 
180  return 0;
181 }
static void * jplephem
Definition: ephemlib.cpp:40
rvector a
Acceleration.
Definition: convertdef.h:167
double utc
UTC of Position.
Definition: convertdef.h:161
static std::mutex eph_mutex
Definition: ephemlib.cpp:42
int iretn
Definition: rw_test.cpp:37
int32_t jplopen()
Definition: ephemlib.cpp:183
rvector s
Location.
Definition: convertdef.h:163
#define JD_MJD_OFFSET
Definition: timelib.h:74
int DLL_FUNC jpl_pleph(void *ephem, const double et, const int ntarg, const int ncent, double rrd[], const int calc_velocity)
Definition: jpleph.cpp:128
rvector rv_zero()
Zero row order vector.
Definition: vector.cpp:107
double col[3]
Definition: vector.h:55
rvector v
Velocity.
Definition: convertdef.h:165
int32_t jplopen ( )
184 {
185  if (jplephem == nullptr)
186  {
187  string fname;
188  int32_t iretn = get_cosmosresources(fname);
189  if (iretn < 0)
190  {
191  return iretn;
192  }
193  fname += "/general/lnx1900.405";
194  jplephem = jpl_init_ephemeris(fname.c_str(),nullptr,nullptr);
195  if (jplephem == nullptr)
196  {
197  return -errno;
198  }
199  }
200  return 0;
201 }
static void * jplephem
Definition: ephemlib.cpp:40
int iretn
Definition: rw_test.cpp:37
string get_cosmosresources(bool create_flag)
Return COSMOS Resources Directory.
Definition: datalib.cpp:1337
static char fname[100]
Definition: geomag.cpp:89
void *DLL_FUNC jpl_init_ephemeris(const char *ephemeris_filename, char nam[][6], double *val)
Definition: jpleph.cpp:596