Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Points, Lines. Polygons OO my

by Zaxo (Archbishop)
on Aug 31, 2001 at 13:08 UTC ( [id://109333]=note: print w/replies, xml ) Need Help??


in reply to Points, Lines. Polygons OO my

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,
Zaxo

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://109333]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-25 19:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found