Loading…

Point to Line in 3d Distance Tool

Math Geometry • Three Dimensional Geometry

View all topics

Distance from Point to Line Calculator in 3D Space

Compute the shortest distance from a point \(P(x,y,z)\) to a line in 3D. The tool uses the cross product formula \(\displaystyle d=\frac{\|\,(P-A)\times \mathbf{v}\,\|}{\|\mathbf{v}\|}\) and also finds the closest point on the line (the perpendicular foot).

Inputs accept 1e-3, pi, e, sqrt(2), sin(), cos(), tan(), ln(), log(), abs(). Use * for multiplication.

Line & point inputs
Line point \(A(x_A,y_A,z_A)\)
Direction \(\mathbf{v}=\langle v_x,v_y,v_z\rangle\)
The line is \(L(t)=A+t\mathbf{v}\). Direction \(\mathbf{v}\) must not be the zero vector.

Point \(P(x,y,z)\)
Formula: \(\displaystyle d=\frac{\|\,(P-A)\times \mathbf{v}\,\|}{\|\mathbf{v}\|}\). The closest point is \(F=A+t^\*\mathbf{v}\), where \(t^\*=\frac{(P-A)\cdot \mathbf{v}}{\|\mathbf{v}\|^2}\).
Display & view

Drag to orbit • Shift+drag to pan • wheel/trackpad to zoom • “Reset view” fits the geometry. Units are square.

Ready
3D view (line + perpendicular)

The line is drawn as a finite segment in the view, centered near \(A\), but it represents the infinite line. The shortest segment is from \(P\) to the closest point \(F\) on the line.

Rate this calculator

0.0 /5 (0 ratings)
Be the first to rate.
Your rating
You can update your rating any time.

Frequently Asked Questions

Why does the cross product give the distance to the line?

||(P−A)×v|| equals the area of a parallelogram with base ||v|| and height equal to the perpendicular distance. Dividing area by base gives the height (the distance).

What if my direction vector v is not a unit vector?

That is fine. The formula divides by ||v||, so any nonzero direction vector works.

How do you find the closest point on the line?

Compute t* = ((P−A)·v)/||v||^2 and then F = A + t* v. This makes (P−F) perpendicular to the direction v.

Can I input the line using two points?

Yes. The calculator converts two-point form into point-direction form using v = B − A.