A vector projection calculator finds the projection of vector a onto vector b: the part of a that points along b. Enter the components of both vectors, separated by commas, and the calculator returns the projection vector, the scalar projection, the dot product, the angle between the vectors and the steps.
It works for 2D vectors such as (3, 4), 3D vectors such as (2, 3, 4), and vectors with up to six components. The two vectors must have the same number of components.
This calculator needs JavaScript. Please enable it in your browser.
How the vector projection calculator works
The projection formula
The projection of a onto b is the vector along b whose length matches how far a reaches in the direction of b.
proj_b a = (a · b ÷ b · b) × b
The scalar projection, also called the component of a along b, is a single number: the signed length of that shadow.
comp_b a = a · b ÷ |b|
Finding the dot product
Multiply matching components and add the results. For a = (a1, a2, a3) and b = (b1, b2, b3), a · b = a1b1 + a2b2 + a3b3.
The perpendicular part
Subtracting the projection from a leaves the component of a that is perpendicular to b. The projection and this remainder always add back up to a.
Worked examples
Example 1: 2D vectors
Project a = (3, 4) onto b = (5, 0). The dot product is 3 × 5 + 4 × 0 = 15 and b · b = 25.
proj_b a = (15 ÷ 25) × (5, 0) = (3, 0)
The scalar projection is 15 ÷ 5 = 3, which is the x-part of a.
Example 2: 3D vectors
Project a = (2, 3, 4) onto b = (1, 2, 2). The dot product is 2 + 6 + 8 = 16 and b · b = 1 + 4 + 4 = 9.
proj_b a = (16 ÷ 9) × (1, 2, 2) ≈ (1.7778, 3.5556, 3.5556)
The scalar projection is 16 ÷ 3 ≈ 5.3333, and the perpendicular part is a minus the projection, about (0.2222, −0.5556, 0.4444).
Example 3: perpendicular vectors
For a = (1, 2) and b = (−2, 1), the dot product is −2 + 2 = 0. The projection is the zero vector, because perpendicular vectors share no direction.
How to read the result
| Result | Meaning |
|---|---|
| Positive scalar projection | a points partly the same way as b |
| Negative scalar projection | a points partly against b |
| Zero | a and b are perpendicular |
Frequently asked questions
What is the difference between scalar and vector projection?
The scalar projection is a single signed number, the length of the shadow of a along b. The vector projection multiplies that length by the unit vector along b, so it is a vector.
How do you find the projection of a onto b?
Work out a · b and b · b, divide the first by the second, then multiply every component of b by that number.
Can a vector projection be negative?
The scalar projection can be negative when the angle between the vectors is greater than 90 degrees. The projection vector then points opposite to b.
Can you project onto the zero vector?
No. The formula divides by b · b, which is zero for the zero vector, so the projection is undefined.
Does the order of the vectors matter?
Yes. Projecting a onto b is not the same as projecting b onto a, although both use the same dot product.