Connect via MCP →

Enter Calculation

Leave the z components blank for 2D vectors. This computes the projection of a onto b.

Formula

Advertisement

Results

Projection of a onto b
(3, 0, 0)
proj_b(a)
Scalar factor (a·b)/(b·b) 3
Dot product a·b 3
Dot product b·b 1
Magnitude of projection 3

What is vector projection?

The vector projection of a onto b is the "shadow" that vector a casts onto the line defined by vector b. The result is itself a vector pointing in the same (or opposite) direction as b. It answers the question: how much of a lies along the direction of b? This is a foundational operation in physics (resolving forces), computer graphics, machine learning, and linear algebra.

Diagram showing vector a, vector b, and the projection of a onto b with a perpendicular dropline
The projection of a onto b is the shadow of a along the direction of b.

How to use this calculator

Enter the components of vector a and vector b. For two-dimensional vectors, simply leave the z fields blank (they default to 0). Click calculate and you'll get the full projection vector, the scalar factor, both dot products, and the magnitude (length) of the projection.

The formula explained

The projection is computed as:

$$\operatorname{proj}_{\vec{b}}\vec{a} = \frac{\vec{a}\cdot\vec{b}}{\vec{b}\cdot\vec{b}}\,\vec{b}$$

First take the dot product \(\vec{a}\cdot\vec{b} = \text{a}_x\text{b}_x + \text{a}_y\text{b}_y + \text{a}_z\text{b}_z\). Then divide by \(\vec{b}\cdot\vec{b}\) (the squared length of b) to get a scalar factor. Finally multiply that scalar by each component of b to scale it. Note that b must be non-zero; if b is the zero vector the projection is undefined and we return zero.

Advertisement
Geometric breakdown of the projection formula showing scalar length along b times the direction of b
The scalar factor (a·b)/(b·b) scales vector b to give the projection vector.

Worked example

Let a = (4, 1) and b = (2, 3). Then \(\vec{a}\cdot\vec{b} = 4\cdot 2 + 1\cdot 3 = 11\), and \(\vec{b}\cdot\vec{b} = 2^2 + 3^2 = 13\). The scalar factor is \(\tfrac{11}{13} \approx 0.8462\). The projection vector is $$0.8462 \cdot (2, 3) = (1.6923,\ 2.5385)$$ with magnitude \(\sqrt{1.6923^2 + 2.5385^2} \approx 3.0509\).

FAQ

What is the difference between scalar and vector projection? The scalar projection is the signed length \(\tfrac{\vec{a}\cdot\vec{b}}{|\vec{b}|}\), a single number. The vector projection (computed here) multiplies that direction by the unit vector of b, giving an actual vector.

Can the projection point opposite to b? Yes — if \(\vec{a}\cdot\vec{b}\) is negative, the scalar factor is negative and the projection vector points in the opposite direction of b.

Does this work in 3D? Yes. Just fill in the z components for both vectors. Leave them blank for 2D problems.

Last updated: