diff --git a/examples/torus_knot_dragon2.scad b/examples/dragon/dragon_head.scad similarity index 57% rename from examples/torus_knot_dragon2.scad rename to examples/dragon/dragon_head.scad index 738147aa..a4d76e1c 100644 --- a/examples/torus_knot_dragon2.scad +++ b/examples/dragon/dragon_head.scad @@ -1,105 +1,11 @@ use ; -use ; -use ; use ; -use ; use ; use ; use ; -use ; use ; -torus_knot_dragon2(); - -module torus_knot_dragon2() { - phi_step = 0.05; - - knot = torus_knot(2, 3, phi_step); - d_path = reverse([for(i = [6:len(knot) - 4]) knot[i]]); - - along_with(d_path, scale = 0.85, method = "EULER_ANGLE") - scale(0.06) - one_segment(); - - function __angy_angz(p1, p2) = - let( - dx = p2[0] - p1[0], - dy = p2[1] - p1[1], - dz = p2[2] - p1[2], - ya = atan2(dz, sqrt(dx * dx + dy * dy)), - za = atan2(dy, dx) - ) [ya, za]; - - h_angy_angz = __angy_angz(d_path[len(d_path) - 2], d_path[len(d_path) - 1]); - - translate([2.75, -.9, .45]) - rotate([0, 28, 245]) - scale(0.0625) - head(h_angy_angz); - - t_angy_angz = __angy_angz(d_path[1], d_path[0]); - - translate([2.25, 1.5, -.8]) - rotate([0, t_angy_angz[0], t_angy_angz[1]]) - rotate([0, -100, -90]) - scale([0.0525, 0.0525, 0.06]) - tail(); -} - -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]) - circle(1, $fn = 4); - } - - for(a = [0:30:330]) { - hull() { - rotate(a) - translate([radius, 0, height]) - one_scale(); - - rotate(a + 15) - translate([radius, 0, height + 1.75]) - one_scale(); - } - } -} - -module one_segment() { - // scales - scale([1,0.85,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); - } - - // dorsal fin - translate([0, 2.5, -3]) - rotate([-65, 0, 0]) - shear(sy = [0, 2]) - linear_extrude(4, scale = 0.2) - square([2, 10], center = true); - - // belly - hull() { - 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); - } -} - -module head(angy_angz) { +module dragon_head(angy_angz) { module hair() { for(i = [16:36]) { rotate(i * 10) @@ -207,14 +113,4 @@ module head(angy_angz) { mirror([0, 1, 0]) one_beard(); } } -} - -module tail() { - scale([1,0.85,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); - } } \ No newline at end of file diff --git a/examples/torus_knot_dragon.scad b/examples/dragon/dragon_head_low_poly.scad similarity index 83% rename from examples/torus_knot_dragon.scad rename to examples/dragon/dragon_head_low_poly.scad index d028e454..9e86a7b5 100644 --- a/examples/torus_knot_dragon.scad +++ b/examples/dragon/dragon_head_low_poly.scad @@ -1,50 +1,8 @@ use ; -use ; use ; use ; -use ; -use ; -torus_knot_dragon(); - -module torus_knot_dragon() { - phi_step = 0.04; - - knot = torus_knot(2, 3, phi_step); - dragon_body_path = reverse([for(i = [9:len(knot) - 3]) knot[i]]); - - body_shape = concat( - bezier_curve(0.25, - [ - [30, -35], [16, 0], [4, 13], - [3, -5], [0, 26], [-3, -5], - [-4, 13], [-16, 0], [-30, -35] - ] - ), - bezier_curve(0.25, - [[-22, -35], [-15, -45], [0, -55], [15, -45], [22, -35]] - ) - ); - - - pts = [for(p = body_shape) p * 0.015]; - p = dragon_body_path[0]; - - path_extrude(pts, concat([p + [0.00001, 0.0000055, 0.000008]], dragon_body_path), scale = 0.9); - - translate([2.975, -0.75, -0.75]) - scale(0.01825) - rotate([-52, -9, -25]) - dragon_head(); - - translate([1.84, 1.635, -0.885]) - rotate([104.95, -154.35, 66.25]) - ellipse_extrude(1.2, slices = 7, twist = 15) - scale(0.9 * 0.0150) - polygon(body_shape); -} - -module dragon_head() { +module dragon_head_low_poly() { module palate() { t_step = 0.15; diff --git a/examples/dragon/hilbert_dragon.scad b/examples/dragon/hilbert_dragon.scad new file mode 100644 index 00000000..f9a8b336 --- /dev/null +++ b/examples/dragon/hilbert_dragon.scad @@ -0,0 +1,104 @@ +use ; +use ; +use ; +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() { + // 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); + } + + // dorsal fin + translate([0, 4, -1.5]) + rotate([-105, 0, 0]) + shear(sy = [0, .75]) + 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); + } + } + + 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); + + dragon_body_path = reverse([for(i = [1:len(smoothed_hilbert_path) - 2]) smoothed_hilbert_path[i]]); + + along_with(dragon_body_path, scale = 0.6) + rotate([90, 0, 0]) + scale(0.035) + one_segment(); + + // tail + translate([0, 0, -0.62]) + rotate(-5) + scale(0.0285) + mirror([0, 0, 1]) + scales(120, 2.5, 2, -9, 1); + + translate([0, 0, -2.5]) + scale(0.035) + dragon_head([0, 0]); +} + + +function hilbert_curve() = + let( + axiom = "A", + rules = [ + ["A", "B-F+CFC+F-D&F^D-F+&&CFC+F+B//"], + ["B", "A&F^CFB^F^D^^-F-D^|F^B|FC^F^A//"], + ["C", "|D^|F^B-F+C^F^A&&FA&F^C+F+B^F^D//"], + ["D", "|CFB-F+B|FA&F^A&&FB-F+B|FC//"] + ] + ) + lsystem3(axiom, rules, 2, 90, 1, 0, [0, 0, 0]); \ No newline at end of file diff --git a/examples/dragon/hilbert_dragon_low_poly.scad b/examples/dragon/hilbert_dragon_low_poly.scad new file mode 100644 index 00000000..05386d25 --- /dev/null +++ b/examples/dragon/hilbert_dragon_low_poly.scad @@ -0,0 +1,67 @@ +use ; +use ; +use ; +use ; +use ; +use ; +use ; +use ; + +hilbert_dragon_low_poly(); + +module hilbert_dragon_low_poly() { + 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.48, t_step = 0.2); + + dragon_body_path = reverse([for(i = [1:len(smoothed_hilbert_path) - 2]) smoothed_hilbert_path[i]]); + + body_shape = concat( + bezier_curve(0.25, + [ + [30, -35], [16, 0], [4, 13], + [3, -5], [0, 26], [-3, -5], + [-4, 13], [-16, 0], [-30, -35] + ] + ), + bezier_curve(0.25, + [[-22, -35], [-15, -45], [0, -55], [15, -45], [22, -35]] + ) + ); + + + pts = [for(p = body_shape) p * 0.007]; + p = dragon_body_path[0]; + + path_extrude(pts, concat([p + [0.0155, 0, 0.175]], [for(i = [1:len(dragon_body_path) - 1]) dragon_body_path[i]]), scale = 0.9); + + translate([0.125, 0, -2.73]) + scale(0.009) + rotate([-60, 0, 90]) + dragon_head_low_poly(); + + translate([0, 0, -0.525]) + rotate([0, -7, 0]) + rotate(90) + ellipse_extrude(0.5, slices = 4, twist = 15) + scale(0.9 * 0.007) + polygon(body_shape); +} + + + +function hilbert_curve() = + let( + axiom = "A", + rules = [ + ["A", "B-F+CFC+F-D&F^D-F+&&CFC+F+B//"], + ["B", "A&F^CFB^F^D^^-F-D^|F^B|FC^F^A//"], + ["C", "|D^|F^B-F+C^F^A&&FA&F^C+F+B^F^D//"], + ["D", "|CFB-F+B|FA&F^A&&FB-F+B|FC//"] + ] + ) + lsystem3(axiom, rules, 2, 90, 1, 0, [0, 0, 0]); \ No newline at end of file diff --git a/examples/spiral/dragon.scad b/examples/dragon/spiral_dragon.scad similarity index 50% rename from examples/spiral/dragon.scad rename to examples/dragon/spiral_dragon.scad index ba103452..a6afe278 100644 --- a/examples/spiral/dragon.scad +++ b/examples/dragon/spiral_dragon.scad @@ -1,17 +1,13 @@ use ; use ; -use ; -use ; use ; use ; use ; -use ; -use ; use ; use ; use ; -use ; use ; +use ; r1 = 25; r2 = 15; @@ -81,117 +77,7 @@ module tail() { } } -module head(angy_angz) { - module hair() { - for(i = [16:36]) { - rotate(i * 10) - translate([0, -13, 0]) - rotate([9, 0, 0]) - linear_extrude(15, scale = 0.05, twist = 50 - rands(0, 100, 1, seed = i)[0]) - translate([0, 10, 0]) - circle(3, $fn = 4); - } - - for(i = [0:35]) { - rotate(i * 12) - translate([0, -11.5, 0]) - rotate([5, 0, 0]) - linear_extrude(20, scale = 0.05, twist = 50 - rands(0, 100, 1, seed = i + 1)[0]) - translate([0, 10, 0]) - circle(3.2, $fn = 5); - } - - for(i = [0:35]) { - rotate(i * 10) - translate([0, -10, 0]) - rotate([2, 0, 0]) - linear_extrude(22, scale = 0.05, twist = 50 - rands(0, 100, 1, seed = i + 2)[0]) - translate([0, 10, 0]) - circle(3, $fn = 5); - } - } - - module one_horn() { - translate([-9, -4, -2]) - rotate([45, -25, 0]) - linear_extrude(30, scale = 0.1, twist = -90) - translate([7.5, 0, 0]) - circle(3, $fn = 4); - } - - module mouth() { - path1 = curve(0.4, [[0, -8, -1], [0, -11, .25], [0, -12, 5], [0, -9, 5], [0, -4, 6], [0, -0.5, 8], [0, 5, 6.5], [0, 8, 6], [0, 12, 1], [0, 16, 0]]); - path2 = [for(p = path1) ptf_rotate(p, [0, -12, 0]) * 0.9 + [-2, 0, 0]]; - path3 = [for(i = [0:len(path1) - 1]) [-i / 6 - 1.5, i / 1.65 - 9, 0]]; - path4 = [for(p = path3) [-p[0], p[1], p[2]]]; - path5 = [for(p = path2) [-p[0], p[1], p[2]]]; - - translate([0, 0, -2]) - rotate([90, 0, -90]) - sweep(paths2sections([path1, path2, path3, path4, path5])); - - translate([0, 0, -3.25]) - rotate([90, 0, -90]) - ellipse_extrude(5.5, slices = 2) - polygon( - shape_trapezium([5, 18], - h = 20, - corner_r = 2, $fn = 4) - ); - - mirror([1, 0, 0]) - translate([0, 0, -3]) - rotate([85, 0, -90]) - ellipse_extrude(4, slices = 2) - polygon( - shape_trapezium([5, 18], - h = 20, - corner_r = 2, $fn = 5) - ); - } - - module one_eye() { - translate([-5, 2.5, -2]) - rotate([-5, -8, -10]) - scale([1, 1, 1.75]) - sphere(1.75, $fn = 6); - - translate([-5.1, 3.75, -2.25]) - rotate([-25, 0, 75]) - sphere(0.65, $fn = 6); - } - - module one_beard() { - translate([-11.15, -12, -10]) - rotate(180) - linear_extrude(8, scale = 0.2, twist = 90) - translate([-10, -10, 0]) - circle(1, $fn = 6); - } - - rotate([0, angy_angz[0] + 15, angy_angz[1]]) - translate([0, 0, -25 / 2]) - scale(1.15) { - scale([0.8, 0.9, 1]) hair(); - - translate([0, 0, 2]) { - rotate(-90) { - one_horn(); - mirror([-1, 0, 0]) one_horn(); - } - - mouth(); - - one_eye(); - mirror([0, 1, 0]) one_eye(); - - one_beard(); - mirror([0, 1, 0]) one_beard(); - } - } -} - -module dragon() { +module spiral_dragon() { path_pts = helix( radius = [r1, r2], levels = levels, @@ -224,7 +110,7 @@ module dragon() { translate([19, 0, 65]) rotate([95, 0, 0]) - head(angy_angz); + dragon_head(angy_angz); } module flame_mountain(beginning_radius, fn, amplitude,curve_step, smoothness) { @@ -266,7 +152,7 @@ module flame_mountain(beginning_radius, fn, amplitude,curve_step, smoothness) { rotate(180) { translate([0, 0, 7]) - dragon($fn = 12); + spiral_dragon($fn = 12); rotate(60) flame_mountain( beginning_radius = 26, diff --git a/examples/dragon/torus_knot_dragon.scad b/examples/dragon/torus_knot_dragon.scad new file mode 100644 index 00000000..42467cb5 --- /dev/null +++ b/examples/dragon/torus_knot_dragon.scad @@ -0,0 +1,105 @@ +use ; +use ; +use ; +use ; +use ; + +torus_knot_dragon(); + +module torus_knot_dragon() { + phi_step = 0.05; + + knot = torus_knot(2, 3, phi_step); + d_path = reverse([for(i = [6:len(knot) - 4]) knot[i]]); + + along_with(d_path, scale = 0.85, method = "EULER_ANGLE") + scale(0.06) + one_segment(); + + function __angy_angz(p1, p2) = + let( + dx = p2[0] - p1[0], + dy = p2[1] - p1[1], + dz = p2[2] - p1[2], + ya = atan2(dz, sqrt(dx * dx + dy * dy)), + za = atan2(dy, dx) + ) [ya, za]; + + h_angy_angz = __angy_angz(d_path[len(d_path) - 2], d_path[len(d_path) - 1]); + + translate([2.75, -.9, .45]) + rotate([0, 28, 245]) + scale(0.0625) + dragon_head(h_angy_angz); + + t_angy_angz = __angy_angz(d_path[1], d_path[0]); + + translate([2.25, 1.5, -.8]) + rotate([0, t_angy_angz[0], t_angy_angz[1]]) + rotate([0, -100, -90]) + scale([0.0525, 0.0525, 0.06]) + tail(); +} + +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]) + circle(1, $fn = 4); + } + + for(a = [0:30:330]) { + hull() { + rotate(a) + translate([radius, 0, height]) + one_scale(); + + rotate(a + 15) + translate([radius, 0, height + 1.75]) + one_scale(); + } + } +} + +module one_segment() { + // scales + scale([1,0.85,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); + } + + // dorsal fin + translate([0, 2.5, -3]) + rotate([-65, 0, 0]) + shear(sy = [0, 2]) + linear_extrude(4, scale = 0.2) + square([2, 10], center = true); + + // belly + hull() { + 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); + } +} + +module tail() { + scale([1,0.85,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); + } +} \ No newline at end of file diff --git a/examples/dragon/torus_knot_dragon_low_poly.scad b/examples/dragon/torus_knot_dragon_low_poly.scad new file mode 100644 index 00000000..860f98df --- /dev/null +++ b/examples/dragon/torus_knot_dragon_low_poly.scad @@ -0,0 +1,46 @@ +use ; +use ; +use ; +use ; +use ; + +use ; + +torus_knot_dragon_low_poly(); + +module torus_knot_dragon_low_poly() { + phi_step = 0.04; + + knot = torus_knot(2, 3, phi_step); + dragon_body_path = reverse([for(i = [9:len(knot) - 3]) knot[i]]); + + body_shape = concat( + bezier_curve(0.25, + [ + [30, -35], [16, 0], [4, 13], + [3, -5], [0, 26], [-3, -5], + [-4, 13], [-16, 0], [-30, -35] + ] + ), + bezier_curve(0.25, + [[-22, -35], [-15, -45], [0, -55], [15, -45], [22, -35]] + ) + ); + + + pts = [for(p = body_shape) p * 0.015]; + p = dragon_body_path[0]; + + path_extrude(pts, concat([p + [0.00001, 0.0000055, 0.000008]], dragon_body_path), scale = 0.9); + + translate([2.975, -0.75, -0.75]) + scale(0.01825) + rotate([-52, -9, -25]) + dragon_head_low_poly(); + + translate([1.84, 1.635, -0.885]) + rotate([104.95, -154.35, 66.25]) + ellipse_extrude(1.2, slices = 7, twist = 15) + scale(0.9 * 0.0150) + polygon(body_shape); +} \ No newline at end of file diff --git a/examples/turtle/hilbert_dragon.scad b/examples/turtle/hilbert_dragon.scad deleted file mode 100644 index dacc5894..00000000 --- a/examples/turtle/hilbert_dragon.scad +++ /dev/null @@ -1,219 +0,0 @@ -use ; -use ; -use ; -use ; -use ; -use ; -use ; -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() { - // 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); - } - - // dorsal fin - translate([0, 4, -1.5]) - rotate([-105, 0, 0]) - shear(sy = [0, .75]) - 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); - } - - } - - module head(angy_angz) { - module hair() { - for(i = [16:36]) { - rotate(i * 10) - translate([0, -13, 0]) - rotate([9, 0, 0]) - linear_extrude(15, scale = 0.05, twist = 50 - rands(0, 100, 1, seed = i)[0]) - translate([0, 10, 0]) - circle(3, $fn = 4); - } - - for(i = [0:35]) { - rotate(i * 12) - translate([0, -11.5, 0]) - rotate([5, 0, 0]) - linear_extrude(20, scale = 0.05, twist = 50 - rands(0, 100, 1, seed = i + 1)[0]) - translate([0, 10, 0]) - circle(3.2, $fn = 5); - } - - for(i = [0:35]) { - rotate(i * 10) - translate([0, -10, 0]) - rotate([2, 0, 0]) - linear_extrude(22, scale = 0.05, twist = 50 - rands(0, 100, 1, seed = i + 2)[0]) - translate([0, 10, 0]) - circle(3, $fn = 5); - } - } - - module one_horn() { - translate([-9, -4, -2]) - rotate([45, -25, 0]) - linear_extrude(30, scale = 0.1, twist = -90) - translate([7.5, 0, 0]) - circle(3, $fn = 4); - } - - module mouth() { - path1 = curve(0.4, [[0, -8, -1], [0, -11, .25], [0, -12, 5], [0, -9, 5], [0, -4, 6], [0, -0.5, 8], [0, 5, 6.5], [0, 8, 6], [0, 12, 1], [0, 16, 0]]); - path2 = [for(p = path1) ptf_rotate(p, [0, -12, 0]) * 0.9 + [-2, 0, 0]]; - path3 = [for(i = [0:len(path1) - 1]) [-i / 6 - 1.5, i / 1.65 - 9, 0]]; - path4 = [for(p = path3) [-p[0], p[1], p[2]]]; - path5 = [for(p = path2) [-p[0], p[1], p[2]]]; - - translate([0, 0, -2]) - rotate([90, 0, -90]) - sweep(paths2sections([path1, path2, path3, path4, path5])); - - translate([0, 0, -3.25]) - rotate([90, 0, -90]) - ellipse_extrude(5.5, slices = 2) - polygon( - shape_trapezium([5, 18], - h = 20, - corner_r = 2, $fn = 4) - ); - - mirror([1, 0, 0]) - translate([0, 0, -3]) - rotate([85, 0, -90]) - ellipse_extrude(4, slices = 2) - polygon( - shape_trapezium([5, 18], - h = 20, - corner_r = 2, $fn = 5) - ); - } - - module one_eye() { - translate([-5, 2.5, -2]) - rotate([-5, -8, -10]) - scale([1, 1, 1.75]) - sphere(1.75, $fn = 6); - - translate([-5.1, 3.75, -2.25]) - rotate([-25, 0, 75]) - sphere(0.65, $fn = 6); - } - - module one_beard() { - translate([-11.15, -12, -10]) - rotate(180) - linear_extrude(8, scale = 0.2, twist = 90) - translate([-10, -10, 0]) - circle(1, $fn = 6); - } - - rotate([0, angy_angz[0] + 15, angy_angz[1]]) - translate([0, 0, -25 / 2]) - scale(1.15) { - scale([0.8, 0.9, 1]) hair(); - - translate([0, 0, 2]) { - rotate(-90) { - one_horn(); - mirror([-1, 0, 0]) one_horn(); - } - - mouth(); - - one_eye(); - mirror([0, 1, 0]) one_eye(); - - one_beard(); - mirror([0, 1, 0]) one_beard(); - } - } - } - - 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); - - dragon_body_path = reverse([for(i = [1:len(smoothed_hilbert_path) - 2]) smoothed_hilbert_path[i]]); - - along_with(dragon_body_path, scale = 0.6) - rotate([90, 0, 0]) - scale(0.035) - one_segment(); - - // tail - translate([0, 0, -0.62]) - rotate(-5) - scale(0.0285) - mirror([0, 0, 1]) - scales(120, 2.5, 2, -9, 1); - - translate([0, 0, -2.5]) - scale(0.035) - head([0, 0]); -} - - -function hilbert_curve() = - let( - axiom = "A", - rules = [ - ["A", "B-F+CFC+F-D&F^D-F+&&CFC+F+B//"], - ["B", "A&F^CFB^F^D^^-F-D^|F^B|FC^F^A//"], - ["C", "|D^|F^B-F+C^F^A&&FA&F^C+F+B^F^D//"], - ["D", "|CFB-F+B|FA&F^A&&FB-F+B|FC//"] - ] - ) - lsystem3(axiom, rules, 2, 90, 1, 0, [0, 0, 0]); \ No newline at end of file diff --git a/examples/turtle/hilbert_dragon_low_poly.scad b/examples/turtle/hilbert_dragon_low_poly.scad deleted file mode 100644 index 52f269a9..00000000 --- a/examples/turtle/hilbert_dragon_low_poly.scad +++ /dev/null @@ -1,276 +0,0 @@ -use ; -use ; -use ; -use ; -use ; -use ; -use ; -use ; - -hilbert_dragon_low_poly(); - -module hilbert_dragon_low_poly() { - 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.48, t_step = 0.2); - - dragon_body_path = reverse([for(i = [1:len(smoothed_hilbert_path) - 2]) smoothed_hilbert_path[i]]); - - body_shape = concat( - bezier_curve(0.25, - [ - [30, -35], [16, 0], [4, 13], - [3, -5], [0, 26], [-3, -5], - [-4, 13], [-16, 0], [-30, -35] - ] - ), - bezier_curve(0.25, - [[-22, -35], [-15, -45], [0, -55], [15, -45], [22, -35]] - ) - ); - - - pts = [for(p = body_shape) p * 0.007]; - p = dragon_body_path[0]; - - path_extrude(pts, concat([p + [0.0155, 0, 0.175]], [for(i = [1:len(dragon_body_path) - 1]) dragon_body_path[i]]), scale = 0.9); - - translate([0.125, 0, -2.73]) - scale(0.009) - rotate([-60, 0, 90]) - dragon_head(); - - translate([0, 0, -0.525]) - rotate([0, -7, 0]) - rotate(90) - ellipse_extrude(0.5, slices = 4, twist = 15) - scale(0.9 * 0.007) - polygon(body_shape); -} - -module dragon_head() { - module palate() { - t_step = 0.15; - - palate_shape = concat( - bezier_curve(0.25, - [ - [31, -35], [19, 0], [8, 15], [-8, 12], [-19, 0], [-31, -35] - ] - ), - bezier_curve(0.25, - [[-20, -35], [-8, -20], [8, -20], [20, -35]] - ) - ); - - palate_path = bezier_curve(t_step, - [[0, -110, 30], [0, -100, 25], [0, -80, 50], [0, -55, 130], [0, -20, -95], [0, 5, 105], [0, 10, 30], [0, 10, 25]] - ); - - path_extrude(palate_shape, palate_path, scale = 0); - } - - module jaw() { - t_step = 0.2; - - jaw_shape = concat( - bezier_curve(t_step, - [ - [-20, 16], [-16, -5], [-8, -25], - [8, -25], [16, -5], [20, 16] - ] - ), - bezier_curve(t_step, - [[15, 14], [8, 0], [-8, 0], [-15, 14]] - ) - ); - - jaw_path = bezier_curve(t_step, - [[0, -60, -5], [0, 5, 0], [0, 10, 0], [0, 35, 39], [0, 25, 40]] - ); - - path_extrude(jaw_shape, jaw_path, scale = 0); - } - - - module horns() { - path1 = bezier_curve(0.15, - [ - [12, -40, 15], - [40, -38, 0], - [30, -60, -10], - [50, -90, -30] - ] - ); - - shape1 = shape_circle(7, $fn = 6); - - path_extrude(shape1, path1, scale = 0); - mirror([1, 0, 0]) - path_extrude(shape1, path1, scale = 0); - - path2 = bezier_curve(0.15, - [ - [12, -42, 15], - [30, -17, 16], - [35, -20, 0], - [40, -40, -10] - ] - ); - - shape2 = shape_circle(7, $fn = 5); - - path_extrude(shape2, path2, scale = 0); - mirror([1, 0, 0]) - path_extrude(shape2, path2, scale = 0); - - - path3 = bezier_curve(0.15, - [ - [10, -40, 4], - [20, -60, 10], - [15, -70, -5], - [15, -125, 0] - ] - ); - - shape3 = shape_circle(12, $fn = 6); - - path_extrude(shape3, path3, twist = 60, scale = 0); - mirror([1, 0, 0]) - path_extrude(shape3, path3, twist = 60, scale = 0); - - path4 = bezier_curve(0.15, - [ - [0, 10, 65], - [0, 5, 70], - [0, 10, 75], - [0, 5, 85], - ] - ); - - path_extrude(shape_circle(5, $fn = 5), path4, scale = 0); - - path5 = bezier_curve(0.15, - [ - [0, 0, 65], - [0, -5, 70], - [0, 0, 70], - [0, -5, 75], - ] - ); - - path_extrude(shape_circle(3, $fn = 5), path5, scale = 0); - - path6 = bezier_curve(0.15, - [ - [0, -18, 45], - [0, -20, 55], - [0, -15, 65], - [0, -20, 75], - ] - ); - - path_extrude(shape_circle(6, $fn = 6), path6, scale = 0); - } - - module tone() { - path1 = bezier_curve(0.15, - [ - [0, -40, -5], - [5, 0, 15], - [-5, 5, 20], - [0, 10, 30], - - ] - ); - - shape1 = shape_circle(6, $fn = 6); - - - path_extrude(shape1, path1, scale = 0); - } - - module eyes() { - path5 = bezier_curve(0.2, - [ - [0, 0, 0], - [0, -5, 5], - [0, 0, 8], - [1, -5, 12], - ] - ); - - module eye() { - eye_shape = shape_circle(5, $fn = 6); - - translate([12, -40, 30.5]) - rotate([-40, 0, 8]) - scale([0.7, 1, 0.7]) - union() { - rotate([-40.25, 0, 0]) - path_extrude(eye_shape, path5, scale = 0); - rotate(180) - mirror([0, 0, 1]) - rotate([-40.25, 0, 0]) - path_extrude(eye_shape, path5, scale = 0); - } - translate([10.5, -36, 28.5]) - sphere(5, $fn = 18); - } - - eye(); - mirror([1, 0, 0]) - eye(); - } - - module neck() { - neck_shape = concat( - bezier_curve(0.25, - [ - [31, -35], [19, 0], [8, 15], [-8, 12], [-19, 0], [-31, -35] - ] - ), - bezier_curve(0.25, - [[-20, -35], [-8, -20], [8, -20], [20, -35]] - ) - ); - - translate([0, -64.5, -1]) - rotate([165, 0, 0]) - linear_extrude(30, scale = 0.9) - scale(0.95) - polygon(neck_shape); - } - - rotate([-45, 0, 0]) - union() { - rotate([45, 0, 0]) - translate([0, 50, 9.5]) - palate(); - - jaw(); - horns(); - tone(); - eyes(); - - neck(); - } - -} - -function hilbert_curve() = - let( - axiom = "A", - rules = [ - ["A", "B-F+CFC+F-D&F^D-F+&&CFC+F+B//"], - ["B", "A&F^CFB^F^D^^-F-D^|F^B|FC^F^A//"], - ["C", "|D^|F^B-F+C^F^A&&FA&F^C+F+B^F^D//"], - ["D", "|CFB-F+B|FA&F^A&&FB-F+B|FC//"] - ] - ) - lsystem3(axiom, rules, 2, 90, 1, 0, [0, 0, 0]); \ No newline at end of file