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

Home » Public Forums » archive » Point/Polygon Routine
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/Polygon Routine [message #5573 is a reply to message #5401] Tue, 09 January 1996 00:00 Go to previous messageGo to previous message
tildes is currently offline  tildes
Messages: 2
Registered: June 1993
Junior Member
In article 760@ncar.ucar.edu, cavanaug@uars1.acd.ucar.edu (Charles Cavanaugh) writes:
>
> Does anyone have a routine that determines if a given 2-D point is inside a
> given 2-D polygon?
>
> Thanks in advance.
>
>
> Charles Cavanaugh
> --
> Charles Cavanaugh | "Words are very unnecessary, they can only do harm"
> cavanaug@ncar.ucar.edu | - Depeche Mode
> NCAR Boulder, CO, USA | "Facts all come with points of view"
> My opinions | - Talking Heads


I dont have any IDL code for doing this but I can outline a method that is
pretty straightforward.

Consider a line from the point in question to plus (or minus) infinity.
Count the intersections between this line and each of the edges of the polygon.
If the total count is zero or even then the point is outside the polygon.
If the total count is odd then the point is inside the polygon.

The only traps to watch out for are:
- where the point is on one of the edges or vertices.
- if the line to infinity goes through one of the vertices (you should only
count one end of each edge as being a part of that edge).

Good luck.
____________________________________________________________ __
Paul Tildesley
Remote Sensing Facility, CSIRO Division of Oceanography

voice : (002) 325-251 (international) +61 02 325251
fax : (002) 325-123 (international) +61 02 325123
email : Paul.Tildesley@ml.csiro.au
post : GPO Box 1538, Hobart, Tasmania 7001, AUSTRALIA
____________________________________________________________ __
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: map_continents, /fill (Ugh!!!)
Next Topic: Problems with draw_xsize keyword in widget_control

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

Current Time: Fri Oct 10 09:53:36 PDT 2025

Total time taken to generate the page: 0.79583 seconds