use crate::config::parameters::*;
pub struct SatelliteGravity {
pub mass: f64,
pub radius: f64,
}
impl SatelliteGravity {
pub fn new(mass: f64, radius: f64) -> Self {
Self { mass, radius }
}
pub fn surface_acceleration(&self) -> f64 {
G * self.mass / (self.radius * self.radius)
}
pub fn escape_velocity(&self) -> f64 {
(2.0 * G * self.mass / self.radius).sqrt()
}
pub fn orbital_velocity(&self, distance: f64) -> f64 {
(G * self.mass / distance).sqrt()
}
pub fn orbital_period(&self, distance: f64) -> f64 {
orbital_period(self.mass, distance)
}
pub fn synchronous_orbit_radius(&self, rotation_period: f64) -> f64 {
synchronous_orbit_radius(self.mass, rotation_period)
}
pub fn sphere_of_influence(&self, parent_mass: f64, distance: f64) -> f64 {
distance * (self.mass / parent_mass).powf(2.0 / 5.0)
}
}
pub fn two_body_force(m1: f64, m2: f64, r: f64) -> f64 {
G * m1 * m2 / (r * r)
}
pub fn hill_sphere(a: f64, m_satellite: f64, m_planet: f64) -> f64 {
a * (m_satellite / (3.0 * m_planet)).cbrt()
}
pub fn roche_limit(r_primary: f64, rho_primary: f64, rho_secondary: f64) -> f64 {
2.456 * r_primary * (rho_primary / rho_secondary).cbrt()
}
pub fn roche_limit_rigid(r_primary: f64, rho_primary: f64, rho_secondary: f64) -> f64 {
1.26 * r_primary * (rho_primary / rho_secondary).cbrt()
}
pub fn gravitational_binding_energy(mass: f64, radius: f64) -> f64 {
3.0 * G * mass * mass / (5.0 * radius)
}
pub fn mutual_hill_radius(a1: f64, m1: f64, a2: f64, m2: f64, m_planet: f64) -> f64 {
let a_avg = (a1 + a2) / 2.0;
a_avg * ((m1 + m2) / (3.0 * m_planet)).cbrt()
}
pub fn tisserand_parameter(a_sat: f64, a_planet: f64, e: f64, i: f64) -> f64 {
a_planet / a_sat + 2.0 * ((a_sat / a_planet) * (1.0 - e * e)).sqrt() * i.cos()
}