use crate::constants::SECONDS_PER_DAY;
use crate::types::BrightDateValue;
pub const SPEED_OF_LIGHT_M_PER_S: f64 = 299_792_458.0;
pub const BRIGHT_METER_M: f64 = SPEED_OF_LIGHT_M_PER_S;
pub const LIGHT_DAY_M: f64 = SPEED_OF_LIGHT_M_PER_S * SECONDS_PER_DAY;
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct BrightUnit {
pub name: &'static str,
pub symbol: &'static str,
pub seconds: f64,
pub metres: f64,
pub context: &'static str,
}
pub const BRIGHT_METER_UNITS: &[BrightUnit] = &[
BrightUnit {
name: "Micro-BrightMeter",
symbol: "μbm",
seconds: 1e-6,
metres: SPEED_OF_LIGHT_M_PER_S * 1e-6,
context: "≈ 300 m (city block, fibre tap distance)",
},
BrightUnit {
name: "Milli-BrightMeter",
symbol: "mbm",
seconds: 1e-3,
metres: SPEED_OF_LIGHT_M_PER_S * 1e-3,
context: "≈ 300 km (low Earth orbit)",
},
BrightUnit {
name: "BrightMeter",
symbol: "bm",
seconds: 1.0,
metres: SPEED_OF_LIGHT_M_PER_S,
context: "≈ 299_792 km (Earth–Moon ≈ 1.28 bm)",
},
BrightUnit {
name: "Mega-BrightMeter",
symbol: "Mbm",
seconds: 1e6,
metres: SPEED_OF_LIGHT_M_PER_S * 1e6,
context: "≈ 2 × Earth–Sun (1 AU ≈ 0.5 Mbm)",
},
BrightUnit {
name: "Giga-BrightMeter",
symbol: "Gbm",
seconds: 1e9,
metres: SPEED_OF_LIGHT_M_PER_S * 1e9,
context: "≈ 32 light-years (interstellar)",
},
];
pub const LIGHT_DAY_UNITS: &[BrightUnit] = &[
BrightUnit {
name: "Light-Microday",
symbol: "Lμd",
seconds: SECONDS_PER_DAY * 1e-6,
metres: LIGHT_DAY_M * 1e-6,
context: "≈ 25.9 km",
},
BrightUnit {
name: "Light-Milliday",
symbol: "Lmd",
seconds: SECONDS_PER_DAY * 1e-3,
metres: LIGHT_DAY_M * 1e-3,
context: "≈ 25_902 km (geostationary belt)",
},
BrightUnit {
name: "Light-Day",
symbol: "Ld",
seconds: SECONDS_PER_DAY,
metres: LIGHT_DAY_M,
context: "≈ 25.9 × 10¹² m (cislunar to inner-system)",
},
BrightUnit {
name: "Light-Kiloday",
symbol: "Lkd",
seconds: SECONDS_PER_DAY * 1e3,
metres: LIGHT_DAY_M * 1e3,
context: "≈ 2.74 light-years",
},
];
#[inline]
pub fn seconds_to_metres(seconds: f64) -> f64 {
seconds * SPEED_OF_LIGHT_M_PER_S
}
#[inline]
pub fn metres_to_seconds(metres: f64) -> f64 {
metres / SPEED_OF_LIGHT_M_PER_S
}
#[inline]
pub fn seconds_to_bright_meters(seconds: f64) -> f64 {
seconds
}
#[inline]
pub fn bright_meters_to_seconds(bright_meters: f64) -> f64 {
bright_meters
}
#[inline]
pub fn metres_to_bright_meters(metres: f64) -> f64 {
metres / BRIGHT_METER_M
}
#[inline]
pub fn bright_meters_to_metres(bright_meters: f64) -> f64 {
bright_meters * BRIGHT_METER_M
}
#[inline]
pub fn days_to_bright_seconds(days: BrightDateValue) -> f64 {
days * SECONDS_PER_DAY
}
#[inline]
pub fn bright_seconds_to_days(bright_seconds: f64) -> BrightDateValue {
bright_seconds / SECONDS_PER_DAY
}
#[inline]
pub fn days_to_metres(days: BrightDateValue) -> f64 {
days * LIGHT_DAY_M
}
#[inline]
pub fn metres_to_days(metres: f64) -> BrightDateValue {
metres / LIGHT_DAY_M
}