Vector Projection Calculator
Calculate the vector projection proj_b(a) = (a·b/|b|²)·b and scalar projection comp_b(a) = a·b/|b|. Decomposes a into parallel and perpendicular components, computes the angle, and shows Gram-Schmidt orthogonalization steps.
proj_b(a) x
—
proj_b(a) y —
proj_b(a) z —
Scalar projection comp_b(a) —
Angle between a and b (deg) —
Extended More scenarios, charts & detailed breakdown ▾
proj_b(a)
—
Scalar projection —
a dot b —
Professional Full parameters & maximum detail ▾
Projection & Angle
proj_b(a) —
Angle (deg) —
Orthogonality check —
Gram-Schmidt & Applications
Gram-Schmidt step —
Applications —
How to Use This Calculator
- Enter vectors a and b (up to 3D) — projection appears instantly.
- Use Scalar Projection tab for the signed length component.
- Use Decomposition tab to split a into parallel and perpendicular parts.
Formula
proj_b(a) = (a·b / |b|²) · b
comp_b(a) = a·b / |b|
a = a_parallel + a_perp
Example
a=[3,4,0], b=[1,0,0]: proj_b(a) = (3/1)*[1,0,0] = [3,0,0]. comp = 3. Angle = 53.13°.
Frequently Asked Questions
- The vector projection of a onto b, written proj_b(a), is the component of a that lies in the same direction as b. The formula is proj_b(a) = (a·b / |b|²) · b, where a·b is the dot product and |b|² is the squared length of b. Example: a = [3, 4], b = [1, 0]. Dot product = 3·1 + 4·0 = 3. |b|² = 1. proj_b(a) = (3/1) · [1, 0] = [3, 0]. Intuitively, this "shadows" a onto the direction of b. A common pitfall is dividing by |b| instead of |b|² — that gives the scalar projection (a number), not the vector projection (a vector in the direction of b).
- The scalar projection of a onto b, written comp_b(a), is the signed length of the vector projection. Formula: comp_b(a) = a·b / |b|. It equals |a|·cos(θ) where θ is the angle between a and b. Example: a = [3, 4], b = [1, 0]. comp_b(a) = (3·1 + 4·0) / √(1² + 0²) = 3/1 = 3. If the angle between a and b exceeds 90°, the scalar projection is negative — meaning a has a component pointing opposite to b. Common pitfall: forgetting to divide by |b| (not |b|²) — this gives the dot product, not the scalar projection. The scalar projection is a unitless signed number, while the vector projection is a vector.
- Any vector a can be decomposed into two orthogonal components relative to a direction b: a parallel component a_∥ = proj_b(a) = (a·b / |b|²) · b, and a perpendicular component a_⊥ = a − a_∥. These satisfy a_∥ · a_⊥ = 0 (orthogonal) and a_∥ + a_⊥ = a (they sum to the original). Example: a = [3, 4], b = [1, 0]. a_∥ = [3, 0] (parallel to b). a_⊥ = [3, 4] − [3, 0] = [0, 4] (perpendicular to b). Check: [3, 0] · [0, 4] = 0 ✓. This decomposition is used in physics (resolving force along a slope) and linear algebra (least-squares fitting).
- The Gram-Schmidt process converts a set of linearly independent vectors into an orthogonal (or orthonormal) basis. Starting with vectors v₁, v₂, …, vₙ: u₁ = v₁; u₂ = v₂ − proj_{u₁}(v₂); u₃ = v₃ − proj_{u₁}(v₃) − proj_{u₂}(v₃); and so on. Example: v₁ = [1, 1], v₂ = [1, 0]. u₁ = [1, 1]. proj_{u₁}(v₂) = ([1,0]·[1,1]/|[1,1]|²)·[1,1] = (1/2)·[1,1] = [0.5, 0.5]. u₂ = [1, 0] − [0.5, 0.5] = [0.5, −0.5]. Now u₁ · u₂ = 0.5 − 0.5 = 0 ✓. The resulting vectors are orthogonal. Divide each by its length to get an orthonormal basis. Common pitfall: forgetting to subtract all previous projections — missing one projection leaves non-orthogonal vectors.
- Vector projection is a fundamental tool in many fields. In 3D computer graphics, lighting calculations use the dot product and projection to determine how much light hits a surface — the angle between the light vector and the surface normal determines brightness. In physics, resolving forces along inclined planes uses projection: the component of gravity along the slope is g·sin(θ), which equals the scalar projection. In statistics, ordinary least squares regression minimizes the perpendicular distance from data points to the fitting hyperplane — geometrically, the fitted values are the projection of the response vector onto the column space of the design matrix. A common pitfall is projecting onto the wrong vector — you must project onto b (the target direction), not a.
Related Calculators
Sources & References (5) ▾
- Introduction to Linear Algebra — Gilbert Strang — Wellesley-Cambridge Press
- OpenStax University Physics Vol 1 — Vectors — OpenStax
- MIT OCW 18.02 Multivariable Calculus — Dot Product and Projection — MIT OpenCourseWare
- Khan Academy — Vector Projections — Khan Academy
- MathWorld — Vector Projection — Wolfram Research