Re: ReferenceError: "cos" is not defined. (line#6)

Posted by Gluender-2 on
URL: http://imagej.273.s1.nabble.com/ReferenceError-cos-is-not-defined-line-6-tp3693275p3693277.html

Not sure what happen in your macro...

>G'day list,
>
>Can anyone help? I get the error message as shown in the subject
>line trying to run this macro:
>
>var pi=3.14159265359;
>for (i=0; i<18; i++){
> angle1=pi+(i/18)*pi;
> angle2=(i/18)*pi;
> x1=384+384*cos(angle1);
> x2=384+384*cos(angle2);
> y1=384+384*sin(angle1);
> y2=384+384*sin(angle2);
> makeLine(x1, y1, x2, y2);
> run("Reslice [/]...", "input=32.000 output=32.000 slice=1");
> selectWindow("Stack");
>}
>
>but I see example after example where cos(angle) and sin(angle)
>functions are used. What am I doing wrong?
>
>Cheers,
>Robert


But the following macro runs fine here:

i = 1;
angle1 = PI * ( 1 + i/18);
print ( 10 * ( 1 + cos(angle1) ) );

Please note that PI is already implemented as a constant in ImageJ.

HTH

Herbie