IsLocInQuad
not ratedDetermines if a given location is in a quad given by the locations of its vertices.
function IsLocInQuadChild takes location p, location l1, location l2 returns integer
if GetLocationY(p) > RMinBJ(GetLocationY(l1),GetLocationY(l2)) then
if GetLocationY(p) <= RMaxBJ(GetLocationY(l1),GetLocationY(l2)) then
if GetLocationX(p) <= RMaxBJ(GetLocationX(l1),GetLocationX(l2)) then
if (GetLocationY(l1) != GetLocationY(l2)) then
if (GetLocationX(l1) == GetLocationX(l2)) or (GetLocationX(p) <= (GetLocationY(p)-GetLocationY(l1))*(GetLocationX(l2)-GetLocationX(l1))/(GetLocationY(l2)-GetLocationY(l1))+GetLocationX(l1)) then
return 1
endif
endif
endif
endif
endif
return 0
endfunction
function IsLocInQuad takes location p, location l1, location l2, location l3, location l4 returns boolean
local integer counter = 0
set counter = counter + IsLocInQuadChild(p, l1, l2)
set counter = counter + IsLocInQuadChild(p, l2, l3)
set counter = counter + IsLocInQuadChild(p, l3, l4)
set counter = counter + IsLocInQuadChild(p, l4, l1)
return (counter / 2) * 2 != counter
endfunctionNo comments.