ioss 0.0.3

Io celestial simulation crate for the MilkyWay SolarSystem workspace
Documentation
use crate::IO_RADIUS_M;

#[derive(Debug, Clone, Copy, PartialEq)]
pub struct LatLonAlt {
    pub latitude_deg: f64,
    pub longitude_deg: f64,
    pub altitude_m: f64,
}

impl LatLonAlt {
    pub fn new(latitude_deg: f64, longitude_deg: f64, altitude_m: f64) -> Self {
        Self {
            latitude_deg,
            longitude_deg,
            altitude_m,
        }
    }
    pub fn to_cartesian(self) -> [f64; 3] {
        let lat = self.latitude_deg.to_radians();
        let lon = self.longitude_deg.to_radians();
        let radius = IO_RADIUS_M + self.altitude_m;
        [
            radius * lat.cos() * lon.cos(),
            radius * lat.cos() * lon.sin(),
            radius * lat.sin(),
        ]
    }
}