|
楼主 |
发表于 2010-9-22 08:33:51
|
显示全部楼层
[jass]//判断Point是否在多点确定的凸多边形中,返回true为在,false为不在,参数hashtable结构如下:父key为InputKey,子key为0,变量类型为integer,内容为全部点总数。父key为InputKey,变量类型为location,内容为全部点(子key从0开始)。
function ISPointInPolygon takes hashtable Points , integer InputKey , location Point returns boolean
local integer TempArrayNum = LoadInteger(Points,InputKey,0)
local integer TempI = 0
local real TempMaxReal = 0
local real TempMinReal = 0
local real TempAngle_0 = AngleBetweenPoints(Point,LoadLocationHandle(Points,InputKey,TempI))
local real TempAngle_1 = 0
loop
exitwhen TempI == TempArrayNum
set TempAngle_1 = TempAngle_0 - AngleBetweenPoints(Point,LoadLocationHandle(Points,InputKey,TempI))
if TempAngle_1 < -180 then
set TempAngle_1 = TempAngle_1 + 360
endif
if TempAngle_1 > 180 then
set TempAngle_1 = TempAngle_1 - 360
endif
if TempAngle_1 > TempMaxReal then
set TempMaxReal = TempAngle_1
endif
if TempAngle_1 < TempMinReal then
set TempMinReal = TempAngle_1
endif
set TempI = TempI+1
endloop
set TempAngle_1 = TempMaxReal - TempMinReal
if TempAngle_1 > 180 then
return true
else
return false
endif
endfunction
[/jass]
这个已经验证成立了 |
|