Narek Saribekyan wrote:
> Here is the most known method to test if point is inside polygon.
>
> p  polygon
> n  number of vertices in polygon
> q  point
>
> RightHorizontalRayIntersection(q,u,v) tests if horizontal ray starting
> from point q (in right direction) intersects a segment (u,v).
>
> bool IsPointInsidePolygon( P *p,int n,P q ) {
>     int i,j,c=0;
>       for (i=0,j=n-1; i<n; j=i++) // Considering all segments (p[i],p[j])
>               if (RightHorizontalRayIntersection( q,p[i],p[j] )) c++;
>     return c%2;
> }
>
> 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.
>
See

http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to