astrodynx.angular_momentum#
- astrodynx.angular_momentum(pos_vec, vel_vec)[source]#
Returns the specific angular momentum of a two-body system.
- Parameters:
- Return type:
- Returns:
The specific angular momentum vector of the object in the two-body system.
- Notes
The specific angular momentum is calculated using the cross product of the position and velocity vectors:
\[ \boldsymbol{h} = \boldsymbol{r} \times \boldsymbol{v} \]where \(\boldsymbol{h}\) is the specific angular momentum, \(\boldsymbol{r}\) is the position vector, and \(\boldsymbol{v}\) is the velocity vector.- References
Battin, 1999, pp.115.
- Examples
A simple example of calculating the specific angular momentum for a position vector [1, 0, 0] and velocity vector [0, 1, 0]:
>>> import jax.numpy as jnp >>> import astrodynx as adx >>> pos_vec = jnp.array([1.0, 0.0, 0.0]) >>> vel_vec = jnp.array([0.0, 1.0, 0.0]) >>> adx.angular_momentum(pos_vec, vel_vec) Array([0., 0., 1.], dtype=float32)
With broadcasting, you can calculate the specific angular momentum for multiple position and velocity vectors:
>>> pos_vec = jnp.array([[1.0, 0.0, 0.0], [2.0, 0.0, 0.0]]) >>> vel_vec = jnp.array([[0.0, 1.0, 0.0], [0.0, 2.0, 0.0]]) >>> adx.angular_momentum(pos_vec, vel_vec) Array([[0., 0., 1.], [0., 0., 4.]], dtype=float32)