Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: Points, Lines. Polygons OO my

by Zaxo (Archbishop)
on Aug 31, 2001 at 13:08 UTC ( #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,

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2023-02-05 11:51 GMT
Find Nodes?
    Voting Booth?
    I prefer not to run the latest version of Perl because:

    Results (31 votes). Check out past polls.