| Store | Cart

RE: Point in Polygon Routine

From: Joseph P. Discenza <jdis...@carletoninc.com>
Tue, 27 Jun 2000 13:41:14 -0400
Dunnigan,Jack [Edm] wrote, on Monday, June 26, 2000 20:04
: Does anyone know of a module which will tell me if an x,y value 
: lies within
: a polygon (i.e. @xyarray)?

A quick search of CPAN (http://www.cpan.org) turns up only
PDL::Graphics::TriD::Polygonize for modules with "polygon" in
the name, and I *know* that's not what you want.

_Mastering_Algorithms_with_Perl_ (Orwant et al., O'Reilly 1999,
ISBN 1-56592-398-7) has a few pages dealing with exactly this
problem, if you want some Perl code; otherwise, many texts on
computer graphics address this subject.

Basically, you can either test "how many edges a ray crosses"
(odd: in the polygon, even: not in), or triangulate the polygon
and test for inclusion in one of the triangles. Orwant directs
the reader to the FAQ for comp.graphics.algorithms (try deja.com),
compiled by Wm. Randolph Franklin; I'll do the same rather than
type in pages of code.

Joe

==============================================================
          Joseph P. Discenza, Sr. Programmer/Analyst
               mailto:jdis...@carletoninc.com
 
          Carleton Inc.   http://www.carletoninc.com
          219.243.6040 ext. 300    fax: 219.243.6060
 
Providing Financial Solutions and Compliance for over 30 Years

Recent Messages in this Thread
Dunnigan,Jack [Edm] Jun 27, 2000 12:04 am
Joseph P. Discenza Jun 27, 2000 05:41 pm
Bill Odom Jun 27, 2000 06:44 pm
Messages in this thread