Re: Point Inside Polygon - Ray Method
- From: klewis@xxxxxxxxxxxxxxxx (Keith A. Lewis)
- Date: Wed, 19 Apr 2006 16:05:55 +0000 (UTC)
"Narek Saribekyan" <narek.saribekyan@xxxxxxxxx> writes in article <1145458218.876150.94550@xxxxxxxxxxxxxxxxxxxxxxxxxxxx> dated 19 Apr 2006 07:50:18 -0700:
There are some special cases.
1. Ray r intersects a segment in one of it's vertices.
2. Ray r is collinear to one of p's segments.
3. Point q is lying on one of p's segments.
I need a good method to avoid this special cases and/or other method to
solve this problem.
There is an alternative method called "winding". It counts the number of
times the polygon goes around the point.
Define the quadrants in the usual manner, except use q for the origin.
Traverse the polygon. When you "increment" the quadrant number (mod 4, so
IV-->I is an increment), add 1/4 to the winding count. When the quadrant
number (mod 4) decreases, subtract 1/4. If the difference is 2 quadrants,
you need to figure out which side of the point the line went.
If the final winding count is 0, the point is outside. If it's 1, the
polygon went counterclockwise around the point.
--Keith Lewis klewis {at} mitre.org
The above may not (yet) represent the opinions of my employer.
.
- Follow-Ups:
- Re: Point Inside Polygon - Ray Method
- From: Larry Hammick
- Re: Point Inside Polygon - Ray Method
- References:
- Point Inside Polygon - Ray Method
- From: Narek Saribekyan
- Point Inside Polygon - Ray Method
- Prev by Date: Re: need in tex
- Next by Date: Re: FFT - sign shift
- Previous by thread: Point Inside Polygon - Ray Method
- Next by thread: Re: Point Inside Polygon - Ray Method
- Index(es):
Relevant Pages
|