Vector Projection Calculator

Created by Miroslav Jerkovic, PhD
Reviewed by Bogna Szyk and Jack Bowater
Last updated: Aug 31, 2022
Table of contents:

This vector projection calculator finds the orthogonal projection of one vector onto the other. We start with two vectors, a and b, which are not on the same line. Imagine a light source above the vectors. Now, think of the vector projection of a onto b as the shadow that vector a projects on the direction of vector b.

This is why this type of vector is known as an orthogonal projection vector (marked as proj in the image):

Another, more technical, way of intuiting the idea of vector projection is to ask a question: how much of the vector a goes in the same direction of vector b?

Let us now move on to the details and discuss the vector projection formula.

What is the vector projection formula?

Here is the orthogonal projection formula you can use to find the projection of a vector a onto the vector b:

proj = (a·b / b·b) × b

The formula utilizes the vector dot product, a·b, also called the scalar product.

But where did this vector projection formula come from?

In the image above, there is a hidden vector. This is the vector orthogonal to vector b, sometimes also called the rejection vector (denoted by ort in the image):

How to derive the vector projection formula?

Here is a step-by-step procedure on how to get to the vector projection formula:

1. Decompose the vector a into a sum of the projection and the rejection vectors: a = proj + ort

2. Express proj as proj = a - ort

3. Also, since proj is parallel to b, we can write it as proj = C × b, where C is some unknown factor we want to determine

4. Now we have C × b = a - ort

5. Calculate the dot product of both sides of this equation with the vector b: C × b·b = a·b - ort·b

6. Since the vector ort is orthogonal to the vector b, their dot product is zero, and we have C × b·b = a·b

7. Finally, we have C = a·b / b·b.

When you insert this expression for C into proj = C × b, you get the formula:

proj = (a·b / b·b) × b!

Since this formula uses the dot product, which can be defined for vectors of any integer dimension, this formula covers vectors of any dimensionality. Its practical applications are for 2-D and 3-D vectors, which is why our calculator is designed for vectors with two or three components.

Also, please be aware that this formula is sometimes called the orthogonal projection formula. If we followed this terminology, we'd have to call our calculator the orthogonal projection calculator. There isn't a big difference. Either way, it'll work the same :)!

How to use the vector projection calculator

Let a and b be a = 2i -3j + 5k and b = 3i + 6j - 4k. From this point on, we will write these 3-D vectors in their component form

a = [2, -3, 5] and b = [3, 6, -4].

Use the vector projection calculator to find out the projection of vector a onto vector b. The result we get is:

proj = [-1.5738, -3.1475, 2.0984]

If you want to calculate the projection by hand, use the vector projection formula p = (a·b / b·b) × b and follow this step-by-step procedure:

1. Calculate the dot product of vectors a and b: a·b = 2×3 + (-3)×6 + 5×(-4) = -32

2. Calculate the dot product of vector b with itself: b·b = 3×3 + 6×6 + (-4)×(-4) = 61

3. Insert these two dot products into the vector projection formula to get proj = (-32/61) × [3, 6, -4] = [-96/61, -192/61, 128/61].

This result, when expressed decimally, equals the result obtained by this calculator.

Maybe you wondered what happens when a is orthogonal to b; what does the projection proj look like? In this case, the shadow of vector a that is perpendicular to b should be non-existent, so we should get the null vector.

This is reflected in the vector projection formula: if a and b are orthogonal, their dot product is zero: a·b = 0. Now we have:

proj = (0 / b·b) × b = 0 × b = 0.

Explore this special case is shown in the following example:

a = [2, 6, -3] and b = [6, 4, 12].

You shouldn't be surprised when [0, 0, 0] pops out since this is the correct result!

Vector projection in physics – playing with forces

One of the most straightforward, and maybe the most interesting, applications of the vector projection formula comes from the physics of forces and their decomposition.

Imagine a cart rolling down the slope of the hill. What is the force one should use to counterbalance the force of the cart? Of course, this counterforce is dependent on the weight of the cart: the more massive the cart, the harder it will be to stop. Also, the slope of the hill itself plays a role - the steeper the hill is, the more force you will need to stop the cart. Here is an image of the situation:

Here α is the angle of the hill's slope relative to the ground, and F the force of gravity between the cart and the Earth. Notice that vector F is perpendicular to the ground, not to the hill's slope itself.

To find the force needed to counterbalance gravity's action on the cart, we should calculate the projection of the force vector F along the direction of the hill. Let's say that F = 400 N (which corresponds to the cart with a mass of around m = 40 kg) and that the hill's slope is α = 45°.

The question is, how do you find a vector along the direction of the hill's slope, the one to project the force vector F on? We can use any vector that has the same direction as the hill's slope, so the most convenient one will be the unit vector u = [cos 45°, sin 45°], marked as the blue vector on the above image. Also, for the force vector F we take F = [0, -400]. The negative sign here means that force F is directed downwards.

Use the vector projection calculator and choose to work with vectors in two dimensions, since we're dealing with a two-dimensional problem. So, the vector a will be equal to the force vector F;

a = [0, -400],

and the vector b is obtained from the vector u, using the sine and cosine calculators to find the values for sin 45° and cos 45°:

b = [0.70710678, 0.70710678].

Working with these numbers, we get the projection vector:

proj = [-200, -200].

Since we want to know the magnitude of the counterbalancing force, we can use the vector magnitude calculator to find the magnitude of proj. It is equal to 282.84 N.

If you play a bit with the hill's slope, i.e., with the angle α, you will see that the less narrow the hill, the smaller force you will need, while in the case of a larger α – a steeper hill – you will need a larger required reactive force.

Besides physics and the problem of finding a component of force along a given direction, vector projection is widespread in one of the most fashionable real-world applications of science, namely data science.

What are the applications of vector projections in data science?

Vector projection is used in the important statistical problem of linear regression, as well as in principal component analysis, one of the most used methods in data science.

Here, one is confronted with the task of representing many, possibly high-dimensional, data points within a space of lower dimensionality in such a way that there is as minimal information loss as possible.

FAQ

How do I calculate the projection of vector a on b?

To determine the projection of a vector a onto the vector b:

1. Compute the dot product a·b.
2. Compute the dot product b·b. This is the same as the squared norm of b.
3. Divide the result of Step 1 by that of Step 2. That is, a·b / b·b.
4. The final result is the coefficient from Step 3 times the vector b onto which we project: proj = (a·b / b·b) × b.

What is the length of vector projection?

You can find the length of the projection of a vector a onto the vector b using the formula a·b / |b|, where a·b is the dot product and |b| is the length of the vector b (the one onto which we project).

What is the projection of [3,4] onto [1,1]?

The answer is [3.5, 3.5]. To derive this result, we apply the formula proj = (a·b / b·b) b with a = [3,4] and b = [1,1]. Indeed, we have a·b = 7 and b·b = 2, so the answer follows easily.

Miroslav Jerkovic, PhD
Dimensions
3D
Vector a
x
y
z
Vector b
x
y
z
Projection of a onto b
x
y
z
Projection factor
People also viewed…

Bit shift

The bit shift calculator lets you perform logical bit shift operations to the left and right on inputs from different numeral systems.

Car vs. Bike

Everyone knows that biking is awesome, but only this Car vs. Bike Calculator turns biking hours into trees! 🌳

Cube Calc: find v, a, d

This cube calc finds V (volume), a (area) and d (diagonal) of a cube.

Test grade

With this test grade calculator you'll easily find out the test percentage score and grade.