Posted by
Cammer, Michael on
May 26, 2015; 3:42am
URL: http://imagej.273.s1.nabble.com/shortest-distance-to-line-or-perpendicular-to-line-tp5012919p5012942.html
This was perfect. Thank you!!
_________________________________________
Michael Cammer, Optical Microscopy Specialist
http://ocs.med.nyu.edu/microscopyhttp://microscopynotes.com/Cell: (914) 309-3270
________________________________________
From: ImageJ Interest Group [
[hidden email]] on behalf of Jim Passmore [
[hidden email]]
Sent: Saturday, May 23, 2015 8:59 AM
To:
[hidden email]
Subject: Re: shortest distance to line &/or perpendicular to line
From this <
http://rsb.info.nih.gov/ij/macros/ToothRootToCrownRatio.txt> (
http://rsb.info.nih.gov/ij/macros/ToothRootToCrownRatio.txt) IJ macro,
function distance(x1, y1, x2, y2, px, py) {
dx=x2-x1; dy=y2-y1;
dd = sqrt(dx*dx+dy*dy);
tx=dx/dd; ty=dy/dd;
nx=-ty; ny=tx;
acx = px-x1; acy=py-y1;
return abs(acx*nx+acy*ny);
}
Quickly looking over the code, I believe the inputs are a line segment
with endpoints at x1,y1 and x2,y2, and a point at px,py.
On Fri, May 22, 2015 at 5:08 PM, Cammer, Michael <
[hidden email]
> wrote:
> Hi.
>
> We have a large object with a bunch of puncta inside it. We want to
> calculate the shortest distance from each dot to the major axis. Getting
> the major axis is simple and drawing it on the image is easy thanks to
> Wayne's macro.
>
> Question: Given this line and each x, y, location of a dot, there must be
> a simple formula to calculate the shortest distance to the line (a
> perpendicular).
>
> Any help greatly appreciated.
>
> Thank you!!
>
> =========================================================================
> Michael Cammer, Microscopy Core & Skirball Institute, NYU Langone Medical
> Center
> Cell: 914-309-3270 ** MY OFFICE HAS MOVED TO
> SKIRBALL 2nd FLOOR, Back right **
>
http://ocs.med.nyu.edu/microscopy &
http://microscopynotes.com/>
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html>
*-- Jim Passmore*
Research Associate
Sealed Air Corporation
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html