// This tool draws a line and displays the angle // between that line and the vertical axis. macro "Line Angle Tool -C00bL1de0L1ee1" { lineWidth = 1; getCursorLoc(x, y, z, flags); xstart = x; ystart = y; x2=x; y2=y; while (true) { getCursorLoc(x, y, z, flags); if (flags&16==0) { setLineWidth(lineWidth); drawLine(xstart, ystart, x, y); run("Select None"); angle = (getAngle(xstart, ystart, x, y)+90)%360; if (angle>180 && angle<360) angle = -(360 - angle); print(angle); exit; } if (x!=x2 || y!=y2) makeLine(xstart, ystart, x, y); x2=x; y2=y; wait(10); } } // Returns the angle in degrees between the specified line and the horizontal axis. function getAngle(x1, y1, x2, y2) { q1=0; q2orq3=2; q4=3; //quadrant dx = x2-x1; dy = y1-y2; if (dx!=0) angle = atan(dy/dx); else { if (dy>=0) angle = PI/2; else angle = -PI/2; } angle = (180/PI)*angle; if (dx>=0 && dy>=0) quadrant = q1; else if (dx<0) quadrant = q2orq3; else quadrant = q4; if (quadrant==q2orq3) angle = angle+180.0; else if (quadrant==q4) angle = angle+360.0; return angle; }