Astro  0.0.0
A C++ library for space dynamics
Loading...
Searching...
No Matches
Planets.hh
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
2 * Copyright (c) 2025, Davide Stocco and Enrico Bertolazzi. *
3 * *
4 * The Astro project is distributed under the GNU GPLv3. *
5 * *
6 * Davide Stocco Enrico Bertolazzi *
7 * University of Trento University of Trento *
8 * e-mail: davide.stocco@unitn.it e-mail: enrico.bertolazzi@unitn.it *
9\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
10
11#ifndef ASTRO_PLANETS_HH
12#define ASTRO_PLANETS_HH
13
14#include "Astro/Body.hh"
15#include "Astro/Utilities.hh"
16
17namespace Astro
18{
19 namespace Planets
20 {
21
22 static const Real KM3_S2_TO_AU3_DAY2{(KM_TO_AU*KM_TO_AU*KM_TO_AU)/(SEC_TO_DAY*SEC_TO_DAY)};
24
25 /*\
26 | ____
27 | / ___| _ _ _ __
28 | \___ \| | | | '_ \
29 | ___) | |_| | | | |
30 | |____/ \__,_|_| |_|
31 |
32 \*/
33
34 static Real const Sun_mass_KG{1.9885E30};
35 static Real const Sun_radius_KM{695700.0};
37 static Real const Sun_mu_KM3_S2{1.32712440018E11};
39
40 /*\
41 | _____ _ _
42 | | ____|__ _ _ __| |_| |__
43 | | _| / _` | '__| __| '_ \
44 | | |__| (_| | | | |_| | | |
45 | |_____\__,_|_| \__|_| |_|
46 |
47 \*/
48
49 static Real const Earth_mass_KG{5.97219E24};
50 static Real const Earth_radius_KM{6378.1370};
52 static Real const Earth_mu_KM3_S2{398600.4418};
55
67 {
69 {
70 this->a = 1.00000011; // Semi-major axis (AU)
71 this->e = 0.01671022; // Eccentricity (-)
72 this->i = Deg_To_Rad(0.00005); // Inclination (rad)
73 this->Omega = Deg_To_Rad(-11.26064); // Longitude of the ascending node (rad)
74 this->omega = Deg_To_Rad(102.93768193); // Argument of periapsis (rad)
75 }
76 };
77
83 inline Body Earth()
84 {
85 Body earth("Earth", Earth_mass_KG, Earth_radius_AU);
86 earth.set_orbit().set_factor(Factor::POSIGRADE);
89 earth.set_epoch(51544.0); // J2000 epoch (MJD 2451545.0 = JD 51544.5)
90 earth.set_epoch_anomaly().set_M(Deg_To_Rad(100.46435), earth.orbit().keplerian(), Factor::POSIGRADE);
91 return earth;
92 }
93
94 static constexpr Real EARTH_MAG_MOMENT{7.96e15};
95
102 inline Vector3 EarthMagneticFieldDipole(Vector3 const & position)
103 {
104 // Compute radial distance
105 Real r{position.norm()};
106 if (r < EPSILON_LOW) {return ZEROS_VEC3;} // avoid division by zero
107
108 // Unit vector
109 Vector3 r_hat{position/r};
110
111 // Magnetic dipole moment aligned with z-axis (simplified)
112 Vector3 m(0.0, 0.0, EARTH_MAG_MOMENT);
113
114 Vector3 B{(3.0 * r_hat * m.dot(r_hat) - m) / Power3(r)};
115
116 return B;
117 }
118
119 /*\
120 | __ __
121 | | \/ | ___ ___ _ __
122 | | |\/| |/ _ \ / _ \| '_ \
123 | | | | | (_) | (_) | | | |
124 | |_| |_|\___/ \___/|_| |_|
125 |
126 \*/
127
128 static Real const Moon_mass_KG{7.34767309E22};
129 static Real const Moon_radius_KM{1737.400};
130 static Real const Moon_radius_AU{Moon_radius_KM*KM_TO_AU};
131 static Real const Moon_mu_M3S2{4.9048695E12};
132 static Real const Moon_mu_KM3_S2{Moon_mu_M3S2/1.0E9};
134
146 {
148 {
149 this->a = 0.002569555; // Semi-major axis (AU)
150 this->e = 0.0549006; // Eccentricity (-)
151 this->i = Deg_To_Rad(5.145396); // Inclination (rad)
152 this->Omega = Deg_To_Rad(125.1228); // Longitude of the ascending node (rad)
153 this->omega = Deg_To_Rad(318.0634); // Argument of periapsis (rad)
154 }
155 };
156
161 inline Body Moon()
162 {
163 Body moon("Moon", Moon_mass_KG, Moon_radius_AU);
164 moon.set_orbit().set_factor(Factor::POSIGRADE);
167 moon.set_epoch(51544.0); // J2000 epoch (JD 2451545.0 = MJD 51544.5)
168 moon.set_epoch_anomaly().set_M(Deg_To_Rad(134.96340251), moon.orbit().keplerian(), Factor::POSIGRADE);
169 return moon;
170 }
171
172 } // namespace Planets
173
174} // namespace Astro
175
176#endif // ASTRO_PLANETS_HH
Astronomical body class container.
Definition Body.hh:45
Orbit const & orbit() const
Definition Body.hh:118
void set_epoch(Real const t_epoch)
Definition Body.hh:173
Orbit & set_orbit()
Definition Body.hh:124
Anomaly & set_epoch_anomaly()
Definition Body.hh:136
Keplerian const & keplerian() const
Definition Orbit.hh:140
void set_mu(Real const t_mu)
Definition Orbit.hh:322
void set_factor(Factor t_factor)
Definition Orbit.hh:310
void set_keplerian(Real const t_a, Real const t_e, Real const t_i, Real const t_Omega, Real const t_omega, Real const nu)
Definition Orbit.hh:151
Definition Planets.hh:20
static Real const Moon_radius_AU
Definition Planets.hh:130
static Real const Moon_mass_KG
Definition Planets.hh:128
static Real const Moon_mu_M3S2
Definition Planets.hh:131
static Real const Moon_mu_AU3_DAY2
Definition Planets.hh:133
Body Earth()
Create a Earth object with J2000 Keplerian orbital elements.
Definition Planets.hh:83
static const Real KM3_S2_TO_AU3_DAY2
Definition Planets.hh:22
static Real const Sun_mass_KG
Definition Planets.hh:34
static Real const Sun_mu_AU3_DAY2
Definition Planets.hh:38
static Real const Moon_radius_KM
Definition Planets.hh:129
static Real const Earth_radius_KM
Definition Planets.hh:50
static Real const Earth_mu_AU3_DAY2
Definition Planets.hh:54
static Real const Sun_radius_AU
Definition Planets.hh:36
Body Moon()
Create a Moon object with Keplerian orbital elements.
Definition Planets.hh:161
static Real const Moon_mu_KM3_S2
Definition Planets.hh:132
static Real const Earth_mu_KM3_S2
Definition Planets.hh:52
static Real const Earth_mass_KG
Definition Planets.hh:49
static Real const Sun_radius_KM
Definition Planets.hh:35
static Real const Earth_mu_KM3_DAY2
Definition Planets.hh:53
static constexpr Real EARTH_MAG_MOMENT
Definition Planets.hh:94
Vector3 EarthMagneticFieldDipole(Vector3 const &position)
Compute the Eath magnetic field at a given positionusing the IGRF model.
Definition Planets.hh:102
static const Real AU3_DAY2_TO_KM3_S2
Definition Planets.hh:23
static Real const Sun_mu_KM3_S2
Definition Planets.hh:37
static Real const Earth_radius_AU
Definition Planets.hh:51
The namespace for the Astro library.
Definition Astro.hh:73
static Vector3 const ZEROS_VEC3
Definition Astro.hh:154
Real KM_To_AU(Real x)
Definition Utilities.hh:141
Real KM3_S2_To_KM3_DAY2(Real x)
Definition Utilities.hh:177
Real Deg_To_Rad(Real x)
Definition Utilities.hh:72
static Real const EPSILON_LOW
Definition Astro.hh:132
Real Power3(Real x)
Definition Utilities.hh:42
double Real
Definition Astro.hh:84
Eigen::Vector< Real, 3 > Vector3
Definition Astro.hh:93
Real KM3_S2_To_AU3_DAY2(Real x)
Definition Utilities.hh:181
void set_M(Real t_M, Keplerian const &kepl, Factor const I)
Definition OrbitalElements.hh:1173
Structure container for the (modified) Keplerian orbital elements.
Definition OrbitalElements.hh:230
Real i
Definition OrbitalElements.hh:233
Real omega
Definition OrbitalElements.hh:235
Real e
Definition OrbitalElements.hh:232
Real Omega
Definition OrbitalElements.hh:234
Real a
Definition OrbitalElements.hh:231
Structure container for the Earth J2000 Keplerian orbital elements for orbit about the Sun.
Definition Planets.hh:67
KeplerianEarth()
Definition Planets.hh:68
Structure container for the Moon Keplerian orbital elements for orbit about the Earth.
Definition Planets.hh:146
KeplerianMoon()
Definition Planets.hh:147