asteroidsfactory 0.0.3

Asteroid factory — classify, build and catalogue asteroids of any type: near-Earth, main belt, trojan, centaur, binary, rubble pile, metallic, and potentially hazardous.
Documentation
use asteroidsfactory::observables::{lightcurve, photometry};
use asteroidsfactory::types::*;
use asteroidsfactory::utils::io;

fn main() {
    let nea = near_earth::NearEarthAsteroid::new(500.0, 2500.0, 1.5, 0.4).with_albedo(0.15);
    let mb = main_belt::MainBeltAsteroid::new(265000.0, 3456.0, 2.362)
        .with_spectral_type(main_belt::SpectralType::V);
    let tr = trojan::Trojan::new(50000.0, 2000.0, 5.2).with_lagrange_point(trojan::TrojanPoint::L4);
    let ce = centaur::Centaur::new(120000.0, 1000.0, 13.7, 0.38);
    let bi = binary::BinaryAsteroid::new(390.0, 80.0, 2170.0, 1180.0);
    let rp = rubble_pile::RubblePile::new(245.0, 3400.0, 0.5);
    let me = metallic::MetallicAsteroid::new(113000.0, 0.85);
    let ph = pha::PotentiallyHazardousAsteroid::new(185.0, 2600.0, 0.922, 0.191, 0.00025);

    let asteroids = vec![
        GeneratedAsteroid::NearEarth(nea),
        GeneratedAsteroid::MainBelt(mb),
        GeneratedAsteroid::Trojan(tr),
        GeneratedAsteroid::Centaur(ce),
        GeneratedAsteroid::Binary(bi),
        GeneratedAsteroid::RubblePile(rp),
        GeneratedAsteroid::Metallic(me),
        GeneratedAsteroid::PHA(ph),
    ];

    let mut total_len = 0;
    for a in &asteroids {
        let line = io::summary_line(a);
        total_len += line.len();
        assert!(!line.is_empty());
    }
    assert!(total_len > 0);

    let h = photometry::absolute_magnitude(265000.0, 0.42);
    let m = photometry::apparent_magnitude(h, 2.362, 1.5, 0.2);
    let diam = photometry::diameter_from_h_albedo(h, 0.42);

    assert!(h > 2.0 && h < 5.0);
    assert!(m > h);
    assert!(diam > 400.0 && diam < 600.0);

    let amp = lightcurve::lightcurve_amplitude(1.5);
    let sp = lightcurve::spin_barrier_period(2700.0);
    let eclipse = lightcurve::binary_eclipse_depth(1000.0, 500.0, 0.15, 0.15);

    assert!(amp > 0.0);
    assert!(sp > 7000.0);
    assert!(eclipse > 0.0 && eclipse < 1.0);

    let sum = h + m + diam + amp + sp + eclipse + total_len as f64;
    assert!(sum > 0.0);
    assert_eq!(asteroids.len(), 8);
}