| 1 |
#ifndef _SGP4h_ |
| 2 |
#define _SGP4h_ |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
#pragma once |
| 52 |
|
| 53 |
#include <math.h> |
| 54 |
#include <stdio.h> |
| 55 |
#include <string.h> |
| 56 |
#include <iostream> |
| 57 |
|
| 58 |
#define SGP4Version "SGP4 Version 2020-07-13" |
| 59 |
|
| 60 |
|
| 61 |
typedef enum |
| 62 |
{ |
| 63 |
wgs72old, |
| 64 |
wgs72, |
| 65 |
wgs84 |
| 66 |
} gravconsttype; |
| 67 |
|
| 68 |
typedef struct elsetrec |
| 69 |
{ |
| 70 |
char satnum[6]; |
| 71 |
int epochyr, epochtynumrev; |
| 72 |
int error; |
| 73 |
char operationmode; |
| 74 |
char init, method; |
| 75 |
|
| 76 |
|
| 77 |
int isimp; |
| 78 |
double aycof , con41 , cc1 , cc4 , cc5 , d2 , d3 , d4 , |
| 79 |
delmo , eta , argpdot, omgcof , sinmao , t , t2cof, t3cof , |
| 80 |
t4cof , t5cof , x1mth2 , x7thm1 , mdot , nodedot, xlcof , xmcof , |
| 81 |
nodecf; |
| 82 |
|
| 83 |
|
| 84 |
int irez; |
| 85 |
double d2201 , d2211 , d3210 , d3222 , d4410 , d4422 , d5220 , d5232 , |
| 86 |
d5421 , d5433 , dedt , del1 , del2 , del3 , didt , dmdt , |
| 87 |
dnodt , domdt , e3 , ee2 , peo , pgho , pho , pinco , |
| 88 |
plo , se2 , se3 , sgh2 , sgh3 , sgh4 , sh2 , sh3 , |
| 89 |
si2 , si3 , sl2 , sl3 , sl4 , gsto , xfact , xgh2 , |
| 90 |
xgh3 , xgh4 , xh2 , xh3 , xi2 , xi3 , xl2 , xl3 , |
| 91 |
xl4 , xlamo , zmol , zmos , atime , xli , xni; |
| 92 |
|
| 93 |
double a, altp, alta, epochdays, jdsatepoch, jdsatepochF, nddot, ndot, |
| 94 |
bstar, rcse, inclo, nodeo, ecco, argpo, mo, no_kozai; |
| 95 |
|
| 96 |
char classification, intldesg[11]; |
| 97 |
int ephtype; |
| 98 |
long elnum , revnum; |
| 99 |
|
| 100 |
double no_unkozai; |
| 101 |
|
| 102 |
double am , em , im , Om , om , mm , nm; |
| 103 |
|
| 104 |
double tumin, mus, radiusearthkm, xke, j2, j3, j4, j3oj2; |
| 105 |
|
| 106 |
|
| 107 |
long dia_mm; |
| 108 |
double period_sec; |
| 109 |
unsigned char active; |
| 110 |
unsigned char not_orbital; |
| 111 |
double rcs_m2; |
| 112 |
|
| 113 |
} elsetrec; |
| 114 |
|
| 115 |
|
| 116 |
namespace SGP4Funcs |
| 117 |
{ |
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
bool sgp4init |
| 123 |
( |
| 124 |
gravconsttype whichconst, char opsmode, const char satn[9], const double epoch, |
| 125 |
const double xbstar, const double xndot, const double xnddot, const double xecco, const double xargpo, |
| 126 |
const double xinclo, const double xmo, const double xno, |
| 127 |
const double xnodeo, elsetrec& satrec |
| 128 |
); |
| 129 |
|
| 130 |
bool sgp4 |
| 131 |
( |
| 132 |
|
| 133 |
elsetrec& satrec, double tsince, |
| 134 |
double r[3], double v[3] |
| 135 |
); |
| 136 |
|
| 137 |
void getgravconst |
| 138 |
( |
| 139 |
gravconsttype whichconst, |
| 140 |
double& tumin, |
| 141 |
double& mus, |
| 142 |
double& radiusearthkm, |
| 143 |
double& xke, |
| 144 |
double& j2, |
| 145 |
double& j3, |
| 146 |
double& j4, |
| 147 |
double& j3oj2 |
| 148 |
); |
| 149 |
|
| 150 |
|
| 151 |
void twoline2rv |
| 152 |
( |
| 153 |
char longstr1[130], char longstr2[130], |
| 154 |
char typerun, char typeinput, char opsmode, |
| 155 |
gravconsttype whichconst, |
| 156 |
double& startmfe, double& stopmfe, double& deltamin, |
| 157 |
elsetrec& satrec |
| 158 |
); |
| 159 |
|
| 160 |
|
| 161 |
double gstime_SGP4 |
| 162 |
( |
| 163 |
double jdut1 |
| 164 |
); |
| 165 |
|
| 166 |
double sgn_SGP4 |
| 167 |
( |
| 168 |
double x |
| 169 |
); |
| 170 |
|
| 171 |
double mag_SGP4 |
| 172 |
( |
| 173 |
double x[3] |
| 174 |
); |
| 175 |
|
| 176 |
void cross_SGP4 |
| 177 |
( |
| 178 |
double vec1[3], double vec2[3], double outvec[3] |
| 179 |
); |
| 180 |
|
| 181 |
double dot_SGP4 |
| 182 |
( |
| 183 |
double x[3], double y[3] |
| 184 |
); |
| 185 |
|
| 186 |
double angle_SGP4 |
| 187 |
( |
| 188 |
double vec1[3], |
| 189 |
double vec2[3] |
| 190 |
); |
| 191 |
|
| 192 |
void newtonnu_SGP4 |
| 193 |
( |
| 194 |
double ecc, double nu, |
| 195 |
double& e0, double& m |
| 196 |
); |
| 197 |
|
| 198 |
double asinh_SGP4 |
| 199 |
( |
| 200 |
double xval |
| 201 |
); |
| 202 |
|
| 203 |
void rv2coe_SGP4 |
| 204 |
( |
| 205 |
double r[3], double v[3], double mus, |
| 206 |
double& p, double& a, double& ecc, double& incl, double& omega, double& argp, |
| 207 |
double& nu, double& m, double& arglat, double& truelon, double& lonper |
| 208 |
); |
| 209 |
|
| 210 |
void jday_SGP4 |
| 211 |
( |
| 212 |
int year, int mon, int day, int hr, int minute, double sec, |
| 213 |
double& jd, double& jdFrac |
| 214 |
); |
| 215 |
|
| 216 |
void days2mdhms_SGP4 |
| 217 |
( |
| 218 |
int year, double days, |
| 219 |
int& mon, int& day, int& hr, int& minute, double& sec |
| 220 |
); |
| 221 |
|
| 222 |
void invjday_SGP4 |
| 223 |
( |
| 224 |
double jd, double jdFrac, |
| 225 |
int& year, int& mon, int& day, |
| 226 |
int& hr, int& minute, double& sec |
| 227 |
); |
| 228 |
|
| 229 |
|
| 230 |
} |
| 231 |
|
| 232 |
#endif |