Based on http://astronomy.swin.edu.au/~pbourke/geometry/insidepoly/
Converted to Delphi by Lord Soth
Is point inside polygon ?
//Based on http://astronomy.swin.edu.au/~pbourke/geometry/insidepoly/
type point = record
x,y : double;
end;
type polygon = array of point;
var firstx : double = -1;
firsty : double = -1;
poly : polygon;
function PointInPoly(p : point;poly : polygon) : Boolean;
var i,j : integer;
Begin
result := false;
j := High(poly);
For i := Low(poly) to High(poly) do begin
if (
( ((poly[i].y <= p.y) and (p.y < poly[j].y)) or ((poly[j].y <= p.y) and (p.y < poly[i].y)) ) and
(p.x < ((poly[j].x - poly[i].x) * (p.y - poly[i].y) / (poly[j].y - poly[i].y) + poly[i].x))
) then result := not result;
j := i
end;
End;
Zajoma 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.