mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-12 01:34:12 +02:00
refactor
This commit is contained in:
@@ -39,11 +39,10 @@ function _build_cell(cell_radius, cell) =
|
|||||||
_row_wall(cell_radius, x, y),
|
_row_wall(cell_radius, x, y),
|
||||||
[_is_top_wall(cell) || _is_top_right_wall(cell) ? _top(cell_radius) : []],
|
[_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) : []]
|
[_is_right_wall(cell) || _is_top_right_wall(cell) ? _right_wall(cell_radius, x) : []]
|
||||||
)
|
),
|
||||||
|
cell_p = _cell_position(cell_radius, x, y)
|
||||||
)
|
)
|
||||||
[
|
[
|
||||||
for(wall = walls)
|
for(wall = walls)
|
||||||
if(wall != [])
|
if(wall != []) [for(p = wall) cell_p + p]
|
||||||
[for(p = wall)
|
|
||||||
_cell_position(cell_radius, x, y) + p]
|
|
||||||
];
|
];
|
||||||
|
@@ -2,8 +2,7 @@ use <_mz_square_comm.scad>;
|
|||||||
|
|
||||||
// create a starting maze for being visited later.
|
// create a starting maze for being visited later.
|
||||||
function _rc_maze(rows, columns) = [
|
function _rc_maze(rows, columns) = [
|
||||||
for(y = [0:rows - 1])
|
for(y = [0:rows - 1], x = [0:columns - 1])
|
||||||
for(x = [0:columns - 1])
|
|
||||||
cell(
|
cell(
|
||||||
x, y,
|
x, y,
|
||||||
// all cells have top and right walls
|
// all cells have top and right walls
|
||||||
|
@@ -9,10 +9,10 @@ function _chebyshev(p1, p2) =
|
|||||||
function _nz_cell_classic(cells, p, dist) =
|
function _nz_cell_classic(cells, p, dist) =
|
||||||
let(
|
let(
|
||||||
dists = [
|
dists = [
|
||||||
for(i = [0:len(cells) - 1])
|
for(cell = cells)
|
||||||
dist == "euclidean" ? norm(cells[i] - p) :
|
dist == "euclidean" ? norm(cell - p) :
|
||||||
dist == "manhattan" ? _manhattan(cells[i] - p) :
|
dist == "manhattan" ? _manhattan(cell - p) :
|
||||||
dist == "chebyshev" ? _chebyshev(cells[i], p) :
|
dist == "chebyshev" ? _chebyshev(cell, p) :
|
||||||
assert("Unknown distance option")
|
assert("Unknown distance option")
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
@@ -21,13 +21,15 @@ function _nz_cell_classic(cells, p, dist) =
|
|||||||
function _nz_cell_border(cells, p) =
|
function _nz_cell_border(cells, p) =
|
||||||
let(
|
let(
|
||||||
dists = [
|
dists = [
|
||||||
for(i = [0:len(cells) - 1])
|
for(cell = cells)
|
||||||
[each cells[i], norm(cells[i] - p)]
|
[each cell, norm(cell - p)]
|
||||||
],
|
],
|
||||||
idx = len(cells[0]),
|
idx = len(cells[0]),
|
||||||
sorted = sort(dists, by = "idx", idx = idx),
|
sorted = sort(dists, by = "idx", idx = idx),
|
||||||
a = [for(i = [0:idx - 1]) sorted[0][i]],
|
sorted0 = sorted[0],
|
||||||
b = [for(i = [0:idx - 1]) sorted[1][i]],
|
sorted1 = sorted[1],
|
||||||
|
a = [for(i = [0:idx - 1]) sorted0[i]],
|
||||||
|
b = [for(i = [0:idx - 1]) sorted1[i]],
|
||||||
m = (a + b) / 2
|
m = (a + b) / 2
|
||||||
)
|
)
|
||||||
(p - m) * (a - m);
|
(p - m) * (a - m);
|
Reference in New Issue
Block a user