From 385258bbc9db6aa5d34dff4e1c96553eee35485d Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Mon, 7 Oct 2019 20:41:55 +0800 Subject: [PATCH] add triangle_splice --- examples/triangle_splice.scad | 49 +++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 examples/triangle_splice.scad diff --git a/examples/triangle_splice.scad b/examples/triangle_splice.scad new file mode 100644 index 00000000..43f4167c --- /dev/null +++ b/examples/triangle_splice.scad @@ -0,0 +1,49 @@ +include ; +include ; + +tri_side_leng = 20; +tris_per_line = 10; +lines = 3; +line_width = 1; + +points = [[10, -6], [-6.5, -6], [-3, 0], [0, 0]]; +// points = [[0, 0], [1.5, 2.5], [1.5, -6], [-4, -6], [-6.5, 0]]; +triangle_splice(tri_side_leng, tris_per_line, lines, line_width) + triangle_pattern(points, line_width); + + +module triangle_pattern(points, line_width) { + polyline2d(points, line_width); + rotate([0, 0, 120]) polyline2d(points, line_width); + rotate([0, 0, 240]) polyline2d(points, line_width); +} + +module triangle_splice_one_line(tri_leng, tris, line_width) { + half_leng = tri_leng / 2; + height = half_leng * sqrt(3); + hd3 = height / 3; + + for(i = [0 : tris - 1]) { + x_offset = half_leng * i; + is_even = i % 2 == 0; + translate([x_offset, is_even ? 0 : hd3, 0]) + mirror([0, is_even ? 0 : 1, 0]) + children(); + } + +} + +module triangle_splice(length, tris_per_line, lines, line_width = 1) { + half_leng = length / 2; + height = half_leng * sqrt(3); + hd3 = height / 3; + + for(i = [0 : lines - 1]) { + is_even = i % 2 == 0; + hoffset = height * i; + translate([0, is_even ? hoffset : hoffset + hd3]) + mirror([0, is_even ? 0 : 1, 0]) + triangle_splice_one_line(length, tris_per_line, line_width) + children(); + } +} \ No newline at end of file