Re: Point Inside Polygon - Ray Method



Larry Hammick wrote:

Keith A. Lewis wrote:

There is an alternative method called "winding". It counts the number of
times the polygon goes around the point.
....
If the final winding count is 0, the point is outside. If it's 1, the
polygon went counterclockwise around the point.

Note, winding numbers may exceed 1 if the polygon isn't simple.

Three rays are enough; any three distinct ones will do.
Related, but fancier, is this suped-up version of Sperner's lemma:
http://planetmath.org/encyclopedia/SpernersLemma.html

Perhaps strict convexity would be a sufficient condition for three
rays to be enough; it seems to me it ought to be, but the link below
says point inclusion can be tested in O(log n) time for convex polygons.

http://softsurfer.com/Archive/algorithm_0103/algorithm_0103.htm
compares crossing-number and winding-number point-is-in-polygon
algorithms, and says that at the moment winding number calculations
can be done slightly faster (although of same asymptotic efficiency).

-jiw
.



Relevant Pages

  • Re: Companion question to polygon winding rule
    ... Bint wrote: ... > do with the outline of a complex polygon. ... > If I fill a polygon that intersects itself so that the holes are ... record the winding count on each side of it); ...
    (comp.graphics.algorithms)
  • Re: Point Inside Polygon - Ray Method
    ... polygon went counterclockwise around the point. ... winding numbers may exceed 1 if the polygon isn't simple. ... If the boundary of a plane region is a simple closed curve, then one ray ...
    (sci.math)
  • Re: Point Inside Polygon - Ray Method
    ... There is an alternative method called "winding". ... Define the quadrants in the usual manner, except use q for the origin. ... Traverse the polygon. ... If the final winding count is 0, ...
    (sci.math)
  • Re: Clipping does not work properly with ATI specific card.
    ... behavior (backface, winding etc). ... If polygon mode is GL_LINE, ... Clipping is performed before the polygon mode takes place, ...
    (comp.graphics.api.opengl)

Quantcast