Formula and Method for Vector Projection
The vector projection of a vector a onto a nonzero vector b is the component of a that points in the direction of b — geometrically, the "shadow" a casts onto the line through b when light falls perpendicular to b. It is built from the dot product: proj_b(a) = ((a·b) / |b|²) × b, where a·b is the dot product of the two vectors and |b|² is the squared magnitude of b. A closely related quantity is the scalar projection (also called the component of a along b), comp_b(a) = (a·b) / |b|, which is just the signed length of that shadow — positive when the angle between the vectors is under 90°, negative when it exceeds 90°.
How the calculation works
Enter the x, y, and z components of vectors a and b (use z = 0 for a 2D problem). The calculator computes the dot product a·b = ax·bx + ay·by + az·bz and the magnitudes |a| = √(ax²+ay²+az²) and |b| = √(bx²+by²+bz²). From these it derives the scalar projection comp_b(a) = (a·b)/|b|, the vector projection proj_b(a) = ((a·b)/|b|²)·b (reported component by component and by its magnitude), and the angle between the vectors θ = cos⁻¹((a·b)/(|a||b|)), which follows directly from the dot-product identity a·b = |a||b|cosθ.
Common mistakes
- Confusing scalar and vector projection: the scalar projection is a single signed number; the vector projection is a full vector pointing along b, obtained by multiplying that scalar's direction ratio back into b.
- Projecting onto the zero vector: the formula divides by |b|² (or |b|), which is undefined when b = (0, 0, 0) — the direction to project onto simply does not exist.
- Ignoring sign: a negative scalar projection is a valid, meaningful result — it means a's shadow points opposite to b, not that something went wrong.
Real-world applications
- Physics uses vector projection to compute work done by a force along a displacement: W = F·d, which is the magnitude of d times the scalar projection of F onto d.
- Decomposing a force into components parallel and perpendicular to an inclined plane relies on projecting the force vector onto the slope direction.
- Gram-Schmidt orthogonalization repeatedly subtracts vector projections to build an orthogonal basis from a set of vectors.
- Computer graphics uses projections for lighting (Lambert's cosine law), shadow mapping, and camera/view transformations.