Documentation
¶
Index ¶
- Constants
- func Apoapsis(a, e float64) float64
- func Degrees(rad float64) float64
- func EccentricAnomaly(e float64, m float64) float64
- func Force(p1 f64.Vec3, p2 f64.Vec3, m1 float64, m2 float64) f64.Vec3
- func OrbitalElements(r f64.Vec3, v f64.Vec3, m1 float64, m2 float64) (a, e, w, lan, i, m float64)
- func Periapsis(a, e float64) float64
- func Period(a, m1, m2 float64) float64
- func Radians(deg float64) float64
- func StateVectors(a, e, w, lan, i, m0, t, m1, m2 float64) (f64.Vec3, f64.Vec3)
Constants ¶
const ( G float64 = 6.6725985e-11 Pi float64 = 3.14159265358979 Epsilon float64 = 1e-15 // very small number Epsilon6 float64 = 1e-06 // small number )
Variables ¶
This section is empty.
Functions ¶
func EccentricAnomaly ¶ added in v0.3.0
EccentricAnomaly (rad) using Newton's method.
e: eccentricity (0-1), m: mean anomaly (rad).
func Force ¶
Force vector due to gravity (N) using Netwon's law of universal gravitation.
p1: position of the primary body (m), p2: position of the secondary body (m), m1: mass of the primary body (kg), m2: mass of the secondary body (kg).
apply {-x, -y, -z} to b1, apply {x, y, z} to b2.
https://en.wikipedia.org/wiki/Newton%27s_law_of_universal_gravitation#Vector_form
func OrbitalElements ¶
OrbitalElements from Cartesian State Vectors.
accepts: r: position relative to primary body (m), v: velocity relative to primary body (m/s), m1: mass of the primary body (kg), m2: mass of the secondary body (kg).
returns: a: semi-major axis (m), e: eccentricity (0-1), w: argument of periapsis (rad), lan: longitude of ascending node (rad), i: inclination (rad), m: mean anomaly (rad).
The various singularities are removed by applying the following transformations where epsilon (eps) is equal to 1e-15. While the transformations are clearly not ideal it is the best I can do for now with my limited math knowledge.
rZ=0 -> rZ=eps, vZ=0 -> vZ=eps, e=0 -> e=eps, i=0 -> i=eps, i=Pi -> i=Pi-eps [180 (deg) = Pi (rad)].
If the primary body is on-rails then set m2 to 0. If you don't set m2 to 0 then the elements will be predicted based on the bodies both orbiting their combined center of mass which is incorrect if the primary body is on-rails.
func Period ¶
Period (s).
a: semi-major axis (m), m1: mass of the primary body (kg), m2: mass of the secondary body (kg).
If the primary body is on-rails then set m2 to 0. See OrbitalElements for more details.
func StateVectors ¶
StateVectors at t seconds after epoch from Keplerian Orbital Elements.
accepts: a: semi-major axis (m), e: eccentricity (0-1), w: argument of periapsis (rad), lan: longitude of ascending node (rad), i: inclination (rad), m0: mean anomaly at epoch (rad), t: time since epoch (seconds), m1: mass of the primary body (kg), m2: mass of the secondary body (kg).
returns: r: position relative to primary body (m), v: velocity relative to primary body (m/s).
If the primary body is on-rails then set m2 to 0. See OrbitalElements for more details.
Types ¶
This section is empty.