10
$\begingroup$

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?

$\endgroup$
3
  • 1
    $\begingroup$ Look at my answer for the formula. You have to write your line in this form... $\endgroup$ Commented Sep 22, 2014 at 13:43
  • 3
    $\begingroup$ 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. $\endgroup$
    – Macavity
    Commented Sep 22, 2014 at 14:21
  • $\begingroup$ It depends if you are using a vector or not. $\endgroup$ Commented May 10, 2023 at 16:58

4 Answers 4

16
$\begingroup$

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}}. $$

$\endgroup$
2
  • 2
    $\begingroup$ "sighed distance"? $\endgroup$ Commented Sep 22, 2014 at 17:41
  • $\begingroup$ That was a typo! Corrected! $\endgroup$ Commented Sep 23, 2014 at 6:34
10
$\begingroup$

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$.

$\endgroup$
2
$\begingroup$

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.

$\endgroup$
0
$\begingroup$

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.

$\endgroup$
1
  • 1
    $\begingroup$ what is 941555? $\endgroup$ Commented Sep 25, 2014 at 14:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .