use crate::ESCAPE_VELOCITY_M_S;

const R_GAS: f64 = 8.314_462_618;

pub fn thermal_speed_m_s(temperature_k: f64, molar_mass_kg_mol: f64) -> f64 {
    (3.0 * R_GAS * temperature_k / molar_mass_kg_mol).sqrt()
}

pub fn jeans_parameter(temperature_k: f64, molar_mass_kg_mol: f64) -> f64 {
    let speed = thermal_speed_m_s(temperature_k, molar_mass_kg_mol);
    0.5 * (ESCAPE_VELOCITY_M_S / speed).powi(2)
}

pub fn ballistic_hop_range_m(launch_speed_m_s: f64, launch_angle_deg: f64) -> f64 {
    let angle = launch_angle_deg.to_radians();
    launch_speed_m_s.powi(2) * (2.0 * angle).sin() / crate::SURFACE_GRAVITY_M_S2
}
