mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-22 14:23:23 +02:00
use matrix index convention
This commit is contained in:
@@ -28,9 +28,9 @@ function next_vis(i, pts, cur_faces, cur_faces_leng, next, vis, j = 0) =
|
||||
d = (pts[f0] - pts[i]) * normal(pts, f),
|
||||
nx = d >= 0 ? [each next, f] : next,
|
||||
s = sign(d),
|
||||
vis1 = m_replace(vis, f1, f0, s),
|
||||
vis2 = m_replace(vis1, f2, f1, s),
|
||||
vis3 = m_replace(vis2, f0, f2, s)
|
||||
vis1 = m_replace(vis, f0, f1, s),
|
||||
vis2 = m_replace(vis1, f1, f2, s),
|
||||
vis3 = m_replace(vis2, f2, f0, s)
|
||||
)
|
||||
next_vis(i, pts, cur_faces, cur_faces_leng, nx, vis3, j + 1);
|
||||
|
||||
|
@@ -70,7 +70,7 @@ function _replaceStatesAt(wf, x, y, states) =
|
||||
wf_width(wf),
|
||||
wf_height(wf),
|
||||
wf_weights(wf),
|
||||
m_replace(wf_eigenstates(wf), x, y, states)
|
||||
m_replace(wf_eigenstates(wf), y, x, states)
|
||||
];
|
||||
|
||||
function wf_not_collapsed_coords(wf, notCollaspedCoords) =
|
||||
|
@@ -1,14 +1,14 @@
|
||||
function m_replace(m, x, y, value) =
|
||||
function m_replace(m, i, j, value) =
|
||||
let(
|
||||
rowY = m[y],
|
||||
newRowY = [
|
||||
for(i = [0:len(rowY) - 1])
|
||||
if(i == x) value
|
||||
else rowY[i]
|
||||
rowI = m[i],
|
||||
newRowI = [
|
||||
for(c = [0:len(rowI) - 1])
|
||||
if(c == j) value
|
||||
else rowI[c]
|
||||
]
|
||||
)
|
||||
[
|
||||
for(i = [0:len(m) - 1])
|
||||
if(i == y) newRowY
|
||||
else m[i]
|
||||
for(r = [0:len(m) - 1])
|
||||
if(r == i) newRowI
|
||||
else m[r]
|
||||
];
|
||||
|
@@ -11,7 +11,7 @@ function update(cells, cell) =
|
||||
z = cell.z,
|
||||
rowY = [for(c = cells[z][y]) if(c.x == x) cell else c]
|
||||
)
|
||||
m_replace(cells, y, z, rowY);
|
||||
m_replace(cells, z, y, rowY);
|
||||
|
||||
// is (x, y) visited?
|
||||
function visited(x, y, z, cells) = cells[z][y][x][4];
|
||||
|
@@ -14,7 +14,7 @@ function visitable(x, y, cells, rows, columns) =
|
||||
|
||||
// setting (x, y) as being visited
|
||||
function set_visited(x, y, cells) =
|
||||
m_replace(cells, x, y, [x, y, get_type(cells[y][x]), VISITED]);
|
||||
m_replace(cells, y, x, [x, y, get_type(cells[y][x]), VISITED]);
|
||||
|
||||
// 0(right), 1(top), 2(left), 3(bottom)
|
||||
_rand_dir_table = [
|
||||
@@ -61,11 +61,11 @@ function next_y(y, dir, rows, wrapping) =
|
||||
|
||||
// go right and carve the right wall
|
||||
function carve_right(x, y, cells) =
|
||||
m_replace(cells, x, y, top_right_wall(cells[y][x]) ? [x, y, TOP_WALL, VISITED] : [x, y, NO_WALL, VISITED]);
|
||||
m_replace(cells, y, x, top_right_wall(cells[y][x]) ? [x, y, TOP_WALL, VISITED] : [x, y, NO_WALL, VISITED]);
|
||||
|
||||
// go up and carve the top wall
|
||||
function carve_top(x, y, cells) =
|
||||
m_replace(cells, x, y, top_right_wall(cells[y][x]) ? [x, y, RIGHT_WALL, VISITED] : [x, y, NO_WALL, VISITED]);
|
||||
m_replace(cells, y, x, top_right_wall(cells[y][x]) ? [x, y, RIGHT_WALL, VISITED] : [x, y, NO_WALL, VISITED]);
|
||||
|
||||
// go left and carve the right wall of the left cell
|
||||
function carve_left(x, y, cells, columns) =
|
||||
@@ -73,7 +73,7 @@ function carve_left(x, y, cells, columns) =
|
||||
x_minus_one = x - 1,
|
||||
nx = x_minus_one < 0 ? x_minus_one + columns : x_minus_one
|
||||
)
|
||||
m_replace(cells, nx, y, [nx, y, TOP_WALL, UNVISITED]);
|
||||
m_replace(cells, y, nx, [nx, y, TOP_WALL, UNVISITED]);
|
||||
|
||||
// go down and carve the top wall of the bottom cell
|
||||
function carve_bottom(x, y, cells, rows) =
|
||||
@@ -81,7 +81,7 @@ function carve_bottom(x, y, cells, rows) =
|
||||
y_minus_one = y - 1,
|
||||
ny = y_minus_one < 0 ? y_minus_one + rows : y_minus_one
|
||||
)
|
||||
m_replace(cells, x, ny, [x, ny, RIGHT_WALL, UNVISITED]);
|
||||
m_replace(cells, ny, x, [x, ny, RIGHT_WALL, UNVISITED]);
|
||||
|
||||
// 0(right), 1(top), 2(left), 3(bottom)
|
||||
function carve(dir, x, y, cells, rows, columns) =
|
||||
|
@@ -116,7 +116,7 @@ function sampling_trySampleFromOneActive(s, seed) =
|
||||
w = sampling_w(s),
|
||||
x = floor(sample.x / w),
|
||||
y = floor(sample.y / w),
|
||||
nx_grid = m_replace(sampling_grid(s), x, y, sample)
|
||||
nx_grid = m_replace(sampling_grid(s), y, x, sample)
|
||||
)
|
||||
[
|
||||
sampling_r(s),
|
||||
|
@@ -5,7 +5,7 @@ use <../../util/find_index.scad>
|
||||
function grid_replace(g, x, y, z, p) =
|
||||
[
|
||||
for(i = [0:len(g) - 1])
|
||||
if(i == z) m_replace(g[z], x, y, p)
|
||||
if(i == z) m_replace(g[z], y, x, p)
|
||||
else g[i]
|
||||
];
|
||||
|
||||
|
Reference in New Issue
Block a user