[Math] Relationship between projection and vector as sum of parallel and perpendicular parts

geometrylinear algebraprojectionvectors

I'm reading a Linear Algebra text that looks to me like it has a contradiction. The exact text is linked below, but here is a summary:

Given two vectors, v and n, you can define v as the sum of a vector perpendicular to n and a vector parallel to v. The parallel vector is referred to as the projection of v onto n.

Which leads to this equation:

$$v_{||} = n\frac{\left|\left|v_{||}\right|\right|}{\left|\left|n\right|\right|}$$

The idea being that since the vectors are parallel they only differ in magnitude. But can't they also point in exactly opposite directions?

If you take the v vector in the picture, and mirror it around the y axis so it now points up and to the left, then the parallel part of the sum now points in the direction opposite n. However as I understand it projection is defined such that it always points in the direction of the vector being projected onto. So shouldn't the equation be:

$$v_{||} = n\frac{\left|\left|v_{||}\right|\right|}{\left|\left|n\right|\right|}$$ when the angle between v and n is less than 90 degrees

and

$$v_{||} = -n\frac{\left|\left|v_{||}\right|\right|}{\left|\left|n\right|\right|}$$ when the angle between v and n is greater than 90 degrees

?

enter image description here

Best Answer

You want $$ v = v_\perp + v_\parallel $$ with $$ n \cdot v_\perp = 0 \\ v_\parallel = s \, n $$ where $s$ is a scalar and $n \ne 0$. We want to treat the case $v_\parallel \ne 0$, so $s \ne 0$. Then $$ v_\parallel \cdot n = (s \, n) \cdot n = s (n \cdot n) = s \, \lVert n \rVert^2 $$ on the other hand $$ v_\parallel \cdot n = \lVert v_\parallel \rVert \lVert n \rVert \cos\angle(v_\parallel, n) = \lvert s \rvert \lVert n \rVert^2 \cos\angle(v_\parallel, n) $$ where we used $$ \lVert v_\parallel \rVert = \lVert s \, n \rVert = \lvert s \lvert \lVert n \rVert $$ so for $\lVert n \rVert \ne 0$ we have $$ s = \lvert s \rvert \cos\angle(v_\parallel, n) $$ or $$ \DeclareMathOperator{sgn}{sgn} \DeclareMathOperator{cos}{cos} \cos\angle(v_\parallel, n) = \frac{s}{\lvert s \rvert} = \sgn(s) $$ which is the sign of the scalar $s$.

We have $$ v_\parallel = s \, n = s \, \lVert n \rVert \frac{n}{\lVert n \rVert} = (\sgn(s) \lvert s \rvert) \, \lVert n \rVert \frac{n}{\lVert n \rVert} $$ On the other hand we saw $$ \lVert v_\parallel \rVert = \lvert s \lvert \lVert n \rVert $$ so we have $$ v_\parallel = \sgn(s) \lVert v_\parallel \rVert \frac{n}{\lVert n \rVert} = \sgn(s) n \frac{\lVert v_\parallel \rVert}{\lVert n \rVert} $$ which answers your question with a yes.