Board index » delphi » URGENT: determine if point is within polygon
Oene Doevendans
Delphi Developer 
Sun, 13 Apr 2003 03:00:00 GMT

Oene Doevendans
Delphi Developer 
Sun, 13 Apr 2003 03:00:00 GMT
URGENT: determine if point is within polygon
Hi,
I have written an algorithm long ago that was able to determine whether TIA Doef. 
Kevan
Delphi Developer 
Sun, 13 Apr 2003 03:00:00 GMT
Re:URGENT: determine if point is within polygoncheck the WIN32 help file on regions. You need to create the ploygon region, then you can test for PtInRegion example : function PtInPolygon( const pt : TPoint; points ; array of TPoints); kevanB 
Sympatic
Delphi Developer 
Sun, 13 Apr 2003 03:00:00 GMT
Re:URGENT: determine if point is within polygonQuote"Oene Doevendans" <Doevend...@fel.tno.nl> wrote in message  Hi,   I have written an algorithm long ago that was able to determine whether  a  point was within a polygon or not (something like: if the number of  times a line, starting from the point, going outwards, crosses the  polylines is odd then the point is within the polygon).  However, I can't find it anywhere and I really need this in a short  timeframe!!   Can anyone help me with sourcecode solving this problem (preferably  short...)   The definitive reference is "Point in Polygon Strategies" by The essence of the raycrossing method is as follows. int pnpoly(int npol, float *xp, float *yp, float x, float y) c = !c; Quote} avoiding the central computation when the inequality can be deduced, and by replacing the division by a multiplication for those processors with slow divides. For code that distinguishes strictly interior points from those on the boundary, see [O'Rourke (C)] pp. 239245. References: 
Neil J. Rubenki
Delphi Developer 
Sun, 13 Apr 2003 03:00:00 GMT
Re:URGENT: determine if point is within polygonIn article <39F6A8C6.7097F...@fel.tno.nl>, Doevend...@fel.tno.nl says... Quote> point was within a polygon or not polygon's shape, and then call PtInRegion() to determine whether the point is within it. What the heck  make Windows do the work!  Neil J. Rubenking Contributing Technical Editor PC Magazine 
Oene Doevendan
Delphi Developer 
Sun, 13 Apr 2003 03:00:00 GMT
Re:URGENT: determine if point is within polygonQuote"Neil J. Rubenking" wrote: Thanks all for replying so soon (and no Earl, it's not a home 
Geir Wikra
Delphi Developer 
Sun, 13 Apr 2003 03:00:00 GMT
Re:URGENT: determine if point is within polygonTPolygon = array[0..0] of TPoint; PPolygon = ^TPolygon; function PointInPolygon(P: TPoint; Polygon: PPolygon; Points: Integer); begin { Compute the delta X and delta Y for the partition line. } Count := 0; { Compute denominator and numerator to find the relation } if not (Denominator = 0.0) then begin if (Fraction >= 0.0) and (Fraction < 1.0) then begin { Recompute denominator, numerator, and fraction to find } if Fraction = 0.0 then Result := 0 { point P is on the edge } Inc(Index); if Result <> 0 then begin 
Joe C. Hech
Delphi Developer 
Sun, 13 Apr 2003 03:00:00 GMT
Re:URGENT: determine if point is within polygon"Neil J. Rubenking" <jrubenki@SPAMBG...@mother.com> wrote in message news:MPG.14607cf2aad345cc9896fb@newsgroups.borland.com... Quote> In article <39F6A8C6.7097F...@fel.tno.nl>, Doevend...@fel.tno.nl says... This solution is brought to you by Joe Hecht's TExcellent products, solving Form.Print and bitmap printing problems. Joe Hecht's TExcellent products can be found at: http://www.code4sale.com/joehecht  Good point. I will point out that Windows will rasterize the entire For the most part, I like to zip though the poly's lines, throwing Performace is another issue entirly. If you need to do many such Glad to see ya back in the newsgroups Neil... we have missed you :) Joe 
Kevan
Delphi Developer 
Mon, 14 Apr 2003 03:00:00 GMT
Re:URGENT: determine if point is within polygonQuote> Performace is another issue entirly. If you need to do many such mouse moves over a map image,using a ptInrect first to "home" in on a given polygon region.. I dont unfortunetly have the time this week to undertake such a test.. KevanB 
1. Determine if a point is in a polygon
2. Code out the to determine a point in\out of a polygon
3. Detecting whether a point lies within a polygon
5. Large Polygon 65k points limit in Win32?
6. is point inside the polygon
7. Finding the polygon that sorrounds a given point.
8. Point in Polygon WINDING without GDI
9. Point in polygon = place in country
10. Determinate if a point is in a polygon (Without the Windows API)