1
Fork 0

added spar generator and part agregiator

This commit is contained in:
Andy Killorin 2023-10-31 11:50:16 -05:00
parent 2bf48965f9
commit 9fe73efc0c
No known key found for this signature in database
GPG key ID: 8CB11B45B690DC2A
2 changed files with 45 additions and 7 deletions

View file

@ -1,8 +1,13 @@
/// Constants
/// the native unit is mm
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;
/// strut count in the main wing
pub const STRUTS: usize = 6;
pub const CARDBOARD_WIDTH: f32 = 2.4;
/// length of each side of the triangular spar
pub const SPAR_SIDE_WIDTH: f32 = 0.75 * IN2MM;
pub const FUSELAGE_GAP: f32 = 10.0 * IN2MM;

View file

@ -7,6 +7,8 @@ mod selig;
fn main() {
let mut scad_file = ScadFile::new();
let mut parts: Vec<ScadObject> = Vec::new();
scad_file.set_detail(50);
// cambered airfoil, used in the wing
@ -17,25 +19,42 @@ fn main() {
let mut wing = scad!(Translate(vec3(0.0,0.0,0.0)));
// struts
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;
let mut spacing = WINGSPAN/STRUTS as f32 * out as f32 + FUSELAGE_GAP / 2.0;
println!("{port} {out} {spacing}");
let falloff = 0.95f32.powf(spacing / 40.0);
if port { spacing = -spacing };
let mut transform = scad!(Translate(vec3(0.0, spacing ,0.0)));
transform.add_child(strut(&e393, CHORD, STRUT_WIDTH));
let strut = strut(&e393, CHORD * falloff, CARDBOARD_WIDTH);
parts.push(strut.clone());
transform.add_child(strut);
wing.add_child(transform);
}
scad_file.add_object(wing.clone());
// spars
scad_file.add_object(spar(WINGSPAN));
scad_file.write_to_file(String::from("out.scad"));
let cardboard = vec3(0.38, 0.26, 0.26);
scad_file.add_object(scad!(Color(cardboard); wing));
scad_file.write_to_file(String::from("build/assembly.scad"));
for (idx, part) in parts.into_iter().enumerate() {
let mut file = ScadFile::new();
file.set_detail(50);
file.add_object(part);
file.write_to_file(format!("build/part{idx}.scad"));
}
}
/// returns a extruded airfoil with the given dimensions
@ -55,3 +74,17 @@ fn strut(airfoil: &Airfoil, chord: f32, width: f32) -> ScadObject {
let rotated = scad!(Rotate(90.0, vec3(1.0, 0.0, 0.0)); strut);
rotated
}
fn spar(length: f32) -> ScadObject {
let mut spar = scad!(Union);
for i in 0..3 {
let panel = scad!(Cube(vec3(SPAR_SIDE_WIDTH, length, CARDBOARD_WIDTH)));
let rot = 120.0 * i as f32;
spar.add_child(scad!(
Rotate(rot, vec3(0.0, 1.0, 0.0)); panel
));
}
spar
}