1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-22 22:35:18 +02:00

use matrix index convention

This commit is contained in:
Justin Lin
2022-07-28 15:21:02 +08:00
parent abd5683698
commit 5b725bd6bb
7 changed files with 21 additions and 21 deletions

View File

@@ -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), d = (pts[f0] - pts[i]) * normal(pts, f),
nx = d >= 0 ? [each next, f] : next, nx = d >= 0 ? [each next, f] : next,
s = sign(d), s = sign(d),
vis1 = m_replace(vis, f1, f0, s), vis1 = m_replace(vis, f0, f1, s),
vis2 = m_replace(vis1, f2, f1, s), vis2 = m_replace(vis1, f1, f2, s),
vis3 = m_replace(vis2, f0, f2, s) vis3 = m_replace(vis2, f2, f0, s)
) )
next_vis(i, pts, cur_faces, cur_faces_leng, nx, vis3, j + 1); next_vis(i, pts, cur_faces, cur_faces_leng, nx, vis3, j + 1);

View File

@@ -70,7 +70,7 @@ function _replaceStatesAt(wf, x, y, states) =
wf_width(wf), wf_width(wf),
wf_height(wf), wf_height(wf),
wf_weights(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) = function wf_not_collapsed_coords(wf, notCollaspedCoords) =

View File

@@ -1,14 +1,14 @@
function m_replace(m, x, y, value) = function m_replace(m, i, j, value) =
let( let(
rowY = m[y], rowI = m[i],
newRowY = [ newRowI = [
for(i = [0:len(rowY) - 1]) for(c = [0:len(rowI) - 1])
if(i == x) value if(c == j) value
else rowY[i] else rowI[c]
] ]
) )
[ [
for(i = [0:len(m) - 1]) for(r = [0:len(m) - 1])
if(i == y) newRowY if(r == i) newRowI
else m[i] else m[r]
]; ];

View File

@@ -11,7 +11,7 @@ function update(cells, cell) =
z = cell.z, z = cell.z,
rowY = [for(c = cells[z][y]) if(c.x == x) cell else c] 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? // is (x, y) visited?
function visited(x, y, z, cells) = cells[z][y][x][4]; function visited(x, y, z, cells) = cells[z][y][x][4];

View File

@@ -14,7 +14,7 @@ function visitable(x, y, cells, rows, columns) =
// setting (x, y) as being visited // setting (x, y) as being visited
function set_visited(x, y, cells) = 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) // 0(right), 1(top), 2(left), 3(bottom)
_rand_dir_table = [ _rand_dir_table = [
@@ -61,11 +61,11 @@ function next_y(y, dir, rows, wrapping) =
// go right and carve the right wall // go right and carve the right wall
function carve_right(x, y, cells) = 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 // go up and carve the top wall
function carve_top(x, y, cells) = 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 // go left and carve the right wall of the left cell
function carve_left(x, y, cells, columns) = function carve_left(x, y, cells, columns) =
@@ -73,7 +73,7 @@ function carve_left(x, y, cells, columns) =
x_minus_one = x - 1, x_minus_one = x - 1,
nx = x_minus_one < 0 ? x_minus_one + columns : x_minus_one 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 // go down and carve the top wall of the bottom cell
function carve_bottom(x, y, cells, rows) = function carve_bottom(x, y, cells, rows) =
@@ -81,7 +81,7 @@ function carve_bottom(x, y, cells, rows) =
y_minus_one = y - 1, y_minus_one = y - 1,
ny = y_minus_one < 0 ? y_minus_one + rows : y_minus_one 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) // 0(right), 1(top), 2(left), 3(bottom)
function carve(dir, x, y, cells, rows, columns) = function carve(dir, x, y, cells, rows, columns) =

View File

@@ -116,7 +116,7 @@ function sampling_trySampleFromOneActive(s, seed) =
w = sampling_w(s), w = sampling_w(s),
x = floor(sample.x / w), x = floor(sample.x / w),
y = floor(sample.y / 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), sampling_r(s),

View File

@@ -5,7 +5,7 @@ use <../../util/find_index.scad>
function grid_replace(g, x, y, z, p) = function grid_replace(g, x, y, z, p) =
[ [
for(i = [0:len(g) - 1]) 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] else g[i]
]; ];