1
Fork 0

initial negative spar

openscad does not support 3d shape interpolation aside from hulls. oops.
This commit is contained in:
Andy Killorin 2023-11-02 14:53:50 -05:00
parent 015cbee1e6
commit cd3580477a
No known key found for this signature in database
GPG key ID: 8CB11B45B690DC2A
2 changed files with 59 additions and 4 deletions

View file

@ -2,12 +2,12 @@
/// the native unit is mm
const IN2MM: f32 = 25.4;
pub const CHORD: f32 = 5.0 * IN2MM;
pub const CHORD: f32 = 7.0 * IN2MM;
pub const WING_TAPER: f32 = 0.6;
pub const WINGSPAN: f32 = 45.0 * IN2MM;
pub const LENGTH: f32 = 30.0*IN2MM;
/// strut count in the main wing
pub const STRUTS: usize = 20;
pub const STRUTS: usize = 12;
pub const CARDBOARD_WIDTH: f32 = 2.4;
/// length of each side of the triangular spar
pub const SPAR_SIDE_WIDTH: f32 = 0.75 * IN2MM;
@ -19,6 +19,8 @@ pub const RUDDER_CHORD: f32 = 3.0 *IN2MM;
pub const RUDDER_TAPER: f32 = 0.7;
pub const RUDDER_STRUTS: usize = 3;
pub const ELEVATOR_HEIGHT: f32 = 8.0 *IN2MM;
pub const ELEVATOR_CHORD: f32 = 3.0 *IN2MM;
pub const ELEVATOR_CHORD: f32 = 5.0 *IN2MM;
pub const ELEVATOR_TAPER: f32 = 0.7;
pub const ELEVATOR_STRUTS: usize = 3;
pub const ELEVATOR_STRUTS: usize = 4;
pub const STOCK_HEIGHT: f32 = 25.0 *IN2MM;
pub const STOCK_WIDTH: f32 = 36.0 *IN2MM;

View file

@ -37,13 +37,16 @@ fn main() {
// struts
for port in [true,false] {
let mut wing = wing(&wing_airfoil, STRUTS/2, WINGSPAN/2.0, CHORD, CHORD * WING_TAPER, SparType::Top);
let top_spar = topwing_spar(&wing_airfoil, STRUTS/2, WINGSPAN/2.0, CHORD, CHORD * WING_TAPER);
wing = scad!(Translate(vec3(0.0, FUSELAGE_GAP,0.0)); wing);
wing.add_child(top_spar);
if port {
wing = scad!(Mirror(vec3(0.0, 1.0, 0.0)); wing);
}
wing_transform.add_child(wing);
}
// spars
// "fuselage"
@ -116,6 +119,10 @@ fn strut(airfoil: &Airfoil, chord: f32, width: f32, spar: &SparType) -> ScadObje
}
};
extrude_strut(shape, strut_hole, width, chord)
}
fn extrude_strut(shape: ScadObject, strut_hole: ScadObject, width: f32, chord: f32) -> ScadObject {
let mut strut_shape = scad!(Difference);
strut_shape.add_child(shape);
strut_shape.add_child(strut_hole);
@ -210,6 +217,52 @@ fn wing(aerofoil: &Airfoil, struts: usize, length: f32, chord: f32, taper: f32,
wing
}
fn topwing_spar(aerofoil: &Airfoil, struts: usize, length: f32, chord: f32, taper: f32) -> ScadObject {
let mut wing = scad!(Translate(vec3(0.0,0.0,0.0)));
let mut last_segment : Option<ScadObject> = None;
let mut pre_vis = scad!(Union);
// struts
for strut_idx in 0..struts + 1 {
let gap = length/struts as f32;
let chord = lerp(chord, taper, strut_idx as f32 / struts as f32);
let spacing = strut_idx as f32 * gap;
let shape = topspar_negative(&aerofoil, chord, 0.1..0.6);
let extruded = extrude_strut(shape.clone(), scad!(Union), CARDBOARD_WIDTH, chord);
let mut transform = scad!(Translate(vec3(0.0, spacing ,0.0)));
transform.add_child(extruded);
// in betweens
if let Some(last) = last_segment {
let mut hull = scad!(Hull);
hull.add_child(last);
hull.add_child(shape.clone());
let unit: Vector3<f32> = Vector3::new(1.0, 1.0, 1.0);
hull = scad!(Scale(unit * chord); hull);
hull = scad!(Rotate(90.0, vec3(1.0, 0.0, 0.0)); hull);
transform.add_child(hull);
}
pre_vis.add_child(transform);
last_segment = Some(shape);
}
wing.add_child(pre_vis);
wing
}
pub fn points_in_range(input: &Vec<Point>, range: Range<f32>) -> Vec<Point> {
let mut last_point: Option<Point> = None;
let mut distance: f32 = 0.0;