mirror of
https://github.com/kepler155c/opus
synced 2025-01-27 07:34:45 +00:00
Pointt.iterateClosest
This commit is contained in:
parent
5d38c307b3
commit
e14a71ab6a
@ -189,6 +189,8 @@ function Point.closest(reference, pts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Point.eachClosest(spt, ipts, fn)
|
function Point.eachClosest(spt, ipts, fn)
|
||||||
|
if not ipts then error('Point.eachClosest: invalid points', 2) end
|
||||||
|
|
||||||
local pts = Util.shallowCopy(ipts)
|
local pts = Util.shallowCopy(ipts)
|
||||||
while #pts > 0 do
|
while #pts > 0 do
|
||||||
local pt = Point.closest(spt, pts)
|
local pt = Point.closest(spt, pts)
|
||||||
@ -200,6 +202,17 @@ function Point.eachClosest(spt, ipts, fn)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Point.iterateClosest(spt, ipts)
|
||||||
|
local pts = Util.shallowCopy(ipts)
|
||||||
|
return function()
|
||||||
|
local pt = Point.closest(spt, pts)
|
||||||
|
if pt then
|
||||||
|
Util.removeByValue(pts, pt)
|
||||||
|
return pt
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function Point.adjacentPoints(pt)
|
function Point.adjacentPoints(pt)
|
||||||
local pts = { }
|
local pts = { }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user