Vector Projection Calculator
Project one vector onto another and get the projection vector, its length and the angle between them.
What it does
A projection answers a direct question: how much of one vector points along another? Push a box up a ramp and only the part of your push that runs parallel to the ramp moves it forward. That parallel part is the vector projection, and it is built from the dot product of the two vectors.
The algebra is short. Divide the dot product of a and b by the squared length of b, then multiply the result by b. The divisor is squared because you first shrink b to a unit vector and then stretch it back out to its original length. The answer is a vector that sits on the line through b.
Two related numbers come from the same dot product. The length of the projection is the absolute value of the dot product divided by the length of b, and the angle between the vectors follows from the cosine form of the dot product. This page reports both so you can see how size and direction fit together.
For the defaults a = (3, 4) and b = (2, 1), the dot product is 10 and b dot b is 5. The scale is 2, so the projection is (4, 2), its length is 4.472 and the angle between the two vectors is 26.6 degrees. Change any component and the tool redraws all five results at once.
The tool works in two dimensions and treats components as plain numbers. If your components carry units, the projection carries those same units, but both vectors must use the same ones. There is no unit switch on this page because vector math does not need one.
How to use
- Enter the x and y components of vector a.
- Enter the x and y components of vector b, which must not be the zero vector.
- Read the projection vector first, written as an ordered pair.
- Check the two component rows if you need the x and y parts separately.
- Use the length row for the magnitude of the shadow a casts on b.
- Use the angle row to see how far a points away from b.
Formula
- a
- The vector being projected, with components ax and ay.
- b
- The vector that sets the direction, with components bx and by. It cannot be zero.
- a · b
- The dot product ax bx + ay by, a single number.
- b · b
- The squared length of b, equal to bx squared + by squared.
- proj_b(a)
- The projection vector, always parallel to b.
- theta
- The angle between a and b, reported from 0 to 180 degrees.
The scale (a · b)/(b · b) can be negative, which turns the projection to point opposite b, but the reported length uses an absolute value and stays nonnegative. The leftover a minus the projection is at right angles to b. The angle is undefined when a is the zero vector, and the tool says so instead of showing a number.
Worked example
Example: project (3, 4) onto (2, 1)
Defaults: a = (3, 4) and b = (2, 1).
- Dot product: a · b = 3 x 2 + 4 x 1 = 10.
- Squared length of b: b · b = 2 squared + 1 squared = 5.
- Scale: 10 / 5 = 2.
- Projection: 2 x (2, 1) = (4, 2).
- Length: |10| / square root of 5 = 4.472.
- Angle: cosine = 10 / (5 x 2.236) = 0.8944, so the angle is 26.6 degrees.
- The tool shows (4, 2), 4, 2, 4.472 and 26.6 deg.
Reference table
| Vectors a and b | Projection of a on b | Length and angle |
|---|---|---|
| (3, 4) on (2, 1) | (4, 2) | 4.472 at 26.6 deg |
| (6, 2) on (3, 4) | (3.12, 4.16) | 5.2 at 34.7 deg |
| (1, 0) on (0, 1) | (0, 0) | 0 at 90 deg |
| (-2, 5) on (1, -1) | (-3.5, 3.5) | 4.95 at 156.8 deg |
Limits
- Works in two dimensions only. A three dimensional pair needs an extra z term in the dot product.
- Vector b cannot be zero, since there is no line to project onto. The tool rejects that input.
- Components are unitless here. If you supply metres, both vectors must be in metres or the projection has no meaning.
- Results are rounded to three decimals and the angle to one decimal, so long repeating values are trimmed.
Common mistakes
- Dividing by |b| instead of |b| squared when building the vector projection, which gives a scalar instead of a vector.
- Forgetting to multiply the scale by b after computing it, and reporting the scale as the final answer.
- Mixing up the direction of projection, projecting b onto a when the question asks for a onto b.
- Reporting a negative length when the scale is negative. The length uses an absolute value.
- Treating the projection as the perpendicular part of a. The two are at right angles to each other.
Try it yourself
Quick checks. Answers sit tucked under each question.
Project (6, 2) onto (3, 4).
The dot product is 26 and b dot b is 25, so the scale is 1.04 and the projection is (3.12, 4.16). Its length is 5.2 and the angle is 34.7 deg.
Project (1, 0) onto (0, 1).
The dot product is zero, so the scale is 0 and the projection is (0, 0). Its length is 0 and the two vectors are 90 deg apart.
Project (-2, 5) onto (1, -1).
The dot product is -7 and b dot b is 2, so the scale is -3.5 and the projection is (-3.5, 3.5). Its length is 4.95 and the angle is 156.8 deg.
Questions
What is a vector projection?
It is the shadow one vector casts on the line through another. The result is a vector parallel to the second vector whose length equals the first vector's component in that direction.
How is this different from a scalar projection?
A scalar projection is just the signed length (a · b)/|b|. The vector projection multiplies that length by a unit vector along b, so it has both size and direction.
Can the scale factor be negative?
Yes. A negative dot product means the angle exceeds 90 degrees, so the projection points opposite b. The reported length is still positive because it uses an absolute value.
Why divide by b dot b instead of the length of b?
Dividing the dot product by |b| gives a length. To rebuild a vector you must also restore the direction of b, which means dividing once more by |b| and multiplying by b.
What happens for perpendicular vectors?
The dot product is zero, so the projection is the zero vector and its length is zero. There is no overlap at all along the direction of b.
Does the projection ever exceed the length of a?
No. Its length is |a| times the absolute cosine of the angle, and a cosine never has a magnitude above 1. Equality happens only when the vectors are parallel or antiparallel.
Sources
- OpenStax Calculus Volume 3: 2.3, The Dot Product
- University of Michigan Calculus III: Projections and components
- Oregon State University: Dot Products and Projections