1
Fork 0

extracted strut to fn

This commit is contained in:
Andy Killorin 2023-10-30 15:25:15 -05:00
parent 9817648a3a
commit fc8267e104
No known key found for this signature in database
GPG key ID: 8CB11B45B690DC2A
3 changed files with 40 additions and 9 deletions

View file

@ -1,5 +1,5 @@
out.scad: e393.selig
cargo run --release
out.scad: e393.selig src/*.rs
cargo run
e393.selig:
curl http://airfoiltools.com/airfoil/seligdatfile?airfoil=e393-il > e393.selig

7
src/constants.rs Normal file
View file

@ -0,0 +1,7 @@
const IN2MM: f32 = 25.4;
pub const CHORD: f32 = 11.2 * IN2MM;
pub const WINGSPAN: f32 = 45.0 * IN2MM;
pub const LENGTH: f32 = 0.0;
pub const STRUTS: usize = 10;
pub const STRUT_WIDTH: f32 = 2.4;
pub const SPAR_SIDE_WIDTH: f32 = 0.75;

View file

@ -1,18 +1,42 @@
use nalgebra::Vector3;
use scad::*;
use constants::*;
use selig::Airfoil;
mod constants;
mod selig;
fn main() {
let e393 = selig::parse(include_str!("../e393.selig"));
let aerofoil = scad::PolygonParameters::new(e393);
let mut scad_file = ScadFile::new();
scad_file.set_detail(50);
let strut = scad!(Translate(vec3(2.0, 2.0, 3.0)); {
scad!(Polygon(aerofoil))
});
let e393 = selig::parse(include_str!("../e393.selig"));
scad_file.add_object(strut.clone());
let mut wing = scad!(Translate(vec3(0.0,0.0,0.0)));
for strut_idx in 0..STRUTS {
let mut transform = scad!(Translate(vec3(0.0, strut_idx as f32 * 30.0 ,0.0)));
transform.add_child(strut(&e393, CHORD, STRUT_WIDTH));
wing.add_child(transform);
}
scad_file.add_object(wing.clone());
scad_file.write_to_file(String::from("out.scad"));
}
fn strut(airfoil: &Airfoil, length: f32, width: f32) -> ScadObject {
let aerofoil = scad::PolygonParameters::new(airfoil.clone());
let shape = scad!(Polygon(aerofoil));
let extrude = LinExtrudeParams {
height: width,
slices: 5,
..Default::default()
};
let unit: Vector3<f32> = Vector3::new(1.0, 1.0, 1.0);
let scaled = scad!(Scale(unit * length); shape);
let strut = scad!(LinearExtrude(extrude); scaled);
let rotated = scad!(Rotate(90.0, vec3(1.0, 0.0, 0.0)); strut);
rotated
}