VOOZH about

URL: https://www.geeksforgeeks.org/maths/distance-of-a-point-from-a-line/

⇱ Distance of a Point From a Line - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Distance of a Point From a Line

Last Updated : 21 Oct, 2025

The concept of distance is fundamental in geometry, whether you're measuring the length between two points or determining how far a point is from a specific geometric object. One of the most common distance-related problems involves finding the shortest distance between a point and a line. This concept is not only crucial in theoretical mathematics but also has practical applications in fields such as engineering, computer graphics, and physics.

👁 point
distance between point and a line in 2d plane


To understand the distance from a point to a line, imagine a line in a 2D plane and a point located somewhere in space. The shortest path from the point to the line is always the perpendicular distance, meaning the line segment connecting the point and the line forms a right angle.

Formula for the Distance of a Point From a Line in 2D

The perpendicular distance from a point P(x1, y1) and line A.x + B.y + C = 0 in 2D space is given by,

Where,

  • d is the distance (shortest) between point(x1, y1).
  • A, B are coefficients of x and y coordinates, respectively, in the general equation of a line.
  • C is the constant in the general equation of a line.

Formula for Distance of a Point From a Line in 3D

The perpendicular distance between a point P(x1, y1, z1) and a line with distance vector: , is given by,

Where,

  • D is the perpendicular distance from point P and the line given by the vector direction: ,
  • A is a point on the line with the distance vector: ,
  • is the distance vector of the line that passes through point A and P.

Perpendicular Distance of a Point From a Line

As defined above, the distance, (shortest distance) of a point from a line, is the length of the perpendicular drawn from the point to the line. Below are the steps to derive the formula for finding the shortest distance between a point and a line.

Step 1: Consider a line (L: Ax + By + C = 0) whose distance from the point {P (x1, y1)} is (d).

Step 2: Draw a perpendicular (PM) from the point (P) to the line (L) as shown in the figure below.

Step 3: Let (Q) and (R) be the points where the line meets the x-axis and y-axis, respectively.

Step 4: Coordinates of the points can be written as Q(-C/A, 0) and R(0, -C/B).

Now using the formula one can easily found the distance of the point from the line.

Derivation of Distance of a Point from a Line in 2D

Let's consider a point P(x1, y1) and a line L: Ax + By + C = 0 passing through and intersecting the x-axis and y-axis at points S and T. Then, the coordinates of S and T are given by S(-C / A, 0) and T (0, -C / B). Also, consider the perpendicular line PM from P to the line segment S and T as d.

👁 distance_formula_from_a_point_to_a_line
Derivation of Distance of a Point from a Line in 2D

We know that,

Area of Triangle PST = 1/2(PM × ST)

2 × area of triangle PST = PM × ST---- equation(i)

Area of triangle PST = (1/2) × ((x1.(0 + (C/B))) + (-C/A)((-C/B) - y1)+ 0(y1 - 0))

= (1/2) × |x1.(C/B) + y1(C/A) + (C2/ AB)|

Or, 2 × area of triangle PST = |x1(C/B) + y1(C/A) + (C2/ AB)|---- equation(ii)

By Distance formula,

ST = ((0 + (C/A))2 + ((C/B) - 0)2)1/2

ST = |C/AB| (A2 + B2)1/2---- equation(iii)

By putting the value of equation (ii) and equation (iii) in equation (i), we get,

|x1(C/B) + y1(C/A) + (C2/ AB)| = PM × |C/AB| (A2 + B2)1/2

PM = (|C/AB| | A.x1 + B.y1 + C |) / (|C/AB| (A2 + B2)1/2)

PM = |A.x1 + B.y1 + C| / (A2 + B2)1/2

Therefore, the shortest perpendicular distance from a point to a line is,

d= | A.x1 + B.y1 + C | / (A2 + B2)1/2

Derivation of Distance of a Point from a Line in 3D

Let's consider a line L in 3D space passing through a point A with direction vector . So, A is any point on the line with distance vector. Let P be any point which is not the line L.

👁 distance_formula_in_3D
Derivation of Distance of a Point from a Line in 3D

In the diagram given above, we have a vector passing through point P which is parallel to the line with distance vector and also, we have a line parallel to line AP with distance vector .

By applying parallelogram law, with the help of given line L with distance vector and line passing through point A and P with distance vector ,

Now, we find the area of parallelogram in two ways,

Way 1 (Finding Area of Parallelogram)

By the geometric interpretation of the magnitude of cross product,

Area of parallelogram = Magnitude of the cross product between vectors and

⇒ Area of Parallelogram = | × |-----> equation(i)

Way 2 (Finding Area of Parallelogram)

We can also find area of parallelogram by multiplying base of the parallelogram with its altitude or height,

Area of Parallelogram = Magnitude of vector × D

⇒ Area of Parallelogram = || × D-----> equation(ii)

From equations, (i) and (ii), we get,

|| × D = | × |

D = | × | / | |

Therefore the shortest perpendicular distance, D from point P(x1, y1, z1) to a line L, is given by,

D = | × | / | |

Solved Examples on Distance of a Point From a Line

Example 1: Find the distance of point(2, -4) from the line 2x - 6y - 24 = 0

Solution:

Let the point(x1, y1) = (2, -4)

Given line is 2x - 6y - 24 = 0, comparing it with the general equation of line, Ax + By + C = 0, we get,

A = 2, B = -6 and C = -24

Now, the distance of point (2, -4) from the line 2x - 6y - 24 = 0 is given by,

d= |A.x1 + B.y1 + C | / (A2 + B2)1/2

d = |2(2) + (-6)(-4) + (-24)| / (22 + (-6)2)1/2

d = |4 + 24 - 24| / (4 + 36)1/2

d = 4/√(40)

d = 2/√(10)

Therefore, the distance from point(2, -4) and line 2x - 6y - 24 = 0 is, 2/√(10) unit.

Example 2: Find the distance between line 3x - 4y + 10 = 0 and point (-2, 6)

Solution:

According to the question,

Let, point(x1, y1) = (-2, 6)

Comparing the given line is 3x - 4y + 10 = 0, with the general equation of line, Ax + By + C = 0, we get,

A = 3, B = -4 and C = 10

Now, the distance of point (-2, 6) from the line 3x - 4y + 10 = 0 is given by,

d= |A.x1 + B.y1 + C | / (A2 + B2)1/2

d = | 3(-2) + (-4)(6) + 10 | / (32 + (-4)2)1/2

d = | (-6) - 24 + 10| / (9 + 16)1/2

d = 20/5

d = 4

Therefore, the distance from point(-2, 6) and line 3x - 4y + 10 = 0 is, 4 unit.

Example 3: Find the shortest distance from point(3 , 4) to 2x + 3y - 5 = 0

Solution:

According to the question,

Let, point(x1, y1) = (3, 4)

Comparing the given line is 2x + 3y - 5 = 0, with the general equation of line, Ax + By + C = 0, we get,

A = 2, B = 3 and C = -5

The shortest distance from point(3, 4) to 2x + 3y - 5 = 0 is given by,

d = | A.x1 + B.y1 + C | / (A2 + B2)1/2

d = | 2(3) + 3(4) + (-5) | / (22 + 32)1/2

d = | 6 + 12 - 5| / (4 + 9)1/2

d = 13 / 131/2

d = √(13)

Therefore, the shortest distance from point(3, 4) to 2x + 3y - 5 = 0 is √(13)unit.

Example 4: Find the perpendicular distance from point(5, 6) to the line x = -3.

Solution:

Given, point(x1, y1) = (5, 6)

Equation of line, x = -3, can be written as, x + 3 = 0. Comparing it with the general equation of line Ax + By + C = 0, we get,

A = 1, B = 0, C = 3

Now, the perpendicular distance from point(5, 6) to the line x + 3 = 0 is given by,

d = | A.x1 + B.y1 + C | / (A2 + B2)1/2

d = |1(5) + 0(6) + 3 | / (12 + 02)1/2

d = 14/1

d = 14

Therefore, the perpendicular distance from point(5, 6) to the line x = -3 is 14 unit.

Example 5: Find the distance from the point(6, 6) passing through points(3, 0) and (0, 4).

Solution:

We are given, point(x1, y1) = (6, 6)

We can find the equation of line passing through points(3, 0) and (0, 4) with the help of distance formula,

Equation of line is given by,

y - y1 = m(x - x1) ----- equation(i)

From point(3, 0), let y1 = 0, x1 = 3,

Slope, m = (4 - 0)/(0 - 3) = (-4)/3

Putting the above obtained values in equation(i), we get,

y - 0 = (-4)/3 (x - 3)

y = -(4x)/3 + 4

4x + 3y - 12 = 0

Now, the distance from point(6, 6) to the line 4x + 3y - 12 = 0 is given by,

By observation, x1 = 6, y1 = 6, A = 4, B = 3 and C = -12

So, d = | A.x1 + B.y1 + C | / (A2 + B2)1/2

d = | 4(6) + 3(6) - 12 | / (42 + 32)1/2

d = | 24 + 18 - 12 | / (16 +9)1/2

d = 30 / √(25)

d = 6

Therefore, the distance from point(6, 6) and line passing through points(3, 0) and (0, 4) is 6 unit.

Example 6: Find the distance between the point P(0, 3, 6) and the line with parameters equations x = 1 - t, y = 1 + 2t, z = 5 + 3t.

Solution:

Given Point P(0 , 3, 6) and line with parametric equations, x = 1 - t, y = 1 + 2t, z = 5 + 3t

= ( -1, 2, 3)

Let the point on line, A = (1, 1, 5) from the parametric equation of line.

So, = Difference between points P and A

= (0, 3, 6) - (1, 1, 5)

= (-1, 2, 1)

Now, × =

=(6 - 2) - (-3 + 1)+ (-2 - (-2))

= 4+2+ 0

By distance formula,

D = | X | / | |

D = (42 + 22 + 02)1/2 / ((-1)2 + 22 + 32)1/2

D = √(70) / 7

Therefore, the distance from point P(0, 3, 6) to the line with parametric equations, x = 1 - t, y = 1 + 2t, z = 5 + 3t is √(70) / 7 unit.

Problem 7: Let L be a line passing through point A(6, 4, 4) in direction vector(1, 3, -10). Find the distance from point P(1, 5, 5) to the line L.

Solution 7:

Given point P(1, 5, 5) and line L passing through point A(6, 4, 4) in = (1, 3, -10)

= (1 , 5, 5) - (6, 4, 4)

= (-5, 1, 1)

Now, ×=

=(-10 -3) - (50 - 1) + (-15 - 1)

= -13 -49 + 14

By distance formula,

D = | × | / | |

D = ((-13)2 + (49)2 + 142)1/2 / (12 + 32 + (-10)2)1/2

D = (2766)1/2 / (110)1/2

D = (25.14545)1/2

D = 5.014 (approx.)

Therefore, 5.014 unit (approx.) is the distance from point (1, 5, 5) to the line passing through (6, 4, 4) in direction vector (1, 3, -10).

Practice Questions on Distance of a Point From a Line

Problem 1: Find the distance of the point (4, 7) from the line 3x − 2y + 5 = 0.

Problem 2: Find the distance between the point (−3, −2) and the line 4x + 5y − 12 = 0.

Problem 3: Find the shortest distance from the point (5, 1) to the line 2x − y − 3 = 0.

Problem 4: Find the perpendicular distance from the point (2, 5) to the line x = 6.

Problem 5: Find the distance from the point (3, −2) to the line 5x + 4y − 7 = 0.

Problem 6: Find the distance from the point (1, 3) to the line passing through the points (4, 0) and (0, 6).

Problem 7: Find the distance between the point (2, 4, 3) and the line with parametric equations x = 3 − t, y = 2 + t, z = 4 + 2t.

Problem 8: Let L be a line passing through the point B(1, 2, 3) in direction vector v = (3, −1, 4). Find the distance from the point P(4, 6, 2) to the line L.

Comment

Explore