astrodynx.semimajor_axis#
- astrodynx.semimajor_axis(r_mag, v_mag, mu=1)[source]#
Returns the semimajor axis of a two-body orbit.
- Parameters:
r_mag (
ArrayLike) – Norm of the object’s position vector in the two-body system.v_mag (
ArrayLike) – Norm of the object’s velocity vector in the two-body system, which shape broadcast-compatible with r.mu (
ArrayLike) – Gravitational parameter of the central body; shape broadcast-compatible with r and v.
- Return type:
- Returns:
The semimajor axis of the orbit.
- Notes
The semimajor axis is calculated using equation (3.16):
\[ a = \left( \frac{2}{r} - \frac{v^2}{\mu} \right)^{-1} \]where \(a\) is the semimajor axis, \(r\) is the norm of the position vector, \(v\) is the norm of the velocity vector, and \(\mu\) is the gravitational parameter.- References
Battin, 1999, pp.116.
- Examples
A simple example of calculating the semimajor axis with a position vector norm of 1.0, velocity vector norm of 1.0, and gravitational parameter of 1.0:
>>> import jax.numpy as jnp >>> import astrodynx as adx >>> r = 1.0 >>> v = 1.0 >>> mu = 1.0 >>> adx.semimajor_axis(r, v, mu) 1.0
With broadcasting, you can calculate the semimajor axis for multiple position and velocity vectors:
>>> r = jnp.array([1.0, 2.0]) >>> v = jnp.array([1.0, 2.0]) >>> mu = jnp.array([1.0, 2.0]) >>> adx.semimajor_axis(r, v, mu) Array([ 1., -1.], dtype=float32)