# Finding point coordinates of a perpendicular

Given that I know the point coordinates of point $A$ and point $B$ on segment $AB$ and the expected length of a perpendicular segment $CA$ (perpendicular over $AB$), how do I calculate the point coordinates of the point $C$?

-

There are, in general, multiple possible solutions for $C$, depending on which direction you go from A. If you restrict yourself to points on a plane, then there are two possible solutions.

Say that the length of $CA$ is known to be $l$. We want to find a perpendicular to $AB$. Say $B-A = (x,y)$ then we want $(a,b)$ with $(x,y) \cdot (a,b) = 0$. Check for yourself that $(-y,x) \cdot (x,y) = 0$.

But we also want $(a,b)$ to have length $l$. To get something in the same direction as $(-y,x)$, but with length $l$, divide $(-y,x)$ by it's length and multiply by $l$. This gives $(a,b) = \frac{l}{\sqrt{x^2+y^2}}(-y,x)$.

So with this choice $(a,b)$ has both the right magnitude and direction. Since this is the displacement from $A$ to $C$, let $C = A + (a,b)$. As I said above, this choice is not unique; you can check that even in the plane $C = A - (a,b)$ gives another valid solution.

-
Thank you for your answers - they helped me solve the problem. – crerem May 18 '12 at 11:06

You have apparently $2$ possible solutions. Consider the vectors $A=(a_1,a_2)$ and $B=(b_1,b_2)$. Then, the vector $B-A=(b_1-a_1,b_2-a_2)$ is the director vector of $AB$. Hence, $u=(a_2-b_2,b_1-a_1)$ is orthogonal to $B-A$. Therefore,

$$C=A\pm|CA|\cdot \frac{u}{\|u\|}$$

are your two desired points.

-