in reply to Processing data with lot of math...
@dist = map sqrt($x[$_]**2+$y[$_]**2+$z[$_]**2), 0..$#x; or, for some $x0, $y0, $z0, @dist = map sqrt(($x[$_]-$x0)**2+($y[$_]-$y0)**2+($z[$_]-$z0)**2), 0..$#x;
@indices = sort {$dist[$a]<=>$dist[$b]} 0..$#dist; @dist = @dist[@indices]; @x = @x[@indices]; @y = @y[@indices]; @z = @z[@indices]; @name = @name[@incides];
for my $one (0..$#@dist-1) { my $two = $one; while (++$two < @dist && $dist[$two]-$dist[$one] <= $cutoff) { print "found pair: ($x[$one],$y[$one],$z[$one]) and ($x[$two],$y[$two],$z[$two])\n" if sqrt(($x[$one]-$x[$two])**2+($y[$one]-$y[$two])**2+($z[ +$one]-$z[$two])**2) <= $cutoff; } }
Update: added code fragments
Update: sort the names with the points :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Processing data with lot of math...
by QM (Parson) on May 12, 2004 at 23:00 UTC | |
by ysth (Canon) on May 12, 2004 at 23:14 UTC | |
by qhayaal (Beadle) on May 13, 2004 at 08:51 UTC | |
|
Re: Re: Processing data with lot of math...
by BrowserUk (Patriarch) on May 12, 2004 at 18:53 UTC | |
by ysth (Canon) on May 12, 2004 at 19:39 UTC | |
by BrowserUk (Patriarch) on May 12, 2004 at 20:32 UTC | |
by ysth (Canon) on May 12, 2004 at 23:00 UTC | |
by BrowserUk (Patriarch) on May 12, 2004 at 23:47 UTC |