added aerofoil visualization
This commit is contained in:
parent
bec6d83b9b
commit
13ab421df4
3 changed files with 16 additions and 15 deletions
1
glider/Cargo.lock
generated
1
glider/Cargo.lock
generated
|
@ -63,6 +63,7 @@ dependencies = [
|
|||
name = "glider"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"nalgebra",
|
||||
"scad",
|
||||
]
|
||||
|
||||
|
|
|
@ -7,3 +7,4 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
scad = "1.2.2"
|
||||
nalgebra = "0.16.14"
|
||||
|
|
|
@ -1,25 +1,24 @@
|
|||
#[macro_use]
|
||||
extern crate scad;
|
||||
|
||||
use nalgebra::Vector2;
|
||||
use scad::*;
|
||||
|
||||
fn main() {
|
||||
println!("{:?}", parse_selig(&String::from(include_str!("../../e393.selig"))));
|
||||
let e393 = parse_selig(&String::from(include_str!("../../e393.selig")));
|
||||
let mut scad_file = ScadFile::new();
|
||||
scad_file.set_detail(50);
|
||||
|
||||
|
||||
//Save the scad code to a file
|
||||
let aerofoil = scad::PolygonParameters::new(e393);
|
||||
//Create an scad object
|
||||
let strut = scad!(Translate(vec3(2.0, 2.0, 3.0)); {
|
||||
scad!(Polygon(aerofoil))
|
||||
});
|
||||
|
||||
scad_file.add_object(strut.clone());
|
||||
|
||||
scad_file.write_to_file(String::from("out.scad"));
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Point {
|
||||
x: f64,
|
||||
y: f64,
|
||||
}
|
||||
|
||||
type Point = Vector2<f32>;
|
||||
type Airfoil = Vec<Point>;
|
||||
|
||||
fn parse_selig(file: &String) -> Airfoil {
|
||||
|
@ -27,9 +26,9 @@ fn parse_selig(file: &String) -> Airfoil {
|
|||
|
||||
for line in file.lines().skip(1) {
|
||||
let mut numbers =line.split(" ").filter(|n| !n.trim().is_empty());
|
||||
let x: f64 = numbers.next().unwrap().parse().unwrap();
|
||||
let y: f64 = numbers.next().unwrap().parse().unwrap();
|
||||
points.push(Point { x, y })
|
||||
let x = numbers.next().unwrap().parse().unwrap();
|
||||
let y = numbers.next().unwrap().parse().unwrap();
|
||||
points.push(Point::new(x,y))
|
||||
}
|
||||
points
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue