Minimum distance between a point and a bounded line in 3D

Click For Summary

Discussion Overview

The discussion revolves around calculating the minimum distance between a point in 3D space and a bounded line defined by its endpoints. Participants explore various methods to determine this distance, including the identification of the closest point on the line to the external point, while considering the constraints imposed by the line being bounded.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • One participant proposes calculating the perpendicular distance to the extended line first and then checking if this point lies within the bounds of the line segment.
  • Another participant suggests using vector notation to derive the equations needed to find the closest point on the line to the external point.
  • There is a discussion on the use of parametric equations to represent the line and the plane perpendicular to it, which contains the external point.
  • A participant introduces the concept of using the dot product to determine if two lines are perpendicular, leading to a method for finding the closest point on the line.
  • Confusion arises regarding the notation used for points, with one participant clarifying the correct labels for the points involved in the calculations.
  • Another participant provides a detailed derivation for the parameter t, which determines the position of the closest point on the line segment, and discusses the implications of t being outside the bounds of the segment.

Areas of Agreement / Disagreement

Participants express some agreement on the methods to calculate the minimum distance, but there is confusion regarding the notation and the specific points being referenced. The discussion includes multiple approaches and interpretations, indicating that no consensus has been reached on a single method.

Contextual Notes

There are limitations in the clarity of point notation, which may affect the understanding of the proposed methods. Additionally, the discussion does not resolve the mathematical steps involved in finding the closest point on the bounded line.

DHeshMan
Messages
5
Reaction score
0
I have a point in 3D specified by its coordinates (x0, y0, z0)

I have a line in 3D specified and bounded by its end points (x1, y1, z1) and (x2, y2, z2)

How do I calculate the minimum distance between the point and the line, keeping in mind that it may not be the perpendicular distance between the point and the extrapolated line because the line is bounded by its end points.

I would also like to know the point (x4, y4, z4) on the line that is closest to the external point.
 
Physics news on Phys.org
Calculate the distance to the extended line (perpendicular). Check if the minimum point is between the bounds. If it is, you're done. If not, check the distances to the end points. The smaller of the two is then the minimum.
 
Can you provide details on how to calculate the perpedicular distance to the extended line?
 
It is best done using vector notation.
Let Pk=(xk,yk,zk)
Let A=(P3-P1)x(P2-P1), (x = vector cross product) A is a vector perpendicular to the plane of the Pk's.
Let B=P3-P2, B is the direction of the line joining P2 and P3.
Let C=AxB, C is a vector (used in the plane of the Pk's) perpendicular to B.

The line from P1 to the line containing the P2 to P3 interval is P1+sC.
The line through P2 and P3 is P2+tB.
In the above s and t are scalars.
To find s and t you need to set P1+sC=P2+tB. (3 equation in 2 unknowns - use 2 to solve and the third one is a check.) The point of intersection of the 2 lines is given by the solution.
 
I'm a little confused. My original problem statement used P0, P1, P2, and P4 (I inadvertently skipped P3). P0 is the external point, P1 and P2 are the end points of the line, and P4 was the point on the line closest to P0.

Your solution uses P1, P2, and P3? If I follow your theory correctly, your P1 is my P0? your P2 is my P1? your P3 is my P2? and your P1 + sC = P2 + tB = my P4?
 
The line through P1= (x_1, y_1, z_1) and P2= (x_2, y_2, z_2) is given by parametric equations x= x_1+ t(x_2- x_1), y= y_1+ t(y_2- y_1), z= z_1+ t(z_2- z_1). The plane, perpendicular to that line and containing P0= (x_0, y_0, z_0), is given by (x_2- x_1)(x- x_0)+ (y_2- y_1)(y- y_0)+ (z_1- z_0)(z- z_0)= 0.

Replacing x, y, and z in the equation of the plane by the parametric equations for the line gives an equation for t where the line intersects the plane. That point is the point, P4, on the line closest to P0.
 
Thank you. For those that want a little more clarification, I have the following:

Using the dot product:

point Pn = <xn, yn, zn>
direction dPn = (dxn, dyn, dzn)

A = The line through P1 and P2 = <x1, y1, z1> + t(x2-x1, y2-y1, z2-z1)

B = The line through P0 and P4 = <x0, y0, z0> + s(x4-x0, y4-y0, z4-z0)

If A and B are perpedicular, the dot product dA . dB = 0
(x2-x1) (x4-x0) + (y2-y1) (y4-y0) + (z2-z1) (z4-z0) = 0

Knowing that P4 is a point somewhere on line A
x4 = x1 + t(x2-x1); y4 = y1 + t(y2-y1); z4 = z1 + t(z2-z1)

(x2-x1) (x1 + t(x2-x1) -x0) + (y2-y1) (y1 + t(y2-y1) -y0) + (z2-z1) (z1 + t(z2-z1) -z0) = 0

Solving for t we get

t = ( (x2-x1) (x0-x1) + (y2-y1) (y0-y1) + (z2-z1) (z0-z1) ) / ( (x2-x1)^2 + (y2-y1)^2 + (z2-z1)^2 )

Knowing t we can find P4, since t is bounded by P1 and P2; 0 <= t <= 1

If t < 0 then P4 = P1; If t > 1 then P4 = P2; otherwise P4 is calculated using t and the parameterization of A

And the distance can be calculated

dist = sqrt ( (x4-x0)^2 + (y4-y0)^2 + (z4-z0)^2 )
 
Last edited:
DHeshMan said:
I'm a little confused. My original problem statement used P0, P1, P2, and P4 (I inadvertently skipped P3). P0 is the external point, P1 and P2 are the end points of the line, and P4 was the point on the line closest to P0.

Your solution uses P1, P2, and P3? If I follow your theory correctly, your P1 is my P0? your P2 is my P1? your P3 is my P2? and your P1 + sC = P2 + tB = my P4?

You are correct. I was careless - I should have said P0, P1, P2 not P1, P2, P3.
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 11 ·
Replies
11
Views
7K
  • · Replies 14 ·
Replies
14
Views
4K
Replies
7
Views
2K
  • · Replies 16 ·
Replies
16
Views
4K
  • · Replies 5 ·
Replies
5
Views
6K
  • · Replies 13 ·
Replies
13
Views
10K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K