Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Speeding up point-in-polygon -- take two

by hardburn (Abbot)
on Aug 28, 2006 at 15:04 UTC ( #569993=note: print w/replies, xml ) Need Help??

in reply to Speeding up point-in-polygon -- take two

Using a bounding box is a good start, but a bounding circle should be even better. A circle only needs to test one dimention:

if( $circle->distance_from_center( $x, $y ) <= $circle->radius ) { # Point ($x, $y) is in circle }

I've also found that dropping some of the calculations into C can speed it up quite a bit without being terribly complex to interface back to Perl.

"There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://569993]
[Corion]: Meh. My lack of embedded Pg is showing. I can get the data for an image gallery with one SQL statement, but not with SQLite as it doesn't do window functions :-(
[Corion]: Hmmm. Maybe I can still fake the one spot where I want/need a window function in SQLite... I think I'm never really interested in the real "next" image (not hidden/deleted)

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2018-03-23 17:51 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (295 votes). Check out past polls.