cometsfactory 0.0.3

Comet factory — classify, build and catalogue comets of any type: short-period, long-period, Halley-type, sungrazer, interstellar, main-belt comet, centaur-transition, and extinct.
Documentation
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct CometShaderData {
    pub coma_radius_km: f32,
    pub dust_tail_length_au: f32,
    pub ion_tail_length_au: f32,
    pub outgassing_rate: f32,
    pub heliocentric_distance_au: f32,
}

impl CometShaderData {
    pub fn at_distance(distance_au: f32) -> Self {
        let activity = if distance_au < 3.0 {
            (3.0 - distance_au) / 3.0
        } else {
            0.0
        };
        Self {
            coma_radius_km: activity * 100_000.0,
            dust_tail_length_au: activity * 0.5,
            ion_tail_length_au: activity * 1.5,
            outgassing_rate: activity * 1e28,
            heliocentric_distance_au: distance_au,
        }
    }

    pub fn perihelion() -> Self {
        Self::at_distance(0.5)
    }

    pub fn aphelion() -> Self {
        Self::at_distance(35.0)
    }

    pub fn tail_direction_away_from_sun(&self, sun_dir: [f32; 3]) -> [f32; 3] {
        let len =
            (sun_dir[0] * sun_dir[0] + sun_dir[1] * sun_dir[1] + sun_dir[2] * sun_dir[2]).sqrt();
        if len < 1e-12 {
            return [0.0, 0.0, 1.0];
        }
        [-sun_dir[0] / len, -sun_dir[1] / len, -sun_dir[2] / len]
    }
}