#weight #aviation #balance #calculations #gravity #center

airplane

A library for easy airplane-related calculations and visualizations, including weight and balance assessments and graphical representations.A Rust library for easy airplane-related calculations and visualizations, including weight and balance assessments and graphical representations

8 releases

0.1.7 Aug 12, 2024
0.1.6 Jul 29, 2024

#81 in Visualization

MIT license

35KB
786 lines

Airplane Library

This Rust library is designed for easy and accurate airplane-related calculations, focusing on weight and balance, as well as visualization. The library provides functions to calculate center of gravity, moment arms, and weight distribution. Additionally, it includes tools for visualizing weight and balance envelopes and other key metrics, making it a comprehensive tool for pilots, engineers, and aviation enthusiasts. With a simple and intuitive API, this library simplifies complex aeronautical calculations and visualizations.

Example

use std::fs;

use airplane::{visualizer::WeightBalanceVisualization, weight_and_balance::{
    Airplane, CenterOfGravity, LeverArm, Limits, Mass, Moment, Volume,
}};

fn main() {
    let plane = Airplane::new(
        String::from("PHXXX"),
        vec![
            Moment::new(LeverArm::Meter(0.4294), Mass::Kilo(517.0)),
            Moment::new(LeverArm::Meter(0.515), Mass::Kilo(80.0)),
            Moment::new(LeverArm::Meter(0.515), Mass::Kilo(89.0)),
            Moment::new(LeverArm::Meter(1.3), Mass::Kilo(5.0)),
            Moment::new(LeverArm::Meter(0.325), Mass::Avgas(Volume::Liter(55.0))),
        ],
        Limits::new(
            Mass::Kilo(558.0),
            Mass::Kilo(750.0),
            CenterOfGravity::Millimeter(427.0),
            CenterOfGravity::Millimeter(523.0),
        ),
    );

    match airplane::visualizer::weight_and_balance(plane, WeightBalanceVisualization::new((1000,1000),(230.0..420.0, 550.0..760.0))) {
        airplane::visualizer::Visualization::Svg(svg) =>  {
            let _ = fs::write("image.svg", svg);
        },
    };
}

Output

image

Dependencies

~4.5–6.5MB
~106K SLoC