1
Fork 0

description

This commit is contained in:
Andy Killorin 2023-11-01 13:14:15 -05:00
parent 4de0171bd3
commit edc19b7e86
No known key found for this signature in database
GPG key ID: 8CB11B45B690DC2A
2 changed files with 11 additions and 2 deletions

View file

@ -17,7 +17,8 @@ fn main() {
// cambered airfoil, used in the wing
let wing_airfoil: Airfoil = Airfoil::parse(include_str!("../ag24.dat"));
println!("perim {}, name {}", wing_airfoil.get_name(), wing_airfoil.perimiter());
println!("name {}, perim {}", wing_airfoil.get_name(), wing_airfoil.perimiter());
println!("desc {}", wing_airfoil.get_description().clone().unwrap_or("no desc".to_string()));
// symetric airfoil, used in the control surfaces
let control_airfoil: Airfoil = Airfoil::parse(include_str!("../edgevertical.dat"));

View file

@ -4,6 +4,7 @@ pub type Point = Vector2<f32>;
pub struct Airfoil {
name: String,
description: Option<String>,
data: Vec<Point>,
}
@ -12,7 +13,9 @@ impl Airfoil {
let mut points = Vec::new();
let mut lines = file.lines();
let name = lines.next().expect("selig .dat is empty").to_string();
let mut header = lines.next().expect("selig .dat is empty").split(" | ").map(|x| x.trim());
let name = header.next().unwrap().to_string();
let description = header.next().map(|d| d.to_string());
for line in lines {
let mut numbers =line.split(" ").filter(|n| !n.trim().is_empty());
@ -22,6 +25,7 @@ impl Airfoil {
}
Airfoil {
name,
description,
data: points
}
}
@ -34,6 +38,10 @@ impl Airfoil {
&self.name
}
pub fn get_description(&self) -> &Option<String> {
&self.description
}
pub fn perimiter(&self) -> f32 {
let mut last_point: Option<Point> = None;
let mut distance: f32 = 0.0;