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


in reply to Points, Lines. Polygons OO my

I don't quite get it.. If this isn't a code solicitation, are you looking for a discussion of how the objects might behave, or at clever ways of attacking the problem...

My first thought would be to:

Given Point A(x,y) and Polygon P with vertices V1..Vn
1.) Create Point B(x,y) such that Bx is greater than all x values of the vertices, and By is greater than all y values of the vertices
2.) Check each edge of P (including endpoints, but excluding those with both endpoints on AB) to see if it intersects segment AB, if so $count++. (fairly trivial, left to excercise for the reader.)
3.) for (V1..Vn) {$count-- if V is on AB} as they were double counted in step 2
4.) $inside = $count%2;

I think I could probably golf that in 150 chars or less... ;-)

Or, maybe you were looking for a discussion on your objects...

-Blake