如图:
local m_rHight = math.ceil( 1334 / 100 ) / 2 -- 高半径
local m_rWide = math.ceil( 750 / 200 ) / 2 -- 宽半径
-- 函数方法实现
function getNewPoints( aX, aY, bX, bY )
local pointsTab = {}
local differY = bY - aY
local differX = bX - aX
local oX1, oY1
if differY > 0 or differX < 0 then
oX1 = bX - m_rHight
oY1 = bY + m_rHight
else -- differY < 0 or differX > 0
oX1 = bX + m_rHight
oY1 = bY - m_rHight
end
if differY > 0 or differX > 0 then
for w = -m_rWide, m_rWide-1, 1 do
T_insert(pointsTab, {oX1+w, oY1+w})
end
else
for w = -m_rWide+1, m_rWide, 1 do
T_insert(pointsTab, {oX1+w, oY1+w})
end
end
--[[ -- 不统一使用如下注释代码,目的防止拐点(转角点)重复
for w = -m_rWide, m_rWide, 1 do
T_insert(pointsTab, {oX1+w, oY1+w})
end
]]
local oX2, oY2
if differY > 0 or differX > 0 then
oX2 = bX + m_rWide
oY2 = bY + m_rWide
else -- differY < 0 or differX < 0
oX2 = bX - m_rWide
oY2 = bY - m_rWide
end
for h = -m_rHight, m_rHight, 1 do
T_insert(pointsTab, {oX2-h, oY2+h})
end
return pointsTab
end