Start New Discussion within our **Software Development Community** # 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;
```