lavender.scad
1 use <pie.scad> 2 use <ptf/ptf_rotate.scad> 3 use <experimental/tile_penrose3.scad> 4 5 n = 5; 6 radius = 30; 7 $fn = 6; 8 9 lavender(n, radius); 10 11 module lavender(n, radius) { 12 module draw(tris, radius) { 13 module draw_tri(type, points) { 14 module draw_acute_pie(p, r, a) { 15 hull() { 16 linear_extrude(layer_thickness * 2) 17 offset(-radius / 175) 18 translate(p) 19 rotate(a) 20 pie(r * 1.1, 72); 21 22 linear_extrude(layer_thickness * 3) 23 offset(-radius / 100) 24 translate(p) 25 rotate(a) 26 pie(r, 72); 27 28 } 29 } 30 31 module draw_obtuse_pie(p, r, a) { 32 hull() { 33 linear_extrude(layer_thickness * 2) 34 offset(-radius / 175) 35 translate(p) 36 rotate(a) 37 pie(r * 1.1, 36); 38 39 linear_extrude(layer_thickness * 3) 40 offset(-radius / 100) 41 translate(p) 42 rotate(a) 43 pie(r, 36); 44 } 45 } 46 47 v1 = points[0] - points[1]; 48 v2 = points[2] - points[1]; 49 r = norm(v1) / 2; 50 clk = cross(v1, v2); 51 52 color("Lavender") 53 if(type == "ACUTE") { 54 if(clk < 0) { 55 v = (points[0] + points[1]) / 2 - points[0]; 56 a = atan2(v[1], v[0]); 57 draw_acute_pie(points[0], r, a); 58 } 59 else { 60 v = (points[2] + points[1]) / 2 - points[2]; 61 a = atan2(v[1], v[0]) - 108; 62 draw_acute_pie(points[0], r, a); 63 } 64 } 65 else { 66 if(clk < 0) { 67 v = (points[0] + points[1]) / 2 - points[0]; 68 a = atan2(v[1], v[0]); 69 draw_obtuse_pie(points[0], r, a); 70 } 71 else { 72 v = (points[0] - points[2]); 73 a = atan2(v[1], v[0]) + 180; 74 draw_obtuse_pie(points[0], r, a); 75 } 76 } 77 78 color("Lime") 79 hull() { 80 linear_extrude(layer_thickness) 81 polygon(points); 82 83 linear_extrude(layer_thickness * 2) 84 offset(-radius / 175) 85 polygon(points); 86 } 87 88 color("Maroon") 89 linear_extrude(layer_thickness) 90 offset(radius / 50) 91 polygon(points); 92 } 93 94 for(t = tris) { 95 draw_tri(t[0], t[1] * radius); 96 } 97 } 98 99 100 layer_thickness = radius / 50; 101 draw(tile_penrose3(n), radius); 102 }