http://www.mathworks.com/matlabcentral/newsreader/view_thread/286449
MATLAB Central Newsreader  how to determine if the shortest distance from one point to a line is inside the line segment or outside
Feed for thread: how to determine if the shortest distance from one point to a line is inside the line segment or outside
enus
©19942014 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Thu, 08 Jul 2010 15:05:05 +0000
how to determine if the shortest distance from one point to a line is inside the line segment or outside
http://www.mathworks.com/matlabcentral/newsreader/view_thread/286449#760924
Edwin
Hello everyone,<br>
We know how to determine the shortest distance from a point to a line.<br>
<br>
<a href="http://www.mathworks.com/support/solutions/en/data/11BYSR/index.html?product=ML&solution=11BYSR">http://www.mathworks.com/support/solutions/en/data/11BYSR/index.html?product=ML&solution=11BYSR</a><br>
<br>
However, can someone point me of a way of how to determine if such minimum<br>
distance fall within the line segment or it is determine it with respect to its projection.<br>
<br>
for example for the line<br>
line=[15 30<br>
50 75<br>
70 95]<br>
<br>
point=[0 0]<br>
<br>
for the first segment of the line the shortest distance (perpendicular distance)<br>
falls within the line segment but for the second segment the shortest distance is determine it with respect the line projection. So How could I know when each case is happening.<br>
<br>
<br>
Thanks in advance

Thu, 08 Jul 2010 15:43:05 +0000
Re: how to determine if the shortest distance from one point to a line is inside the line segment or outside
http://www.mathworks.com/matlabcentral/newsreader/view_thread/286449#760951
Jan Simon
Dear Edwin,<br>
<br>
> line=[15 30<br>
> 50 75<br>
> 70 95]<br>
<br>
Is this a [3 x 2] matrix? How is the "line" defined by these values? 2 points or one point a orientation vector?<br>
<br>
However, find the point, where the shortest distance between the point and the line touchs the line. Then determine, in this point is between the two points defining the line.<br>
<br>
I do not want to solve a homework, but of course you can get comments for all what you have done so far.<br>
<br>
Kind regards, Jan

Thu, 08 Jul 2010 22:04:04 +0000
Re: how to determine if the shortest distance from one point to a line is inside the line segment or outside
http://www.mathworks.com/matlabcentral/newsreader/view_thread/286449#761088
Roger Stafford
"Edwin " <onest30@gmail.com> wrote in message <i14pf1$41k$1@fred.mathworks.com>...<br>
> Hello everyone,<br>
> We know how to determine the shortest distance from a point to a line.<br>
> <br>
> <a href="http://www.mathworks.com/support/solutions/en/data/11BYSR/index.html?product=ML&solution=11BYSR">http://www.mathworks.com/support/solutions/en/data/11BYSR/index.html?product=ML&solution=11BYSR</a><br>
> <br>
> However, can someone point me of a way of how to determine if such minimum<br>
> distance fall within the line segment or it is determine it with respect to its projection.<br>
> <br>
> for example for the line<br>
> line=[15 30<br>
> 50 75<br>
> 70 95]<br>
> <br>
> point=[0 0]<br>
> <br>
> for the first segment of the line the shortest distance (perpendicular distance)<br>
> falls within the line segment but for the second segment the shortest distance is determine it with respect the line projection. So How could I know when each case is happening.<br>
> <br>
> Thanks in advance<br>
        <br>
Suppose A and B are the two endpoints of your line segment and C is the point you are asking about. Now consider the triangle ABC. If the perpendicular projection of C onto line AB lies within segment AB, what can you say about the two angles CAB and CBA? You don't even have to find the point of projection of C onto AB in order to answer that easy question. I DOT if you will have any trouble with this. :)<br>
<br>
Roger Stafford

Fri, 09 Jul 2010 11:13:39 +0000
Re: how to determine if the shortest distance from one point to a
http://www.mathworks.com/matlabcentral/newsreader/view_thread/286449#761184
Torsten Hennig
> Hello everyone,<br>
> We know how to determine the shortest distance from a<br>
> point to a line.<br>
> <br>
> <a href="http://www.mathworks.com/support/solutions/en/data/11">http://www.mathworks.com/support/solutions/en/data/11</a><br>
> BYSR/index.html?product=ML&solution=11BYSR<br>
> <br>
> However, can someone point me of a way of how to<br>
> determine if such minimum<br>
> distance fall within the line segment or it is<br>
> determine it with respect to its projection.<br>
> <br>
> for example for the line<br>
> line=[15 30<br>
> 50 75<br>
> 70 95]<br>
> <br>
> point=[0 0]<br>
> <br>
> for the first segment of the line the shortest<br>
> distance (perpendicular distance)<br>
> falls within the line segment but for the second<br>
> segment the shortest distance is determine it with<br>
> respect the line projection. So How could I know when<br>
> each case is happening.<br>
> <br>
> <br>
> Thanks in advance<br>
<br>
In the notation of the link above, if<br>
v1 = (v11,v12), v2 = (v21,v22), pt = (pt1,pt2)<br>
then the point with the smallest distance to pt on<br>
the line through v1 and v2 lies on the line segment<br>
(v1v2) if the quantity<br>
lambda = ((v11v21)*(v11pt1)+(v12v22)*(v12pt2))/<br>
((v11v21)^2 + (v12v22)^2)<br>
is between 0 and 1.<br>
<br>
Best wishes<br>
Torsten.

Fri, 09 Jul 2010 17:25:07 +0000
Re: how to determine if the shortest distance from one point to a
http://www.mathworks.com/matlabcentral/newsreader/view_thread/286449#761295
Roger Stafford
Torsten Hennig <Torsten.Hennig@umsicht.fhg.de> wrote in message <1987639511.93716.1278674049147.JavaMail.root@gallium.mathforum.org>...<br>
> In the notation of the link above, if<br>
> v1 = (v11,v12), v2 = (v21,v22), pt = (pt1,pt2)<br>
> then the point with the smallest distance to pt on<br>
> the line through v1 and v2 lies on the line segment<br>
> (v1v2) if the quantity<br>
> lambda = ((v11v21)*(v11pt1)+(v12v22)*(v12pt2))/<br>
> ((v11v21)^2 + (v12v22)^2)<br>
> is between 0 and 1.<br>
> <br>
> Best wishes<br>
> Torsten.<br>
       <br>
Or equivalently, if the two angles CAB and CBA I referred to earlier are each no greater than pi/2, which can be tested by:<br>
<br>
dot(CA,BA) >= 0 and dot(CB,AB) >= 0<br>
<br>
Roger Stafford