problem measuring angles.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

problem measuring angles.

AdamC
I'm trying to do a very simple measurement of an angle between two  
line segments.
If use the angle tool, draw a two part line and hit measure it gives  
me the angle fine.
If I use the macro recorder to record this I get these lines.

setTool(14);
makeLine(201,111,122,180,245,206);
run("Measure");

If I run this, then it returns: Angle= 0, Length = 231.
I'm I missing something?

(I'm doing this with 1.41k)

Thanks

Adam


Dr Adam Cliffe
Research Fellow
Rørth Lab
Cell Migration Group
Temasek Lifescience Laboratory
1 Research Link
National University of Singapore
Singapore 117604

tel: (65) 6872 8406
fax: (65) 6872 7007
Reply | Threaded
Open this post in threaded view
|

Re: problem measuring angles.

Kota Miura
Hi Adam,

If you specify the Selection tool, it will work

example 1----
xcoord = newArray(201,122,245);
ycoord = newArray(111,180,206);
makeSelection("angle", xcoord, ycoord);
run("Measure");
---------------

otherwise, you could also get the angle by using scalar product of vectors.

example 2----

setTool(14);
makeLine(201,111,122,180,245,206);

//run("Measure");

getSelectionCoordinates(xCoord, yCoord);

x1=xCoord[0]; y1=yCoord[0];
x2=xCoord[1]; y2=yCoord[1];
x3=xCoord[2]; y3=yCoord[2];

vx1 = (x1-x2); vy1 = (y1-y2);
vx2 = (x3-x2); vy2 = (y3-y2);

scalarProduct=(vx1*vx2 + vy1*vy2);
lengthProduct =sqrt((pow(vx1, 2)+pow(vy1, 2))) * sqrt((pow(vx2,
2)+pow(vy2, 2)));
costheta = scalarProduct/lengthProduct ;

thetadegrees = acos(costheta)*180/PI;
print(thetadegrees);
-----------

Cheers,
Kota

Adam Cliffe wrote:

> I'm trying to do a very simple measurement of an angle between two
> line segments.
> If use the angle tool, draw a two part line and hit measure it gives
> me the angle fine.
> If I use the macro recorder to record this I get these lines.
>
> setTool(14);
> makeLine(201,111,122,180,245,206);
> run("Measure");
>
> If I run this, then it returns: Angle= 0, Length = 231.
> I'm I missing something?
>
> (I'm doing this with 1.41k)
>
> Thanks
>
> Adam
>
>
> Dr Adam Cliffe
> Research Fellow
> Rørth Lab
> Cell Migration Group
> Temasek Lifescience Laboratory
> 1 Research Link
> National University of Singapore
> Singapore 117604
>
> tel: (65) 6872 8406
> fax: (65) 6872 7007
>
>

--
-------------------------------------------------------------
Dr. Kota Miura

Scientist & IT Engineer
Centre for Molecular and Cellular Imaging,
European Molecular Biology Laboratory
Meyerhofstr. 1
69117 Heidelberg
GERMANY

Tel +49 6221 387 404
Fax +49 6221 387 512
http://www.embl.org/cmci/
-------------------------------------------------------------