1
0
mirror of https://github.com/kepler155c/opus synced 2024-06-16 10:19:59 +00:00

dont require heading for point.closest

This commit is contained in:
kepler155c@gmail.com 2019-01-08 04:40:58 -05:00
parent f5294d4fce
commit b761b3429a

View File

@ -177,7 +177,12 @@ function Point.closest(reference, pts)
local lm, lpt = math.huge local lm, lpt = math.huge
for _,pt in pairs(pts) do for _,pt in pairs(pts) do
local distance = Point.turtleDistance(reference, pt) local distance = Point.turtleDistance(reference, pt)
if distance < lm then if not reference.heading then
if distance < lm then
lpt = pt
lm = distance
end
elseif distance < lm then
local _, _, m = Point.calculateMoves(reference, pt, distance) local _, _, m = Point.calculateMoves(reference, pt, distance)
if m < lm then if m < lm then
lpt = pt lpt = pt