45 #include "constexpertrig.h" 52 constexpr T RADIANS(T deg) {
53 return deg * M_PI / 180.;
57 constexpr T DEGREES(T rad) {
58 return rad * 180. / M_PI;
66 constexpr
static double RE = 6378.137;
67 constexpr
static double FL = 1. / 298.257224;
68 constexpr
static double GM = 3.986E5;
69 constexpr
static double J2 = 1.08263E-3;
70 constexpr
static double YM = 365.25;
71 constexpr
static double YT = 365.2421874;
72 constexpr
static double WW = 2. * M_PI / YT;
73 constexpr
static double WE = 2. * M_PI + WW;
74 constexpr
static double W0 = WE / 86400.;
75 constexpr
static double YG = 2014.;
76 constexpr
static double G0 = 99.5828;
77 constexpr
static double MAS0 = 356.4105;
78 constexpr
static double MASD = 0.98560028;
79 constexpr
static double EQC1 = 0.03340;
80 constexpr
static double EQC2 = 0.00035;
81 constexpr
static double INS = RADIANS(23.4375);
82 constexpr
static double CNS = cx_math::cos(INS);
83 constexpr
static double SNS = cx_math::sin(INS);
100 [[nodiscard]]
static constexpr std::tuple<T, T> mod(
const T x) {
103 return std::make_tuple(f, i);
107 [[maybe_unused]] [[nodiscard]]
static constexpr T to_integer(
const T x) {
113 [[maybe_unused]] [[nodiscard]]
static constexpr T to_fraction(
const T x) {
153 [[nodiscard]]
static long fnday(
long year, uint8_t month, uint8_t day);
160 [[nodiscard]]
static std::tuple<int, uint8_t, uint8_t> fndate(
long dt);
171 DateTime(
int year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t seconds)
172 :
DateTime() { settime(year, month, day, hour, minute, seconds); }
178 explicit DateTime(
bool setToNow =
false) : DN{0}, TN{0} {
198 void settime(
int year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t seconds);
204 [[nodiscard]] std::tuple<int, uint, uint, uint, uint, uint>
207 [[nodiscard]] time_t mktime()
const;
209 bool operator<(
const DateTime &rhs)
const;
211 bool operator>(
const DateTime &rhs)
const {
return (rhs < *
this); }
221 double operator-(
const DateTime &rhs)
const;
227 auto t = time(
nullptr);
229 int yr = tm->tm_year + 1900;
230 uint8_t mo = tm->tm_mon + 1;
231 uint8_t dy = tm->tm_mday;
232 uint8_t hr = tm->tm_hour;
233 uint8_t mn = tm->tm_min;
234 uint8_t sc = tm->tm_sec;
236 settime(yr, mo, dy, hr, mn, sc);
239 [[maybe_unused]] std::ostream &print_on(std::ostream &os)
const {
240 auto[yr, mo, da, h, m, s] = gettime();
241 os << yr <<
'-' << (long) mo <<
'-' << (
long) da <<
' ' << (long) h <<
':' << (
long) m <<
':' << (long) s;
246 inline std::ostream &operator<<(std::ostream &os,
const DateTime &dateTime) {
return dateTime.print_on(os); }
269 Observer(
double const &latitude,
double const &longitude,
double const &elevation);
314 double N0{}, A_0{}, B_0{};
316 double QD{}, WD{}, DC{};
324 void tle(
const std::string_view &l1,
const std::string_view &l2);
341 explicit Satellite(
const std::array<std::string_view, 3> &ephemeris);
343 void setEphemeris(
const std::array<std::string_view,3> &ephemeris);
345 constexpr
explicit operator bool()
const noexcept {
return isValid; }
351 void predict(
const DateTime &dateTime);
357 [[nodiscard]] std::string_view
getName()
const {
379 bool eclipsed(
const Sun &sp);
387 [[nodiscard]] std::tuple<double, double, double, double> topo(
const Observer &obs);
394 [[nodiscard]] std::tuple<double, double> geo();
401 [[nodiscard]] std::tuple<double, double> celest();
407 [[nodiscard]]
double period()
const;
414 double viewingRadius(
double alt);
420 [[nodiscard]]
DateTime epoch()
const;
Encapsulate the day-in-space for orbital mechanics computations.
Definition: Plan13.h:141
Sun position in the sky.
Definition: Plan13.h:282
DateTime(int year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t seconds)
Constructor to initialize to a calendar date and clock time.
Definition: Plan13.h:171
static constexpr double MAX_TLE_AGE
max age to use a TLE, days (except moon)
Definition: Plan13.h:96
bool checkSatEpoch() const
Determine if the sat epoch is known to be good.
Definition: Plan13.h:365
Data specifying an observer for computing relative visibility data.
Definition: Plan13.h:254
Plan13 general functions and constants.
Definition: Plan13.h:65
DateTime(bool setToNow=false)
Default constructor with the option to initialzie to current time.
Definition: Plan13.h:178
std::string_view getName() const
Access the satellite name.
Definition: Plan13.h:357
static constexpr double MAX_TLE_AGE_MOON
max age to use a TLE, days for the moon
Definition: Plan13.h:97
GaugeIndex operator+(const GaugeIndex &gaugeIndex, unsigned long increment)
Add an unsigned integer to a GaugeIndex.
Definition: Gauge.h:60
Satellite orbital mechanics.
Definition: Plan13.h:294