Correct bugs in polygon_triangulation and _cleave_connected_region(

This commit is contained in:
RonaldoCMP
2021-11-01 04:42:02 +00:00
parent 94033a0bfd
commit c5da41ed8c
5 changed files with 307 additions and 80 deletions

View File

@@ -491,12 +491,11 @@ function _bt_tree(points, ind, leafsize=25) =
bounds = pointlist_bounds(select(points,ind)),
coord = max_index(bounds[1]-bounds[0]),
projc = [for(i=ind) points[i][coord] ],
pmc = mean(projc),
pivot = min_index([for(p=projc) abs(p-pmc)]),
meanpr = mean(projc),
pivot = min_index([for(p=projc) abs(p-meanpr)]),
radius = max([for(i=ind) norm(points[ind[pivot]]-points[i]) ]),
median = median(projc),
Lind = [for(i=idx(ind)) if(projc[i]<=median && i!=pivot) ind[i] ],
Rind = [for(i=idx(ind)) if(projc[i] >median && i!=pivot) ind[i] ]
Lind = [for(i=idx(ind)) if(projc[i]<=meanpr && i!=pivot) ind[i] ],
Rind = [for(i=idx(ind)) if(projc[i] >meanpr && i!=pivot) ind[i] ]
)
[ ind[pivot], radius, _bt_tree(points, Lind, leafsize), _bt_tree(points, Rind, leafsize) ];