From 5033c415dbb1bcc52bde514c1b76ad23f46f9658 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Wed, 11 Mar 2020 09:39:01 +0800 Subject: [PATCH] add circle_maze --- examples/maze/circle_maze.scad | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 examples/maze/circle_maze.scad diff --git a/examples/maze/circle_maze.scad b/examples/maze/circle_maze.scad new file mode 100644 index 00000000..0b274906 --- /dev/null +++ b/examples/maze/circle_maze.scad @@ -0,0 +1,41 @@ +use ; +use ; +use ; + +function ptf_circle(point, offset) = + let( + p = [point[0] - offset, point[1] - offset], + n = max(abs(p[0]), abs(p[1])), + r = n * 1.414, + a = atan2(p[0], p[1]) + ) + [r * cos(a), r * sin(a)]; + + +module circle_maze(start, r_blocks, block_width, wall_thickness, origin_offset) { + double_r_blocks = r_blocks * 2; + blocks = mz_blocks( + start, + double_r_blocks, double_r_blocks + ); + + width = double_r_blocks * block_width; + walls = mz_walls(blocks, double_r_blocks, double_r_blocks, block_width); + + offset = is_undef(origin_offset) ? width / 2 : origin_offset; + + for(wall = walls) { + for(i = [0:len(wall) - 2]) { + p0 = ptf_circle(wall[i], offset); + p1 = ptf_circle(wall[i + 1], offset); + hull_polyline2d([p0, p1], width = wall_thickness); + } + } +} + +circle_maze( + start = [1, 1], + r_blocks = 10, + block_width = 2, + wall_thickness = .75 +); \ No newline at end of file