comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Point inside/outside a polygon?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Point inside/outside a polygon? [message #26239 is a reply to message #26180] Mon, 13 August 2001 09:07 Go to previous messageGo to previous message
James Kuyper is currently offline  James Kuyper
Messages: 425
Registered: March 2000
Senior Member
Med Bennett wrote:
>
> Here is what I ended up with when I had to solve this problem a few years
> back:
>
> 1) define a point that is outside of the polygon - easy enough.
>
> 2) define a line from the point in question to your outside point, say
> A-A'.
>
> 3) Count the number of times that this line crosses any of the line
> segments making up the polygon. If it's an even number, your point is
> outside the polygon. If it's odd, your point is inside the polygon.
>
> It's easy to see why this works geometrically with a simple drawing, and
> it's pretty straightforward to code. David's method appears to be more
> computationally efficient, as it avoids loops, but I don't fully understand
> why it works. I'd be happy to send you my actual code if you'd like. The

For a point on the inside of a polygon, travelling around the polygon
involves a net angular motion of 360 degrees around that point. For a
point outside the polygon, the net angular change must be 0 degrees.
It's easier to see that this is so, if you first consider a simple
convex polygon, but it remains true even if it's not convex.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Discussion on global variables in IDL
Next Topic: visualizing data in 3-D

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 15 16:31:19 PDT 2025

Total time taken to generate the page: 0.74577 seconds