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"
|
name = "glider"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"nalgebra",
|
||||||
"scad",
|
"scad",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -7,3 +7,4 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
scad = "1.2.2"
|
scad = "1.2.2"
|
||||||
|
nalgebra = "0.16.14"
|
||||||
|
|
|
@ -1,25 +1,24 @@
|
||||||
#[macro_use]
|
use nalgebra::Vector2;
|
||||||
extern crate scad;
|
|
||||||
|
|
||||||
use scad::*;
|
use scad::*;
|
||||||
|
|
||||||
fn main() {
|
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();
|
let mut scad_file = ScadFile::new();
|
||||||
scad_file.set_detail(50);
|
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"));
|
scad_file.write_to_file(String::from("out.scad"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Point = Vector2<f32>;
|
||||||
#[derive(Debug)]
|
|
||||||
struct Point {
|
|
||||||
x: f64,
|
|
||||||
y: f64,
|
|
||||||
}
|
|
||||||
|
|
||||||
type Airfoil = Vec<Point>;
|
type Airfoil = Vec<Point>;
|
||||||
|
|
||||||
fn parse_selig(file: &String) -> Airfoil {
|
fn parse_selig(file: &String) -> Airfoil {
|
||||||
|
@ -27,9 +26,9 @@ fn parse_selig(file: &String) -> Airfoil {
|
||||||
|
|
||||||
for line in file.lines().skip(1) {
|
for line in file.lines().skip(1) {
|
||||||
let mut numbers =line.split(" ").filter(|n| !n.trim().is_empty());
|
let mut numbers =line.split(" ").filter(|n| !n.trim().is_empty());
|
||||||
let x: f64 = numbers.next().unwrap().parse().unwrap();
|
let x = numbers.next().unwrap().parse().unwrap();
|
||||||
let y: f64 = numbers.next().unwrap().parse().unwrap();
|
let y = numbers.next().unwrap().parse().unwrap();
|
||||||
points.push(Point { x, y })
|
points.push(Point::new(x,y))
|
||||||
}
|
}
|
||||||
points
|
points
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue