From f4bf9d83fcf75ffaf9edc0e77bb2bea498747ed4 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Sat, 15 Feb 2020 21:11:09 +0800 Subject: [PATCH] add tiled_line_torus --- examples/tiled_line_torus.scad | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 examples/tiled_line_torus.scad diff --git a/examples/tiled_line_torus.scad b/examples/tiled_line_torus.scad new file mode 100644 index 00000000..cb5bd06f --- /dev/null +++ b/examples/tiled_line_torus.scad @@ -0,0 +1,36 @@ +use ; +use ; +use ; + +size = [20, 50]; +line_width = 1; +step = 1; +twist = 180; +$fn = 4; + +module tiled_line_torus(size, twist, step, line_width = 1) { + sizexy = is_num(size) ? [size, size] : size; + s = is_undef(step) ? line_width * 2 : step; + + function rand_diagonal_line_pts(x, y, size) = + rand(0, 1) >= 0.5 ? [[x, y], [x + size, y + size]] : [[x + size, y], [x, y + size]]; + + lines = concat( + [ + for(x = [0:s:sizexy[0] - s]) + for(y = [0:s:sizexy[1] - s]) + rand_diagonal_line_pts(x, y, s) + ] + ); + + for(line = lines) { + pts = [for(p = line) tf_torus(size, p, [size[0], size[0] / 2], twist = twist)]; + hull_polyline3d(pts, thickness = line_width); + } +} + +tiled_line_torus(size, twist, step, line_width); +color("black") +rotate_extrude($fn = 36) +translate([size[0] * 1.5, 0, 0]) + circle(size[0] / 2);