marss 0.0.3

Mars celestial simulation crate for the MilkyWay SolarSystem workspace
Documentation
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum MarsBiome {
    DarkDune,
    BrightDust,
    Regolith,
    Basalt,
    SulfateSalt,
    PolarIce,
    Co2Frost,
    VolcanicSummit,
    ImpactEjecta,
}

pub struct SplatWeights {
    pub biome_a: MarsBiome,
    pub biome_b: MarsBiome,
    pub biome_c: MarsBiome,
    pub biome_d: MarsBiome,
    pub weights: [f32; 4],
}

pub struct BiomeClassifier {
    pub dust_coverage_factor: f64,
}

impl Default for BiomeClassifier {
    fn default() -> Self {
        Self {
            dust_coverage_factor: 0.4,
        }
    }
}

impl BiomeClassifier {
    pub fn classify(&self, lat_deg: f64, elevation_m: f64, thermal_inertia: f64) -> MarsBiome {
        let abs_lat = lat_deg.abs();

        if abs_lat > 80.0 {
            return if elevation_m < -2000.0 {
                MarsBiome::Co2Frost
            } else {
                MarsBiome::PolarIce
            };
        }

        if elevation_m > 15_000.0 {
            return MarsBiome::VolcanicSummit;
        }

        if thermal_inertia < 100.0 {
            return MarsBiome::BrightDust;
        }

        if thermal_inertia > 400.0 {
            return MarsBiome::Basalt;
        }

        if thermal_inertia > 250.0 && elevation_m < 0.0 {
            return MarsBiome::DarkDune;
        }

        if elevation_m < -5000.0 {
            return MarsBiome::ImpactEjecta;
        }

        if elevation_m < -3000.0 && thermal_inertia < 200.0 {
            return MarsBiome::SulfateSalt;
        }

        MarsBiome::Regolith
    }

    pub fn splat_weights(
        &self,
        lat_deg: f64,
        elevation_m: f64,
        thermal_inertia: f64,
    ) -> SplatWeights {
        let primary = self.classify(lat_deg, elevation_m, thermal_inertia);
        let secondary = MarsBiome::Regolith;
        let tertiary = MarsBiome::BrightDust;
        let quaternary = MarsBiome::Basalt;
        SplatWeights {
            biome_a: primary,
            biome_b: secondary,
            biome_c: tertiary,
            biome_d: quaternary,
            weights: [0.6, 0.2, 0.1, 0.1],
        }
    }
}