Astro.Orbit (ex_astro v0.3.0)

View Source

Work with SPICE osculating orbital elements.

Distances are expressed in kilometers, angles in radians, and epochs in Ephemeris Time (ET) seconds past J2000. The elements describe an instantaneous conic at their epoch rather than a long-term perturbation model.

The struct fields follow the element order used by SPICE's oscelt_c: periapsis radius, eccentricity, inclination, longitude of the ascending node, argument of periapsis, mean anomaly at epoch, epoch, and gravitational parameter.

Summary

Functions

Return the apoapsis radius in kilometers.

Solve Kepler's equation for the eccentric anomaly of an elliptic orbit.

Return the eccentric anomaly at an epoch.

Build an orbit from the eight elements returned by Astro.Ephemeris.oscelt/3.

Derive osculating elements from a Cartesian state vector.

Return the normalized mean anomaly at an epoch.

Return the mean motion in radians per second.

Look up a target's state and derive its osculating orbit around an observer.

Return the periapsis radius in kilometers.

Return the perifocal basis vectors in the elements' reference frame.

Return the orbital period in seconds.

Return the semi-major axis in kilometers.

Propagate an orbit to an epoch and return its Cartesian state vector.

Return the orbit's elements in the order expected by Astro.Ephemeris.conics/2.

Convert eccentric anomaly to true anomaly for an elliptic orbit.

Return the true anomaly at an epoch.

Types

t()

@type t() :: %Astro.Orbit{
  argp: float(),
  ecc: float(),
  inc: float(),
  lnode: float(),
  m0: float(),
  mu: float(),
  rp: float(),
  t0: float()
}

vec3()

@type vec3() :: {float(), float(), float()}

Functions

apoapsis(orbit)

@spec apoapsis(t()) :: float()

Return the apoapsis radius in kilometers.

eccentric_anomaly(mean_anomaly, ecc)

@spec eccentric_anomaly(float(), float()) :: float()

Solve Kepler's equation for the eccentric anomaly of an elliptic orbit.

eccentric_anomaly_at(orbit, et)

@spec eccentric_anomaly_at(t(), float()) :: float()

Return the eccentric anomaly at an epoch.

from_elements(list)

@spec from_elements([float()]) :: t()

Build an orbit from the eight elements returned by Astro.Ephemeris.oscelt/3.

from_state(state, et, mu)

@spec from_state([float()], float(), float()) :: {:ok, t()} | {:error, String.t()}

Derive osculating elements from a Cartesian state vector.

mean_anomaly_at(orbit, et)

@spec mean_anomaly_at(t(), float()) :: float()

Return the normalized mean anomaly at an epoch.

mean_motion(orbit)

@spec mean_motion(t()) :: float()

Return the mean motion in radians per second.

osculating(target, observer, et, opts \\ [])

@spec osculating(String.t(), String.t(), float(), keyword()) ::
  {:ok, t()} | {:error, String.t()}

Look up a target's state and derive its osculating orbit around an observer.

The default frame is "J2000" and the default aberration correction is "NONE". Pass :mu to override the observer's gravitational parameter; otherwise it is read from the loaded kernels with Astro.Support.gm/1.

periapsis(orbit)

@spec periapsis(t()) :: float()

Return the periapsis radius in kilometers.

perifocal_basis(orbit)

@spec perifocal_basis(t()) :: {vec3(), vec3(), vec3()}

Return the perifocal basis vectors in the elements' reference frame.

The tuple contains the unit vectors toward periapsis, 90 degrees ahead in the orbital plane, and normal to the orbital plane.

period(orbit)

@spec period(t()) :: float()

Return the orbital period in seconds.

semi_major_axis(orbit)

@spec semi_major_axis(t()) :: float()

Return the semi-major axis in kilometers.

Hyperbolic orbits use the standard negative semi-major axis convention.

state_at(orbit, et)

@spec state_at(t(), float()) :: {:ok, [float()]} | {:error, String.t()}

Propagate an orbit to an epoch and return its Cartesian state vector.

to_elements(orbit)

@spec to_elements(t()) :: [float()]

Return the orbit's elements in the order expected by Astro.Ephemeris.conics/2.

true_anomaly(eccentric_anomaly, ecc)

@spec true_anomaly(float(), float()) :: float()

Convert eccentric anomaly to true anomaly for an elliptic orbit.

true_anomaly_at(orbit, et)

@spec true_anomaly_at(t(), float()) :: float()

Return the true anomaly at an epoch.