# When does the projection of $\vec{u}$ onto $\vec{v}$ is $\vec{v} \cos(\phi)$?

I was trying to understand when a projection of a vector $\vec{u}$ onto a vector $\vec{v}$ is $\vec{v} \cos(\phi)$, where $\phi$ is the angle between the vectors. In the picture below, it's called $\alpha$.

I want to understand this because, in the context of computer graphics, in an explanation of the formula to find the reflection vector to a point $p$ on a surface uses the fact that the projection of vector light (which I call it here $\vec{u}$) onto the surface normal at point $p$ (which I call here $\vec{v}$) is $\vec{v} \cos(\phi)$.

For example, suppose we have this situation:

We first compute the number $OA'$ that multiplied by $\vec{v}$ gives the projected vector of $\vec{u}$ onto $\vec{v}$, lets call it $\vec{w}$.

$$\cos(\phi) = \frac{OA'}{|\vec{u}|}$$

This comes from that $|\vec{u}|$ is the hypotenuse and $OA'$ is the adjacent catheti.

So we have

$$|\vec{u}|\cos(\phi) = OA'$$

The dot product between $\vec{u}$ and vector $\vec{v}$ is

$$\vec{u}\cdot\vec{v} = |\vec{v}||\vec{u}| \cos(\phi) = |\vec{v}|OA'$$

Thus we have that $$\frac{\vec{v} \cdot \vec{u}}{|\vec{v}|} = OA'$$

The vector projection is thus $OA'$ times the $\frac{\vec{v}}{|\vec{v}|}$ to obtain $\vec{w}$.

$$\vec{w} = OA'* \frac{\vec{v}}{|\vec{v}|} = \frac{\vec{v} \cdot \vec{u}}{|\vec{v}|} * \frac{\vec{v}}{|\vec{v}|} = \frac{\vec{u} \cdot \vec{v}}{|\vec{v}|^2} \vec{v} = \frac{1}{|\vec{v}|}\frac{\vec{u} \cdot \vec{v}}{|\vec{v}|} \vec{v} = \frac{1}{|\vec{v}|}OA' \vec{v} = \frac{1}{|\vec{v}|}|\vec{u}|\cos(\phi) \vec{v} = \frac{|\vec{u}|}{|\vec{v}|} \cos(\phi) \vec{v}$$

So, the conclusion to my initial question seems to be when the length of vector $\vec{u}$ and vector $\vec{v}$ are the same. Is this correct?

• I don't know if this will help, but the main thing to remember is which angle $\phi$ to use. In the case of the diagram you showed it is the acute angle $\alpha$. If the vectors were orthogonal then the same holds. If the vectors form a straight line you are just multiplying two magnitudes in opposite directions i.e. $cos(180)=-1$. And when $\alpha$ in the diagram is obtuse, you use the acute angle $\phi$. The rest is just trigonometry. – shredalert Jan 19 '17 at 11:35

As you’ve already worked out, the projection of $|\vec u|$ onto $|\vec v|$ is ${\vec u\cdot\vec v\over|\vec v|^2}={\vec u\over\vec v}\cos\phi\,\vec v$. If this is equal to $\cos\phi\,\vec v$, then $|\vec u|\cos\phi=|\vec v|\cos\phi$, so there are two possibilities.
One is that $|\vec u|=|\vec v|$, as you’ve found. This make perfect sense. Imagine the two vectors as radii of a circle centered at the origin and set the $x$-axis in the direction of $|\vec v|$. The projection is then just the $x$-coordinate of $\vec u$ in this coordinate system, which is $\cos\phi$ scaled by the radius of the circle.
The other possibility is that $\cos\phi=0$, which means that the vectors are perpendicular (orthogonal).
• Not sure this is correct. I'm asking about the projection of $\vec{u}$ onto $\vec{v}$... not sure how you go from the dot product to my problem... – nbro Jan 19 '17 at 20:52