Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Points, Lines. Polygons OO my

by blakem (Monsignor)
on Aug 31, 2001 at 12:53 UTC ( #109329=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://109329]
help
Chatterbox?
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: (3)
As of 2022-01-25 06:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (65 votes). Check out past polls.

    Notices?