1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-29 17:30:11 +02:00
This commit is contained in:
Justin Lin
2020-12-20 18:15:11 +08:00
parent 3271a9e129
commit 4022f867ba
7 changed files with 26 additions and 26 deletions

View File

@@ -59,14 +59,14 @@ module heart_to_heart_wall(radius, length, angle, thickness) {
} }
module heart_maze(cells, radius, ccells, levels, thickness = 1) { module heart_maze(cells, radius, ccells, levels, thickness = 1) {
function no_wall(cell) = get_wall_type(cell) == "NO_WALL"; function no_wall(cell) = get_type(cell) == "NO_WALL";
function top_wall(cell) = get_wall_type(cell) == "TOP_WALL"; function top_wall(cell) = get_type(cell) == "TOP_WALL";
function right_wall(cell) = get_wall_type(cell) == "RIGHT_WALL"; function right_wall(cell) = get_type(cell) == "RIGHT_WALL";
function top_right_wall(cell) = get_wall_type(cell) == "TOP_RIGHT_WALL"; function top_right_wall(cell) = get_type(cell) == "TOP_RIGHT_WALL";
function get_x(cell) = mz_square_get(cell, "x"); function get_x(cell) = mz_square_get(cell, "x");
function get_y(cell) = mz_square_get(cell, "y"); function get_y(cell) = mz_square_get(cell, "y");
function get_wall_type(cell) = mz_square_get(cell, "w"); function get_type(cell) = mz_square_get(cell, "t");
arc_angle = 360 / ccells; arc_angle = 360 / ccells;
r = radius / (levels + 1); r = radius / (levels + 1);

View File

@@ -37,14 +37,14 @@ module regular_polygon_to_polygon_wall(radius, length, angle, thickness, sides)
} }
module regular_polygon_maze(radius, ccells, levels, thickness = 1, sides) { module regular_polygon_maze(radius, ccells, levels, thickness = 1, sides) {
function no_wall(cell) = get_wall_type(cell) == "NO_WALL"; function no_wall(cell) = get_type(cell) == "NO_WALL";
function top_wall(cell) = get_wall_type(cell) == "TOP_WALL"; function top_wall(cell) = get_type(cell) == "TOP_WALL";
function right_wall(cell) = get_wall_type(cell) == "RIGHT_WALL"; function right_wall(cell) = get_type(cell) == "RIGHT_WALL";
function top_right_wall(cell) = get_wall_type(cell) == "TOP_RIGHT_WALL"; function top_right_wall(cell) = get_type(cell) == "TOP_RIGHT_WALL";
function get_x(cell) = mz_square_get(cell, "x"); function get_x(cell) = mz_square_get(cell, "x");
function get_y(cell) = mz_square_get(cell, "y"); function get_y(cell) = mz_square_get(cell, "y");
function get_wall_type(cell) = mz_square_get(cell, "w"); function get_type(cell) = mz_square_get(cell, "t");
arc_angle = 360 / ccells; arc_angle = 360 / ccells;
r = radius / (levels + 1); r = radius / (levels + 1);

View File

@@ -20,7 +20,7 @@ function visitable(x, y, cells, rows, columns) =
function set_visited(x, y, cells) = [ function set_visited(x, y, cells) = [
for(cell = cells) for(cell = cells)
[x, y] == [get_x(cell), get_y(cell)] ? [x, y] == [get_x(cell), get_y(cell)] ?
[x, y, get_wall_type(cell), true] : cell [x, y, get_type(cell), true] : cell
]; ];
// 0(right), 1(top), 2(left), 3(bottom) // 0(right), 1(top), 2(left), 3(bottom)

View File

@@ -4,12 +4,12 @@
// TOP_RIGHT_WALL = 3; // TOP_RIGHT_WALL = 3;
// MASK = 4; // MASK = 4;
function no_wall(cell) = get_wall_type(cell) == 0; function no_wall(cell) = get_type(cell) == 0;
function top_wall(cell) = get_wall_type(cell) == 1; function top_wall(cell) = get_type(cell) == 1;
function right_wall(cell) = get_wall_type(cell) == 2; function right_wall(cell) = get_type(cell) == 2;
function top_right_wall(cell) = get_wall_type(cell) == 3; function top_right_wall(cell) = get_type(cell) == 3;
function cell(x, y, wall_type, visited) = [x, y, wall_type, visited]; function cell(x, y, type, visited) = [x, y, type, visited];
function get_x(cell) = cell[0]; function get_x(cell) = cell[0];
function get_y(cell) = cell[1]; function get_y(cell) = cell[1];
function get_wall_type(cell) = cell[2]; function get_type(cell) = cell[2];

View File

@@ -2,11 +2,11 @@ use <../mz_square_get.scad>;
function _get_x(cell) = mz_square_get(cell, "x"); function _get_x(cell) = mz_square_get(cell, "x");
function _get_y(cell) = mz_square_get(cell, "y"); function _get_y(cell) = mz_square_get(cell, "y");
function _get_wall_type(cell) = mz_square_get(cell, "w"); function _get_type(cell) = mz_square_get(cell, "t");
function _is_top_wall(cell) = _get_wall_type(cell) == "TOP_WALL"; function _is_top_wall(cell) = _get_type(cell) == "TOP_WALL";
function _is_right_wall(cell) = _get_wall_type(cell) == "RIGHT_WALL"; function _is_right_wall(cell) = _get_type(cell) == "RIGHT_WALL";
function _is_top_right_wall(cell) = _get_wall_type(cell) == "TOP_RIGHT_WALL"; function _is_top_right_wall(cell) = _get_type(cell) == "TOP_RIGHT_WALL";
function _cell_position(cell_radius, x_cell, y_cell) = function _cell_position(cell_radius, x_cell, y_cell) =
let( let(

View File

@@ -16,10 +16,10 @@ function mz_hamiltonian(rows, columns, start, seed) =
let( let(
x = mz_square_get(cell, "x"), x = mz_square_get(cell, "x"),
y = mz_square_get(cell, "y"), y = mz_square_get(cell, "y"),
wall_type = mz_square_get(cell, "w"), type = mz_square_get(cell, "t"),
pts = wall_type == "TOP_WALL" ? _mz_hamiltonian_top(x, y) : pts = type == "TOP_WALL" ? _mz_hamiltonian_top(x, y) :
wall_type == "RIGHT_WALL" ? _mz_hamiltonian_right(x, y) : type == "RIGHT_WALL" ? _mz_hamiltonian_right(x, y) :
wall_type == "TOP_RIGHT_WALL" ? _mz_hamiltonian_top_right(x, y) : [] type == "TOP_RIGHT_WALL" ? _mz_hamiltonian_top_right(x, y) : []
) )
each pts each pts
], ],

View File

@@ -3,7 +3,7 @@ function mz_square_get(cell, query) =
i = search(query, [ i = search(query, [
["x", 0], ["x", 0],
["y", 1], ["y", 1],
["w", 2] ["t", 2]
])[0] ])[0]
) )
i != 2 ? cell[i] : ["NO_WALL", "TOP_WALL", "RIGHT_WALL", "TOP_RIGHT_WALL", "MASK"][cell[i]]; i != 2 ? cell[i] : ["NO_WALL", "TOP_WALL", "RIGHT_WALL", "TOP_RIGHT_WALL", "MASK"][cell[i]];