Re: Measure of the angles of a segmented line

Posted by ERIC on
URL: http://imagej.273.s1.nabble.com/Measure-of-the-angles-of-a-segmented-line-tp5001041p5001048.html

Thanks Wayne,
That's what I needed !!!

Eric Denarier
Grenoble Institut des Neurosciences
Inserm U836
Chemin Fortuné Ferrini
38700 La Tronche
France


Tél :33 (0)4 56 52 05 38
Fax :33 (0)4 56 52 06 57

http://neurosciences.ujf-grenoble.fr/

Le 05/12/2012 19:11, Rasband, Wayne (NIH/NIMH) [E] a écrit :

> On Dec 5, 2012, at 8:23 AM, Eric Denarier wrote:
>
>> Hi all,
>> Is there a macro/plugin to measure all the angles formed by a segmented
>> line selection ?
> Here is a macro that does this:
>
>    getSelectionCoordinates(x, y);
>    for (i=1; i<x.length-1; i++) {
>      dotprod = (x[i+1]-x[i])*(x[i-1]-x[i])+(y[i+1]-y[i])*(y[i-1]-y[i]);
>      len1 = sqrt((x[i-1]-x[i])*(x[i-1]-x[i])+(y[i-1]-y[i])*(y[i-1]-y[i]));
>      len2 = sqrt((x[i+1]-x[i])*(x[i+1]-x[i])+(y[i+1]-y[i])*(y[i+1]-y[i]));
>      angle = (180/PI)*acos(dotprod/(len1*len2));
>      print(i, angle);
>    }
>
> I found the code for calculating an angle given 3 points using the dot product at
>
>     http://stackoverflow.com/questions/6719563/
>
> -wayne
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html