Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am sure this is something completely dumb but my mathematics is, well awful, so be kind...

I know three coordinates (2D standard x and y things where the top left is 0,0 and the x increases from left to right and y increases from top to bottom) and I can plot a line between two of them and then make a third point where the intersection with the line should be 90 degrees and what I want to calculate is the length of the line that made this angle (I am sure if I could explain myself properly I would have found an answer to this already).

Here is a picture of what I mean (with some example values for the three coordinates A, B and C that are known to me):


So, how do I calculate the length marked L in the above?

I thought, well, the line L is normal to the vector A to B so I could say...

The vector from A to B is (4, 7) and therefore the normal vectors would be (-7, 4) and (7, -4) but then I am stuck - where do I go now? Am I even on the right track?

share|cite|improve this question
The red line is often called "dropping a perpendicular" in geometry. Optional reading material: – anon May 2 '12 at 8:13
@anon Thanks! That was all I needed (you could put that as an answer). – kmp May 2 '12 at 8:19
up vote 1 down vote accepted

Here is the easiest way I can think of:

  • Find the normal vector for $AB$.

  • Take the dot product of the normal vector and $A$.

  • Take the dot product of the normal vector and $C$.

  • Subtract the two dot products.

  • Divide by the length of the normal vector.

The result is the length of $L$.

Per your example:

  • $N = B-A = (7, -4)$.

  • $a = N \cdot A = (1 \cdot 7) + (1 \cdot -4) = 7 - 4 = 3$.

  • $c = N \cdot C = (7 \cdot 7) + (-4 \cdot 5) = 49 - 20 = 29$.

  • $c - a = 29 - 3 = 26$.

  • $|N| = \sqrt{7^2 + 4^2} = \sqrt{49 + 16} = \sqrt{65} \approx 8.062$.

  • $26 \div 8.062 \approx 3.225$.

So $L$ is about 3.225 units long.

share|cite|improve this answer
The normal vector alone isn't sufficient to find the distance. To see why, notice that all parallel lines have the same normal vector, but their distances from a fixed point change depending on where the line is located in the plane. – Ayman Hourieh May 2 '12 at 10:25
You are of course correct. Give me a minute to fix my answer... – MathematicalOrchid May 2 '12 at 10:30
@AymanHourieh: Fixed now. – MathematicalOrchid May 2 '12 at 10:34

What you want a point-line distance in 2D.

Let's calculate the formula of $AB$:

$$ y-y_A = \frac{y_B-y_A}{x_B-x_A} (x-x_A) $$

Plug and simplify:

$$ 7x -4y -3 = 0 $$

Now let's use the point-line distance formula:

\begin{align*} d &= \frac{|ax_0+by_0+c|}{\sqrt{a^2+b^2}} \\ &= \frac{|7\times7+(-4)\times5+(-3)|}{\sqrt{7^2+(-4)^2}} \\ &= \frac{26}{\sqrt{65}} \approx 3.224 \end{align*}

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.