From 271e71f63fbbdf94f6cb19969515f4485850f13b Mon Sep 17 00:00:00 2001 From: Justin Lin Date: Tue, 10 Nov 2020 14:54:01 +0800 Subject: [PATCH] rename --- src/maze/_impl/_mz_blocks_impl.scad | 18 ++++++++--------- src/maze/_impl/_mz_comm.scad | 8 ++++---- src/maze/_impl/_mz_hamiltonian_impl.scad | 4 ++-- src/maze/_impl/_mz_hex_walls.scad | 24 +++++++++++------------ src/maze/_impl/_mz_square_walls_impl.scad | 6 +++--- src/maze/mz_get.scad | 2 +- src/maze/mz_hamiltonian.scad | 4 ++-- src/maze/mz_hex_walls.scad | 8 ++++---- 8 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/maze/_impl/_mz_blocks_impl.scad b/src/maze/_impl/_mz_blocks_impl.scad index 070414c0..0864a2b9 100644 --- a/src/maze/_impl/_mz_blocks_impl.scad +++ b/src/maze/_impl/_mz_blocks_impl.scad @@ -6,7 +6,7 @@ function starting_maze(rows, columns) = [ for(x = [1:columns]) block( x, y, - // all blocks have upper and right walls + // all blocks have top and right walls 3, // unvisited false @@ -36,7 +36,7 @@ function set_visited(x, y, maze) = [ [x, y, get_wall_type(b), true] : b ]; -// 0(right), 1(upper), 2(left), 3(down) +// 0(right), 1(top), 2(left), 3(bottom) _rand_dir_table = [ [0, 1, 2, 3], [0, 1, 3, 2], @@ -92,17 +92,17 @@ function next_y(y, dir, rows, circular) = // go right and carve the right wall function go_right_from(x, y, maze) = [ for(b = maze) [get_x(b), get_y(b)] == [x, y] ? ( - upper_right_wall(b) ? + top_right_wall(b) ? [x, y, 1, visited(x, y, maze)] : [x, y, 0, visited(x, y, maze)] ) : b ]; -// go up and carve the upper wall +// go up and carve the top wall function go_up_from(x, y, maze) = [ for(b = maze) [get_x(b), get_y(b)] == [x, y] ? ( - upper_right_wall(b) ? + top_right_wall(b) ? [x, y, 2, visited(x, y, maze)] : [x, y, 0, visited(x, y, maze)] @@ -117,26 +117,26 @@ function go_left_from(x, y, maze, columns) = ) [ for(b = maze) [get_x(b), get_y(b)] == [nx, y] ? ( - upper_right_wall(b) ? + top_right_wall(b) ? [nx, y, 1, visited(nx, y, maze)] : [nx, y, 0, visited(nx, y, maze)] ) : b ]; -// go down and carve the upper wall of the down block +// go down and carve the top wall of the bottom block function go_down_from(x, y, maze, rows) = [ let( y_minus_one = y - 1, ny = y_minus_one < 1 ? y_minus_one + rows : y_minus_one ) for(b = maze) [get_x(b), get_y(b)] == [x, ny] ? ( - upper_right_wall(b) ? + top_right_wall(b) ? [x, ny, 2, visited(x, ny, maze)] : [x, ny, 0, visited(x, ny, maze)] ) : b ]; -// 0(right), 1(upper), 2(left), 3(down) +// 0(right), 1(top), 2(left), 3(bottom) function try_block(dir, x, y, maze, rows, columns) = dir == 0 ? go_right_from(x, y, maze) : dir == 1 ? go_up_from(x, y, maze) : diff --git a/src/maze/_impl/_mz_comm.scad b/src/maze/_impl/_mz_comm.scad index aed53c5e..60dcff2c 100644 --- a/src/maze/_impl/_mz_comm.scad +++ b/src/maze/_impl/_mz_comm.scad @@ -1,12 +1,12 @@ // NO_WALL = 0; -// UPPER_WALL = 1; +// TOP_WALL = 1; // RIGHT_WALL = 2; -// UPPER_RIGHT_WALL = 3; +// TOP_RIGHT_WALL = 3; function no_wall(block) = get_wall_type(block) == 0; -function upper_wall(block) = get_wall_type(block) == 1; +function top_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 top_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]; diff --git a/src/maze/_impl/_mz_hamiltonian_impl.scad b/src/maze/_impl/_mz_hamiltonian_impl.scad index f95cf9d4..4b7a6885 100644 --- a/src/maze/_impl/_mz_hamiltonian_impl.scad +++ b/src/maze/_impl/_mz_hamiltonian_impl.scad @@ -1,6 +1,6 @@ use <../../util/has.scad>; -function _mz_hamiltonian_upper(x, y) = +function _mz_hamiltonian_top(x, y) = let( nx = (x - 1) * 2, ny = (y - 1) * 2 @@ -14,7 +14,7 @@ function _mz_hamiltonian_right(x, y) = ) [[nx + 2, ny + 2], [nx + 2, ny + 1], [nx + 2, ny]]; -function _mz_hamiltonian_upper_right(x, y) = +function _mz_hamiltonian_top_right(x, y) = let( nx = (x - 1) * 2, ny = (y - 1) * 2 diff --git a/src/maze/_impl/_mz_hex_walls.scad b/src/maze/_impl/_mz_hex_walls.scad index e3b2abfe..ca218f1f 100644 --- a/src/maze/_impl/_mz_hex_walls.scad +++ b/src/maze/_impl/_mz_hex_walls.scad @@ -4,9 +4,9 @@ function _get_x(block) = mz_get(block, "x"); function _get_y(block) = mz_get(block, "y"); function _get_wall_type(block) = mz_get(block, "w"); -function _is_upper_wall(block) = _get_wall_type(block) == "UPPER_WALL"; +function _is_top_wall(block) = _get_wall_type(block) == "TOP_WALL"; function _is_right_wall(block) = _get_wall_type(block) == "RIGHT_WALL"; -function _is_upper_right_wall(block) = _get_wall_type(block) == "UPPER_RIGHT_WALL"; +function _is_top_right_wall(block) = _get_wall_type(block) == "TOP_RIGHT_WALL"; function _cell_position(cell_radius, x_cell, y_cell) = let( @@ -18,18 +18,18 @@ function _cell_position(cell_radius, x_cell, y_cell) = function _hex_seg(cell_radius, begin, end) = [for(a = [begin:60:end]) [cell_radius * cos(a), cell_radius * sin(a)]]; -function _upper_right(cell_radius) = _hex_seg(cell_radius, 0, 60); -function _upper(cell_radius) = _hex_seg(cell_radius, 60, 120); -function _upper_left(cell_radius) = _hex_seg(cell_radius, 120, 180); -function _down_left(cell_radius) = _hex_seg(cell_radius, 180, 240); -function _down(cell_radius) = _hex_seg(cell_radius, 240, 300); -function _down_right(cell_radius) = _hex_seg(cell_radius, 300, 360); +function _top_right(cell_radius) = _hex_seg(cell_radius, 0, 60); +function _top(cell_radius) = _hex_seg(cell_radius, 60, 120); +function _top_left(cell_radius) = _hex_seg(cell_radius, 120, 180); +function _bottom_left(cell_radius) = _hex_seg(cell_radius, 180, 240); +function _bottom(cell_radius) = _hex_seg(cell_radius, 240, 300); +function _bottom_right(cell_radius) = _hex_seg(cell_radius, 300, 360); function _right_wall(cell_radius, x_cell) = - (x_cell % 2 != 0) ? _down_right(cell_radius) : _upper_right(cell_radius); + (x_cell % 2 != 0) ? _bottom_right(cell_radius) : _top_right(cell_radius); function _row_wall(cell_radius, x_cell, y_cell) = - x_cell % 2 != 0 ? [_upper_right(cell_radius), _upper_left(cell_radius)] : [_down_right(cell_radius)]; + x_cell % 2 != 0 ? [_top_right(cell_radius), _top_left(cell_radius)] : [_bottom_right(cell_radius)]; function _build_cell(cell_radius, block) = let( @@ -37,8 +37,8 @@ function _build_cell(cell_radius, block) = y = _get_y(block) - 1, walls = concat( _row_wall(cell_radius, x, y), - [_is_upper_wall(block) || _is_upper_right_wall(block) ? _upper(cell_radius) : []], - [_is_right_wall(block) || _is_upper_right_wall(block) ? _right_wall(cell_radius, x) : []] + [_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) : []] ) ) [ diff --git a/src/maze/_impl/_mz_square_walls_impl.scad b/src/maze/_impl/_mz_square_walls_impl.scad index 6b8da732..d63ee2bd 100644 --- a/src/maze/_impl/_mz_square_walls_impl.scad +++ b/src/maze/_impl/_mz_square_walls_impl.scad @@ -3,7 +3,7 @@ use <_mz_comm.scad>; function _square_walls(block, block_width) = let( loc = [get_x(block) - 1, get_y(block) - 1] * block_width, - upper = upper_wall(block) || upper_right_wall(block) ? [[0, block_width] + loc, [block_width, block_width] + loc] : [], - right = right_wall(block) || upper_right_wall(block) ? [[block_width, block_width] + loc, [block_width, 0] + loc] : [] + 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] : [] ) - concat(upper, right); + concat(top, right); diff --git a/src/maze/mz_get.scad b/src/maze/mz_get.scad index 92149910..8a0e1a38 100644 --- a/src/maze/mz_get.scad +++ b/src/maze/mz_get.scad @@ -6,4 +6,4 @@ function mz_get(block, query) = ["w", 2] ])[0] ) - i != 2 ? block[i] : ["NO_WALL", "UPPER_WALL", "RIGHT_WALL", "UPPER_RIGHT_WALL"][block[i]]; \ No newline at end of file + i != 2 ? block[i] : ["NO_WALL", "TOP_WALL", "RIGHT_WALL", "TOP_RIGHT_WALL"][block[i]]; \ No newline at end of file diff --git a/src/maze/mz_hamiltonian.scad b/src/maze/mz_hamiltonian.scad index 00c0a911..73fd86ae 100644 --- a/src/maze/mz_hamiltonian.scad +++ b/src/maze/mz_hamiltonian.scad @@ -18,9 +18,9 @@ function mz_hamiltonian(rows, columns, start, seed) = x = mz_get(block, "x"), y = mz_get(block, "y"), wall_type = mz_get(block, "w"), - pts = wall_type == "UPPER_WALL" ? _mz_hamiltonian_upper(x, y) : + pts = wall_type == "TOP_WALL" ? _mz_hamiltonian_top(x, y) : wall_type == "RIGHT_WALL" ? _mz_hamiltonian_right(x, y) : - wall_type == "UPPER_RIGHT_WALL" ? _mz_hamiltonian_upper_right(x, y) : [] + wall_type == "TOP_RIGHT_WALL" ? _mz_hamiltonian_top_right(x, y) : [] ) each pts ], diff --git a/src/maze/mz_hex_walls.scad b/src/maze/mz_hex_walls.scad index b555feab..e2e9fc1c 100644 --- a/src/maze/mz_hex_walls.scad +++ b/src/maze/mz_hex_walls.scad @@ -11,8 +11,8 @@ function mz_hex_walls(blocks, rows, columns, cell_radius, wall_thickness, left_b for(y = [0:rows - 1]) let( cell_p = _cell_position(cell_radius, 0, y), - walls1 = _upper_left(cell_radius), - walls2 = _down_left(cell_radius) + walls1 = _top_left(cell_radius), + walls2 = _bottom_left(cell_radius) ) [ [walls1[0] + cell_p, walls1[1] + cell_p], @@ -28,9 +28,9 @@ function mz_hex_walls(blocks, rows, columns, cell_radius, wall_thickness, left_b for(x = [0:columns - 1]) let( cell_p = _cell_position(cell_radius, x, 0), - walls1 = _down(cell_radius), + walls1 = _bottom(cell_radius), walls2 = [ - for(pair = (x % 2 == 0 ? [_down_left(cell_radius), _down_right(cell_radius)] : [])) + for(pair = (x % 2 == 0 ? [_bottom_left(cell_radius), _bottom_right(cell_radius)] : [])) for(wall = pair) wall ]