use kalast::{
    EnvironmentSystem, Properties, SingleBody, Time, World, ASTRONAUMICAL_UNIT, DAY, HOUR, M3,
    MINUTE, V3,
};

fn main() {
    // Define an empty object.
    let mut asteroid = SingleBody::empty_object(
        "Dimorphos",
        -V3::new(1.0, 0.0, 0.0) * ASTRONAUMICAL_UNIT * 1.074,
        Properties::new(
            11.92 * HOUR, // rotation period
            11.92 * HOUR, // revolution period
            0.0,          // obliquity
            500.0,        // thermal inertia
            2146.0,       // density
            600.0,        // heat capacity
            0.07,         // albedo
            0.9,          // emissivity
        ),
    );

    // Add a single facet at longitude = latitude = 0° of 2m² surface area (pointing outward
    // relatively to the center of the body).
    asteroid
        .body_mut()
        .object
        .new_face(&M3::from_column_slice(&[
            1.0,
            -2. / 3.,
            2. / 3.,
            1.0,
            -2.0 / 3.,
            -4. / 3.,
            1.0,
            4. / 3.,
            2. / 3.,
        ]));
    asteroid.body_mut().recompute();
    asteroid.complete_model(false);

    // Time
    let time = Time::new(
        //4.0 * asteroid.body().properties.revolution_period(),
        2.0 * DAY,
        30.0 * MINUTE,
    );

    // World
    let mut world = World::new(time, asteroid);
    world.start();
    world.save("rsc/data/tmp.txt");

    println!(
        "min: {:.2}, max: {:.2}",
        world.environment_system.body().surface_temperatures().min(),
        world.environment_system.body().surface_temperatures().max()
    );

    world
        .environment_system
        .body_mut()
        .object
        .set_longitude_latitude_zero();
}
