1
0
mirror of https://github.com/JustinSDK/dotSCAD.git synced 2025-08-01 04:20:27 +02:00

voronoi 3d ok

This commit is contained in:
Justin Lin
2020-03-29 20:03:28 +08:00
parent fae0991e21
commit 5bd42db365

View File

@@ -8,8 +8,11 @@ function _nz_voronoi3(p, seed, dim, m, n, o) =
dists = [
for(nbr = nbrs)
if(!is_undef(nbr[1])) // Here's a workaround for a weired undef problem. bug of 2019.05?
[norm(nbr - p)]
[nbr[0], nbr[1], nbr[2], norm(nbr - p)]
],
sorted = sort(dists)
sorted = sort(dists, by = "idx", idx = 3),
a = [sorted[0][0], sorted[0][1], sorted[0][2]],
b = [sorted[1][0], sorted[1][1], sorted[1][2]],
m = (a + b) / 2
)
sorted[1][0] - sorted[0][0];
(p - m) * (a - m);