mirror of
https://github.com/JustinSDK/dotSCAD.git
synced 2025-01-18 06:38:14 +01:00
optimization
This commit is contained in:
parent
99ee4e4e74
commit
f791eccf25
@ -18,15 +18,15 @@ function _nz_cell_classic(cells, p, dist) =
|
|||||||
|
|
||||||
function _nz_cell_border(cells, p) =
|
function _nz_cell_border(cells, p) =
|
||||||
let(
|
let(
|
||||||
dists = [
|
dists = [for(cell = cells) norm(cell - p)],
|
||||||
for(cell = cells)
|
m1 = min(dists),
|
||||||
[each cell, norm(cell - p)]
|
i1 = search(m1, dists)[0],
|
||||||
],
|
dists2 = [for(i = [0:len(dists) - 1]) if(i != i1) dists[i]],
|
||||||
idx = len(cells[0]),
|
cells2 = [for(i = [0:len(cells) - 1]) if(i != i1) cells[i]],
|
||||||
sorted_dists = sorted(dists, key = function(elem) elem[idx]),
|
m2 = min(dists2),
|
||||||
sorted0 = sorted_dists[0],
|
i2 = search(m2, dists2)[0],
|
||||||
sorted1 = sorted_dists[1],
|
fst = cells[i1],
|
||||||
a = [for(i = [0:idx - 1]) sorted0[i]],
|
snd = cells2[i2],
|
||||||
m = (a + [for(i = [0:idx - 1]) sorted1[i]]) / 2
|
m = (fst + snd) / 2
|
||||||
)
|
)
|
||||||
(p - m) * (a - m);
|
(p - m) * (fst - m);
|
Loading…
x
Reference in New Issue
Block a user