SPH
TwoBody.h
Go to the documentation of this file.
1 #pragma once
2 
5 
7 
8 namespace Kepler {
9 
15 struct Elements {
16  Float a;
17  Float e;
18  Float i;
19 
22 
23 
25  Float periapsisArgument() const;
26 
28  Float ascendingNode() const;
29 
31  Float pericenterDist() const;
32 
34  Float semiminorAxis() const;
35 };
36 
44 Optional<Elements> computeOrbitalElements(const Float M, const Float mu, const Vector& r, const Vector& v);
45 
50 Float solveKeplersEquation(const Float M, const Float e, const Size iterCnt = 10);
51 
54 
57 
64 Vector position(const Float a, const Float e, const Float u);
65 
73 Vector velocity(const Float a, const Float e, const Float u, const Float n);
74 
76 Float meanMotion(const Float a, const Float m_total);
77 
78 } // namespace Kepler
79 
NAMESPACE_SPH_BEGIN
Definition: BarnesHut.cpp:13
uint32_t Size
Integral type used to index arrays (by default).
Definition: Globals.h:16
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
Definition: Globals.h:13
#define NAMESPACE_SPH_END
Definition: Object.h:12
Wrapper of type value of which may or may not be present.
Basic vector algebra. Computations are accelerated using SIMD.
Wrapper of type value of which may or may not be present.
Definition: Optional.h:23
Definition: TwoBody.h:8
Optional< Elements > computeOrbitalElements(const Float M, const Float mu, const Vector &r, const Vector &v)
Computes the orbital elements, given position and velocity of a body.
Definition: TwoBody.cpp:37
Float trueAnomalyToEccentricAnomaly(const Float v, const Float e)
Computes the eccentric anomaly from the true anomaly and the eccentricity.
Definition: TwoBody.cpp:76
Float eccentricAnomalyToTrueAnomaly(const Float u, const Float e)
Computes the true anomaly from the eccentric anomaly and the eccentricity.
Definition: TwoBody.cpp:70
Float solveKeplersEquation(const Float M, const Float e, const Size iterCnt=10)
Computes the eccentric anomaly by solving the Kepler's equation.
Definition: TwoBody.cpp:62
Float meanMotion(const Float a, const Float m_total)
Computes the mean motion from the Kepler's 3rd law.
Definition: TwoBody.cpp:90
Vector position(const Float a, const Float e, const Float u)
Computes the position on the elliptic trajectory.
Definition: TwoBody.cpp:82
Vector velocity(const Float a, const Float e, const Float u, const Float n)
Computes the velocity vector on the elliptic trajectory.
Definition: TwoBody.cpp:86
Object holding Keplerian orbital elements of a body.
Definition: TwoBody.h:15
Float e
Excentricity.
Definition: TwoBody.h:17
Float periapsisArgument() const
Computes the argument of periapsis of the orbit. In the singular case e=0, returns 0.
Definition: TwoBody.cpp:15
Vector K
Laplace vector, integral of motion with direction towards pericenter.
Definition: TwoBody.h:21
Float pericenterDist() const
Computes the distance of the pericenter.
Definition: TwoBody.cpp:29
Float ascendingNode() const
Computes the longitude of the ascending node. In the singular case i=0, reutrns 0.
Definition: TwoBody.cpp:6
Float i
Inclination with respect to the z=0 plane.
Definition: TwoBody.h:18
Float a
Semi-major axis.
Definition: TwoBody.h:16
Float semiminorAxis() const
Computes the semi-minor axis.
Definition: TwoBody.cpp:33
Vector L
Angular momentum, perpendicular to the orbital plane.
Definition: TwoBody.h:20