COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
convertlib.h
Go to the documentation of this file.
1 
7 
56 #ifndef _CONVERTLIB_H
57 #define _CONVERTLIB_H 1
58 
59 #include "support/configCosmos.h"
60 
61 #include "math/mathlib.h"
62 using namespace Cosmos::Math::Matrices;
63 using namespace Cosmos::Math::Vectors;
64 using namespace Cosmos::Math::Quaternions;
65 #include "support/convertdef.h"
66 
67 //#include <fcntl.h>
68 //#include <cmath>
69 //#include <ctime>
70 //#include <cerrno>
71 //#include <cstring>
72 
76 
77 // TODO: implement using pos_geoc2geod
78 int32_t loc_clear(locstruc *loc);
79 int32_t pos_extra(locstruc *loc);
80 int32_t pos_icrf(locstruc *loc);
81 int32_t pos_eci(locstruc *loc);
82 int32_t pos_sci(locstruc *loc);
83 int32_t pos_geoc(locstruc *loc);
84 int32_t pos_geos(locstruc *loc);
85 int32_t pos_geod(locstruc *loc);
86 int32_t pos_selc(locstruc *loc);
87 int32_t pos_selg(locstruc *loc);
88 int32_t pos_icrf2eci(locstruc *loc);
89 int32_t pos_eci2icrf(locstruc *loc);
90 int32_t pos_icrf2sci(locstruc *loc);
91 int32_t pos_sci2icrf(locstruc *loc);
92 int32_t pos_eci2geoc(locstruc *loc);
93 int32_t pos_eci2selc(locstruc *loc);
94 int32_t pos_geoc2eci(locstruc *loc);
95 int32_t pos_geoc2geod(locstruc *loc);
96 int32_t pos_geod2geoc(locstruc *loc);
97 int32_t pos_geoc2geos(locstruc *loc);
98 int32_t pos_geos2geoc(locstruc *loc);
99 int32_t pos_eci2sci(locstruc *loc);
100 int32_t pos_sci2eci(locstruc *loc);
101 int32_t pos_sci2selc(locstruc *loc);
102 int32_t pos_selc2selg(locstruc *loc);
103 int32_t pos_selc2sci(locstruc *loc);
104 int32_t pos_selg2selc(locstruc *loc);
105 int32_t pos_selc2eci(locstruc *loc);
106 
107 int32_t loc_clear(locstruc &loc);
108 int32_t pos_extra(locstruc &loc);
109 int32_t pos_clear(locstruc &loc);
110 int32_t pos_icrf(locstruc &loc);
111 int32_t pos_eci(locstruc &loc);
112 int32_t pos_sci(locstruc &loc);
113 int32_t pos_geoc(locstruc &loc);
114 int32_t pos_geos(locstruc &loc);
115 int32_t pos_geod(locstruc &loc);
116 int32_t pos_selc(locstruc &loc);
117 int32_t pos_selg(locstruc &loc);
118 int32_t pos_icrf2eci(locstruc &loc);
119 int32_t pos_eci2icrf(locstruc &loc);
120 int32_t pos_icrf2sci(locstruc &loc);
121 int32_t pos_sci2icrf(locstruc &loc);
122 int32_t pos_eci2geoc(locstruc &loc);
123 int32_t pos_eci2selc(locstruc &loc);
124 int32_t pos_geoc2eci(locstruc &loc);
125 int32_t pos_geoc2geod(locstruc &loc);
126 int32_t pos_geod2geoc(locstruc &loc);
127 int32_t pos_geoc2geos(locstruc &loc);
128 int32_t pos_geos2geoc(locstruc &loc);
129 int32_t pos_eci2sci(locstruc &loc);
130 int32_t pos_sci2eci(locstruc &loc);
131 int32_t pos_sci2selc(locstruc &loc);
132 int32_t pos_selc2selg(locstruc &loc);
133 int32_t pos_selc2sci(locstruc &loc);
134 int32_t pos_selg2selc(locstruc &loc);
135 int32_t pos_selc2eci(locstruc &loc);
136 
137 int32_t eci2kep(cartpos &eci, kepstruc &kep);
138 int32_t kep2eci(kepstruc &kep,cartpos &eci);
139 double rearth(double lat);
140 double mjd2year(double mjd);
141 
142 int32_t att_extra(locstruc *loc);
143 int32_t att_icrf(locstruc *loc);
144 int32_t att_lvlh(locstruc *loc);
145 int32_t att_geoc(locstruc *loc);
146 int32_t att_selc(locstruc *loc);
147 int32_t att_topo(locstruc *loc);
148 int32_t att_planec2topo(locstruc *loc);
149 int32_t att_topo2planec(locstruc *loc);
150 int32_t att_icrf2geoc(locstruc *loc);
151 int32_t att_icrf2lvlh(locstruc *loc);
152 int32_t att_icrf2selc(locstruc *loc);
153 int32_t att_geoc2icrf(locstruc *loc);
154 int32_t att_planec2lvlh(locstruc *loc);
155 int32_t att_lvlh2planec(locstruc *loc);
156 int32_t att_lvlh2icrf(locstruc *loc);
157 int32_t att_selc2icrf(locstruc *loc);
158 int32_t loc_update(locstruc *loc);
159 
160 int32_t att_extra(locstruc &loc);
161 int32_t att_clear(attstruc &att);
162 int32_t att_icrf(locstruc &loc);
163 int32_t att_lvlh(locstruc &loc);
164 int32_t att_geoc(locstruc &loc);
165 int32_t att_selc(locstruc &loc);
166 int32_t att_topo(locstruc &loc);
167 int32_t att_planec2topo(locstruc &loc);
168 int32_t att_topo2planec(locstruc &loc);
169 int32_t att_icrf2geoc(locstruc &loc);
170 int32_t att_icrf2geoc(locstruc &loc);
171 int32_t att_icrf2lvlh(locstruc &loc);
172 int32_t att_icrf2selc(locstruc &loc);
173 int32_t att_geoc2icrf(locstruc &loc);
174 int32_t att_planec2lvlh(locstruc &loc);
175 int32_t att_lvlh2planec(locstruc &loc);
176 int32_t att_lvlh2icrf(locstruc &loc);
177 int32_t att_selc2icrf(locstruc &loc);
178 int32_t loc_update(locstruc &loc);
179 
180 double mjd2gmst(double mjd);
181 int32_t geoc2geod(cartpos &geoc, geoidpos &geod);
182 int32_t geos2geoc(spherpos *geos, cartpos *geoc);
183 int32_t geod2geoc(geoidpos &geod, cartpos &geoc);
184 int32_t geoc2geos(cartpos *geoc, spherpos *geos);
185 int32_t selg2selc(geoidpos *selg, cartpos *selc);
186 int32_t gcrf2itrs(double utc, rmatrix *rnp, rmatrix *rm, rmatrix *drm, rmatrix *ddrm);
187 int32_t itrs2gcrf(double utc, rmatrix *rnp, rmatrix *rm, rmatrix *drm, rmatrix *ddrm);
188 int32_t true2pef(double utc, rmatrix *rm);
189 int32_t pef2true(double utc, rmatrix *rm);
190 int32_t pef2itrs(double utc, rmatrix *rm);
191 int32_t itrs2pef(double utc, rmatrix *rm);
192 int32_t true2mean(double ep1, rmatrix *pm);
193 int32_t mean2true(double ep0, rmatrix *pm);
194 int32_t j20002mean(double ep1, rmatrix *pm);
195 int32_t mean2j2000(double ep0, rmatrix *pm);
196 int32_t gcrf2j2000(rmatrix *rm);
197 int32_t j20002gcrf(rmatrix *rm);
198 int32_t teme2true(double ep0, rmatrix *rm);
199 int32_t true2teme(double ep0, rmatrix *rm);
200 int32_t mean2mean(double ep0, double ep1, rmatrix *pm);
201 int32_t geoc2topo(gvector gs, rvector geoc, rvector &topo);
202 int32_t body2topo(Vector com, Vector body, Vector &topo);
203 int32_t topo2azel(rvector tpos, float &az, float &el);
204 int32_t topo2azel(Vector tpos, float &az, float &el);
205 int lines2eci(double mjd, vector<tlestruc> tle, cartpos &eci);
206 int tle2eci(double mjd, tlestruc tle, cartpos &eci);
207 int32_t eci2tle(double utc, cartpos eci, tlestruc &tle);
208 int sgp4(double utc, tlestruc tle, cartpos &pos_teme);
209 tlestruc get_line(uint16_t index, vector<tlestruc> tle);
210 int32_t load_lines(string fname, vector<tlestruc>& tle);
211 int32_t load_lines_multi(string fname, vector<tlestruc>& tle);
212 int32_t loadTLE(char *fname, tlestruc &tle);
213 int32_t load_stk(string filename, stkstruc &stkdata);
214 int stk2eci(double utc, stkstruc &stk, cartpos &eci);
215 int32_t tle2sgp4(tlestruc tle, sgp4struc &sgp4);
216 int32_t sgp42tle(sgp4struc sgp4, tlestruc &tle);
217 int tle_checksum(char *line);
218 int32_t eci2tlestring(cartpos eci, string &tle, std::string ref_tle, double bstar=0);
219 
220 namespace Cosmos {
221  namespace Coords {
222 
223  class Position {
224 
225  public:
226 
227  explicit Position(Vector s0=Vector(), Vector v0=Vector(), Vector a0=Vector())
228  {
229  s = s0;
230  v = v0;
231  a = a0;
232  }
233 
234  // 0th derivative
236  // 1st derivative
238  // 2nd derivative
240  };
241  }
242 }
243 
245 
246 #endif
double mjd2gmst(double mjd)
int32_t att_selc(locstruc *loc)
Definition: convertlib.cpp:1794
Definition: agentclass.cpp:54
int32_t true2pef(double utc, rmatrix *rm)
Definition: convertlib.cpp:2436
Definition: matrix.cpp:1678
Vector a
Definition: convertlib.h:239
Definition: convertlib.h:223
int32_t eci2kep(cartpos &eci, kepstruc &kep)
Definition: convertlib.cpp:2934
int32_t pos_eci2selc(locstruc *loc)
In units for the SGP4 propogator (not NORAD TLE itself).
Definition: convertdef.h:921
static std::vector< tlestruc > tle
Definition: agent_antenna.cpp:177
int32_t geos2geoc(spherpos *geos, cartpos *geoc)
3 element generic row vector
Definition: vector.h:53
int32_t pos_selc2sci(locstruc *loc)
Convert SELC to SCI.
Definition: convertlib.cpp:1366
Geodetic position structure.
Definition: convertdef.h:259
int32_t sgp42tle(sgp4struc sgp4, tlestruc &tle)
Definition: convertlib.cpp:4212
int32_t pos_icrf2sci(locstruc *loc)
Convert Barycentric to SCI.
Definition: convertlib.cpp:730
Cartesian full position structure.
Definition: convertdef.h:158
int32_t pos_sci(locstruc *loc)
Set SCI position.
Definition: convertlib.cpp:312
int32_t kep2eci(kepstruc &kep, cartpos &eci)
Definition: convertlib.cpp:2878
Definition: vector.cpp:1578
int32_t geoc2topo(gvector source, rvector targetgeoc, rvector &topo)
Geocentric to Topocentric.
Definition: convertlib.cpp:3033
int32_t geod2geoc(geoidpos &geod, cartpos &geoc)
Convert GEOD to GEOC.
Definition: convertlib.cpp:1215
int32_t true2teme(double ep0, rmatrix *rm)
Definition: convertlib.cpp:2429
int32_t j20002gcrf(rmatrix *rm)
Definition: convertlib.cpp:2831
int32_t att_icrf2selc(locstruc *loc)
Definition: convertlib.cpp:1710
int32_t itrs2pef(double utc, rmatrix *rm)
Definition: convertlib.cpp:2460
int32_t att_icrf(locstruc *loc)
Definition: convertlib.cpp:1836
int32_t gcrf2itrs(double utc, rmatrix *rnp, rmatrix *rm, rmatrix *drm, rmatrix *ddrm)
J2000 to ITRS rotation matrix.
Definition: convertlib.cpp:2659
int tle_checksum(char *line)
Definition: convertlib.cpp:4234
int32_t att_lvlh2icrf(locstruc *loc)
Convert LVLH attitude to ICRF attitude.
Definition: convertlib.cpp:2035
int32_t pos_selg(locstruc *loc)
Set Selenographic position.
Definition: convertlib.cpp:484
Definition: convertdef.h:1012
int32_t selg2selc(geoidpos *selg, cartpos *selc)
int32_t pos_sci2eci(locstruc *loc)
int32_t pos_geos(locstruc *loc)
Set Geographic position.
Definition: convertlib.cpp:530
int32_t tle2sgp4(tlestruc tle, sgp4struc &sgp4)
Definition: convertlib.cpp:4198
int32_t att_extra(locstruc *loc)
Calculate Extra attitude information.
Definition: convertlib.cpp:1572
int32_t gcrf2j2000(rmatrix *rm)
Definition: convertlib.cpp:2823
int32_t loadTLE(char *fname, tlestruc &tle)
Load TLE from file. TODO!!! create new class for dealing with TLEs.
Definition: convertlib.cpp:3535
int32_t pos_geoc2eci(locstruc *loc)
Convert GEOC to ECI.
Definition: convertlib.cpp:913
STK positions structure.
Definition: convertdef.h:999
int32_t pos_sci2icrf(locstruc *loc)
Convert SCI to Barycentric.
Definition: convertlib.cpp:784
int32_t pos_clear(locstruc *loc)
Initialize posstruc.
Definition: convertlib.cpp:77
Definition: vector.cpp:2097
int32_t pos_selg2selc(locstruc *loc)
Definition: convertlib.cpp:1494
int32_t eci2tle(double utc, cartpos eci, tlestruc &tle)
TLE from ECI.
Definition: convertlib.cpp:3418
int32_t loc_clear(locstruc *loc)
Initialize locstruc.
Definition: convertlib.cpp:58
int32_t j20002mean(double ep1, rmatrix *pm)
Definition: convertlib.cpp:2779
int32_t true2mean(double ep0, rmatrix *pm)
Rotate True of Epoch to Mean of Epoch.
Definition: convertlib.cpp:2512
3x3 element generic matrix
Definition: matrix.h:41
static char fname[100]
Definition: geomag.cpp:89
int32_t att_planec2lvlh(locstruc *loc)
Convert ITRS attitude to LVLH attitude.
Definition: convertlib.cpp:1863
int32_t mean2true(double ep0, rmatrix *pm)
Rotate Mean of Epoch to True of Epoch.
Definition: convertlib.cpp:2486
int32_t geoc2geod(cartpos &geoc, geoidpos &geod)
Convert GEOC to GEOD.
Definition: convertlib.cpp:1105
int32_t pos_eci2geoc(locstruc *loc)
Convert ECI to GEOC.
Definition: convertlib.cpp:836
Headers and definitions common to all COSMOS.
int32_t pos_geos2geoc(locstruc *loc)
Convert GEOS to GEOC.
Definition: convertlib.cpp:1047
tlestruc get_line(uint16_t index, vector< tlestruc > lines)
Get TLE from array of TLE&#39;s.
Definition: convertlib.cpp:3512
int32_t geoc2geos(cartpos *geoc, spherpos *geos)
Vector s
Definition: convertlib.h:235
int32_t att_geoc2icrf(locstruc *loc)
Definition: convertlib.cpp:1639
int32_t pos_geoc(locstruc *loc)
Set Geocentric position.
Definition: convertlib.cpp:366
int32_t att_geoc(locstruc *loc)
Definition: convertlib.cpp:1682
int32_t att_planec2topo(locstruc *loc)
Planetocentric to Topo attitude.
Definition: convertlib.cpp:2105
int32_t att_clear(attstruc &att)
Initialize attstruc.
Definition: convertlib.cpp:96
int32_t pos_eci(locstruc *loc)
Set ECI position.
Definition: convertlib.cpp:258
int32_t pos_extra(locstruc *loc)
Calculate Extra position information.
Definition: convertlib.cpp:107
stkstruc stk
Definition: testengine.cpp:46
double mjd
Definition: udp_send.cpp:41
int32_t pos_eci2sci(locstruc *loc)
int32_t pos_geoc2geos(locstruc *loc)
Convert GEOC to GEOS.
Definition: convertlib.cpp:983
int32_t pos_icrf(locstruc *loc)
Set Barycentric position.
Definition: convertlib.cpp:162
int32_t pos_geod(locstruc *loc)
Set Geodetic position.
Definition: convertlib.cpp:576
int32_t pos_geod2geoc(locstruc *loc)
Update GEOD to GEOC in locstruc.
Definition: convertlib.cpp:1250
Classical elements structure.
Definition: convertdef.h:529
int32_t load_lines_multi(string fname, vector< tlestruc > &lines)
Definition: convertlib.cpp:3714
int32_t itrs2gcrf(double utc, rmatrix *rnp, rmatrix *rm, rmatrix *drm, rmatrix *ddrm)
ITRS to J2000 rotation matrix.
Definition: convertlib.cpp:2625
int32_t att_icrf2geoc(locstruc *loc)
Definition: convertlib.cpp:1591
Spherical position structure.
Definition: convertdef.h:314
Definition: eci2kep_test.cpp:33
int32_t mean2mean(double ep0, double ep1, rmatrix *pm)
Definition: convertlib.cpp:2838
int32_t att_selc2icrf(locstruc *loc)
Definition: convertlib.cpp:1760
int32_t pef2true(double utc, rmatrix *rm)
Definition: convertlib.cpp:2443
int sgp4(double utc, tlestruc tle, cartpos &pos_teme)
Definition: convertlib.cpp:3186
int32_t load_lines(string fname, vector< tlestruc > &lines)
Load TLE from file. TODO!!! Rename Function to loadTle and create new class for dealing with TLEs...
Definition: convertlib.cpp:3612
int32_t loc_update(locstruc *loc)
Synchronize all frames in location structure.
Definition: convertlib.cpp:2294
int32_t pos_selc2selg(locstruc *loc)
Convert SELC to SELG.
Definition: convertlib.cpp:1432
mathlib include file
Vector v
Definition: convertlib.h:237
int32_t body2topo(Vector source, Vector target, Vector &topo)
Body Centric to Topocentric.
Definition: convertlib.cpp:3080
int32_t att_icrf2lvlh(locstruc *loc)
Definition: convertlib.cpp:1822
int32_t teme2true(double ep0, rmatrix *rm)
Definition: convertlib.cpp:2421
int32_t pos_selc(locstruc *loc)
Set Selenocentric position.
Definition: convertlib.cpp:428
int32_t att_topo2planec(locstruc *loc)
Topocentric to Planetocentric attitude.
Definition: convertlib.cpp:2174
int32_t pos_sci2selc(locstruc *loc)
Convert SCI to SELC.
Definition: convertlib.cpp:1291
int32_t eci2tlestring(cartpos eci, string &tle, std::string ref_tle, double bstar=0)
int32_t topo2azel(rvector tpos, float &az, float &el)
Definition: convertlib.cpp:3129
int32_t att_lvlh2planec(locstruc *loc)
Convert LVLH attitude to ITRS attitude.
Definition: convertlib.cpp:1943
int32_t pos_selc2eci(locstruc *loc)
Vector Class.
Definition: vector.h:672
Definition: convertdef.h:823
int32_t pef2itrs(double utc, rmatrix *rm)
Definition: convertlib.cpp:2450
3 element geodetic vector
Definition: vector.h:222
int32_t att_topo(locstruc *loc)
Definition: convertlib.cpp:2252
int32_t pos_eci2icrf(locstruc *loc)
Convert ECI to Barycentric.
Definition: convertlib.cpp:679
Definition: convertdef.h:876
int lines2eci(double utc, vector< tlestruc >lines, cartpos &eci)
Return position from TLE set.
Definition: convertlib.cpp:3155
int32_t pos_geoc2geod(locstruc *loc)
Update locstruc GEOC to GEOD.
Definition: convertlib.cpp:1167
int32_t load_stk(string filename, stkstruc &stkdata)
Load STK elements.
Definition: convertlib.cpp:3792
double rearth(double lat)
Definition: convertlib.cpp:1556
int32_t att_lvlh(locstruc *loc)
Definition: convertlib.cpp:2064
int tle2eci(double utc, tlestruc tle, cartpos &eci)
Definition: convertlib.cpp:3466
Position(Vector s0=Vector(), Vector v0=Vector(), Vector a0=Vector())
Definition: convertlib.h:227
int32_t pos_icrf2eci(locstruc *loc)
Convert Barycentric to ECI.
Definition: convertlib.cpp:626
int stk2eci(double utc, stkstruc &stk, cartpos &eci)
ECI from STK data.
Definition: convertlib.cpp:3842
int32_t mean2j2000(double ep0, rmatrix *pm)
Rotate Mean of Epoch to J2000.
Definition: convertlib.cpp:2563
double mjd2year(double mjd)
Year from MJD.
Definition: timelib.cpp:997