From be7f736f95cde7f769560104ffaab4708ffe7ddf Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Sun, 16 Feb 2020 16:25:31 +0800 Subject: [PATCH] refactor --- examples/maze/regular_polygon_maze.scad | 26 ++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/examples/maze/regular_polygon_maze.scad b/examples/maze/regular_polygon_maze.scad index a70518fd..0cc7a92a 100644 --- a/examples/maze/regular_polygon_maze.scad +++ b/examples/maze/regular_polygon_maze.scad @@ -1,6 +1,7 @@ use ; use ; -use ; +use ; +use ; // only for creating a small maze @@ -36,13 +37,28 @@ module regular_polygon_to_polygon_wall(radius, length, angle, thickness, sides) } module regular_polygon_maze(radius, cblocks, levels, thickness = 1, sides) { + // NO_WALL = 0; + // UPPER_WALL = 1; + // RIGHT_WALL = 2; + // UPPER_RIGHT_WALL = 3; + + function no_wall(block) = get_wall_type(block) == 0; + function upper_wall(block) = get_wall_type(block) == 1; + function right_wall(block) = get_wall_type(block) == 2; + function upper_right_wall(block) = get_wall_type(block) == 3; + + function block(x, y, wall_type, visited) = [x, y, wall_type, visited]; + function get_x(block) = block[0]; + function get_y(block) = block[1]; + function get_wall_type(block) = block[2]; + arc_angle = 360 / cblocks; r = radius / (levels + 1); - maze = go_maze(1, 1, - starting_maze(cblocks, levels), - cblocks, levels, y_circular = true - ); + maze = mz_blocks( + [1, 1], + cblocks, levels, y_circular = true + ); difference() { render() union() {