Vector Projection in 3D (Scalar and Vector Projection)
In 3D geometry and physics, projection answers a very common question: “How much of vector \(A\) lies in the
direction of vector \(B\)?” Think of shining a light perpendicular to a line—what you see on the line is a “shadow.”
For vectors, the shadow of \(A\) on the direction of \(B\) is the vector projection \(\mathrm{proj}_B(A)\), and the signed length of that
shadow is the scalar projection (also called the component) \(\mathrm{comp}_B(A)\).
The projection formulas are built from the dot product. For two vectors
\(A=\langle A_x,A_y,A_z\rangle\) and \(B=\langle B_x,B_y,B_z\rangle\), the dot product is
\[
A\cdot B = A_xB_x + A_yB_y + A_zB_z = \lVert A\rVert\lVert B\rVert\cos\theta,
\]
where \(\theta\) is the angle between them. If \(\lVert B\rVert \neq 0\), the unit vector in the direction of \(B\) is
\(\hat{B} = \dfrac{B}{\lVert B\rVert}\). The scalar projection of \(A\) onto \(B\) is then
\[
\mathrm{comp}_B(A)=A\cdot \hat{B}=\frac{A\cdot B}{\lVert B\rVert}.
\]
This number can be positive, negative, or zero depending on whether \(A\) points generally with \(B\), against \(B\), or perpendicular to \(B\).
The vector projection is a vector pointing along \(B\) whose length equals the scalar projection:
\[
\mathrm{proj}_B(A)=\big(\mathrm{comp}_B(A)\big)\hat{B}
= \frac{A\cdot B}{\lVert B\rVert^2}B.
\]
A useful way to interpret this is that \(\mathrm{proj}_B(A)\) is the “best” approximation to \(A\) using only vectors parallel to \(B\).
The difference between \(A\) and its projection is the perpendicular component (also called the rejection):
\[
A_\perp = A - \mathrm{proj}_B(A).
\]
By construction, \(A_\perp\) is orthogonal to \(B\), meaning \(A_\perp\cdot B = 0\). This produces the decomposition
\(A = \mathrm{proj}_B(A) + A_\perp\), which is the vector version of splitting a motion or force into “along the direction” plus “sideways.”
Projections are everywhere in applications. On an inclined plane, a force vector can be decomposed into a component along the slope
(causing motion) and a perpendicular component (causing normal force). In computer graphics, projections help measure how a vector aligns with
a surface direction. In linear algebra, projections are the foundation of least squares fitting and orthogonal decompositions.
One key warning: if \(B=0\), the direction of \(B\) is undefined, so \(\mathrm{comp}_B(A)\) and \(\mathrm{proj}_B(A)\) do not exist.
This tool computes the scalar and vector projections, the perpendicular component, and the angle \(\theta\) between \(A\) and \(B\).
The interactive 3D visualization shows \(A\), \(B\), and the projection “shadow” \(\mathrm{proj}_B(A)\), making the geometry behind the formulas clear.