From f594215469cf58821074a88f28f5a5cebc3dec52 Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Sun, 20 Dec 2020 10:49:16 +0800 Subject: [PATCH] rename block to cell --- examples/maze/cube_maze.scad | 14 +-- examples/maze/cylinder_maze.scad | 16 ++-- examples/maze/gyro_maze.scad | 8 +- examples/maze/heart2heart_maze.scad | 16 ++-- examples/maze/heart_maze.scad | 44 ++++----- examples/maze/maze_masking.scad | 22 ++--- examples/maze/mobius_maze.scad | 12 +-- examples/maze/noisy_circle_maze.scad | 18 ++-- examples/maze/pyramid_hex_maze.scad | 8 +- examples/maze/pyramid_maze.scad | 10 +- examples/maze/regular_polygon_maze.scad | 44 ++++----- examples/maze/sphere_maze.scad | 14 +-- examples/maze/square_maze.scad | 10 +- examples/maze/step_pyramid_maze.scad | 18 ++-- examples/maze/stereographic_hex_maze.scad | 6 +- examples/maze/stereographic_square_maze.scad | 12 +-- examples/maze/torus_maze.scad | 12 +-- examples/maze/twisted_maze.scad | 10 +- ...z_blocks_impl.scad => _mz_cells_impl.scad} | 92 +++++++++---------- src/maze/_impl/_mz_comm.scad | 16 ++-- src/maze/_impl/_mz_hex_walls.scad | 22 ++--- src/maze/_impl/_mz_initialize.scad | 10 +- src/maze/_impl/_mz_square_walls_impl.scad | 8 +- src/maze/mz_hamiltonian.scad | 12 +-- src/maze/mz_hex_walls.scad | 6 +- src/maze/mz_square_blocks.scad | 9 -- src/maze/mz_square_cells.scad | 9 ++ src/maze/mz_square_get.scad | 4 +- src/maze/mz_square_walls.scad | 10 +- 29 files changed, 245 insertions(+), 247 deletions(-) rename src/maze/_impl/{_mz_blocks_impl.scad => _mz_cells_impl.scad} (51%) delete mode 100644 src/maze/mz_square_blocks.scad create mode 100644 src/maze/mz_square_cells.scad diff --git a/examples/maze/cube_maze.scad b/examples/maze/cube_maze.scad index 462ec430..eca7cb2f 100644 --- a/examples/maze/cube_maze.scad +++ b/examples/maze/cube_maze.scad @@ -1,15 +1,15 @@ use ; maze_rows = 8; -block_width = 2; +cell_width = 2; wall_thickness = 1; inner_cube = true; travel_all = true; -module cube_maze(maze_rows, block_width, wall_thickness, inner_cube, travel_all) { - blocks_size = block_width * maze_rows; - cube_size = blocks_size - wall_thickness; - maze_size = blocks_size + wall_thickness; +module cube_maze(maze_rows, cell_width, wall_thickness, inner_cube, travel_all) { + cells_size = cell_width * maze_rows; + cube_size = cells_size - wall_thickness; + maze_size = cells_size + wall_thickness; half_wall_thickness = wall_thickness / 2; half_cube_size = cube_size / 2; @@ -21,7 +21,7 @@ module cube_maze(maze_rows, block_width, wall_thickness, inner_cube, travel_all) module one_maze() { translate([origin, origin, half_cube_size]) linear_extrude(wall_thickness) - square_maze(maze_rows, block_width, wall_thickness); + square_maze(maze_rows, cell_width, wall_thickness); } one_maze(); @@ -64,4 +64,4 @@ module cube_maze(maze_rows, block_width, wall_thickness, inner_cube, travel_all) } } -cube_maze(maze_rows, block_width, wall_thickness, inner_cube, travel_all); +cube_maze(maze_rows, cell_width, wall_thickness, inner_cube, travel_all); diff --git a/examples/maze/cylinder_maze.scad b/examples/maze/cylinder_maze.scad index 57f503e3..6e8a75df 100644 --- a/examples/maze/cylinder_maze.scad +++ b/examples/maze/cylinder_maze.scad @@ -1,10 +1,10 @@ use ; -use ; +use ; use ; radius = 30; height = 60; -block_width = 8; +cell_width = 8; wall_thickness = 5; wall_height = 5; @@ -32,19 +32,19 @@ module cylinder_maze() { } } - maze_rows = round(height / block_width); - maze_columns = round(2 * 3.14159 * radius / block_width); + maze_rows = round(height / cell_width); + maze_columns = round(2 * 3.14159 * radius / cell_width); - maze_blocks = mz_square_blocks( + maze_cells = mz_square_cells( maze_rows, maze_columns, x_wrapping = true ); - walls = mz_square_walls(maze_blocks, maze_rows, maze_columns, block_width, left_border = false); + walls = mz_square_walls(maze_cells, maze_rows, maze_columns, cell_width, left_border = false); - leng_circumference = block_width * maze_columns + wall_thickness; + leng_circumference = cell_width * maze_columns + wall_thickness; - bend(size = [leng_circumference, block_width * maze_rows + wall_thickness, wall_height], angle = 360 + 360 * wall_thickness / leng_circumference, frags = fn) + bend(size = [leng_circumference, cell_width * maze_rows + wall_thickness, wall_height], angle = 360 + 360 * wall_thickness / leng_circumference, frags = fn) translate([0, wall_thickness / 2]) for(wall = walls) { for(i = [0:len(wall) - 2]) { diff --git a/examples/maze/gyro_maze.scad b/examples/maze/gyro_maze.scad index d1aca5fc..2935d9cd 100644 --- a/examples/maze/gyro_maze.scad +++ b/examples/maze/gyro_maze.scad @@ -1,14 +1,14 @@ use ; use ; -cblocks = 8; +ccells = 8; wall_thickness = 1.5; spacing = 0.6; $fn = 48; -gyro_maze(cblocks, wall_thickness, spacing); +gyro_maze(ccells, wall_thickness, spacing); -module gyro_maze(cblocks, wall_thickness, spacing) { +module gyro_maze(ccells, wall_thickness, spacing) { // Don't change these variables. They require more math. radius = 15; wall_height = 1; @@ -20,7 +20,7 @@ module gyro_maze(cblocks, wall_thickness, spacing) { linear_extrude(wall_height) scale(1.029) { difference() { - regular_polygon_maze(radius - wall_thickness, cblocks, levels - 1, wall_thickness, $fn); + regular_polygon_maze(radius - wall_thickness, ccells, levels - 1, wall_thickness, $fn); circle(radius / 3.5); } circle(radius / 3.5 - wall_thickness / 1.45); diff --git a/examples/maze/heart2heart_maze.scad b/examples/maze/heart2heart_maze.scad index 5c8a105e..9aff8f14 100644 --- a/examples/maze/heart2heart_maze.scad +++ b/examples/maze/heart2heart_maze.scad @@ -1,6 +1,6 @@ use ; use ; -use ; +use ; names = ["Justin", "Monica"]; font_name = "Arial Black"; @@ -9,7 +9,7 @@ font_size = 8; radius_of_heart = 15; tip_r_of_heart = 5; wall_thickness = 2.5; -cblocks = 6; +ccells = 6; levels = 3; spacing = 0.4; @@ -30,14 +30,14 @@ module heart_base(name, font_name, font_size, radius, ring_thickness, tip_r_of_h arc(radius = radius / 3, angle = [25, 155], width = ring_thickness); } -module heart2heart_maze(names, font_name, font_size, radius_of_heart, tip_r_of_heart, wall_thickness, cblocks, levels, spacing) { - maze = mz_square_blocks( - cblocks, levels, y_wrapping = true +module heart2heart_maze(names, font_name, font_size, radius_of_heart, tip_r_of_heart, wall_thickness, ccells, levels, spacing) { + maze = mz_square_cells( + ccells, levels, y_wrapping = true ); translate([0, 0, wall_thickness]) linear_extrude(wall_thickness) - heart_maze(maze, radius_of_heart, cblocks, levels, wall_thickness); + heart_maze(maze, radius_of_heart, ccells, levels, wall_thickness); heart_base(names[0], font_name, font_size, radius_of_heart + wall_thickness / 2, wall_thickness, tip_r_of_heart); translate([radius_of_heart * 4, 0, 0]) { @@ -50,9 +50,9 @@ module heart2heart_maze(names, font_name, font_size, radius_of_heart, tip_r_of_h heart(radius_of_heart, tip_r_of_heart); linear_extrude(wall_thickness * 2) offset(delta = spacing) - heart_maze(maze, radius_of_heart, cblocks, levels, wall_thickness); + heart_maze(maze, radius_of_heart, ccells, levels, wall_thickness); } } } -heart2heart_maze(names, font_name, font_size, radius_of_heart, tip_r_of_heart, wall_thickness, cblocks, levels, spacing); \ No newline at end of file +heart2heart_maze(names, font_name, font_size, radius_of_heart, tip_r_of_heart, wall_thickness, ccells, levels, spacing); \ No newline at end of file diff --git a/examples/maze/heart_maze.scad b/examples/maze/heart_maze.scad index 8d82c95b..0708b2f7 100644 --- a/examples/maze/heart_maze.scad +++ b/examples/maze/heart_maze.scad @@ -2,14 +2,14 @@ use ; use ; use ; use ; -use ; +use ; use ; radius_of_heart = 12; height_of_heart = 25; tip_r_of_heart = 5; wall_thickness = 2; -cblocks = 6; +ccells = 6; levels = 3; $fn = 36; @@ -58,17 +58,17 @@ module heart_to_heart_wall(radius, length, angle, thickness) { } } -module heart_maze(maze, radius, cblocks, levels, thickness = 1) { - function no_wall(block) = get_wall_type(block) == "NO_WALL"; - function top_wall(block) = get_wall_type(block) == "TOP_WALL"; - function right_wall(block) = get_wall_type(block) == "RIGHT_WALL"; - function top_right_wall(block) = get_wall_type(block) == "TOP_RIGHT_WALL"; +module heart_maze(maze, radius, ccells, levels, thickness = 1) { + function no_wall(cell) = get_wall_type(cell) == "NO_WALL"; + function top_wall(cell) = get_wall_type(cell) == "TOP_WALL"; + function right_wall(cell) = get_wall_type(cell) == "RIGHT_WALL"; + function top_right_wall(cell) = get_wall_type(cell) == "TOP_RIGHT_WALL"; - function get_x(block) = mz_square_get(block, "x"); - function get_y(block) = mz_square_get(block, "y"); - function get_wall_type(block) = mz_square_get(block, "w"); + function get_x(cell) = mz_square_get(cell, "x"); + function get_y(cell) = mz_square_get(cell, "y"); + function get_wall_type(cell) = mz_square_get(cell, "w"); - arc_angle = 360 / cblocks; + arc_angle = 360 / ccells; r = radius / (levels + 1); difference() { @@ -79,13 +79,13 @@ module heart_maze(maze, radius, cblocks, levels, thickness = 1) { for(i = [0:len(maze) - 1]) { - block = maze[i]; - cr = get_x(block) + 1; - cc = get_y(block); + cell = maze[i]; + cr = get_x(cell) + 1; + cc = get_y(cell); angle = cc * arc_angle; - if(top_wall(block) || top_right_wall(block)) { + if(top_wall(cell) || top_right_wall(cell)) { heart_to_heart_wall(r * cr, r, cc * arc_angle , thickness); } } @@ -94,11 +94,11 @@ module heart_maze(maze, radius, cblocks, levels, thickness = 1) { render() union() { // road to the next level for(i = [0:len(maze) - 1]) { - block = maze[i]; - cr = get_x(block) + 1; - cc = get_y(block); + cell = maze[i]; + cr = get_x(cell) + 1; + cc = get_y(cell); - if(no_wall(block) || top_wall(block)) { + if(no_wall(cell) || top_wall(cell)) { ring_heart_sector(r * (cr + 1), (cc + 0.5) * arc_angle , thickness, thickness * 0.75); } } @@ -106,8 +106,8 @@ module heart_maze(maze, radius, cblocks, levels, thickness = 1) { } } -maze = mz_square_blocks( - cblocks, levels, y_wrapping = true +maze = mz_square_cells( + ccells, levels, y_wrapping = true ); intersection() { @@ -121,7 +121,7 @@ intersection() { } linear_extrude(height_of_heart, center = true) - heart_maze(maze, radius_of_heart, cblocks, levels, wall_thickness); + heart_maze(maze, radius_of_heart, ccells, levels, wall_thickness); } linear_extrude(wall_thickness * 2, center = true) diff --git a/examples/maze/maze_masking.scad b/examples/maze/maze_masking.scad index 04a4e45a..398f2921 100644 --- a/examples/maze/maze_masking.scad +++ b/examples/maze/maze_masking.scad @@ -1,4 +1,4 @@ -use ; +use ; use ; use ; use ; @@ -18,18 +18,18 @@ mask = [ [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] ]; -block_width = 3; +cell_width = 3; wall_thickness = 1; wall_height = 2; base_height = 1; contour = true; base = true; -module maze_masking(start, mask, block_width, wall_thickness, wall_height, base_height, contour, base) { +module maze_masking(start, mask, cell_width, wall_thickness, wall_height, base_height, contour, base) { rows = len(mask); columns = len(mask[0]); - blocks = mz_square_blocks( + cells = mz_square_cells( rows, columns, start, mz_square_initialize(mask = mask) ); @@ -41,7 +41,7 @@ module maze_masking(start, mask, block_width, wall_thickness, wall_height, base_ [x, y] ], sorted = true) : []; - walls = mz_square_walls(blocks, rows, columns, block_width); + walls = mz_square_walls(cells, rows, columns, cell_width); color("gray") linear_extrude(wall_height) @@ -62,8 +62,8 @@ module maze_masking(start, mask, block_width, wall_thickness, wall_height, base_ for(y = [0:rows - 1]) { for(x = [0:columns - 1]) { if(mask[rows - y - 1][x] == 0) { - translate([x * block_width + wall_thickness, y * block_width + wall_thickness]) - square(block_width); + translate([x * cell_width + wall_thickness, y * cell_width + wall_thickness]) + square(cell_width); } } } @@ -71,7 +71,7 @@ module maze_masking(start, mask, block_width, wall_thickness, wall_height, base_ if(contour) { translate([wall_thickness * 2, wall_thickness * 2]) - polygon(pts * block_width); + polygon(pts * cell_width); } } @@ -80,15 +80,15 @@ module maze_masking(start, mask, block_width, wall_thickness, wall_height, base_ translate([0, 0, -base_height]) linear_extrude(base_height) translate([wall_thickness * 2, wall_thickness * 2]) - polygon(pts * block_width); + polygon(pts * cell_width); } else { translate([0, 0, -base_height]) linear_extrude(base_height) translate([wall_thickness, wall_thickness]) - square([columns, rows] * block_width); + square([columns, rows] * cell_width); } } } -maze_masking(start, mask, block_width, wall_thickness, wall_height, base_height, contour, base); \ No newline at end of file +maze_masking(start, mask, cell_width, wall_thickness, wall_height, base_height, contour, base); \ No newline at end of file diff --git a/examples/maze/mobius_maze.scad b/examples/maze/mobius_maze.scad index f4e88f5d..9c456979 100644 --- a/examples/maze/mobius_maze.scad +++ b/examples/maze/mobius_maze.scad @@ -1,27 +1,27 @@ use ; -use ; +use ; use ; use ; rows = 48; columns = 8; -block_width = 2; +cell_width = 2; wall_thickness = 1; angle = 180; // $fn = 24; -leng = rows * block_width; +leng = rows * cell_width; radius = 0.5 * leng / PI; a_step = 360 / leng; -blocks = mz_square_blocks( +cells = mz_square_cells( rows, columns, y_wrapping = true ); -walls = mz_square_walls(blocks, rows, columns, block_width, bottom_border = false); +walls = mz_square_walls(cells, rows, columns, cell_width, bottom_border = false); -size = [columns * block_width, rows * block_width]; +size = [columns * cell_width, rows * cell_width]; for(wall_pts = walls) { transformed = [for(pt = wall_pts) ptf_ring(size, pt, radius, 360, angle)]; hull_polyline3d(transformed, wall_thickness); diff --git a/examples/maze/noisy_circle_maze.scad b/examples/maze/noisy_circle_maze.scad index ed3882d1..9cec9dee 100644 --- a/examples/maze/noisy_circle_maze.scad +++ b/examples/maze/noisy_circle_maze.scad @@ -1,18 +1,18 @@ use ; use ; -use ; +use ; use ; use ; use ; -module noisy_circle_maze(r_blocks, block_width, wall_thickness, origin_offset, noisy_factor) { - double_r_blocks = r_blocks * 2; - blocks = mz_square_blocks( - double_r_blocks, double_r_blocks +module noisy_circle_maze(r_cells, cell_width, wall_thickness, origin_offset, noisy_factor) { + double_r_cells = r_cells * 2; + cells = mz_square_cells( + double_r_cells, double_r_cells ); - width = double_r_blocks * block_width; - walls = mz_square_walls(blocks, double_r_blocks, double_r_blocks, block_width); + width = double_r_cells * cell_width; + walls = mz_square_walls(cells, double_r_cells, double_r_cells, cell_width); half_width = width / 2; rect_size = is_undef(origin_offset) ? [width, width] : [width, width] - origin_offset * 2; @@ -34,8 +34,8 @@ module noisy_circle_maze(r_blocks, block_width, wall_thickness, origin_offset, n } noisy_circle_maze( - r_blocks = 8, - block_width = 5, + r_cells = 8, + cell_width = 5, wall_thickness = 2, noisy_factor = 2 ); \ No newline at end of file diff --git a/examples/maze/pyramid_hex_maze.scad b/examples/maze/pyramid_hex_maze.scad index c825607a..23b8e995 100644 --- a/examples/maze/pyramid_hex_maze.scad +++ b/examples/maze/pyramid_hex_maze.scad @@ -1,5 +1,5 @@ use ; -use ; +use ; use ; columns = 10; @@ -30,11 +30,9 @@ module pyramid_hex_maze(columns, cell_radius, wall_thickness) { pyramid_height = square_w / sqrt(2); - blocks = mz_square_blocks( - rows, columns - ); + cells = mz_square_cells(rows, columns); - walls = mz_hex_walls(blocks, rows, columns, cell_radius, wall_thickness); + walls = mz_hex_walls(cells, rows, columns, cell_radius, wall_thickness); intersection() { linear_extrude(pyramid_height) diff --git a/examples/maze/pyramid_maze.scad b/examples/maze/pyramid_maze.scad index 76dc023e..dcb6ba9e 100644 --- a/examples/maze/pyramid_maze.scad +++ b/examples/maze/pyramid_maze.scad @@ -1,26 +1,26 @@ use ; maze_rows = 10; -block_width = 2; +cell_width = 2; wall_thickness = 1; -module pyramid_maze(maze_rows, block_width, wall_thickness) { +module pyramid_maze(maze_rows, cell_width, wall_thickness) { module pyramid(leng) { height = leng / 1.4142135623730950488016887242097; linear_extrude(height, scale = 0) square(leng, center = true); } - leng = maze_rows * block_width ; + leng = maze_rows * cell_width ; half_leng = leng / 2; intersection() { linear_extrude(leng * 2) translate([-half_leng, -half_leng]) - square_maze(maze_rows, block_width, wall_thickness); + square_maze(maze_rows, cell_width, wall_thickness); pyramid(leng + wall_thickness); } } -pyramid_maze(maze_rows, block_width, wall_thickness); \ No newline at end of file +pyramid_maze(maze_rows, cell_width, wall_thickness); \ No newline at end of file diff --git a/examples/maze/regular_polygon_maze.scad b/examples/maze/regular_polygon_maze.scad index 9fe2bf47..ec2bc12f 100644 --- a/examples/maze/regular_polygon_maze.scad +++ b/examples/maze/regular_polygon_maze.scad @@ -1,6 +1,6 @@ use ; use ; -use ; +use ; use ; // only for creating a small maze @@ -8,7 +8,7 @@ use ; radius_of_circle_wrapper = 15; wall_thickness = 1; wall_height = 1; -cblocks = 6; +ccells = 6; levels = 3; sides = 3; @@ -36,21 +36,21 @@ module regular_polygon_to_polygon_wall(radius, length, angle, thickness, sides) } } -module regular_polygon_maze(radius, cblocks, levels, thickness = 1, sides) { - function no_wall(block) = get_wall_type(block) == "NO_WALL"; - function top_wall(block) = get_wall_type(block) == "TOP_WALL"; - function right_wall(block) = get_wall_type(block) == "RIGHT_WALL"; - function top_right_wall(block) = get_wall_type(block) == "TOP_RIGHT_WALL"; +module regular_polygon_maze(radius, ccells, levels, thickness = 1, sides) { + function no_wall(cell) = get_wall_type(cell) == "NO_WALL"; + function top_wall(cell) = get_wall_type(cell) == "TOP_WALL"; + function right_wall(cell) = get_wall_type(cell) == "RIGHT_WALL"; + function top_right_wall(cell) = get_wall_type(cell) == "TOP_RIGHT_WALL"; - function get_x(block) = mz_square_get(block, "x"); - function get_y(block) = mz_square_get(block, "y"); - function get_wall_type(block) = mz_square_get(block, "w"); + function get_x(cell) = mz_square_get(cell, "x"); + function get_y(cell) = mz_square_get(cell, "y"); + function get_wall_type(cell) = mz_square_get(cell, "w"); - arc_angle = 360 / cblocks; + arc_angle = 360 / ccells; r = radius / (levels + 1); - maze = mz_square_blocks( - cblocks, levels, y_wrapping = true + maze = mz_square_cells( + ccells, levels, y_wrapping = true ); difference() { @@ -61,13 +61,13 @@ module regular_polygon_maze(radius, cblocks, levels, thickness = 1, sides) { for(i = [0:len(maze) - 1]) { - block = maze[i]; - cr = get_x(block) + 1; - cc = get_y(block); + cell = maze[i]; + cr = get_x(cell) + 1; + cc = get_y(cell); angle = cc * arc_angle; - if(top_wall(block) || top_right_wall(block)) { + if(top_wall(cell) || top_right_wall(cell)) { regular_polygon_to_polygon_wall(r * cr, r, cc * arc_angle , thickness, sides); } } @@ -79,11 +79,11 @@ module regular_polygon_maze(radius, cblocks, levels, thickness = 1, sides) { // road to the next level for(i = [0:len(maze) - 1]) { - block = maze[i]; - cr = get_x(block) + 1; - cc = get_y(block); + cell = maze[i]; + cr = get_x(cell) + 1; + cc = get_y(cell); - if(no_wall(block) || top_wall(block)) { + if(no_wall(cell) || top_wall(cell)) { ring_regular_polygon_sector(r * (cr + 1), (cc + 0.5) * arc_angle , thickness, thickness * 0.75 , sides); } } @@ -92,4 +92,4 @@ module regular_polygon_maze(radius, cblocks, levels, thickness = 1, sides) { } linear_extrude(wall_height) - regular_polygon_maze(radius_of_circle_wrapper, cblocks, levels, wall_thickness, sides); + regular_polygon_maze(radius_of_circle_wrapper, ccells, levels, wall_thickness, sides); diff --git a/examples/maze/sphere_maze.scad b/examples/maze/sphere_maze.scad index a8268cd7..d40d2c1e 100644 --- a/examples/maze/sphere_maze.scad +++ b/examples/maze/sphere_maze.scad @@ -1,15 +1,15 @@ use ; -use ; +use ; use ; use ; r = 10; rows = 24; columns = 18; -block_width = .5; +cell_width = .5; wall_thickness = .5; wall_height = 1.5; -pole_offset = block_width * 2.5; +pole_offset = cell_width * 2.5; module sphere_maze() { function _angles(p) = @@ -50,16 +50,16 @@ module sphere_maze() { } - size = [rows * block_width, columns * block_width + pole_offset * 2]; - blocks = mz_square_blocks( + size = [rows * cell_width, columns * cell_width + pole_offset * 2]; + cells = mz_square_cells( rows, columns, y_wrapping = true ); - p_offset = [block_width * rows, pole_offset, 0]; + p_offset = [cell_width * rows, pole_offset, 0]; mr = m_rotation(90); - walls = mz_square_walls(blocks, rows, columns, block_width, bottom_border = false); + walls = mz_square_walls(cells, rows, columns, cell_width, bottom_border = false); for(wall_pts = walls) { rxpts = [ for(p = wall_pts) diff --git a/examples/maze/square_maze.scad b/examples/maze/square_maze.scad index 6baf57d8..8a24fca7 100644 --- a/examples/maze/square_maze.scad +++ b/examples/maze/square_maze.scad @@ -1,12 +1,12 @@ -use ; +use ; use ; -module square_maze(rows, block_width, wall_thickness) { - blocks = mz_square_blocks( +module square_maze(rows, cell_width, wall_thickness) { + cells = mz_square_cells( rows, rows ); - walls = mz_square_walls(blocks, rows, rows, block_width); + walls = mz_square_walls(cells, rows, rows, cell_width); for(wall = walls) { for(i = [0:len(wall) - 2]) { @@ -20,6 +20,6 @@ module square_maze(rows, block_width, wall_thickness) { square_maze( rows = 10, - block_width = 2, + cell_width = 2, wall_thickness = 1 ); \ No newline at end of file diff --git a/examples/maze/step_pyramid_maze.scad b/examples/maze/step_pyramid_maze.scad index 36eb72a6..d22f204b 100644 --- a/examples/maze/step_pyramid_maze.scad +++ b/examples/maze/step_pyramid_maze.scad @@ -1,7 +1,7 @@ use ; maze_rows = 8; -block_width = 10; +cell_width = 10; stairs_width = 5; module pyramid_with_stairs(base_width, stairs_width, rows) { @@ -29,29 +29,29 @@ module pyramid_with_stairs(base_width, stairs_width, rows) { } } -module step_pyramid_maze(maze_rows, block_width, stairs_width) { +module step_pyramid_maze(maze_rows, cell_width, stairs_width) { intersection() { pyramid_with_stairs( - maze_rows * block_width, stairs_width, maze_rows); + maze_rows * cell_width, stairs_width, maze_rows); - linear_extrude(maze_rows * block_width * sqrt(2) / 2) difference() { + linear_extrude(maze_rows * cell_width * sqrt(2) / 2) difference() { - square([block_width * maze_rows + stairs_width, block_width * maze_rows + stairs_width], center = true); + square([cell_width * maze_rows + stairs_width, cell_width * maze_rows + stairs_width], center = true); - translate([-(maze_rows * block_width) / 2, -(maze_rows * block_width) / 2, 0]) + translate([-(maze_rows * cell_width) / 2, -(maze_rows * cell_width) / 2, 0]) difference() { - square_maze(maze_rows, block_width, stairs_width); + square_maze(maze_rows, cell_width, stairs_width); // entry translate([0, stairs_width]) square(stairs_width, center = true); // exit - translate([maze_rows * block_width, maze_rows * block_width - stairs_width]) + translate([maze_rows * cell_width, maze_rows * cell_width - stairs_width]) square(stairs_width, center = true); } } } } -step_pyramid_maze(maze_rows, block_width, stairs_width); \ No newline at end of file +step_pyramid_maze(maze_rows, cell_width, stairs_width); \ No newline at end of file diff --git a/examples/maze/stereographic_hex_maze.scad b/examples/maze/stereographic_hex_maze.scad index e0b6ff7f..697f319e 100644 --- a/examples/maze/stereographic_hex_maze.scad +++ b/examples/maze/stereographic_hex_maze.scad @@ -1,6 +1,6 @@ use ; use ; -use ; +use ; use ; columns = 10; @@ -24,11 +24,11 @@ module hex_maze_stereographic_projection(columns, cell_radius, wall_thickness, f pyramid_height = square_w / sqrt(2); // create a maze - blocks = mz_square_blocks( + cells = mz_square_cells( rows, columns ); - walls = mz_hex_walls(blocks, rows, columns, cell_radius, wall_thickness); + walls = mz_hex_walls(cells, rows, columns, cell_radius, wall_thickness); stereographic_extrude(square_w, $fn = fn) translate([grid_w - square_w / 2, grid_h - square_w / 2, 0]) diff --git a/examples/maze/stereographic_square_maze.scad b/examples/maze/stereographic_square_maze.scad index b69a7c7c..474c6e3f 100644 --- a/examples/maze/stereographic_square_maze.scad +++ b/examples/maze/stereographic_square_maze.scad @@ -2,18 +2,18 @@ use ; use ; maze_rows = 10; -block_width = 40; +cell_width = 40; wall_thickness = 20; fn = 24; shadow = "YES"; // [YES, NO] wall_height = 2; -module stereographic_projection_maze2(maze_rows, block_width, wall_thickness, fn, wall_height, shadow) { - length = block_width * maze_rows + wall_thickness; +module stereographic_projection_maze2(maze_rows, cell_width, wall_thickness, fn, wall_height, shadow) { + length = cell_width * maze_rows + wall_thickness; module maze() { - translate([-block_width * maze_rows / 2, -block_width * maze_rows / 2, 0]) - square_maze(maze_rows, block_width, wall_thickness); + translate([-cell_width * maze_rows / 2, -cell_width * maze_rows / 2, 0]) + square_maze(maze_rows, cell_width, wall_thickness); } stereographic_extrude(shadow_side_leng = length, $fn = fn) @@ -26,4 +26,4 @@ module stereographic_projection_maze2(maze_rows, block_width, wall_thickness, fn } } -stereographic_projection_maze2(maze_rows, block_width, wall_thickness, fn, wall_height, shadow); \ No newline at end of file +stereographic_projection_maze2(maze_rows, cell_width, wall_thickness, fn, wall_height, shadow); \ No newline at end of file diff --git a/examples/maze/torus_maze.scad b/examples/maze/torus_maze.scad index 1037d3f3..55130c0d 100644 --- a/examples/maze/torus_maze.scad +++ b/examples/maze/torus_maze.scad @@ -1,27 +1,27 @@ use ; use ; -use ; +use ; use ; rows = 36; columns = 12; -block_width = 2; +cell_width = 2; wall_thickness = 1; angle = 180; twist = 360; -leng = rows * block_width; +leng = rows * cell_width; radius = 0.5 * leng / PI; a_step = 360 / leng; -blocks = mz_square_blocks( +cells = mz_square_cells( rows, columns, x_wrapping = true, y_wrapping = true ); -walls = mz_square_walls(blocks, rows, columns, block_width, left_border = false, bottom_border = false); +walls = mz_square_walls(cells, rows, columns, cell_width, left_border = false, bottom_border = false); -size = [columns * block_width, rows * block_width]; +size = [columns * cell_width, rows * cell_width]; for(wall_pts = walls) { transformed = [for(pt = wall_pts) ptf_torus(size, pt, [radius, radius / 2], twist = twist)]; hull_polyline3d(transformed, wall_thickness, $fn = 4); diff --git a/examples/maze/twisted_maze.scad b/examples/maze/twisted_maze.scad index 96b63e39..e95ebf40 100644 --- a/examples/maze/twisted_maze.scad +++ b/examples/maze/twisted_maze.scad @@ -1,24 +1,24 @@ use ; -use ; +use ; use ; use ; use ; rows = 10; columns = 10; -block_width = 4; +cell_width = 4; wall_thickness = 1; angle = 90; axis = "X_AXIS"; // [X_AXIS, Y_AXIS] // $fn = 24; -blocks = mz_square_blocks( +cells = mz_square_cells( rows, columns ); -walls = mz_square_walls(blocks, rows, columns, block_width); +walls = mz_square_walls(cells, rows, columns, cell_width); -size = [columns * block_width, rows * block_width]; +size = [columns * cell_width, rows * cell_width]; for(wall_pts = walls) { transformed = [for(pt = wall_pts) axis == "X_AXIS" ? ptf_x_twist(size, pt, angle) : ptf_y_twist(size, pt, angle)]; hull_polyline3d(transformed, wall_thickness); diff --git a/src/maze/_impl/_mz_blocks_impl.scad b/src/maze/_impl/_mz_cells_impl.scad similarity index 51% rename from src/maze/_impl/_mz_blocks_impl.scad rename to src/maze/_impl/_mz_cells_impl.scad index f3fd5057..2d8a69eb 100644 --- a/src/maze/_impl/_mz_blocks_impl.scad +++ b/src/maze/_impl/_mz_cells_impl.scad @@ -1,26 +1,26 @@ use <_mz_comm.scad>; -// find out the index of a block with the position (x, y) -function indexOf(x, y, maze, i = 0) = - i == len(maze) ? -1 : ( - [get_x(maze[i]), get_y(maze[i])] == [x, y] ? i : - indexOf(x, y, maze, i + 1) +// find out the index of a cell with the position (x, y) +function indexOf(x, y, cells, i = 0) = + i == len(cells) ? -1 : ( + [get_x(cells[i]), get_y(cells[i])] == [x, y] ? i : + indexOf(x, y, cells, i + 1) ); // is (x, y) visited? -function visited(x, y, maze) = maze[indexOf(x, y, maze)][3]; +function visited(x, y, cells) = cells[indexOf(x, y, cells)][3]; // is (x, y) visitable? -function visitable(x, y, maze, rows, columns) = +function visitable(x, y, cells, rows, columns) = y >= 0 && y < rows && // y bound x >= 0 && x < columns && // x bound - !visited(x, y, maze); // unvisited + !visited(x, y, cells); // unvisited // setting (x, y) as being visited -function set_visited(x, y, maze) = [ - for(b = maze) - [x, y] == [get_x(b), get_y(b)] ? - [x, y, get_wall_type(b), true] : b +function set_visited(x, y, cells) = [ + for(cell = cells) + [x, y] == [get_x(cell), get_y(cell)] ? + [x, y, get_wall_type(cell), true] : cell ]; // 0(right), 1(top), 2(left), 3(bottom) @@ -67,92 +67,92 @@ function next_y(y, dir, rows, wrapping) = wrapping ? (ny < 0 ? ny + rows : ny % rows) : ny; // go right and carve the right wall -function carve_right(x, y, maze) = [ - for(b = maze) [get_x(b), get_y(b)] == [x, y] ? ( - top_right_wall(b) ? [x, y, 1, 1] : [x, y, 0, 1] - ) : b +function carve_right(x, y, cells) = [ + for(cell = cells) [get_x(cell), get_y(cell)] == [x, y] ? ( + top_right_wall(cell) ? [x, y, 1, 1] : [x, y, 0, 1] + ) : cell ]; // go up and carve the top wall -function carve_top(x, y, maze) = [ - for(b = maze) [get_x(b), get_y(b)] == [x, y] ? ( - top_right_wall(b) ? [x, y, 2, 1] : [x, y, 0, 1] - ) : b +function carve_top(x, y, cells) = [ + for(cell = cells) [get_x(cell), get_y(cell)] == [x, y] ? ( + top_right_wall(cell) ? [x, y, 2, 1] : [x, y, 0, 1] + ) : cell ]; -// go left and carve the right wall of the left block -function carve_left(x, y, maze, columns) = +// go left and carve the right wall of the left cell +function carve_left(x, y, cells, columns) = let( x_minus_one = x - 1, nx = x_minus_one < 0 ? x_minus_one + columns : x_minus_one ) - [for(b = maze) [get_x(b), get_y(b)] == [nx, y] ? [nx, y, 1, 0] : b]; + [for(cell = cells) [get_x(cell), get_y(cell)] == [nx, y] ? [nx, y, 1, 0] : cell]; -// go down and carve the top wall of the bottom block -function carve_bottom(x, y, maze, rows) = +// go down and carve the top wall of the bottom cell +function carve_bottom(x, y, cells, rows) = let( y_minus_one = y - 1, ny = y_minus_one < 0 ? y_minus_one + rows : y_minus_one ) - [for(b = maze) [get_x(b), get_y(b)] == [x, ny] ? [x, ny, 2, 0] : b]; + [for(cell = cells) [get_x(cell), get_y(cell)] == [x, ny] ? [x, ny, 2, 0] : cell]; // 0(right), 1(top), 2(left), 3(bottom) -function carve(dir, x, y, maze, rows, columns) = - dir == 0 ? carve_right(x, y, maze) : - dir == 1 ? carve_top(x, y, maze) : - dir == 2 ? carve_left(x, y, maze, columns) : - /*dir 3*/ carve_bottom(x, y, maze, rows); +function carve(dir, x, y, cells, rows, columns) = + dir == 0 ? carve_right(x, y, cells) : + dir == 1 ? carve_top(x, y, cells) : + dir == 2 ? carve_left(x, y, cells, columns) : + /*dir 3*/ carve_bottom(x, y, cells, rows); // find out visitable dirs from (x, y) -function visitable_dirs(r_dirs, x, y, maze, rows, columns, x_wrapping, y_wrapping) = [ +function visitable_dirs(r_dirs, x, y, cells, rows, columns, x_wrapping, y_wrapping) = [ for(dir = r_dirs) - if(visitable(next_x(x, dir, columns, x_wrapping), next_y(y, dir, rows, y_wrapping), maze, rows, columns)) + if(visitable(next_x(x, dir, columns, x_wrapping), next_y(y, dir, rows, y_wrapping), cells, rows, columns)) dir ]; // go maze from (x, y) -function go_maze(x, y, maze, rows, columns, x_wrapping = false, y_wrapping = false, seed) = +function go_maze(x, y, cells, rows, columns, x_wrapping = false, y_wrapping = false, seed) = let( r_dirs = rand_dirs(x * rows + y, seed), - v_dirs = visitable_dirs(r_dirs, x, y, maze, rows, columns, x_wrapping, y_wrapping) + v_dirs = visitable_dirs(r_dirs, x, y, cells, rows, columns, x_wrapping, y_wrapping) ) // have visitable dirs? len(v_dirs) == 0 ? - set_visited(x, y, maze) // road closed + set_visited(x, y, cells) // road closed : walk_around_from( x, y, v_dirs, - set_visited(x, y, maze), + set_visited(x, y, cells), rows, columns, x_wrapping, y_wrapping, seed = seed ); // try four directions -function walk_around_from(x, y, dirs, maze, rows, columns, x_wrapping, y_wrapping, i = 0, seed) = +function walk_around_from(x, y, dirs, cells, rows, columns, x_wrapping, y_wrapping, i = 0, seed) = // all done? i < len(dirs) ? // not yet walk_around_from(x, y, dirs, // try one direction - try_routes_from(x, y, dirs[i], maze, rows, columns, x_wrapping, y_wrapping, seed), + try_routes_from(x, y, dirs[i], cells, rows, columns, x_wrapping, y_wrapping, seed), rows, columns, x_wrapping, y_wrapping, i + 1, seed) - : maze; + : cells; -function try_routes_from(x, y, dir, maze, rows, columns, x_wrapping, y_wrapping, seed) = +function try_routes_from(x, y, dir, cells, rows, columns, x_wrapping, y_wrapping, seed) = // is the dir visitable? - visitable(next_x(x, dir, columns, x_wrapping), next_y(y, dir, rows, y_wrapping), maze, rows, columns) ? - // try the block + visitable(next_x(x, dir, columns, x_wrapping), next_y(y, dir, rows, y_wrapping), cells, rows, columns) ? + // try the cell go_maze( next_x(x, dir, columns, x_wrapping), next_y(y, dir, rows, y_wrapping), - carve(dir, x, y, maze, rows, columns), + carve(dir, x, y, cells, rows, columns), rows, columns, x_wrapping, y_wrapping, seed ) - // road closed so return maze directly - : maze; \ No newline at end of file + // road closed so return cells directly + : cells; \ No newline at end of file diff --git a/src/maze/_impl/_mz_comm.scad b/src/maze/_impl/_mz_comm.scad index acc258dc..33ca0bbe 100644 --- a/src/maze/_impl/_mz_comm.scad +++ b/src/maze/_impl/_mz_comm.scad @@ -4,12 +4,12 @@ // TOP_RIGHT_WALL = 3; // MASK = 4; -function no_wall(block) = get_wall_type(block) == 0; -function top_wall(block) = get_wall_type(block) == 1; -function right_wall(block) = get_wall_type(block) == 2; -function top_right_wall(block) = get_wall_type(block) == 3; +function no_wall(cell) = get_wall_type(cell) == 0; +function top_wall(cell) = get_wall_type(cell) == 1; +function right_wall(cell) = get_wall_type(cell) == 2; +function top_right_wall(cell) = get_wall_type(cell) == 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]; \ No newline at end of file +function cell(x, y, wall_type, visited) = [x, y, wall_type, visited]; +function get_x(cell) = cell[0]; +function get_y(cell) = cell[1]; +function get_wall_type(cell) = cell[2]; \ No newline at end of file diff --git a/src/maze/_impl/_mz_hex_walls.scad b/src/maze/_impl/_mz_hex_walls.scad index 0e153a79..3eb34774 100644 --- a/src/maze/_impl/_mz_hex_walls.scad +++ b/src/maze/_impl/_mz_hex_walls.scad @@ -1,12 +1,12 @@ use <../mz_square_get.scad>; -function _get_x(block) = mz_square_get(block, "x"); -function _get_y(block) = mz_square_get(block, "y"); -function _get_wall_type(block) = mz_square_get(block, "w"); +function _get_x(cell) = mz_square_get(cell, "x"); +function _get_y(cell) = mz_square_get(cell, "y"); +function _get_wall_type(cell) = mz_square_get(cell, "w"); -function _is_top_wall(block) = _get_wall_type(block) == "TOP_WALL"; -function _is_right_wall(block) = _get_wall_type(block) == "RIGHT_WALL"; -function _is_top_right_wall(block) = _get_wall_type(block) == "TOP_RIGHT_WALL"; +function _is_top_wall(cell) = _get_wall_type(cell) == "TOP_WALL"; +function _is_right_wall(cell) = _get_wall_type(cell) == "RIGHT_WALL"; +function _is_top_right_wall(cell) = _get_wall_type(cell) == "TOP_RIGHT_WALL"; function _cell_position(cell_radius, x_cell, y_cell) = let( @@ -31,14 +31,14 @@ function _right_wall(cell_radius, x_cell) = function _row_wall(cell_radius, x_cell, y_cell) = x_cell % 2 != 0 ? [_top_right(cell_radius), _top_left(cell_radius)] : [_bottom_right(cell_radius)]; -function _build_cell(cell_radius, block) = +function _build_cell(cell_radius, cell) = let( - x = _get_x(block), - y = _get_y(block), + x = _get_x(cell), + y = _get_y(cell), walls = concat( _row_wall(cell_radius, x, y), - [_is_top_wall(block) || _is_top_right_wall(block) ? _top(cell_radius) : []], - [_is_right_wall(block) || _is_top_right_wall(block) ? _right_wall(cell_radius, x) : []] + [_is_top_wall(cell) || _is_top_right_wall(cell) ? _top(cell_radius) : []], + [_is_right_wall(cell) || _is_top_right_wall(cell) ? _right_wall(cell_radius, x) : []] ) ) [ diff --git a/src/maze/_impl/_mz_initialize.scad b/src/maze/_impl/_mz_initialize.scad index f6c20953..c6efa2fe 100644 --- a/src/maze/_impl/_mz_initialize.scad +++ b/src/maze/_impl/_mz_initialize.scad @@ -4,9 +4,9 @@ use <_mz_comm.scad>; function _rc_maze(rows, columns) = [ for(y = [0:rows - 1]) for(x = [0:columns - 1]) - block( + cell( x, y, - // all blocks have top and right walls + // all cells have top and right walls 3, // unvisited false @@ -22,15 +22,15 @@ function _mz_mask(mask) = for(y = [0:rows - 1]) for(x = [0:columns - 1]) mask[rows - y - 1][x] == 0 ? - block( + cell( x, y, 4, // mask true // visited ) : - block( + cell( x, y, - // all blocks have top and right walls + // all cells have top and right walls 3, // unvisited false ) diff --git a/src/maze/_impl/_mz_square_walls_impl.scad b/src/maze/_impl/_mz_square_walls_impl.scad index 26961f25..9c549a8c 100644 --- a/src/maze/_impl/_mz_square_walls_impl.scad +++ b/src/maze/_impl/_mz_square_walls_impl.scad @@ -1,9 +1,9 @@ use <_mz_comm.scad>; -function _square_walls(block, block_width) = +function _square_walls(cell, cell_width) = let( - loc = [get_x(block), get_y(block)] * block_width, - top = top_wall(block) || top_right_wall(block) ? [[0, block_width] + loc, [block_width, block_width] + loc] : [], - right = right_wall(block) || top_right_wall(block) ? [[block_width, block_width] + loc, [block_width, 0] + loc] : [] + loc = [get_x(cell), get_y(cell)] * cell_width, + top = top_wall(cell) || top_right_wall(cell) ? [[0, cell_width] + loc, [cell_width, cell_width] + loc] : [], + right = right_wall(cell) || top_right_wall(cell) ? [[cell_width, cell_width] + loc, [cell_width, 0] + loc] : [] ) concat(top, right); diff --git a/src/maze/mz_hamiltonian.scad b/src/maze/mz_hamiltonian.scad index ed533281..bb4f772c 100644 --- a/src/maze/mz_hamiltonian.scad +++ b/src/maze/mz_hamiltonian.scad @@ -1,22 +1,22 @@ use <_impl/_mz_hamiltonian_impl.scad>; -use ; +use ; use ; use <../util/sort.scad>; use <../util/dedup.scad>; function mz_hamiltonian(rows, columns, start, seed) = let( - blocks = mz_square_blocks( + cells = mz_square_cells( rows, columns, seed = seed ), all = concat( [ - for(block = blocks) + for(cell = cells) let( - x = mz_square_get(block, "x"), - y = mz_square_get(block, "y"), - wall_type = mz_square_get(block, "w"), + x = mz_square_get(cell, "x"), + y = mz_square_get(cell, "y"), + wall_type = mz_square_get(cell, "w"), pts = wall_type == "TOP_WALL" ? _mz_hamiltonian_top(x, y) : wall_type == "RIGHT_WALL" ? _mz_hamiltonian_right(x, y) : wall_type == "TOP_RIGHT_WALL" ? _mz_hamiltonian_top_right(x, y) : [] diff --git a/src/maze/mz_hex_walls.scad b/src/maze/mz_hex_walls.scad index e2e9fc1c..af1485cf 100644 --- a/src/maze/mz_hex_walls.scad +++ b/src/maze/mz_hex_walls.scad @@ -1,10 +1,10 @@ use <_impl/_mz_hex_walls.scad>; -function mz_hex_walls(blocks, rows, columns, cell_radius, wall_thickness, left_border = true, bottom_border = true) = +function mz_hex_walls(cells, rows, columns, cell_radius, wall_thickness, left_border = true, bottom_border = true) = let( walls = [ - for(block = blocks) - for(wall = _build_cell(cell_radius, block)) + for(cell = cells) + for(wall = _build_cell(cell_radius, cell)) wall ], left_pair_walls = left_border ? [ diff --git a/src/maze/mz_square_blocks.scad b/src/maze/mz_square_blocks.scad deleted file mode 100644 index 6d109472..00000000 --- a/src/maze/mz_square_blocks.scad +++ /dev/null @@ -1,9 +0,0 @@ -use <_impl/_mz_blocks_impl.scad>; -use ; - -function mz_square_blocks(rows, columns, start = [0, 0], init_blocks, x_wrapping = false, y_wrapping = false, seed) = - go_maze( - start[0], start[1], // starting point - is_undef(init_blocks) ? mz_square_initialize(rows, columns) : init_blocks, - rows, columns, x_wrapping, y_wrapping, seed - ); diff --git a/src/maze/mz_square_cells.scad b/src/maze/mz_square_cells.scad new file mode 100644 index 00000000..4bd8e466 --- /dev/null +++ b/src/maze/mz_square_cells.scad @@ -0,0 +1,9 @@ +use <_impl/_mz_cells_impl.scad>; +use ; + +function mz_square_cells(rows, columns, start = [0, 0], init_cells, x_wrapping = false, y_wrapping = false, seed) = + go_maze( + start[0], start[1], // starting point + is_undef(init_cells) ? mz_square_initialize(rows, columns) : init_cells, + rows, columns, x_wrapping, y_wrapping, seed + ); diff --git a/src/maze/mz_square_get.scad b/src/maze/mz_square_get.scad index 42b760bb..ca413bc2 100644 --- a/src/maze/mz_square_get.scad +++ b/src/maze/mz_square_get.scad @@ -1,4 +1,4 @@ -function mz_square_get(block, query) = +function mz_square_get(cell, query) = let( i = search(query, [ ["x", 0], @@ -6,4 +6,4 @@ function mz_square_get(block, query) = ["w", 2] ])[0] ) - i != 2 ? block[i] : ["NO_WALL", "TOP_WALL", "RIGHT_WALL", "TOP_RIGHT_WALL", "MASK"][block[i]]; \ No newline at end of file + i != 2 ? cell[i] : ["NO_WALL", "TOP_WALL", "RIGHT_WALL", "TOP_RIGHT_WALL", "MASK"][cell[i]]; \ No newline at end of file diff --git a/src/maze/mz_square_walls.scad b/src/maze/mz_square_walls.scad index 7bca5851..5b49088e 100644 --- a/src/maze/mz_square_walls.scad +++ b/src/maze/mz_square_walls.scad @@ -1,14 +1,14 @@ use <_impl/_mz_square_walls_impl.scad>; -function mz_square_walls(blocks, rows, columns, block_width, left_border = true, bottom_border = true) = +function mz_square_walls(cells, rows, columns, cell_width, left_border = true, bottom_border = true) = let( - left_walls = left_border ? [for(y = [0:rows - 1]) [[0, block_width * (y + 1)], [0, block_width * y]]] : [], - buttom_walls = bottom_border ? [for(x = [0:columns - 1]) [[block_width * x, 0], [block_width * (x + 1), 0]]] : [] + left_walls = left_border ? [for(y = [0:rows - 1]) [[0, cell_width * (y + 1)], [0, cell_width * y]]] : [], + buttom_walls = bottom_border ? [for(x = [0:columns - 1]) [[cell_width * x, 0], [cell_width * (x + 1), 0]]] : [] ) concat( [ - for(block = blocks) - let(pts = _square_walls(block, block_width)) + for(cell = cells) + let(pts = _square_walls(cell, cell_width)) if(pts != []) pts ] , left_walls, buttom_walls