Folk, I wrote a PDL vectorized version of the 'points in a polygon' program a few years ago for my own use. [BTW Matt the problem was selecting points in a area of a color-color diagram]
Here is the code. i/o are all vectors. Read it and weep :-) Karl # Test points tx,ty to be in a polygon following # http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html # Nice fast VECTOR code! sub pnpoly{ my($tx, $ty, $vertx, $verty) = @_; my $testx = $tx->dummy(0); my $testy = $ty->dummy(0); my $vertxj = $vertx->rotate(1); my $vertyj = $verty->rotate(1); $c = sumover( (($verty>$testy) != ($vertyj>$testy)) & ($testx < ($vertxj-$vertx) * ($testy-$verty) / ($vertyj-$verty) + $vertx) ) %2; return $c; } _______________________________________________ Perldl mailing list [email protected] http://mailman.jach.hawaii.edu/mailman/listinfo/perldl
