perturb 1.0.0
A modern C++11 wrapper for the SGP4 orbit propagator
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
perturb.hpp
Go to the documentation of this file.
1/*
2 * perturb -- A modern C++11 wrapper for the SGP4 orbit propagator
3 * Version 1.0.0
4 * https://github.com/gunvirranu/perturb
5 *
6 * Licensed under the MIT License <http://opensource.org/licenses/MIT>.
7 * SPDX-License-Identifier: MIT
8 *
9 * Copyright (c) 2022 Gunvir Ranu
10 */
11
17
18#ifndef PERTURB_PERTURB_HPP
19#define PERTURB_PERTURB_HPP
20
21#include "perturb/sgp4.hpp"
22#include "perturb/tle.hpp"
23
24#include <array>
25#ifndef PERTURB_DISABLE_IO
26# include <string>
27#endif
28
32namespace perturb {
33
35using Vec3 = std::array<double, 3>;
36
50enum class Sgp4Error : int {
51 NONE = 0,
52 MEAN_ELEMENTS,
53 MEAN_MOTION,
54 PERT_ELEMENTS,
55 SEMI_LATUS_RECTUM,
56 EPOCH_ELEMENTS_SUB_ORBITAL,
57 DECAYED,
58 INVALID_TLE, // Not from base impl, added in
59 UNKNOWN
60};
61
69enum class GravModel {
70 WGS72_OLD,
71 WGS72,
72 WGS84
73};
74
95struct DateTime {
96 int year;
97 int month;
98 int day;
99 int hour;
100 int min;
101 double sec;
102};
103
119 double jd;
121 double jd_frac;
122
124 JulianDate();
125
127 explicit JulianDate(double jd);
128
136 explicit JulianDate(double jd, double jd_frac);
137
144 explicit JulianDate(DateTime t);
145
149 DateTime to_datetime() const;
150
157 void normalize();
158
160 JulianDate normalized() const;
161
163 double operator-(const JulianDate &rhs) const;
164
175 JulianDate operator+(const double &delta_jd) const;
177 JulianDate &operator+=(const double &delta_jd);
179 JulianDate operator-(const double &delta_jd) const;
181 JulianDate &operator-=(const double &delta_jd);
182
184 bool operator<(const JulianDate &rhs) const;
186 bool operator>(const JulianDate &rhs) const;
188 bool operator<=(const JulianDate &rhs) const;
190 bool operator>=(const JulianDate &rhs) const;
191};
192
205};
206
215 double inclination;
216 double raan;
223
229 StateVector sv, GravModel grav_model = GravModel::WGS72
230 );
231};
232
242public:
245
250
270 explicit Satellite(
271 const TwoLineElement &tle, GravModel grav_model = GravModel::WGS72
272 );
273
274#ifndef PERTURB_DISABLE_IO
286 static Satellite from_tle(
287 char *line_1, char *line_2, GravModel grav_model = GravModel::WGS72
288 );
289#endif // PERTURB_DISABLE_IO
290
291#ifndef PERTURB_DISABLE_IO
298 static Satellite from_tle(
299 std::string &line_1, std::string &line_2, GravModel grav_model = GravModel::WGS72
300 );
301#endif // PERTURB_DISABLE_IO
302
304 Sgp4Error last_error() const;
305
307 JulianDate epoch() const;
308
314 Sgp4Error propagate_from_epoch(double mins_from_epoch, StateVector &sv);
315
322};
323} // namespace perturb
324
325#endif // PERTURB_PERTURB_HPP
Represents a specific orbital ephemeris for an Earth-centered trajectory.
Definition: perturb.hpp:241
sgp4::elsetrec sat_rec
Internal SGP4 type.
Definition: perturb.hpp:244
static Satellite from_tle(char *line_1, char *line_2, GravModel grav_model=GravModel::WGS72)
Construct and initialize a Satellite from a TLE record.
Definition: perturb.cpp:189
Sgp4Error propagate_from_epoch(double mins_from_epoch, StateVector &sv)
Propagate the SGP4 model based on time around the epoch.
Definition: perturb.cpp:228
Sgp4Error propagate(JulianDate jd, StateVector &sv)
Propagate the SGP4 model to a specific time point.
Definition: perturb.cpp:236
JulianDate epoch() const
Return the epoch of the orbital ephemeris, likely from a TLE.
Definition: perturb.cpp:224
Sgp4Error last_error() const
Return the last recorded error in the internal SGP4 record.
Definition: perturb.cpp:220
Primary namespace for the perturb library, everything is in here.
Definition: perturb.hpp:32
std::array< double, 3 > Vec3
Alias for representing position and velocity vectors.
Definition: perturb.hpp:35
GravModel
Choice of gravity model / constants for the underlying SGP4 impl.
Definition: perturb.hpp:69
Sgp4Error
Possible issues during SGP4 propagation or even TLE parsing.
Definition: perturb.hpp:50
Header for the internal SGP4 impl from Vallado.
Classical Keplerian orbital elements.
Definition: perturb.hpp:211
double arg_of_perigee
Argument of perigee in [rad].
Definition: perturb.hpp:217
double semilatus_rectum
Samilatus rectum in [km].
Definition: perturb.hpp:212
double eccentricity
Eccentricity (unitless)
Definition: perturb.hpp:214
double semimajor_axis
Semimajor axis in [km].
Definition: perturb.hpp:213
double arg_of_latitude
Argument of latitude in [rad].
Definition: perturb.hpp:220
double longitude_of_periapsis
Longitude of periapsis in [rad].
Definition: perturb.hpp:222
double mean_anomaly
Mean anomaly in [rad].
Definition: perturb.hpp:219
double true_longitude
True longitude in [rad].
Definition: perturb.hpp:221
double inclination
Inlination in [rad].
Definition: perturb.hpp:215
double true_anomaly
True anomaly in [rad].
Definition: perturb.hpp:218
double raan
Right ascension of ascending node in [rad].
Definition: perturb.hpp:216
A basic and human readable representation of a point in time.
Definition: perturb.hpp:95
int month
Month from 1 to 12.
Definition: perturb.hpp:97
double sec
Fractional seconds from 0.0 to 59.999...
Definition: perturb.hpp:101
int day
Day from 1 to {28, 29, 30, 31} (depending on month)
Definition: perturb.hpp:98
int min
Minute from 0 to 59.
Definition: perturb.hpp:100
int year
Year from 1900 to 2100.
Definition: perturb.hpp:96
int hour
Hour from 0 to 23.
Definition: perturb.hpp:99
Represents a specific point in time on the Julian calendar.
Definition: perturb.hpp:117
JulianDate & operator+=(const double &delta_jd)
Add a delta number of days offset to this time point.
Definition: perturb.cpp:91
DateTime to_datetime() const
Convert to a DateTime representing the same time point.
Definition: perturb.cpp:53
void normalize()
Normalizes a Julian date representation to a canonical representation.
Definition: perturb.cpp:59
bool operator>=(const JulianDate &rhs) const
Compare if after than or same as another time point.
Definition: perturb.cpp:115
JulianDate()
Construct an empty julian date initialized to 0.
Definition: perturb.cpp:40
bool operator>(const JulianDate &rhs) const
Compare if chronologically after than another time point.
Definition: perturb.cpp:107
JulianDate operator+(const double &delta_jd) const
Returns another time point offset by a number of days.
Definition: perturb.cpp:85
double operator-(const JulianDate &rhs) const
Returns the difference/delta in times as a fractional number of days.
Definition: perturb.cpp:80
bool operator<=(const JulianDate &rhs) const
Compare if earlier than or same as another time point.
Definition: perturb.cpp:111
bool operator<(const JulianDate &rhs) const
Compare if chronologically earlier than another time point.
Definition: perturb.cpp:103
JulianDate normalized() const
Get a normalized copy of a julian date.
Definition: perturb.cpp:74
JulianDate & operator-=(const double &delta_jd)
Subtracts a delta number of days offset to this time point.
Definition: perturb.cpp:99
double jd_frac
Smaller fractional number of days.
Definition: perturb.hpp:121
double jd
Fractional number of days since the epoch (4713 B.C.)
Definition: perturb.hpp:119
Represents the output prediction from SGP4.
Definition: perturb.hpp:198
Vec3 velocity
Velocity in the TEME frame in [km/s].
Definition: perturb.hpp:204
JulianDate epoch
Time-stamp of the state vector.
Definition: perturb.hpp:200
Vec3 position
Position in the TEME frame in [km].
Definition: perturb.hpp:202
Represents a pre-parsed TLE record.
Definition: tle.hpp:65
Definition: sgp4.hpp:90
Header for custom TLE (two line element) processing.