use crate::{MARS_MASS, MARS_PHOBOS_DISTANCE_M, PHOBOS_RADIUS_M};

pub const LOVE_NUMBER_K2: f64 = 0.2;
pub const QUALITY_FACTOR_Q: f64 = 100.0;
const G: f64 = 6.674_30e-11;

#[derive(Debug, Clone, Copy, PartialEq)]
pub struct TidalResponse {
    pub love_number: f64,
    pub quality_factor: f64,
    pub mean_displacement_m: f64,
}

impl TidalResponse {
    pub fn current() -> Self {
        Self {
            love_number: LOVE_NUMBER_K2,
            quality_factor: QUALITY_FACTOR_Q,
            mean_displacement_m: 0.001,
        }
    }
}

pub fn mars_tidal_acceleration(angle_deg: f64) -> f64 {
    let angle_factor = angle_deg.to_radians().cos();
    2.0 * G * MARS_MASS * PHOBOS_RADIUS_M / MARS_PHOBOS_DISTANCE_M.powi(3) * angle_factor
}

pub fn tidal_bulge_m(response: TidalResponse, angle_deg: f64) -> f64 {
    response.mean_displacement_m * angle_deg.to_radians().cos().abs()
}

pub fn dissipation_power_w(response: TidalResponse) -> f64 {
    1.0e4 * response.love_number / response.quality_factor
}
