-
Moroz4 (22.04.08 15:16) [0]как узнать находится ли точка в полигоне 2D?
-
PtInRegion + CreatePolygonRgn
-
MBo © (22.04.08 15:38) [2]
-
function PtInPolygon(const Points: TPoints; P: TPoint): Boolean;
var
Cnt, I, J: Integer;
begin
Result := False;
Cnt := Length(Points);
J := Cnt - 1;
for I := 0 to Cnt - 1 do
begin
if ((Points[I].y <= P.y) and (P.y < Points[J].y)) or
((Points[J].y <= P.y) and (P.y < Points[I].y)) then
begin
if (P.x < (Points[J].x - Points[I].x) * (P.y - Points[I].y) /
(Points[J].y - Points[I].y) + Points[I].x) then
Result := not Result;
end;
J := I;
end;
end;