titanss 0.0.1

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

pub const SIDEREAL_DAY_S: f64 = 15.945 * 86_400.0;
pub const SYNODIC_DAY_S: f64 = 15.95 * 86_400.0;
pub const AXIAL_TILT_DEG: f64 = 0.3;

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

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

impl TitanRotation {
    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() * TITAN_RADIUS_M
    }
    pub fn solar_drift_deg_per_earth_day(&self) -> f64 {
        360.0 * 86_400.0 / self.synodic_period_s
    }
}