Skip to main content

vis_viva_speed

Function vis_viva_speed 

Source
pub fn vis_viva_speed(
    mu: f64,
    orbital_radius: f64,
    semi_major_axis: f64,
) -> Option<f64>
Expand description

Computes orbital speed from the vis-viva equation.

Formula: v = sqrt(μ * (2/r - 1/a))

Returns None when mu is negative, when orbital_radius or semi_major_axis is less than or equal to zero, when the value under the square root is negative, or when the input or result is not finite.

§Examples

use use_orbit::vis_viva_speed;

assert!(vis_viva_speed(100.0, 10.0, 15.0).is_some_and(|value| value > 0.0));