--多边形与矩形碰撞
function PolygonToRect(polygon,rectLeftBottomX,rectLeftBottomY,rectWidth,rectHeight)
local flag1 = PolygonToPoint(polygon,{x = rectLeftBottomX,y = rectLeftBottomY})
local flag2 = PolygonToPoint(polygon,{x = rectLeftBottomX+rectWidth,y = rectLeftBottomY})
local flag3 = PolygonToPoint(polygon,{x = rectLeftBottomX+rectWidth,y = rectLeftBottomY+rectHeight})
local flag4 = PolygonToPoint(polygon,{x = rectLeftBottomX,y = rectLeftBottomY+rectHeight})
if (flag1 or flag2 or flag3 or flag4) then
return true
end
local vectorNum = polygon:VectorNumber();
local next = 0
for current = 0 , vectorNum do
if (current == vectorNum - 1) then
next = 0
else
next = current + 1
end
local vc = polygon:GetVector(current)
local vn = polygon:GetVector(next)
--线是否与圆碰撞
if LineToRect(vc,vn,rectLeftBottomX,rectLeftBottomY,rectWidth,rectHeight) then
return true
碰撞算法14 --多边形与矩形的碰撞
于 2024-12-12 10:24:21 首次发布

最低0.47元/天 解锁文章
2014

被折叠的 条评论
为什么被折叠?



