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

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

by explorer (Chaplain)
on Aug 28, 2006 at 16:35 UTC ( #570006=note: print w/replies, xml ) Need Help??


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

Unroll the condition and duplicate the process (or subroutine):

if ( $y[i] <= $y ) { if ( $y < $y[$j] ) { # process ... } } elsif ( $y >= $y[$j] ) { # the same process .. }
Or a simple calculation:
if ( ( $y[$i] - $y ) * ( $y - $y[$j] ) > 0 ) { # process
Remember: Memoize is your friend.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://570006]
help
Chatterbox?
[talexb]: Great quote from Re: (OT) Motivating the Unmotivated Programmer: "As Weinberg suggests, when a programmer becomes irreplaceable, it's time to replace him."
[jedikaiti]: SuicideJunkie++ #Apgrade is the highest point it will reach. They're informing you that it will all be downhill from here until the software hits a PEgrade, or impacts the terrain depending on the details of the orbit.

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2017-07-25 18:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (377 votes). Check out past polls.