From 21754293c8937ee75241538693eb6399a53be72b Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Wed, 25 Aug 2021 17:33:24 +0800 Subject: [PATCH] add lavender --- examples/tiles/lavender.scad | 107 +++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 examples/tiles/lavender.scad diff --git a/examples/tiles/lavender.scad b/examples/tiles/lavender.scad new file mode 100644 index 00000000..a0dc4dc7 --- /dev/null +++ b/examples/tiles/lavender.scad @@ -0,0 +1,107 @@ +use ; +use ; +use ; +use ; + +n = 5; +radius = 30; +$fn = 6; + +lavender(n, radius); + +module lavender(n, radius) { + module draw(tris, radius) { + module draw_tri(type, points) { + module draw_acute_pie(p, r, a) { + hull() { + linear_extrude(layer_thickness * 2) + offset(-radius / 175) { + translate(p) + rotate(a) + pie(r * 1.1, 72); + } + + linear_extrude(layer_thickness * 3) + offset(-radius / 100) { + translate(p) + rotate(a) + pie(r, 72); + } + } + } + + module draw_obtuse_pie(p, r, a) { + hull() { + linear_extrude(layer_thickness * 2) + offset(-radius / 175) { + translate(p) + rotate(a) + pie(r * 1.1, 36); + } + + linear_extrude(layer_thickness * 3) + offset(-radius / 100) { + translate(p) + rotate(a) + pie(r, 36); + } + } + } + + v1 = points[0] - points[1]; + v2 = points[2] - points[1]; + r = norm(v1) / 2; + clk = cross(v1, v2); + + color("Lavender") + if(type == "ACUTE") { + if(clk < 0) { + v = (points[0] + points[1]) / 2 - points[0]; + a = atan2(v[1], v[0]); + draw_acute_pie(points[0], r, a); + } + else { + v = (points[2] + points[1]) / 2 - points[2]; + a = atan2(v[1], v[0]) - 108; + draw_acute_pie(points[0], r, a); + } + } + else { + if(clk < 0) { + v = (points[0] + points[1]) / 2 - points[0]; + a = atan2(v[1], v[0]); + draw_obtuse_pie(points[0], r, a); + } + else { + v = (points[0] - points[2]); + a = atan2(v[1], v[0]) + 180; + draw_obtuse_pie(points[0], r, a); + } + } + + color("Lime") + hull() { + linear_extrude(layer_thickness) + + polygon(points); + + linear_extrude(layer_thickness * 2) + offset(-radius / 175) + polygon(points); + } + + color("Maroon") + linear_extrude(layer_thickness) + offset(radius / 50) + polygon(points); + } + + for(t = tris) { + draw_tri(t[0], t[1] * radius); + } + } + + + layer_thickness = radius / 50; + draw(tile_penrose3(n), radius); +} \ No newline at end of file