ioss 0.0.3

Io celestial simulation crate for the MilkyWay SolarSystem workspace
Documentation
use crate::IO_RADIUS_M;
use std::f64::consts::PI;

pub const SIDEREAL_DAY_S: f64 = 1.769 * 86_400.0;
pub const SYNODIC_DAY_S: f64 = 1.77 * 86_400.0;
pub const AXIAL_TILT_DEG: f64 = 0.05;

#[derive(Debug, Clone, Copy, PartialEq)]
pub struct IoRotation {
    pub sidereal_period_s: f64,
    pub synodic_period_s: f64,
    pub axial_tilt_deg: f64,
    pub synchronous: bool,
}

impl Default for IoRotation {
    fn default() -> Self {
        Self::new()
    }
}

impl IoRotation {
    pub fn new() -> Self {
        Self {
            sidereal_period_s: SIDEREAL_DAY_S,
            synodic_period_s: SYNODIC_DAY_S,
            axial_tilt_deg: AXIAL_TILT_DEG,
            synchronous: true,
        }
    }
    pub fn angular_velocity_rad_s(&self) -> f64 {
        2.0 * PI / self.sidereal_period_s
    }
    pub fn equatorial_speed_m_s(&self) -> f64 {
        self.angular_velocity_rad_s() * IO_RADIUS_M
    }
    pub fn solar_drift_deg_per_earth_day(&self) -> f64 {
        360.0 * 86_400.0 / self.synodic_period_s
    }
}