http://qs1969.pair.com?node_id=109333


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