Re: distance between adjacent particles
Posted by Gabriel Landini on May 11, 2007; 1:02pm
URL: http://imagej.273.s1.nabble.com/distance-between-adjacent-particles-tp3699485p3699492.html
On Thursday 10 May 2007 18:48:09 Jeffrey C Hanson wrote:
> It looks like you initialize the value of "dist1" inside the for
> loop where you're calculating all of the distances. You should just
> initialize it to a large value outside of the for loop. Try this,
> instead:
[...]
> dist=sqrt(((XM2-XM)*(XM2-XM))+((YM2-YM)*(YM2-YM)));
A handy trick. You can save some time by not doing the sqrt and comparing the
squares instead.
Then do the sqrt at the end only on the values you kept.
I hope it helps.
Cheers,
G.