satellitesfactory 0.0.3

Satellite factory — classify, build and catalogue natural satellites for any planetary system: Solar System moons (Moon, Galileans, Titan, Triton…) or custom configurations.
Documentation
pub fn band_depth(continuum: f64, band_minimum: f64) -> f64 {
    1.0 - band_minimum / (continuum + 1e-30)
}

pub fn water_ice_index(reflectance_1_5: f64, reflectance_2_0: f64) -> f64 {
    reflectance_1_5 / (reflectance_2_0 + 1e-30)
}

pub fn spectral_slope(
    reflectance_low: f64,
    reflectance_high: f64,
    wavelength_low: f64,
    wavelength_high: f64,
) -> f64 {
    (reflectance_high - reflectance_low)
        / ((wavelength_high - wavelength_low + 1e-30) * reflectance_low.max(1e-30))
}

pub fn color_index(mag_blue: f64, mag_visual: f64) -> f64 {
    mag_blue - mag_visual
}

pub fn thermal_inertia_from_diurnal(delta_t: f64, rotation_period: f64, solar_flux: f64) -> f64 {
    let omega = 2.0 * std::f64::consts::PI / rotation_period;
    solar_flux / (delta_t * omega.sqrt())
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SurfaceComposition {
    WaterIce,
    DirtyIce,
    Silicate,
    Carbonaceous,
    Sulfur,
    TholinRich,
}

pub fn composition_from_albedo_and_density(albedo: f64, density: f64) -> SurfaceComposition {
    if albedo > 0.8 {
        SurfaceComposition::WaterIce
    } else if albedo > 0.5 && density < 1500.0 {
        SurfaceComposition::DirtyIce
    } else if albedo > 0.3 && density > 3000.0 {
        SurfaceComposition::Silicate
    } else if albedo < 0.1 {
        SurfaceComposition::Carbonaceous
    } else if albedo > 0.3 && density > 2000.0 && density < 3500.0 {
        SurfaceComposition::Sulfur
    } else {
        SurfaceComposition::TholinRich
    }
}