# Finding the distance between a point and a line, can there be a negative distance?

In finding the distance from a point $(x_1, y_1)$ to a line L: Ax + By + C = 0, can there be a negative distance?

Is this the formula for finding the distance? $$d= \frac{|Ax + By + C|}{\sqrt{ A^2 + B^2}}$$

can I used other variables except x and y in the formula?

• Look at my answer for the formula. You have to write your line in this form... – nullgeppetto Sep 22 '14 at 13:43
• Distance usually does not have a sign. Signed distances are however useful in a few applications, for e.g. If you want to find if two points are on the same or opposite sides of a line. – Macavity Sep 22 '14 at 14:21

I have edited your question to make it more specific.

Then, the correct format of your formula should be $d= \frac{A x_1 + B y_1 + C}{\pm \sqrt{ A^2 + B^2}}$

The above answers your 3rd question----The substitution $(x = x_1$ and $y = y_1)$ is a must if $(x_1, y_1)$ is the point in question.

Note. You can still use the absolute sign form.

Let $\mathcal{H}\colon\mathbf{w}\cdot\mathbf{x}+b=0$ be a hyperplane in $\Bbb{R}^n$, then $$d = \frac{\mathbf{w}\cdot\mathbf{x}_0+b}{\lVert\mathbf{w}\rVert}$$ gives the signed distance (with respect to the normal vector) between a point $\mathbf{x}_0$ and the hyperplane. $\lvert d \rvert$ gives the "traditional" distance.

The signed distance takes into consideration in which halfspace the point lies.

For instance, if you have your line in the form $Ax+By+c=0$, then $\mathbf{w}=(A, B)^\top$, $b=c$, and the signed distance is $$d = \frac{Ax+By+c}{\sqrt{A^2+B^2}}.$$

• "sighed distance"? – Ryan Sep 22 '14 at 17:41
• That was a typo! Corrected! – nullgeppetto Sep 23 '14 at 6:34

If you're talking about a distance function, it has to be non-negative: http://en.wikipedia.org/wiki/Metric_%28mathematics%29.

You might want to define a signed distance (which is clearly not a distance anymore, in the axiomatic sense of the term).

For instance, in $\mathbb{R}$ you can define the distance from a certain point $x_0$ as $d(x)=\vert x-x_0\vert$. But you can also define this function $f(x)=x-x_0$, which is a not a metric, but it represents the distance of $x$ from $x_0$ with the convention that positive values mean $x$ in on the right of $x_0$ and negative values mean $x$ is at the left of $x_0$.

941555 The formula

$d={{|Ax_1+By_1+C|}\over\sqrt{A^2+B^2}}$ (1)

is actually a simplification of

$d={\sqrt{(Aq)^2+(Bq)^2}\over{A^2+B^2}}$ (2),
where $q=Ax_1+By_1+C$.

··· The sign of (1), when it has not been forced to positive by application of the absolute value, shows whether the point $(x_1\mid y_1)$ is on the same side of the line $Ax+By+C=0$ as the origin or not. (negative, if same side; positive, if other side; and zero, if the line passes through the point)
··· The sign of (2) is never negative.

• what is 941555? – John Alexiou Sep 25 '14 at 14:47