fern_leaf_stencil.scad
1 use <polyline_join.scad> 2 use <hollow_out.scad> 3 use <turtle/t2d.scad> 4 5 radius = 40; 6 height = 3; 7 thickness = 1; 8 width = 1; 9 10 min_leng = 0.1; 11 k1 = 0.9; 12 k2 = 0.3; 13 14 module fern_leaf(t, leng, min_leng, k1, k2, width) { 15 t1 = t2d(t, "forward", leng = leng); 16 polyline_join([t2d(t, "point"), t2d(t1, "point")]) 17 circle(width / 2); 18 19 if(leng > min_leng) { 20 fern_leaf( 21 t2d(t1, "turn", angle = 70), 22 k2 * leng, min_leng, k1, k2, width 23 ); 24 25 t2 = t2d(t1, "forward", leng = k1 * leng); 26 polyline_join([t2d(t1, "point"), t2d(t2, "point")]) 27 circle(width / 2); 28 29 t3 = t2d(t2, "turn", angle = -69.0); 30 fern_leaf( 31 t3, 32 k1 * k2 * leng, min_leng, k1, k2, width 33 ); 34 fern_leaf( 35 t2d(t3, "turn", angle = 68.0), 36 k1 * k1 * leng, min_leng, k1, k2, width 37 ); 38 } 39 } 40 41 module fern_leaf_stencil(radius, height, thickness, width, min_leng, k1, k2) { 42 $fn = 48; 43 44 linear_extrude(thickness) 45 difference() { 46 union() { 47 translate([radius, 0]) 48 scale([1, 0.5, 1]) 49 hollow_out(radius / 3) 50 circle(radius / 1.5); 51 52 circle(radius); 53 } 54 translate([-radius, 0]) 55 fern_leaf( 56 t2d(point = [0, 0], angle = 0), 57 radius / 5, min_leng, k1, k2, width 58 ); 59 } 60 61 linear_extrude(height) 62 hollow_out(thickness) 63 circle(radius + thickness); 64 } 65 66 fern_leaf_stencil(radius, height, thickness, width, min_leng, k1, k2);