Skip to main content

gravitational_potential_energy

Function gravitational_potential_energy 

Source
pub fn gravitational_potential_energy(
    mass_a: f64,
    mass_b: f64,
    distance: f64,
) -> Option<f64>
Expand description

Computes gravitational potential energy between two masses.

Formula: U = -G * m1 * m2 / r

Returns None when either mass is negative, when distance is less than or equal to zero, or when the computed result is not finite.