#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DaylightState {
Day,
Twilight,
Night,
}
pub struct DayNightCycle {
pub ls_deg: f64,
}
impl DayNightCycle {
pub fn new(ls_deg: f64) -> Self {
Self { ls_deg }
}
pub fn state_at(&self, lat_deg: f64, local_time_h: f64) -> DaylightState {
let s =
super::solar_position::SolarPosition::compute(self.ls_deg, local_time_h, lat_deg, 0.0);
if s.elevation_deg > 0.0 {
DaylightState::Day
} else if s.elevation_deg > -12.0 {
DaylightState::Twilight
} else {
DaylightState::Night
}
}
}