in reply to Determing whether point falls inside or outside a complex polygon

Find any point that is beyond the right most point of the polygon. That's easy, just find a x that is greater than the greatest x of the polygon, with any reasonable y. Call this point ForSureOutside.

Then draw a line between the point under investigation and ForSureOutside. (Not physically draw, but find the equation of the line with those two points)

If this line intersects with any line SEGMENT that form the polygon, then the point under investigation is inside the polygon.

  • Comment on Re: Determing whether point falls inside or outside a complex polygon

Replies are listed 'Best First'.
Re^2: Determing whether point falls inside or outside a complex polygon
by bgreenlee (Friar) on Nov 08, 2004 at 17:17 UTC
    Not quite. If the line intersects with an *odd* number of polygon segments, then the point is inside the polygon (see the drawings on that link I posted above).

    -b

      You are right ;-) However with one addition, if the point of insect is also the intersect of two line segments of the polygon, you have to be careful.

Re^2: Determing whether point falls inside or outside a complex polygon
by ww (Archbishop) on Nov 08, 2004 at 19:53 UTC
    Don't think so.
    
    
                   X                   
                                         A
          B                       Y fso
    
                               C
             Z
    

    Ascii graphic above includes polygon XYZ, fso is the point "for sure outside" as described above and points A and C for which there is no interesection between FSO-A or FSO-C and any line in the polygon.

    However, for point B there is an intersection, very close to the vertex at Y (ie, it may be on XY or on YZ) and another on XZ.