ZestCalc

Vector Projection Calculator

Project one vector onto another, exactly. Get the shadow it casts, how long that shadow is, and the perpendicular part left over.

Vectors

Enter the vector a and the vector b to project it onto, or start from an example.

Entries2
a=a =
b=b =

Projection

Updates as you type.

Vector projection
proj⁡ba=(95, 35)\operatorname{proj}_b a = \left(\frac{9}{5},\ \frac{3}{5}\right)
Scalar projection
comp⁡ba=3105\operatorname{comp}_b a = \frac{3\sqrt{10}}{5}
Orthogonal remainder
a−proj⁡ba=(−45, 125)a - \operatorname{proj}_b a = \left(-\frac{4}{5},\ \frac{12}{5}\right)
Check
(a−proj⁡ba)⋅b=0(a - \operatorname{proj}_b a) \cdot b = 0

The shadow points the same way as b, and it's a positive multiple of b.

What a projection is

The projection of aa onto bb is the shadow aa casts on the line through bb, with light falling straight down at a right angle to that line. The shadow is a multiple of bb, and the Dot Product and Angle Calculator gives the multiple:

proj⁡ba=a⋅bb⋅b b\operatorname{proj}_b a = \frac{a \cdot b}{b \cdot b}\, b

The scalar projection is the shadow's signed length. It's negative when the shadow points against bb:

comp⁡ba=a⋅b∣b∣\operatorname{comp}_b a = \frac{a \cdot b}{|b|}

The perpendicular part

Whatever isn't in the shadow is left over, and it's always perpendicular to bb:

a=proj⁡ba+(a−proj⁡ba)a = \operatorname{proj}_b a + \left(a - \operatorname{proj}_b a\right)

So any vector splits into a part along bb and a part at a right angle to it. You can confirm that the second part is perpendicular by checking that its dot product with bb is 0, which is the check shown with the result.

Two special cases are worth knowing. If aa is perpendicular to bb, its shadow is the zero vector. If aa is already along bb, it's its own shadow and nothing is left over. Projecting onto the zero vector isn't defined, since it has no direction.

Where it comes up

  • Physics. Splitting a force along a ramp and against it is a projection.
  • Closest point. The tip of the shadow is the closest point on the line to the tip of aa. That idea is the basis of least squares.
  • Building perpendicular vectors. Subtracting projections one at a time is how Gram-Schmidt turns any basis into an orthogonal one.
  • As a matrix. Projection onto a line is a linear transformation that flattens the plane, and it has rank 1. Try the projection preset in the Linear Transformation Visualizer, then check it with the Matrix Rank Calculator.