1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-01-17 06:08:31 +01:00
This commit is contained in:
Justin Lin 2022-07-03 10:37:23 +08:00
parent a6e74ca978
commit 160d2e67ac
2 changed files with 12 additions and 7 deletions

View File

@ -29,14 +29,19 @@ function sampling_inRow(s, y) = y > -1 && y < sampling_rows(s);
function sampling_inGrid(s, x, y) =
sampling_inRow(s, y) && x > -1 && x < sampling_columns(s);
NBRS = [
[-1, -1], [0, -1], [1, -1],
[-1, 0], [0, 0], [1, 0],
[-1, 1], [0, 1], [1, 1]
];
function sampling_noAdjacentNeighbor(s, sample, x, y) =
let(me = [x, y])
every(
[
[x - 1, y - 1], [x, y - 1], [x + 1, y - 1],
[x - 1, y], [x, y], [x + 1, y],
[x - 1, y + 1], [x, y + 1], [x + 1, y + 1]
],
function(nbr) !sampling_inRow(s, nbr.y) ||
NBRS,
function(NBR)
let(nbr = me + NBR)
!sampling_inRow(s, nbr.y) ||
(let(p = sampling_grid(s)[nbr.y][nbr.x])
is_undef(p) ||
norm(sample - p) >= sampling_r(s))

View File

@ -71,7 +71,7 @@ function sampling_noAdjacentNeighbor(s, sample, x, y, z) =
function sampling_randomSample(s, pos, seed) =
let(
r = sampling_r(s),
theta = rands(0, 360, 1, seed)[0] - 180,
theta = rands(-180, 180, 1, seed)[0],
phi = rands(0, 180, 1, seed + 1)[0],
sin_phi = sin(phi)
)