1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-09 00:06:42 +02:00

use for comp

This commit is contained in:
Justin Lin
2022-05-15 14:33:30 +08:00
parent cf32517302
commit c678589c15

View File

@@ -47,25 +47,19 @@ function columnLengOfRow(ri, cellWidth, previousColumnLeng, dividedRatio) =
previousColumnLeng * ratio; previousColumnLeng * ratio;
function init_theta_maze(totalRows, beginingColumns, dividedRatio = 1.5) = function init_theta_maze(totalRows, beginingColumns, dividedRatio = 1.5) =
let( let(cellWidth = 1 / totalRows)
cellWidth = 1 / totalRows, [
r0 = [ for(
for(ci=0; ci < beginingColumns; ci = ci + 1) ri = 0,
cell(0, ci, INWARD_CCW_WALL) columnLeng = -1,
] row = [for(ci = 0; ci < beginingColumns; ci = ci + 1) cell(0, ci, INWARD_CCW_WALL)];
) ri < totalRows;
_init_theta_maze(1, [r0], totalRows, dividedRatio, cellWidth); ri = ri + 1,
columnLeng = ri < totalRows ? columnLengOfRow(ri, cellWidth, len(row), dividedRatio) : undef,
function _init_theta_maze(ri, maze, totalRows, dividedRatio, cellWidth) = row = ri < totalRows ? [for(ci = 0; ci < columnLeng; ci = ci + 1) cell(ri, ci, INWARD_CCW_WALL)] : undef
ri == totalRows ? maze : )
let( row
columnLeng = columnLengOfRow(ri, cellWidth, len(maze[ri - 1]), dividedRatio), ];
row = [
for(ci = 0; ci < columnLeng; ci = ci + 1)
cell(ri, ci, INWARD_CCW_WALL)
]
)
_init_theta_maze(ri + 1, [each maze, row], totalRows, dividedRatio, cellWidth);
function update_maze_row(row, cell) = function update_maze_row(row, cell) =
let(leng = len(row)) let(leng = len(row))
@@ -86,14 +80,17 @@ function cell_from(maze, cell_idx) = maze[cell_idx[0]][cell_idx[1]];
function _config_outwards(maze, cell_outwards_lt, leng, i = 0) = function _config_outwards(maze, cell_outwards_lt, leng, i = 0) =
i == leng ? maze : i == leng ? maze :
let( _config_outwards(
c = add_outward( update_maze(maze,
cell_from(maze, cell_outwards_lt[i][0]), add_outward(
cell_outwards_lt[i][1] cell_from(maze, cell_outwards_lt[i][0]),
), cell_outwards_lt[i][1]
mz = update_maze(maze, c) )
) ),
_config_outwards(mz, cell_outwards_lt, leng, i + 1); cell_outwards_lt,
leng,
i + 1
);
function config_nbrs(maze) = function config_nbrs(maze) =
let( let(