Vulcan
Aerospace Engineering Utilities Built on Janus
Loading...
Searching...
No Matches
EarthModel.hpp
Go to the documentation of this file.
1// Vulcan Earth Model
2// Ellipsoid parameters and Earth rotation models for coordinate transformations
3#pragma once
4
6
7#include <cmath>
8#include <memory>
9
10namespace vulcan {
11
12// =============================================================================
13// EarthModel - Ellipsoid Parameters
14// =============================================================================
15
27struct EarthModel {
28 double a;
29 double f;
30 double omega;
31 double mu;
32
33 // Derived quantities (computed at construction)
34 double b;
35 double e2;
36 double e_prime2;
37
39 constexpr EarthModel(double a_, double f_, double omega_, double mu_)
40 : a(a_), f(f_), omega(omega_), mu(mu_), b(a_ * (1.0 - f_)),
41 e2(2.0 * f_ - f_ * f_),
42 e_prime2((2.0 * f_ - f_ * f_) / (1.0 - (2.0 * f_ - f_ * f_))) {}
43
45 static constexpr EarthModel WGS84() {
46 return EarthModel(constants::wgs84::a, // 6378137.0 m
47 constants::wgs84::f, // 1/298.257223563
48 constants::wgs84::omega, // 7.292115e-5 rad/s
49 constants::wgs84::mu // 3.986004418e14 m³/s²
50 );
51 }
52
54 static constexpr EarthModel Spherical() {
55 return EarthModel(constants::earth::R_mean, // 6371008.8 m
56 0.0, // No flattening (perfect sphere)
57 constants::earth::omega, // 7.292115e-5 rad/s
58 constants::earth::mu // 3.986004418e14 m³/s²
59 );
60 }
61};
62
63// =============================================================================
64// EarthRotationModel - Abstract Interface
65// =============================================================================
66
76 virtual ~EarthRotationModel() = default;
77
81 [[nodiscard]] virtual double gmst(double t_seconds) const = 0;
82
85 [[nodiscard]] virtual double ecef_to_eci_angle(double t_seconds) const {
86 return gmst(t_seconds);
87 }
88};
89
90// =============================================================================
91// ConstantOmegaRotation - Simple Rotation Model (Phase 3a)
92// =============================================================================
93
107 double omega;
108 double theta0;
109
110 constexpr ConstantOmegaRotation(double omega_, double theta0_ = 0.0)
111 : omega(omega_), theta0(theta0_) {}
112
113 [[nodiscard]] double gmst(double t_seconds) const override {
114 return theta0 + omega * t_seconds;
115 }
116
121
123 static constexpr ConstantOmegaRotation from_model(const EarthModel &model,
124 double theta0 = 0.0) {
125 return ConstantOmegaRotation(model.omega, theta0);
126 }
127};
128
129// =============================================================================
130// GMSTRotation - GMST-Based Rotation Model (Optional Enhancement)
131// =============================================================================
132
141 double jd_epoch;
142
143 explicit constexpr GMSTRotation(double jd_epoch_ = 2451545.0) // J2000.0
144 : jd_epoch(jd_epoch_) {}
145
146 [[nodiscard]] double gmst(double t_seconds) const override {
147 // Convert seconds to Julian centuries from J2000.0
148 constexpr double sec_per_century = 86400.0 * 36525.0;
149 const double T = t_seconds / sec_per_century;
150
151 // IAU 1982 GMST formula (in seconds of time)
152 const double gmst_sec = 67310.54841 +
153 (876600.0 * 3600.0 + 8640184.812866) * T +
154 0.093104 * T * T - 6.2e-6 * T * T * T;
155
156 // Convert seconds of time to radians
157 // 1 second of time = 15 arcsec = 15/3600 deg = π/(43200) rad
158 constexpr double sec_to_rad = constants::angle::pi / 43200.0;
159 return std::fmod(gmst_sec * sec_to_rad, 2.0 * constants::angle::pi);
160 }
161};
162
163} // namespace vulcan
constexpr double pi
Pi.
Definition Constants.hpp:153
constexpr double omega
Angular velocity [rad/s].
Definition Constants.hpp:37
constexpr double R_mean
Mean radius [m].
Definition Constants.hpp:22
constexpr double mu
Gravitational parameter (GM) [m^3/s^2].
Definition Constants.hpp:13
constexpr double omega
Angular velocity [rad/s].
Definition Constants.hpp:63
constexpr double mu
Gravitational parameter [m^3/s^2].
Definition Constants.hpp:60
constexpr double a
Semi-major axis (equatorial radius) [m].
Definition Constants.hpp:45
constexpr double f
Flattening.
Definition Constants.hpp:48
Definition Aerodynamics.hpp:11
double theta0
Initial angle at t=0 [rad].
Definition EarthModel.hpp:108
static constexpr ConstantOmegaRotation from_model(const EarthModel &model, double theta0=0.0)
Create rotation model using specified Earth model.
Definition EarthModel.hpp:123
static constexpr ConstantOmegaRotation from_wgs84(double theta0=0.0)
Create rotation model using WGS84 angular velocity.
Definition EarthModel.hpp:118
double gmst(double t_seconds) const override
Definition EarthModel.hpp:113
double omega
Angular velocity [rad/s].
Definition EarthModel.hpp:107
constexpr ConstantOmegaRotation(double omega_, double theta0_=0.0)
Definition EarthModel.hpp:110
Definition EarthModel.hpp:27
double b
Semi-minor axis (polar radius) [m].
Definition EarthModel.hpp:34
double omega
Angular velocity [rad/s].
Definition EarthModel.hpp:30
double a
Semi-major axis (equatorial radius) [m].
Definition EarthModel.hpp:28
constexpr EarthModel(double a_, double f_, double omega_, double mu_)
Construct an EarthModel with derived quantities computed.
Definition EarthModel.hpp:39
static constexpr EarthModel WGS84()
WGS84 reference ellipsoid (most common for GPS/navigation).
Definition EarthModel.hpp:45
double f
Flattening (a-b)/a.
Definition EarthModel.hpp:29
static constexpr EarthModel Spherical()
Spherical Earth (for simplified calculations).
Definition EarthModel.hpp:54
double e_prime2
Second eccentricity squared: e'² = e²/(1-e²).
Definition EarthModel.hpp:36
double mu
Gravitational parameter (GM) [m³/s²].
Definition EarthModel.hpp:31
double e2
First eccentricity squared: e² = 2f - f²
Definition EarthModel.hpp:35
Definition EarthModel.hpp:75
virtual ~EarthRotationModel()=default
virtual double gmst(double t_seconds) const =0
virtual double ecef_to_eci_angle(double t_seconds) const
Definition EarthModel.hpp:85
constexpr GMSTRotation(double jd_epoch_=2451545.0)
Definition EarthModel.hpp:143
double gmst(double t_seconds) const override
Definition EarthModel.hpp:146
double jd_epoch
Julian Date of the reference epoch.
Definition EarthModel.hpp:141