mirror of https://github.com/kepler155c/opus
naming
This commit is contained in:
parent
8d3f5329f2
commit
22a432492c
|
@ -27,7 +27,7 @@ function Point.subtract(a, b)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Euclidian distance
|
-- Euclidian distance
|
||||||
function Point.pythagoreanDistance(a, b)
|
function Point.distance(a, b)
|
||||||
return math.sqrt(
|
return math.sqrt(
|
||||||
math.pow(a.x - b.x, 2) +
|
math.pow(a.x - b.x, 2) +
|
||||||
math.pow(a.y - b.y, 2) +
|
math.pow(a.y - b.y, 2) +
|
||||||
|
@ -57,28 +57,28 @@ function Point.calculateTurns(ih, oh)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Point.calculateHeading(pta, ptb)
|
function Point.calculateHeading(pta, ptb)
|
||||||
|
|
||||||
local heading
|
local heading
|
||||||
|
local xd, zd = pta.x - ptb.x, pta.z - ptb.z
|
||||||
|
|
||||||
if (pta.heading % 2) == 0 and pta.z ~= ptb.z then
|
if (pta.heading % 2) == 0 and zd ~= 0 then
|
||||||
if ptb.z > pta.z then
|
if zd < 0 then
|
||||||
heading = 1
|
heading = 1
|
||||||
else
|
else
|
||||||
heading = 3
|
heading = 3
|
||||||
end
|
end
|
||||||
elseif (pta.heading % 2) == 1 and pta.x ~= ptb.x then
|
elseif (pta.heading % 2) == 1 and xd ~= 0 then
|
||||||
if ptb.x > pta.x then
|
if xd < 0 then
|
||||||
heading = 0
|
heading = 0
|
||||||
else
|
else
|
||||||
heading = 2
|
heading = 2
|
||||||
end
|
end
|
||||||
elseif pta.heading == 0 and pta.x > ptb.x then
|
elseif pta.heading == 0 and xd > 0 then
|
||||||
heading = 2
|
heading = 2
|
||||||
elseif pta.heading == 2 and pta.x < ptb.x then
|
elseif pta.heading == 2 and xd < 0 then
|
||||||
heading = 0
|
heading = 0
|
||||||
elseif pta.heading == 1 and pta.z > ptb.z then
|
elseif pta.heading == 1 and zd > 0 then
|
||||||
heading = 3
|
heading = 3
|
||||||
elseif pta.heading == 3 and pta.z < ptb.z then
|
elseif pta.heading == 3 and zd < 0 then
|
||||||
heading = 1
|
heading = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -134,7 +134,6 @@ function Point.closest(reference, pts)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Point.eachClosest(spt, ipts, fn)
|
function Point.eachClosest(spt, ipts, fn)
|
||||||
|
|
||||||
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)
|
||||||
|
@ -176,6 +175,20 @@ function Point.inBox(pt, box)
|
||||||
pt.z <= box.ez
|
pt.z <= box.ez
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Point.rotate(pt, facing)
|
||||||
|
local x, z = pt.x, pt.z
|
||||||
|
if facing == 1 then
|
||||||
|
pt.x = z
|
||||||
|
pt.z = -x
|
||||||
|
elseif facing == 2 then
|
||||||
|
pt.x = -x
|
||||||
|
pt.z = -z
|
||||||
|
elseif facing == 3 then
|
||||||
|
pt.x = -z
|
||||||
|
pt.z = x
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return Point
|
return Point
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
|
|
Loading…
Reference in New Issue