From 2939d0387971e84cc6e549999eda8f2ef28144c4 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Sun, 1 Aug 2021 16:46:51 +0800 Subject: [PATCH] re-design scales --- examples/dragon/hilbert_dragon.scad | 66 +++++++++-------------------- 1 file changed, 20 insertions(+), 46 deletions(-) diff --git a/examples/dragon/hilbert_dragon.scad b/examples/dragon/hilbert_dragon.scad index f9a8b336..a11f36f3 100644 --- a/examples/dragon/hilbert_dragon.scad +++ b/examples/dragon/hilbert_dragon.scad @@ -6,42 +6,17 @@ use ; use ; use ; use ; +use ; hilbert_dragon(); module hilbert_dragon() { - module scales(ang, leng, radius, height, thickness) { - module one_scale() { - rotate([0, ang, 0]) - shear(sx = [0, -1.5]) - linear_extrude(thickness, center = true) - scale([leng, 1.6]) - circle(1, $fn = 4); - } - - for(a = [0:45:315]) { - hull() { - rotate(a) - translate([radius, 0, height]) - one_scale(); - - rotate(a + 15) - translate([radius, 0, height + 1.75]) - one_scale(); - } - } - } - - module one_segment() { + module one_segment(body_r, body_fn, one_scale_data) { // scales - scale([1, 0.8, 1]) union() { - scales(60, 4, 5, 0, 1.5); - scales(75, 2.5, 5, -4, 1.25); - scales(100, 1.25, 4.5, -7, 1); - scales(110, 1.25, 3, -9, 1); -// scales(120, 2.5, 2, -9, 1); - } - + //scale([1, 1, 1.25]) + rotate([-90, 0, 0]) + dragon_body_scales(body_r, body_fn, one_scale_data); + // dorsal fin translate([0, 4, -1.5]) rotate([-105, 0, 0]) @@ -49,41 +24,40 @@ module hilbert_dragon() { linear_extrude(5, scale = 0.15) square([2.5, 4], center = true); - hull() { - // belly - translate([0, -2.5, 1]) - rotate([-10, 0, 0]) - scale([1.1, 0.8, 1.25]) - sphere(5.8, $fn = 8); - - translate([0, 0, -1.65]) - rotate([-5, 0, 0]) - scale([1, 0.8, 1.6]) - sphere(5.5, $fn = 8); - } + translate([0, -2.5, 1]) + rotate([-10, 0, 0]) + scale([1.1, 0.8, 1.25]) + sphere(body_r * 1.075, $fn = 8); } + body_r = 5; + body_fn = 12; + scale_fn = 5; + scale_tilt_a = -3; + lines = hilbert_curve(); hilbert_path = dedup( concat( [for(line = lines) line[0]], [lines[len(lines) - 1][1]]) ); - smoothed_hilbert_path = bezier_smooth(hilbert_path, 0.45, t_step = 0.2); + smoothed_hilbert_path = bezier_smooth(hilbert_path, 0.45, t_step = 0.15); dragon_body_path = reverse([for(i = [1:len(smoothed_hilbert_path) - 2]) smoothed_hilbert_path[i]]); + one_body_scale_data = one_body_scale(body_r, body_fn, scale_fn, scale_tilt_a); + along_with(dragon_body_path, scale = 0.6) rotate([90, 0, 0]) scale(0.035) - one_segment(); + one_segment(body_r, body_fn, one_body_scale_data); // tail translate([0, 0, -0.62]) rotate(-5) scale(0.0285) mirror([0, 0, 1]) - scales(120, 2.5, 2, -9, 1); + tail_scales(120, 2.5, 2, -9, 1, $fn = 4); translate([0, 0, -2.5]) scale(0.035)