description
This commit is contained in:
parent
4de0171bd3
commit
edc19b7e86
2 changed files with 11 additions and 2 deletions
|
@ -17,7 +17,8 @@ fn main() {
|
||||||
|
|
||||||
// cambered airfoil, used in the wing
|
// cambered airfoil, used in the wing
|
||||||
let wing_airfoil: Airfoil = Airfoil::parse(include_str!("../ag24.dat"));
|
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
|
// symetric airfoil, used in the control surfaces
|
||||||
let control_airfoil: Airfoil = Airfoil::parse(include_str!("../edgevertical.dat"));
|
let control_airfoil: Airfoil = Airfoil::parse(include_str!("../edgevertical.dat"));
|
||||||
|
|
10
src/selig.rs
10
src/selig.rs
|
@ -4,6 +4,7 @@ pub type Point = Vector2<f32>;
|
||||||
|
|
||||||
pub struct Airfoil {
|
pub struct Airfoil {
|
||||||
name: String,
|
name: String,
|
||||||
|
description: Option<String>,
|
||||||
data: Vec<Point>,
|
data: Vec<Point>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +13,9 @@ impl Airfoil {
|
||||||
let mut points = Vec::new();
|
let mut points = Vec::new();
|
||||||
|
|
||||||
let mut lines = file.lines();
|
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 {
|
for line in lines {
|
||||||
let mut numbers =line.split(" ").filter(|n| !n.trim().is_empty());
|
let mut numbers =line.split(" ").filter(|n| !n.trim().is_empty());
|
||||||
|
@ -22,6 +25,7 @@ impl Airfoil {
|
||||||
}
|
}
|
||||||
Airfoil {
|
Airfoil {
|
||||||
name,
|
name,
|
||||||
|
description,
|
||||||
data: points
|
data: points
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,6 +38,10 @@ impl Airfoil {
|
||||||
&self.name
|
&self.name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_description(&self) -> &Option<String> {
|
||||||
|
&self.description
|
||||||
|
}
|
||||||
|
|
||||||
pub fn perimiter(&self) -> f32 {
|
pub fn perimiter(&self) -> f32 {
|
||||||
let mut last_point: Option<Point> = None;
|
let mut last_point: Option<Point> = None;
|
||||||
let mut distance: f32 = 0.0;
|
let mut distance: f32 = 0.0;
|
||||||
|
|
Loading…
Reference in a new issue