diff --git a/src/constants.rs b/src/constants.rs index b0c1818..553d9eb 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -5,3 +5,4 @@ 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; +pub const FUSELAGE_GAP: f32 = 10.0 * IN2MM; diff --git a/src/main.rs b/src/main.rs index dcbb1d0..563e00f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,11 +9,25 @@ fn main() { let mut scad_file = ScadFile::new(); scad_file.set_detail(50); - let e393 = selig::parse(include_str!("../e393.selig")); + // cambered airfoil, used in the wing + let e393: Airfoil = selig::parse(include_str!("../e393.selig")); + + // symetric airfoil, used in the control surfaces + let exxx: Airfoil = selig::parse(include_str!("../e393.selig")); 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))); + + for strut_idx in 0..STRUTS + 2 { + let port: bool = strut_idx % 2 == 1; + let out: usize = strut_idx/2; + + let mut spacing = WINGSPAN/2.0 * out as f32 + FUSELAGE_GAP / 2.0; + + println!("{port} {out} {spacing}"); + + if port { spacing = -spacing }; + + let mut transform = scad!(Translate(vec3(0.0, spacing ,0.0))); transform.add_child(strut(&e393, CHORD, STRUT_WIDTH)); wing.add_child(transform); @@ -24,18 +38,19 @@ fn main() { scad_file.write_to_file(String::from("out.scad")); } -fn strut(airfoil: &Airfoil, length: f32, width: f32) -> ScadObject { +/// returns a extruded airfoil with the given dimensions +fn strut(airfoil: &Airfoil, chord: f32, width: f32) -> ScadObject { let aerofoil = scad::PolygonParameters::new(airfoil.clone()); let shape = scad!(Polygon(aerofoil)); let extrude = LinExtrudeParams { height: width, - slices: 5, + center: true, ..Default::default() }; let unit: Vector3 = Vector3::new(1.0, 1.0, 1.0); - let scaled = scad!(Scale(unit * length); shape); + let scaled = scad!(Scale(unit * chord); shape); let strut = scad!(LinearExtrude(extrude); scaled); let rotated = scad!(Rotate(90.0, vec3(1.0, 0.0, 0.0)); strut); rotated