mercurys 0.0.3

Mercury celestial simulation crate for the MilkyWay SolarSystem workspace
Documentation
pub struct TimeScale {
    pub factor: f64,
}

impl TimeScale {
    pub fn new(factor: f64) -> Self {
        Self {
            factor: factor.max(0.0),
        }
    }

    pub fn realtime() -> Self {
        Self { factor: 1.0 }
    }

    pub fn solar_day_per_second() -> Self {
        Self {
            factor: crate::SOLAR_DAY_S,
        }
    }

    pub fn year_per_second() -> Self {
        Self {
            factor: 7_600_521.6,
        }
    }

    pub fn apply(&self, dt_s: f64) -> f64 {
        dt_s * self.factor
    }

    pub fn set_factor(&mut self, factor: f64) {
        self.factor = factor.max(0.0);
    }

    pub fn pause(&mut self) {
        self.factor = 0.0;
    }

    pub fn is_paused(&self) -> bool {
        self.factor == 0.0
    }
}