mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-18 12:31:17 +02:00
rename parameters
This commit is contained in:
@@ -38,7 +38,7 @@ module cylinder_maze() {
|
||||
maze_blocks = mz_square_blocks(
|
||||
[1, maze_rows],
|
||||
maze_rows, maze_columns,
|
||||
x_circular = true
|
||||
x_wrapping = true
|
||||
);
|
||||
|
||||
walls = mz_square_walls(maze_blocks, maze_rows, maze_columns, block_width, left_border = false);
|
||||
|
@@ -33,7 +33,7 @@ module heart_base(name, font_name, font_size, radius, ring_thickness, tip_r_of_h
|
||||
module heart2heart_maze(names, font_name, font_size, radius_of_heart, tip_r_of_heart, wall_thickness, cblocks, levels, spacing) {
|
||||
maze = mz_square_blocks(
|
||||
[1, 1],
|
||||
cblocks, levels, y_circular = true
|
||||
cblocks, levels, y_wrapping = true
|
||||
);
|
||||
|
||||
translate([0, 0, wall_thickness])
|
||||
|
@@ -108,7 +108,7 @@ module heart_maze(maze, radius, cblocks, levels, thickness = 1) {
|
||||
|
||||
maze = mz_square_blocks(
|
||||
[1, 1],
|
||||
cblocks, levels, y_circular = true
|
||||
cblocks, levels, y_wrapping = true
|
||||
);
|
||||
|
||||
intersection() {
|
||||
|
@@ -17,7 +17,7 @@ a_step = 360 / leng;
|
||||
blocks = mz_square_blocks(
|
||||
[1, 1],
|
||||
rows, columns,
|
||||
y_circular = true
|
||||
y_wrapping = true
|
||||
);
|
||||
|
||||
walls = mz_square_walls(blocks, rows, columns, block_width, bottom_border = false);
|
||||
|
@@ -51,7 +51,7 @@ module regular_polygon_maze(radius, cblocks, levels, thickness = 1, sides) {
|
||||
|
||||
maze = mz_square_blocks(
|
||||
[1, 1],
|
||||
cblocks, levels, y_circular = true
|
||||
cblocks, levels, y_wrapping = true
|
||||
);
|
||||
|
||||
difference() {
|
||||
|
@@ -54,7 +54,7 @@ module sphere_maze() {
|
||||
blocks = mz_square_blocks(
|
||||
[1, 1],
|
||||
rows, columns,
|
||||
y_circular = true
|
||||
y_wrapping = true
|
||||
);
|
||||
|
||||
p_offset = [block_width * rows, pole_offset, 0];
|
||||
|
@@ -17,7 +17,7 @@ a_step = 360 / leng;
|
||||
blocks = mz_square_blocks(
|
||||
[1, 1],
|
||||
rows, columns,
|
||||
x_circular = true, y_circular = true
|
||||
x_wrapping = true, y_wrapping = true
|
||||
);
|
||||
|
||||
walls = mz_square_walls(blocks, rows, columns, block_width, left_border = false, bottom_border = false);
|
||||
|
@@ -56,9 +56,9 @@ function rand_dirs(c, seed) =
|
||||
|
||||
// get x value by dir
|
||||
_next_x_table = [1, 0, -1, 0];
|
||||
function next_x(x, dir, columns, circular) =
|
||||
function next_x(x, dir, columns, wrapping) =
|
||||
let(nx = x + _next_x_table[dir])
|
||||
circular ?
|
||||
wrapping ?
|
||||
nx < 1 ? nx + columns : (
|
||||
nx > columns ? nx % columns : nx
|
||||
)
|
||||
@@ -67,9 +67,9 @@ function next_x(x, dir, columns, circular) =
|
||||
|
||||
// get y value by dir
|
||||
_next_y_table = [0, 1, 0, -1];
|
||||
function next_y(y, dir, rows, circular) =
|
||||
function next_y(y, dir, rows, wrapping) =
|
||||
let(ny = y + _next_y_table[dir])
|
||||
circular ?
|
||||
wrapping ?
|
||||
ny < 1 ? ny + rows : (
|
||||
ny > rows ? ny % rows : ny
|
||||
)
|
||||
@@ -115,17 +115,17 @@ function carve(dir, x, y, maze, rows, columns) =
|
||||
|
||||
|
||||
// find out visitable dirs from (x, y)
|
||||
function visitable_dirs(r_dirs, x, y, maze, rows, columns, x_circular, y_circular) = [
|
||||
function visitable_dirs(r_dirs, x, y, maze, rows, columns, x_wrapping, y_wrapping) = [
|
||||
for(dir = r_dirs)
|
||||
if(visitable(next_x(x, dir, columns, x_circular), next_y(y, dir, rows, y_circular), maze, rows, columns))
|
||||
if(visitable(next_x(x, dir, columns, x_wrapping), next_y(y, dir, rows, y_wrapping), maze, rows, columns))
|
||||
dir
|
||||
];
|
||||
|
||||
// go maze from (x, y)
|
||||
function go_maze(x, y, maze, rows, columns, x_circular = false, y_circular = false, seed) =
|
||||
function go_maze(x, y, maze, 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_circular, y_circular)
|
||||
v_dirs = visitable_dirs(r_dirs, x, y, maze, rows, columns, x_wrapping, y_wrapping)
|
||||
)
|
||||
// have visitable dirs?
|
||||
len(v_dirs) == 0 ?
|
||||
@@ -135,33 +135,33 @@ function go_maze(x, y, maze, rows, columns, x_circular = false, y_circular = fal
|
||||
v_dirs,
|
||||
set_visited(x, y, maze),
|
||||
rows, columns,
|
||||
x_circular, y_circular,
|
||||
x_wrapping, y_wrapping,
|
||||
seed = seed
|
||||
);
|
||||
|
||||
// try four directions
|
||||
function walk_around_from(x, y, dirs, maze, rows, columns, x_circular, y_circular, i = 0, seed) =
|
||||
function walk_around_from(x, y, dirs, maze, 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_circular, y_circular, seed),
|
||||
try_routes_from(x, y, dirs[i], maze, rows, columns, x_wrapping, y_wrapping, seed),
|
||||
rows, columns,
|
||||
x_circular, y_circular,
|
||||
x_wrapping, y_wrapping,
|
||||
i + 1,
|
||||
seed)
|
||||
: maze;
|
||||
|
||||
function try_routes_from(x, y, dir, maze, rows, columns, x_circular, y_circular, seed) =
|
||||
function try_routes_from(x, y, dir, maze, rows, columns, x_wrapping, y_wrapping, seed) =
|
||||
// is the dir visitable?
|
||||
visitable(next_x(x, dir, columns, x_circular), next_y(y, dir, rows, y_circular), maze, rows, columns) ?
|
||||
visitable(next_x(x, dir, columns, x_wrapping), next_y(y, dir, rows, y_wrapping), maze, rows, columns) ?
|
||||
// try the block
|
||||
go_maze(
|
||||
next_x(x, dir, columns, x_circular), next_y(y, dir, rows, y_circular),
|
||||
next_x(x, dir, columns, x_wrapping), next_y(y, dir, rows, y_wrapping),
|
||||
carve(dir, x, y, maze, rows, columns),
|
||||
rows, columns,
|
||||
x_circular, y_circular,
|
||||
x_wrapping, y_wrapping,
|
||||
seed
|
||||
)
|
||||
// road closed so return maze directly
|
||||
|
@@ -1,9 +1,9 @@
|
||||
use <_impl/_mz_blocks_impl.scad>;
|
||||
use <mz_square_initialize.scad>;
|
||||
|
||||
function mz_square_blocks(start, rows, columns, maze, x_circular = false, y_circular = false, seed) =
|
||||
function mz_square_blocks(start, rows, columns, maze, x_wrapping = false, y_wrapping = false, seed) =
|
||||
go_maze(
|
||||
start[0], start[1], // starting point
|
||||
is_undef(maze) ? mz_square_initialize(rows, columns) : maze,
|
||||
rows, columns, x_circular, y_circular, seed
|
||||
rows, columns, x_wrapping, y_wrapping, seed
|
||||
);
|
||||
|
Reference in New Issue
Block a user