mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-08-12 09:44:16 +02:00
start accept a list of points
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
use <../../matrix/m_replace.scad>
|
use <../../matrix/m_replace.scad>
|
||||||
use <../../util/every.scad>
|
use <../../util/every.scad>
|
||||||
|
use <../../util/find_index.scad>
|
||||||
|
|
||||||
function grid_replace(g, x, y, z, p) =
|
function grid_replace(g, x, y, z, p) =
|
||||||
[
|
[
|
||||||
@@ -14,14 +15,25 @@ function sampling(size, r, start, k, sd) =
|
|||||||
layers = floor(size.z / w),
|
layers = floor(size.z / w),
|
||||||
rows = floor(size.y / w),
|
rows = floor(size.y / w),
|
||||||
columns = floor(size.x / w),
|
columns = floor(size.x / w),
|
||||||
pt = is_undef(start) ? [rands(0, size.x, 1, sd)[0], rands(0, size.y, 1, sd + 1)[0], rands(0, size.z, 1, sd + 2)[0]] : start,
|
pts = is_undef(start) ? [[rands(0, size.x, 1, sd)[0], rands(0, size.y, 1, sd + 1)[0], rands(0, size.z, 1, sd + 2)[0]]] :
|
||||||
active = [pt],
|
is_num(start[0]) ? [start] : start,
|
||||||
px = floor(pt.x / w),
|
active = pts,
|
||||||
py = floor(pt.y / w),
|
pijk = [for(pt = pts) [floor(pt.x / w), floor(pt.y / w), floor(pt.z / w), pt]],
|
||||||
pz = floor(pt.z / w),
|
_ = echo(pijk),
|
||||||
grid_row = [for(i = [0:columns - 1]) undef],
|
grid = [
|
||||||
grid_layer = [for(i = [0:rows - 1]) grid_row],
|
for(k = [0:layers - 1])
|
||||||
grid = grid_replace([for(i = [0:layers - 1]) grid_layer], px, py, pz, pt)
|
[
|
||||||
|
for(j = [0:rows - 1])
|
||||||
|
[
|
||||||
|
for(i = [0:columns - 1])
|
||||||
|
let(found = find_index(pijk, function(ijk) ijk[0] == i && ijk[1] == j && ijk[2] == k))
|
||||||
|
if(found != -1)
|
||||||
|
pijk[found][3]
|
||||||
|
else
|
||||||
|
undef
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
)
|
)
|
||||||
[r, k, w, active, grid, layers, rows, columns, []];
|
[r, k, w, active, grid, layers, rows, columns, []];
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user