|
|
how to determine if the shortest distance from one point to a line is inside the line segment or outside
Hello everyone,
We know how to determine the shortest distance from a point to a line.
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
|
|
0
|
|
|
|
Reply
|
Edwin
|
7/8/2010 3:05:05 PM |
|
Dear Edwin,
> 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
|
|
0
|
|
|
|
Reply
|
Jan
|
7/8/2010 3:43:05 PM
|
|
"Edwin " <onest30@gmail.com> wrote in message <i14pf1$41k$1@fred.mathworks.com>...
> Hello everyone,
> We know how to determine the shortest distance from a point to a line.
>
> 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
- - - - - - - - -
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. :-)
Roger Stafford
|
|
0
|
|
|
|
Reply
|
Roger
|
7/8/2010 10:04:04 PM
|
|
> Hello everyone,
> We know how to determine the shortest distance from a
> point to a line.
>
> http://www.mathworks.com/support/solutions/en/data/1-1
> BYSR/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
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.
|
|
0
|
|
|
|
Reply
|
Torsten
|
7/9/2010 6:13:39 AM
|
|
Torsten Hennig <Torsten.Hennig@umsicht.fhg.de> wrote in message <1987639511.93716.1278674049147.JavaMail.root@gallium.mathforum.org>...
> 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.
- - - - - - - -
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:
dot(C-A,B-A) >= 0 and dot(C-B,A-B) >= 0
Roger Stafford
|
|
0
|
|
|
|
Reply
|
Roger
|
7/9/2010 5:25:07 PM
|
|
|
4 Replies
344 Views
(page loaded in 0.041 seconds)
|
|
|
|
|
|
|
|
|