Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re: Points, Lines. Polygons OO myby Zaxo (Archbishop) |
on Aug 31, 2001 at 13:08 UTC ( [id://109333]=note: print w/replies, xml ) | Need Help?? |
The Wolf Book, pp441-445 has an implementation which is C-like and unreliable for corner cases. The algorithm is the same one you cite: does a ray from the test point cross edges an even or odd number of times? If odd, it's an interior point. My take on the OO issues you raise derives from the hierarchy of 0- to 1- to 2-dimensional geometry. Interior and exterior are properties of of each particular polygon, so I suppose that $poly->is_interior($point) is natural. A Line has-a pair of Points to define it, so Point methods are available to it. A Polygon has-a list of Points as vertices, or equivalently a list of Lines with common endpoints. Point and Line methods are available to Polygon. After Compline,
In Section
Seekers of Perl Wisdom
|
|