Distance from a Point to a Line

Online calculator for the Euclidean distance between point and line

Point-Line Distance Calculator

Euclidean Distance

Calculates the shortest distance from a point C to an infinite line through points A and B using the perpendicular method.

Line Definition (through two points)
X-coordinate of point A
Y-coordinate of point A
X-coordinate of point B
Y-coordinate of point B
External Point
X-coordinate of external point
Y-coordinate of external point
Result
Shortest distance:

Visualization

Distance from point to line

The graphic shows the shortest distance as a perpendicular line from the point to the line.
The perpendicular forms a right angle to the original line.

What is the Distance from a Point to a Line?

The distance is the shortest distance between a point and a line:

  • Shortest path: Always perpendicular to the line
  • Perpendicular method: Right angle to the original line
  • Infinite line: Endpoints are not considered
  • Euclidean geometry: Standard method in the plane
  • Always unique: There is only one shortest distance
  • Positive value: Distance is always ≥ 0

Euclidean Distance and Mathematical Derivation

The calculation is done using the perpendicular foot method of analytical geometry:

Line Equation
\[\vec{g}: \vec{r} = \vec{A} + t \cdot \overrightarrow{AB}\]

Parametric form of the line through A and B

Foot of Perpendicular
\[\overrightarrow{CP_{\text{foot}}} \perp \overrightarrow{AB}\]

Perpendicular from point to line

The Perpendicular Method Step by Step

The perpendicular method is the mathematically exact method for distance calculation:

Step 1: Direction Vector
\[\overrightarrow{AB} = \begin{pmatrix} x_2 - x_1 \\ y_2 - y_1 \end{pmatrix}\]

Determine direction of the line

Step 2: Foot of Perpendicular
\[t_{\text{opt}} = \frac{\overrightarrow{AC} \cdot \overrightarrow{AB}}{|\overrightarrow{AB}|^2}\]

Parameter for the foot of perpendicular

Formulas for Point-Line Distance

Distance Formula (Coordinate Form)
\[d = \frac{|ax_C + by_C + c|}{\sqrt{a^2 + b^2}}\]

For line in normal form: ax + by + c = 0

Distance Formula (Vector Form)
\[d = \frac{|\overrightarrow{AC} \times \overrightarrow{AB}|}{|\overrightarrow{AB}|}\]

Via cross product in 2D (determinant)

Determinant Form
\[d = \frac{|(x_2-x_1)(y_1-y_C) - (x_1-x_C)(y_2-y_1)|}{\sqrt{(x_2-x_1)^2 + (y_2-y_1)^2}}\]

Direct calculation from coordinates

Calculate Foot of Perpendicular
\[P_{\text{foot}} = A + t_{\text{opt}} \cdot \overrightarrow{AB}\]

Coordinates of the foot of perpendicular

Example

Example Calculation
A(0,0) B(5,8) C(6,2)
Calculation
\[\overrightarrow{AB} = \begin{pmatrix} 5 \\ 8 \end{pmatrix}\] \[\overrightarrow{AC} = \begin{pmatrix} 6 \\ 2 \end{pmatrix}\]

Direction and connection vector

Determinant
\[|\det| = |5 \cdot 2 - 8 \cdot 6| = |10 - 48| = 38\]

Cross product in 2D

Result
\[d = \frac{38}{\sqrt{5^2 + 8^2}} = \frac{38}{\sqrt{89}} \approx 4.03\]

The distance is approximately 4.03 units

Applications

Computer graphics, robotics, navigation, collision detection, CAD systems.

Point-Line Distance in Practice

The distance from a point to a line is a fundamental problem in analytical geometry. It describes the shortest distance between a given point and an infinitely extended straight line in two-dimensional space.

Mathematical Foundations

The shortest distance from a point to a line is always the perpendicular distance. This means that the connecting line from the point to the nearest point on the line (the so-called foot of perpendicular) forms a right angle to the original line.

The Perpendicular Method

The mathematically exact calculation is done using the perpendicular method:

  1. Direction vector: Determining the direction of the line through points A and B
  2. Foot of perpendicular: Finding the point on the line that is closest to the given point
  3. Distance calculation: Calculating the distance between the given point and the foot of perpendicular

Important Properties

Uniqueness

For every point, there is exactly one shortest distance to a line.

Infinite Line

The calculation refers to an infinitely extended line, not just the segment between the two points.

Right Angle

The shortest distance is always perpendicular to the original line.

Positive Values

The distance is always a positive number or zero (if the point lies on the line).

Practical Applications

Point-line distance calculation is found in many practical areas:

  • Computer graphics: Collision detection, rendering, distance calculations
  • Robotics: Path planning, obstacle avoidance, navigation
  • CAD/CAM: Technical drawings, tolerance calculations
  • GIS (Geographic Information Systems): Distances to roads, boundaries
  • Mechanical engineering: Fits, distances in mechanical components
  • Architecture: Distance calculations in building plans

Special Cases

Point on the Line

Distance = 0
The point lies exactly on the line

Horizontal Line

Distance = |y₀ - y_line|
Simple Y-difference

Vertical Line

Distance = |x₀ - x_line|
Simple X-difference

Is this page helpful?            
Thank you for your feedback!

Sorry about that

How can we improve it?


More graphics functions

Angle of two lines  •  Angle of two vectors  •  Center of a straight line  •  Distance of two points  •  Distance of a point and a line  •  Rise over Run  •  Slope of a line  •  Straight line equation  •  Circular arc  •  Helix  •  Koch snowflake  •