Page 1 of 1

Math&graphic

PostPosted: April 30th, 2006, 6:41 am
by hani
Hi,
How i can know if point is inside polygon or not




Thanks

PostPosted: April 30th, 2006, 10:23 am
by Kambiz
Code: Select all
function PtInPolygon(const Polygon: array of TPoint; const Pt: TPoint): Boolean;
var
  Rgn: HRGN;
begin
  Rgn := CreatePolygonRgn(Polygon, Length(Polygon), WINDING);
  try
    Result := PtInRegion(Rgn, Pt.X, Pt.Y);
  finally
    DeleteObject(Rgn);
  end;
end;

PostPosted: April 30th, 2006, 11:22 pm
by kokkoras
Is PtInRegion a win API call?

PostPosted: May 1st, 2006, 7:30 am
by HPW
Yes, from the delphi windows SDK help:

Code: Select all
BOOL PtInRegion(

    HRGN hrgn,   // handle of region
    int X,   // x-coordinate of point 
    int Y    // y-coordinate of point 
   );