pub const J2000EPOCH: f64 = 2451545.0;
pub const J1950EPOCH: f64 = 2433282.5;
pub const MJDOFFSET: f64 = 2400000.5;
pub struct Epoch {
pub juliandate: f64,
}
impl Epoch {
pub fn j2000() -> Self {
Self {
juliandate: J2000EPOCH,
}
}
pub fn fromjd(jd: f64) -> Self {
Self { juliandate: jd }
}
pub fn frommjd(mjd: f64) -> Self {
Self {
juliandate: mjd + MJDOFFSET,
}
}
pub fn tomjd(&self) -> f64 {
self.juliandate - MJDOFFSET
}
pub fn centuriessincej2000(&self) -> f64 {
(self.juliandate - J2000EPOCH) / 36525.0
}
pub fn dayssincej2000(&self) -> f64 {
self.juliandate - J2000EPOCH
}
pub fn jupitergmstdegrees(&self) -> f64 {
let d = self.dayssincej2000();
let jupitersiderealdays = 0.4135;
(280.0 + 360.0 / jupitersiderealdays * d) % 360.0
}
pub fn advancedays(&mut self, days: f64) {
self.juliandate += days;
}
pub fn advanceseconds(&mut self, seconds: f64) {
self.juliandate += seconds / super::calendar::SECONDSPERDAY;
}
}