# Common direction between two vectors

I have two vectors with the same origin and I need to find the common direction between them, that is the vector perpendicular to the line that join them. For instance, referring to this image I need the vector that points perpendicularly from $A$ to the line joining $B$ and $D$.

I am very rusty at algebra, can someone help me?

From the picture that you link to the line that you want is the orthogonal projection of the vector $v = \overrightarrow{AB}$ onto the vector $u = \overrightarrow{BD}$. What this means is you want the vector which is $v$ minus the component of $v$ that points in the direction of $u$. The vector that you want is given by

$\displaystyle v - \frac{\langle v, u\rangle}{\langle u, u\rangle}u$

where $\langle\ \cdot\ ,\ \cdot\ \rangle$ is the inner product.

To see where this comes from consider that we have two arbitrary vectors $u,\ v \in \mathbb{R}^{2}$. Consider that $v$ can be represented as

$v = \alpha u + u^{\perp}$

for $u^{\perp} \perp u$ (i.e. $u^{\perp}$ is perpendicular to $u$). Now consider that perpendicular vectors have zero inner product, such that

$\langle u, u^{\perp}\rangle = 0$

and so

$\langle v, u \rangle = \langle \alpha u + u^{\perp}, u \rangle \\ \quad \quad\ = \alpha\langle u , u \rangle$

from which

$\displaystyle \alpha = \frac{\langle v, u\rangle}{\langle u, u \rangle}$

implies that

$\displaystyle u^{\perp} = v - \alpha u = v - \frac{\langle v, u \rangle}{\langle u, u \rangle}u.$

Since $u^{\perp}$ was defined to be perpendicular to $u$, we have the orthogonal vector to $u$.

If you want to brush up on your linear algebra then 'Linear Algebra and its Applications' by Strang is a very good book

• Thanks a lot, that's a very complete answer! Oct 7 '13 at 21:47