Login  Register

Re: measuring distance along a line at a set angle

Posted by jmutterer on Feb 05, 2009; 11:31pm
URL: http://imagej.273.s1.nabble.com/measuring-distance-along-a-line-at-a-set-angle-tp3693828p3693829.html

Dear Connor,
The following tool macro allows you to draw lines with constant angle. To
change this angle, open the tool's options dialog by double clicking on the
tool icon, or adjust the angle manually by pressing the 'alt' key while
dragging the mouse. Also while dragging, the 'shift' key will measure the
current line.

Jerome

// Fixed Angle Line Tool Macro
var a=0;
var pi=3.1415926535;
var leftClick=16;
macro 'Fixed Angle Line Tool - C000L05f0L0af5' {
getCursorLoc(x1, y1, z, flags);
while (true) {
  getCursorLoc(x2, y2, z, flags);
  if (flags&leftClick==0) exit();
  if (x2!=x1 || y2!=y1) {
    dx=(x2-x1); dy=(y2-y1);
    if (isKeyDown('alt')) {
      makeLine(x1,y1,x2,y2);
      a=atan2(dy,dx);
    } else if (isKeyDown('shift')) {
     run ('Measure');
    } else {
    d=sqrt(dx*dx+dy*dy);
      makeLine(x1,y1,x1+d*cos(a),y1+d*sin(a));
    }
  }
  wait(10);
}
}

macro 'Fixed Angle Line Tool Options' {
da=180*a/pi;
da=getNumber("fixed angle",da);
a= pi*da/180;
}

// end

On Thu, Feb 5, 2009 at 12:37 AM, connor <[hidden email]> wrote:

> hello
>
> i need to measure a series of distances from a set point at various angles.
> is there a way using imagej to specify a point from which a line tool
> measurement should begin, and then set the angle at which the line should
> extend but still be able to manually manipulate the distance (something
> like
> how holding shift fixes the line at either 90 or 0 degrees but still allows
> you to change its length)? i'm new to imagej so this might be a fairly
> obvious question, but i haven't been able to find any documentation about
> it, nor any previous threads on the topic.
>
> thanks for your help!
>
> connor
> --
> View this message in context:
> http://n2.nabble.com/measuring-distance-along-a-line-at-a-set-angle-tp2272390p2272390.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>