cometsfactory 0.0.1

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
pub mod centaur_transition;
pub mod extinct;
pub mod halley_type;
pub mod interstellar;
pub mod long_period;
pub mod main_belt_comet;
pub mod short_period;
pub mod sungrazer;

pub use centaur_transition::CentaurTransition;
pub use extinct::Extinct;
pub use halley_type::HalleyType;
pub use interstellar::Interstellar;
pub use long_period::LongPeriod;
pub use main_belt_comet::MainBeltComet;
pub use short_period::ShortPeriod;
pub use sungrazer::Sungrazer;

/// Unified enum wrapping all comet types produced by the factory.
#[derive(Debug)]
pub enum GeneratedComet {
    ShortPeriod(ShortPeriod),
    LongPeriod(LongPeriod),
    HalleyType(HalleyType),
    Sungrazer(Sungrazer),
    Interstellar(Interstellar),
    MainBeltComet(MainBeltComet),
    CentaurTransition(CentaurTransition),
    Extinct(Extinct),
}

impl GeneratedComet {
    pub fn nucleus_radius(&self) -> f64 {
        match self {
            Self::ShortPeriod(c) => c.nucleus_radius,
            Self::LongPeriod(c) => c.nucleus_radius,
            Self::HalleyType(c) => c.nucleus_radius,
            Self::Sungrazer(c) => c.nucleus_radius,
            Self::Interstellar(c) => c.nucleus_radius,
            Self::MainBeltComet(c) => c.nucleus_radius,
            Self::CentaurTransition(c) => c.nucleus_radius,
            Self::Extinct(c) => c.nucleus_radius,
        }
    }

    pub fn semi_major_axis(&self) -> f64 {
        match self {
            Self::ShortPeriod(c) => c.semi_major_axis,
            Self::LongPeriod(c) => c.semi_major_axis,
            Self::HalleyType(c) => c.semi_major_axis,
            Self::Sungrazer(c) => c.semi_major_axis,
            Self::Interstellar(_) => f64::INFINITY,
            Self::MainBeltComet(c) => c.semi_major_axis,
            Self::CentaurTransition(c) => c.semi_major_axis,
            Self::Extinct(c) => c.semi_major_axis,
        }
    }

    pub fn eccentricity(&self) -> f64 {
        match self {
            Self::ShortPeriod(c) => c.eccentricity,
            Self::LongPeriod(c) => c.eccentricity,
            Self::HalleyType(c) => c.eccentricity,
            Self::Sungrazer(c) => c.eccentricity,
            Self::Interstellar(c) => c.eccentricity,
            Self::MainBeltComet(c) => c.eccentricity,
            Self::CentaurTransition(c) => c.eccentricity,
            Self::Extinct(c) => c.eccentricity,
        }
    }
}