Associated Topics || Dr. Math Home || Search Dr. Math

### Distance Between a Line and a Point Using Vectors

```
Date: 09/25/1999 at 17:08:46
From: Ian Bui
Subject: Distance between line and point using vectors

How do you use scalar vector projections to prove that the distance
between the line ax+by+c = 0 and point (x1,y1) is

|ax1+by1+c|/sqrt(a^2+b^2)

I tried choosing an arbitrary point on the line, but with each step,
things got more complex.
```

```
Date: 09/25/1999 at 19:46:50
From: Doctor Anthony
Subject: Re: Distance between line and point using vectors

The equation ax + by + c = 0 can be written:

y = -(a/b)x - (c/a)

So the gradient of line is -(a/b). This means that the cosine of the
angle between the line and the x axis is -b/sqrt(a^2+b^2) and the
cosine of the angle between the line and the y axis is
a/sqrt(a^2+b^2).

So the direction ratios of the line are (-b,a).

If we have a line perpendicular to this, its direction ratios will be
(a,b) since (-ab) + (ab) = 0.

So the perpendicular line through (x1,y1) is:

x-x1   y-y1
---- = ---- = t/sqrt(a^2+b^2)     where t is a parameter.
a      b

t will be the distance from the point (x1,y1) along the perpendicular.

So

x = x1 + a.t/sqrt(a^2+b^2)

and

y = y1 + b.t/sqrt(a^2+b^2)

This meets the given line ax+by+c = 0 where:

a(x1+a.t/sqrt(a^2+b^2)) + b(y1+b.t/sqrt(a^2+b^2)) + c = 0

ax1 + by1 + c + t(a^2+b^2)/sqrt(a^2+b^2) + c = 0

ax1 + by1 + c + t.sqrt(a^2+b^2) = 0

so

t.sqrt(a^2+b^2) = -(ax1+by1+c)

t = -(ax1+by1+c)/sqrt(a^2+b^2)

Therefore the perpendicular distance from (x1,y1) to the line
ax+by+c = 0 is:

ax1 + by1 + c
|t| =  -------------
sqrt(a^2+b^2)

- Doctor Anthony, The Math Forum
http://mathforum.org/dr.math/
```
Associated Topics:
High School Linear Algebra

Search the Dr. Math Library:

 Find items containing (put spaces between keywords):   Click only once for faster results: [ Choose "whole words" when searching for a word like age.] all keywords, in any order at least one, that exact phrase parts of words whole words

Submit your own question to Dr. Math
Math Forum Home || Math Library || Quick Reference || Math Forum Search