ioss 0.0.3

Io celestial simulation crate for the MilkyWay SolarSystem workspace
Documentation
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct SolarIllumination {
    pub incidence_deg: f64,
    pub phase_angle_deg: f64,
}

pub fn subsolar_longitude_deg(io_day_fraction: f64) -> f64 {
    360.0 * io_day_fraction.rem_euclid(1.0) - 180.0
}

pub fn solar_elevation_deg(latitude_deg: f64, local_time_hours: f64) -> f64 {
    let hour_angle_deg = (local_time_hours - 21.25) * (360.0 / 42.5);
    (90.0 - latitude_deg.abs() - hour_angle_deg.abs() * 0.6).clamp(-90.0, 90.0)
}

pub fn illumination(
    latitude_deg: f64,
    local_time_hours: f64,
    phase_angle_deg: f64,
) -> SolarIllumination {
    let elevation = solar_elevation_deg(latitude_deg, local_time_hours);
    SolarIllumination {
        incidence_deg: (90.0 - elevation).clamp(0.0, 180.0),
        phase_angle_deg,
    }
}