use crate::PHOBOS_RADIUS_M;
use std::f64::consts::PI;

pub const SIDEREAL_DAY_S: f64 = 0.319 * 86_400.0;
pub const SYNODIC_DAY_S: f64 = 0.32 * 86_400.0;
pub const AXIAL_TILT_DEG: f64 = 0.0;

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

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

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