99 this->m_cart.
r << r_x, r_y, r_z;
100 this->m_cart.
v << v_x, v_y, v_z;
114 this->
set_cartesian(t_r(0), t_r(1), t_r(2), t_v(0), t_v(1), t_v(2));
124 this->
set_cartesian(t_cart(0), t_cart(1), t_cart(2), t_cart(3), t_cart(4), t_cart(5));
155 this->m_kepl.
a = t_a;
156 this->m_kepl.
e = t_e;
157 this->m_kepl.
i = t_i;
158 this->m_kepl.
Omega = t_Omega;
159 this->m_kepl.
omega = t_omega;
175 this->
set_keplerian(t_kepl(0), t_kepl(1), t_kepl(2), t_kepl(3), t_kepl(4), nu);
207 this->m_equi.
p = t_p;
208 this->m_equi.
f = t_f;
209 this->m_equi.
g = t_g;
210 this->m_equi.
h = t_h;
211 this->m_equi.
k = t_k;
227 this->
set_equinoctial(t_equi(0), t_equi(1), t_equi(2), t_equi(3), t_equi(4), L);
256 this->m_quat.
q.x() = t_q_1;
257 this->m_quat.
q.y() = t_q_2;
258 this->m_quat.
q.z() = t_q_3;
259 this->m_quat.
q.w() = t_q_4;
288 this->m_type = Type::ELLIPTIC;
290 this->m_type = Type::PARABOLIC;
292 this->m_type = Type::HYPERBOLIC;
294 this->m_type = Type::CIRCULAR;
296 ASTRO_ERROR(
"Astro::Orbit::type(...): invalid eccentricity detected: e = " << e);
329 std::ostringstream os;
331 "Cartesian orbit parameters:" << std::endl <<
332 this->m_cart.
info() << std::endl <<
333 "Keplerian orbit parameters:" << std::endl <<
334 this->m_kepl.
info() << std::endl <<
335 "Equinoctial orbit parameters:" << std::endl <<
336 this->m_equi.
info() << std::endl <<
337 "Quaternionic orbit parameters:" << std::endl <<
338 this->m_quat.
info() << std::endl <<
339 "Orbit:" << std::endl <<
340 "µ: grav. const. = " << this->m_mu <<
" (UA³/day²)" << std::endl <<
341 "type = " << (this->m_type == Type::UNDEFINED ?
"undefined" :
342 (this->m_type == Type::ELLIPTIC ?
"elliptic" :
343 (this->m_type == Type::PARABOLIC ?
"parabolic" :
344 (this->m_type == Type::HYPERBOLIC ?
"hyperbolic" :
"undefined")))) << std::endl <<
345 "factor = " << (this->m_factor == Factor::UNDEFINED ?
"undefined" :
346 (this->m_factor == Factor::POSIGRADE ?
"posigrade" :
347 (this->m_factor == Factor::RETROGRADE ?
"retrograde" :
"undefined"))) << std::endl;
361 this->m_cart.
reset();
362 this->m_kepl.
reset();
363 this->m_equi.
reset();
364 this->m_quat.
reset();
365 this->m_type = Type::UNDEFINED;
366 this->m_factor = Factor::UNDEFINED;
377 #define CMD "Astro::Orbit::sanity_check(...): "
379 if (this->m_factor == Factor::UNDEFINED) {
ASTRO_ERROR(
CMD "orbit factor is undefined.");
return false;}
380 if (std::isnan(this->m_mu)) {
ASTRO_ERROR(
CMD "gravitational constant is not set.");
return false;}
392 Real s_Omega{std::sin(this->m_kepl.
Omega)};
393 Real c_Omega{std::cos(this->m_kepl.
Omega)};
394 Real s_omega{std::sin(this->m_kepl.
omega)};
395 Real c_omega{std::cos(this->m_kepl.
omega)};
396 Real s_i{std::sin(this->m_kepl.
i)};
397 Real c_i{std::cos(this->m_kepl.
i)};
401 c_Omega*c_omega - s_Omega*s_omega*c_i, -c_Omega*s_omega - s_Omega*c_omega*c_i, s_Omega*s_i,
402 s_Omega*c_omega + c_Omega*s_omega*c_i, -s_Omega*s_omega + c_Omega*c_omega*c_i, -c_Omega*s_i,
403 s_i*s_omega, s_i*c_omega, c_i;
413 Real h{this->m_equi.
h};
414 Real k{this->m_equi.
k};
418 Real I{
static_cast<Real>(this->m_factor)};
422 1.0-h2+k2, 2.0*I*hk, 2.0*h,
423 2.0*hk, I*(1.0+h2-k2), -2.0*k,
424 -2.0*I*h, 2.0*k, I*(1.0-h2-k2);
425 return R / (1.0+h2+k2);
439 "Astro::Orbit::cartesian_to_frenet_rtn(...): invalid input vectors detected.");
446 rtn.col(0).normalize();
449 rtn.col(2) = r.cross(v);
450 rtn.col(2).normalize();
453 rtn.col(1) = rtn.col(2).cross(r);
454 rtn.col(1).normalize();
468 Real h{this->m_equi.
h};
470 Real c_L{std::cos(L)};
471 Real s_L{std::sin(L)};
480 ((h2-k2+1)*c_L+2.0*I*hk*s_L)/bf, ((k2-h2-1.0)*s_L+2.0*hk*I*c_L)/bf, 2.0*k/bf,
481 (2.0*hk*c_L-I*(h2-k2-1.0)*s_L)/bf, (I*(1.0+k2-h2)*c_L-2.0*hk*s_L)/bf, -2.0*h/bf,
482 (2.0*(h*s_L-c_L*k*I))/bf, (2.0*k*I*s_L+2.0*h*c_L)/bf, I*(1-h2-k2)/bf;
496 return this->cartesian_to_frenet_rtn(r, v) * vec;
508 return this->equinoctial_to_frenet_rtn(L) * vec;
521 return this->cartesian_to_frenet_rtn(r, v).transpose() * vec;
533 return this->equinoctial_to_frenet_rtn(L).transpose() * vec;
543 Real bf{std::sqrt(this->
m_equi.p * this->m_mu) / (1.0 + h2 + k2)};
545 L << 2.0 * this->
m_equi.k * bf, -2.0 * this->
m_equi.h * bf, (1.0 - (h2 + k2)) * bf;
546 if (this->
m_factor == Factor::RETROGRADE) {L.z() = -L.z();}
559 Real bf{this->
m_mu / (1.0 + h2 + k2)};
561 bf * ((1.0 + h2 - k2) * this->
m_equi.f + 2.0 * hk * this->m_equi.g),
562 bf * ((1.0 - h2 + k2) * this->m_equi.g + 2.0 * hk * this->m_equi.f),
563 bf * (2.0 * (this->m_equi.h * this->m_equi.g - this->m_equi.k * this->m_equi.f))
571 Real energy()
const {
580 Real period()
const {
582 #define CMD "Astro::Orbit::period(...): "
585 CMD "the orbit period is defined only for elliptic and circular orbits.");
587 return 2.0 * M_PI * std::sqrt(
Power3(this->
m_kepl.a) / this->m_mu);
604 Real M{epoch_anom.M + n * t};
607 if (this->
m_type == Type::ELLIPTIC || this->
m_type == Type::CIRCULAR) {
619 if (this->
m_factor == Factor::RETROGRADE) {lambda -= this->
m_kepl.Omega;}
620 else {lambda += this->
m_kepl.Omega;}
635 if (this->
m_kepl.e < 1.0) {
636 Real L0{this->compute_lambda(t, epoch_anom)};
637 Real L1{this->compute_lambda(t + dt, epoch_anom)};
639 Real pf{dt / this->period()};
643 while (dL < 0.0) {dL += 2.0 * M_PI;}
644 while (pf > 1.0) {dL += 2.0 * M_PI; pf -= 1.0;}
646 while (dL > 0.0) {dL -= 2.0 * M_PI;}
647 while (pf < -1.0) {dL -= 2.0 * M_PI; pf += 1.0;}
652 return this->compute_lambda(t + dt, epoch_anom);
#define ASTRO_ASSERT(COND, MSG)
Definition Astro.hh:43
#define ASTRO_ERROR(MSG)
Definition Astro.hh:32
Rotation equinoctial_to_reference() const
Definition Orbit.hh:411
Real m_mu
Definition Orbit.hh:53
OrbitalElements::Keplerian Keplerian
Definition Orbit.hh:41
OrbitalElements::Equinoctial Equinoctial
Definition Orbit.hh:42
Rotation keplerian_to_reference() const
Definition Orbit.hh:390
void set_keplerian(Keplerian const &t_kepl, Real const nu)
Definition Orbit.hh:183
OrbitalElements::Cartesian Cartesian
Definition Orbit.hh:40
Keplerian m_kepl
Definition Orbit.hh:48
void set_cartesian(Vector3 const &t_r, Vector3 const &t_v)
Definition Orbit.hh:112
Vector3 cartesian_rtn_to_xyz(Vector3 const &r, Vector3 const &v, Vector3 const &vec) const
Definition Orbit.hh:494
void set_cartesian(Cartesian const &t_cart)
Definition Orbit.hh:131
Quaternionic const & quaternionic() const
Definition Orbit.hh:244
void set_equinoctial(Equinoctial const &t_equi, Real const L)
Definition Orbit.hh:235
Orbit(Orbit const &)=default
Vector3 equinoctial_rtn_to_xyz(Vector3 const &vec) const
Definition Orbit.hh:505
void set_quaternionic(Quaternion const &t_quat)
Definition Orbit.hh:270
Factor m_factor
Definition Orbit.hh:52
Real mu() const
Definition Orbit.hh:316
Keplerian const & keplerian() const
Definition Orbit.hh:140
Type m_type
Definition Orbit.hh:51
void set_type(Real const e)
Definition Orbit.hh:285
void info(std::ostream &os)
Definition Orbit.hh:355
void set_equinoctial(Real const t_p, Real const t_f, Real const t_g, Real const t_h, Real const t_k, Real const L)
Definition Orbit.hh:203
Type type() const
Definition Orbit.hh:279
void reset()
Definition Orbit.hh:360
void set_cartesian(Real r_x, Real r_y, Real r_z, Real v_x, Real v_y, Real v_z)
Definition Orbit.hh:96
void set_equinoctial(Vector5 const &t_equi, Real const L)
Definition Orbit.hh:225
void set_mu(Real const t_mu)
Definition Orbit.hh:322
Equinoctial m_equi
Definition Orbit.hh:49
Orbit()
Definition Orbit.hh:59
void set_quaternionic(Real const t_q_1, Real const t_q_2, Real const t_q_3, Real const t_q_4)
Definition Orbit.hh:253
OrbitalElements::Anomaly Anomaly
Definition Orbit.hh:44
void set_keplerian(Vector5 const &t_kepl, Real const nu)
Definition Orbit.hh:173
std::string info() const
Definition Orbit.hh:328
bool sanity_check() const
Definition Orbit.hh:375
void set_cartesian(Vector6 const &t_cart)
Definition Orbit.hh:122
OrbitalElements::Quaternionic Quaternionic
Definition Orbit.hh:43
void set_factor(Factor t_factor)
Definition Orbit.hh:310
Factor factor() const
Definition Orbit.hh:304
Quaternionic m_quat
Definition Orbit.hh:50
Orbit & operator=(const Orbit &)=default
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
Equinoctial const & equinoctial() const
Definition Orbit.hh:192
Cartesian const & cartesian() const
Definition Orbit.hh:85
Orbit & operator=(Orbit &&)=default
Cartesian m_cart
Definition Orbit.hh:47
Real E_to_nu(Real const E, Real const e)
Definition OrbitalElements.hh:963
Real cartesian_to_keplerian(Cartesian const &cart, Real const mu, Keplerian &kepl)
Definition OrbitalElements.hh:1367
Real M_to_E(Real M, Real const e)
Definition OrbitalElements.hh:865
Real H_to_M(Real const H, Keplerian const &kepl)
Definition OrbitalElements.hh:1032
Real cartesian_to_equinoctial(Cartesian const &cart, Real const mu, Equinoctial &equi)
Definition OrbitalElements.hh:1576
void keplerian_to_cartesian(Keplerian const &kepl, Real const nu, Real const mu, Cartesian &cart)
Definition OrbitalElements.hh:1434
void equinoctial_to_cartesian(Equinoctial const &equi, Real const L, Real const mu, Cartesian &cart)
Definition OrbitalElements.hh:1487
Real H_to_nu(Real const H, Keplerian const &kepl)
Definition OrbitalElements.hh:1020
The namespace for the Astro library.
Definition Astro.hh:73
Eigen::Quaternion< Real > Quaternion
Definition Astro.hh:112
Eigen::Vector< Real, 5 > Vector5
Definition Astro.hh:97
Eigen::Matrix< Real, 3, 3 > Rotation
Definition Astro.hh:111
static Real const QUIET_NAN
Definition Astro.hh:134
Real Power3(Real x)
Definition Utilities.hh:42
Eigen::Vector< Real, 6 > Vector6
Definition Astro.hh:99
double Real
Definition Astro.hh:84
enum class Type :Integer { UNDEFINED=0, HYPERBOLIC=1, ELLIPTIC=2, CIRCULAR=3, PARABOLIC=4 } Type
Definition OrbitalElements.hh:27
enum class Factor :Integer { POSIGRADE=1, UNDEFINED=0, RETROGRADE=-1 } Factor
Definition OrbitalElements.hh:22
Eigen::Vector< Real, 3 > Vector3
Definition Astro.hh:93
static Real const EPSILON_MEDIUM
Definition Astro.hh:131
Structure container for the orbital anomalies.
Definition OrbitalElements.hh:1110
Structure container for the cartesian orbital elements.
Definition OrbitalElements.hh:59
Vector3 v
Definition OrbitalElements.hh:61
void reset()
Definition OrbitalElements.hh:145
Vector3 r
Definition OrbitalElements.hh:60
std::string info() const
Definition OrbitalElements.hh:128
Struct container for the (modified) equinoctial orbital elements.
Definition OrbitalElements.hh:439
Real h
Definition OrbitalElements.hh:443
Real g
Definition OrbitalElements.hh:442
Real p
Definition OrbitalElements.hh:440
Real f
Definition OrbitalElements.hh:441
std::string info() const
Definition OrbitalElements.hh:506
void reset()
Definition OrbitalElements.hh:526
Real k
Definition OrbitalElements.hh:444
Structure container for the (modified) Keplerian orbital elements.
Definition OrbitalElements.hh:230
Real i
Definition OrbitalElements.hh:233
std::string info() const
Definition OrbitalElements.hh:298
void reset()
Definition OrbitalElements.hh:318
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 quaternionic orbital elements.
Definition OrbitalElements.hh:676
void reset()
Definition OrbitalElements.hh:771
Quaternion q
Definition OrbitalElements.hh:677
std::string info() const
Definition OrbitalElements.hh:752