☖ Home Units Converter Geometry Σ Math Physics Electricity

Distance of a point to 3D line calculator

Print distance between two 3D lines
Parametric line equation L1
x
 = 
 + t 
y
 = 
 + t 
z
 = 
 + t 
General line equation L1
 x
+
=
 y
+
=
 z
+
Lines defined
by 2 points
L1
x1
 
   y1
 
   z1
 
x2
 
   y2
 
   z2
 
Distance from point
xp
 
   yp
 
   zp
 
Distance of the point to the line:
 
Connecting point coordinate:
 
Values of  t:
 
       

Calculating distance of a point to a 3D line

Print distance point to 3D line
General axis

The line is given by two points (x1, y1, z1) and (x2, y2, z2)

In parametric notation it can be written as:

L1 = r1 + t e1 = (x1, y1, z1) + t (x2 − x1, y2 − y1, z2 − z1)

The vector   e1 = (x2 − x1)i, (y2 − y1)j, (z2 − z1)k

The vector from point r1 to point P is:

QP = (px − x1)i + (py − y1)j + (pz − z1)k

The cross product of the line direction vector  e1  with  QP   QP ✕ e1  will give us the vector n which is perpendicular to the plane containing both the line and the vector  QP, it also contains the line that contain the required distance.

Finally, the distance of the point from the line can be calculated by dividing the norm of n by the norm (denoted by double lines) of e1.

d=‖n‖/‖e_1 ‖ =‖PQ×e_1 ‖/‖e_1 ‖

3D lines - Example 1

Print Example 1
Question:
Find the distance between the line L1 = (5, 1, 2) + t(−3, 2, −5) and the
point P(1, 5, −5).
Solution:

From the line equation we denote  r1 = (5, 1, 2)  and  e1 = (−3, 2, −5).

The vector from point r1 to point P is:

QP = (px − x1)i + (py − y1)j + (pz − z1)k

QP = (1 − 5)i + (5 −1)j + (−5 − 2)k = −4i + 4j − 7k

The perpendicular vector to QP and the line is the cross product of this vectors and is:

QP×e_1=|■(i&j&k@-5&1&1@2&4&-9)|=-13i-43j-22k

The norm (magnitude) of the cross product is:

‖QP×e_1 ‖=√(13^2+43^2+22^2 )=√2502=50.02

The norm of the line directions numbers vector is:

‖e_1 ‖=√(2^2+4^2+9^2 )=√101=10.05

And the distance of the line from the point is:

d=‖n‖/‖e_1 ‖ =‖PQ×e_1 ‖/‖e_1 ‖ =50.02/10.05=4.98

3D lines - Example 2

Print Example 2
Question:

Find the distance and the intersection point of the shortest line given by the cartesian form

L_1: (x-3)/2=(y+4)/1=(z-2)/4
and the point P(4, 1, −5).
Solution:

From the line equation we denote  r1 = (3, −4, 2)  and  e1 = (2, 1, 4).

The vector from point r1 to point P is:

QP = (px − x1)i + (py − y1)j + (pz − z1)k

QP = (4 − 3)i + [1 − (−4)]j + (−5 −2)k = i + 5j −7k

The perpendicular vector to QP and the line is the cross product of this vectors and is:

QP×e_1=|■(i&j&k@5&0&-8@2&1&4)|=8i-36j+5k

The norm (magnitude) of the cross product is:

‖QP×e_1 ‖=√(8^2+36^2+5^2 )=√1385=37.22

The norm of the line directions numbers vector is:

‖e_1 ‖=√(2^2+1^2+4^2 )=√21=4.58

And the distance of the line from the point is:

d=‖n‖/‖e_1 ‖ =‖PQ×e_1 ‖/‖e_1 ‖ =37.22/4.58=8.13
A point on the plane
We mark the point (x, y, z) as the intersection point of the shortest line from the given point to the given line. this line is located on the perpendicular plane from line L1. The point P is also located on the same plane and has direction numbers of (2, 1, 4). The following relation is true.
(■(2@1@4))∙(■(x@y@z))=(■(2@1@4))∙(■(4@2@-1))
2x+y+4z=6

To find the shortest line intersection point with the given line, we set the line equation divisions equal to t.

(x-1)/2=(y+2)/1=(z-3)/4=t

We get a set of 3 equations in the x, y and z direction with the unknown t:

x = 2t + 3
y = t − 4
z = 4t + 2

Substitute the values of x, y and z into the equation found before, we get:

2(2t+3)+t-4+4(4t+2)=-11

And the value of the parameter t is:
t=(-21)/21=-1

The value of the intersection point x,y and z is:     (1, −5, −2)