StatGardenREF. DESK
Calculators/Maths/Vector projection
Maths

Vector projection calculator

Projects vector a onto vector b in 3D (set z = 0 for 2D vectors).

Published 8 August 2026 · Updated 24 September 2026

What this calculator does

Projecting a onto b asks how much of a points along b. The answer comes in two forms: a scalar giving the length of that component, and a vector giving the component itself.

The extremes make it clear. Projecting (3, 4, 0) onto the x-axis gives (3.000, 0, 0), keeping only the x part, while projecting (0, 4, 0) onto the same axis gives the zero vector, since nothing of it points that way.

The formula

Formulascalar projection = (a·b)/|b|; vector projection = [(a·b)/|b|²]·b

The dot product of a and b divided by the magnitude of b gives the scalar projection. Dividing instead by the squared magnitude and multiplying by b gives the vector projection.

TermMeaning
Scalar projectionThe signed length of the component of a along b.
Vector projectionThat component as a vector, pointing along b.
Orthogonal componentWhat remains of a after the projection is removed.

The inputs explained

FieldWhat to enter
a: xVector a, x component.
a: yVector a, y component.
a: zVector a, z component.
b: xVector b, x component. This is the direction being projected onto.
b: yVector b, y component.
b: zVector b, z component.

When to use it

Resolving a force

Splitting a force into components along and across a surface is a projection.

Computer graphics

Reflections and shadows both rely on projecting vectors onto directions.

Least squares fitting

Regression is projection onto a subspace, and this is the simplest case.

Worked examples

Every figure in the tables below is produced by this page’s own calculator at build time, so the numbers and the tool always agree. Select any row to load that scenario.

How much of each vector lies along the x-axis?

Three vectors projected onto the same direction.

Projecting onto (5, 0, 0)
Vector a x component (y = 4)Vector projectionScalar projection
(0, 4, 0) (0, 0, 0)0
(3, 4, 0) (3.000, 0, 0)3.000
(5, 4, 0) (5.000, 0, 0)5.000
The vector (0, 4, 0) is perpendicular to the x-axis, so its projection is the zero vector with a scalar projection of 0. At (3, 4, 0) the projection is (3.000, 0, 0), keeping only the x component regardless of how large y is.

Questions

Why are there two kinds of projection?

Because sometimes you want the length and sometimes the vector. The scalar tells you how far along b the shadow of a falls; the vector tells you where that shadow actually sits in space.

Can the scalar projection be negative?

Yes, when the angle between the vectors exceeds 90 degrees. A negative value means the component points opposite to b rather than along it, which the vector projection reflects by pointing backwards.

Why does the magnitude of b not matter for the vector projection?

Because dividing by the squared magnitude and multiplying by b cancels the scale. Only the direction of b affects the result, which is why projecting onto (5, 0, 0) and (1, 0, 0) gives the same answer.

What is the orthogonal component?

Whatever is left after subtracting the projection from a. The two components together reconstruct a, and they are perpendicular to each other, which is the basis of orthogonal decomposition.

For the dot product behind it, see the dot product calculator. For vector length, see the vector magnitude calculator.