http://www.mathworks.com/support/solutions/en/data/1-1BYSR/index.html?product=ML&solution=1-1BYSR
However, can someone point me of a way of how to determine if such minimum
distance fall within the line segment or it is determine it with respect to its projection.
for example for the line
line=[-15 -30
-50 75
-70 95]
point=[0 0]
for the first segment of the line the shortest distance (perpendicular distance)
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.
Thanks in advance
> line=[-15 -30
> -50 75
> -70 95]
Is this a [3 x 2] matrix? How is the "line" defined by these values? 2 points or one point a orientation vector?
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.
I do not want to solve a homework, but of course you can get comments for all what you have done so far.
Kind regards, Jan
Roger Stafford
In the notation of the link above, if
v1 = (v11,v12), v2 = (v21,v22), pt = (pt1,pt2)
then the point with the smallest distance to pt on
the line through v1 and v2 lies on the line segment
(v1v2) if the quantity
lambda = ((v11-v21)*(v11-pt1)+(v12-v22)*(v12-pt2))/
((v11-v21)^2 + (v12-v22)^2)
is between 0 and 1.
Best wishes
Torsten.
dot(C-A,B-A) >= 0 and dot(C-B,A-B) >= 0
Roger Stafford