marss 0.0.2

Mars celestial simulation crate for the MilkyWay SolarSystem workspace
Documentation
pub struct DustLayer {
    pub base_altitude_m: f64,
    pub top_altitude_m: f64,
    pub optical_depth: f64,
    pub single_scatter_albedo: f64,
    pub asymmetry_parameter: f64,
}

impl DustLayer {
    pub fn background() -> Self {
        Self {
            base_altitude_m: 0.0,
            top_altitude_m: 40_000.0,
            optical_depth: crate::MEAN_DUST_OPTICAL_DEPTH,
            single_scatter_albedo: 0.92,
            asymmetry_parameter: 0.65,
        }
    }

    pub fn global_storm() -> Self {
        Self {
            base_altitude_m: 0.0,
            top_altitude_m: 80_000.0,
            optical_depth: crate::GLOBAL_STORM_OPTICAL_DEPTH,
            single_scatter_albedo: 0.92,
            asymmetry_parameter: 0.65,
        }
    }

    pub fn density_at_altitude(&self, alt_m: f64) -> f64 {
        if alt_m < self.base_altitude_m || alt_m > self.top_altitude_m {
            return 0.0;
        }
        let scale_h = (self.top_altitude_m - self.base_altitude_m) / 3.0;
        (-(alt_m - self.base_altitude_m) / scale_h).exp()
    }

    pub fn surface_solar_fraction(&self) -> f64 {
        (-self.optical_depth).exp()
    }

    pub fn phase_function(&self, cos_theta: f64) -> f64 {
        let g = self.asymmetry_parameter;
        let denom = 1.0 + g * g - 2.0 * g * cos_theta;
        (1.0 - g * g) / (4.0 * std::f64::consts::PI * denom.powf(1.5))
    }
}

pub fn effective_dust_radius_um() -> f64 {
    1.5
}

pub fn dust_color_linear() -> [f64; 3] {
    [0.9, 0.6, 0.3]
}