Say I have a vector in 2D space defined by two points $(x_1, y_1)$ and $(x_2, y_2)$: $$\vec{v}=(x_2 - x_1, y_2 - y_1)$$ I would like to find how far along that vector an arbitrary point $(x_3, y_3)$ is. This very woolly language$^*$, so I've attempted to create a diagram showing the sitation.

enter image description here

In this diagram, the quantity I'm interested in $a$, which I can calculate using Pythagoras' theorem if I know $b$ and $c$. I know $c$, which is the length of vector $(x_3 - x_1,y_3 - y_1)$, given by, $$c = \sqrt{(x_3 - x_1)^2 + (y_3 - y_1)^2}$$ So, now I need to calculate $b$: the length of a vector – that I'll call $\vec{u}$ – that is perpendicular to $\vec{v}$ and passes through point $(x_3, y_3)$. For $\vec{u}$ and $\vec{v}$ to be perpendicular the dot product must be zero. That is,

$$\vec{v}\cdot \vec{u}=0$$


This is where I begin to falter: one equation with two unknowns, $y_4$ & $x_4$. I expect there is some obvious constraint on $\vec{u}$ that I should be using to eliminate an unknown, but my sleep-deprived mind is offering no help. Can someone point out what I've missed?


$^*$I really want to use the word project to describe how my arbitrary point $(x_3, y_3)$ is placed along that vector. Is this the correct terminology?


You are right in calling this a projection. If $(x_1,y_1)$ is the origin, then you can project ${\bf u} = (x_3,y_3)$ onto $\bf v$ thus:

$${\rm proj}_{\bf v}{\bf u} = \frac{\bf u \cdot v}{\bf v \cdot v}{\bf v}.$$

If $(x_1,y_1)$ is not the origin, then just shift the frame of reference to make it so.


Consider the vectors $v_1 = (x_2-x_1,y_2-y_1)$ and $v_2 = (x_3-x_1,y_3-y_1)$. You can compute the cosine of the angle between these two vectors as follows:

$\cos \theta = \frac{<v_1,v_2>}{||v_1||||v_2||}$,

where $<v_1,v_2>$ is the dot-product and $||.||$ is the norm. Once you have done this computation, it is easy to see that $a = c \cos \theta$ and $b = c \sin \theta$.

The quantity $a$ is the projection you speak of and it is related to the dot-product as described above.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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