Projection Calculator
Project vector a onto vector b: scalar projection, projected vector, and the working.
Projection Results
Imagine sunlight hitting a flagpole at an angle. The shadow the pole casts on the ground is a kind of projection: it is the part of the pole’s direction that runs along the ground. Vectors have the same idea. Projecting one vector onto another finds how much of the first vector points in the direction of the second.
This projection calculator performs that operation for two-dimensional vectors. You enter the x and y components of vector a and vector b, and it returns the scalar projection, the vector projection, the dot product, and the magnitude of b, with every step of the working shown. It is a quick way to check homework, test physics ideas, or explore how vectors behave.
What This Calculator Does
Given two vectors, a = (ax, ay) and b = (bx, by), the projection of a onto b answers a simple question: if you drop a perpendicular line from the tip of a down to the line of b, where does it land? The landing point splits into two useful answers. The scalar projection is a single number: the signed length of a’s shadow along b. The vector projection is an actual vector pointing along b with that length.
The calculator produces four values from your inputs. The dot product a · b measures how much the two vectors agree in direction. The magnitude |b| is the length of vector b. The scalar projection equals the dot product divided by |b|. The vector projection takes that scalar and stretches the unit direction of b by it. Along with these, the results panel shows the full substitution of your numbers so you can trace every step.
There is one input the calculator will not accept: a zero vector for b. The direction of projection comes entirely from b, and the zero vector (0, 0) points nowhere, so dividing by its length would be meaningless. If both components of b are zero, the tool explains the problem and asks for a real direction.
How to Use This Calculator
Enter the components of vector a in the first two boxes: its x component and its y component. Then enter the components of vector b in the next two boxes. Components can be positive, negative, or decimal numbers. For example, the vector (3, 4) goes in as x = 3 and y = 4.
Press the Calculate button to see the results instantly. The dot product, the magnitude of b, the scalar projection, and the vector projection all appear below the form, followed by a line that walks through the arithmetic. The Reset button clears the form for a fresh calculation.
Order matters here. Projecting a onto b is not the same as projecting b onto a, so be sure you know which vector is being projected and which one supplies the direction. Swapping them is the most common mistake, and it gives a completely different vector.
The Math Behind Projection
Everything starts with the dot product. For a = (ax, ay) and b = (bx, by), the dot product is a · b = ax×bx + ay×by. It is a single number, not a vector. When both vectors point roughly the same way, the dot product is positive. When they point in opposite directions, it is negative. When they are perpendicular, it is exactly zero.
The magnitude of b is its length, found with the Pythagorean theorem: |b| = √(bx² + by²). Dividing the dot product by this length gives the scalar projection: scalar = (a · b) / |b|. This number tells you how many units of a lie along b. A negative value means a’s shadow falls in the direction opposite to b.
To turn that length back into a vector, multiply the unit vector in the b direction by the scalar. The unit vector is simply b divided by its own length, so the final formula is: proj of a onto b = scalar × (b / |b|). The result always points along the line of b, either with it or against it, and it is the closest vector to a that stays on that line.
A neat fact falls out of this: the difference between a and its projection is always perpendicular to b. That leftover piece is called the orthogonal component, and splitting a vector into a parallel part and a perpendicular part is one of the most useful tricks in physics and engineering.
Worked Example: a = (3, 4), b = (1, 0)
Let a = (3, 4) and b = (1, 0). Since b points straight along the x-axis, the projection should simply pull out the x part of a. Let us verify with the full arithmetic, exactly as the calculator does it.
First the dot product: a · b = 3×1 + 4×0 = 3 + 0 = 3. Next the magnitude of b: |b| = √(1² + 0²) = √1 = 1. The scalar projection is 3 / 1 = 3. The vector projection is 3 × (1, 0) / 1 = (3, 0). As expected, the answer is the vector (3, 0): the horizontal part of a, with the vertical part dropped.
Check the perpendicular leftover: a minus the projection = (3, 4) − (3, 0) = (0, 4). Dotting this with b gives 0×1 + 4×0 = 0, confirming it is perpendicular to b. The original vector has been cleanly split into a part along b and a part across it.
Worked Example With a Negative Scalar
Now take a = (5, −2) and b = (−1, 1). The dot product is 5×(−1) + (−2)×1 = −5 − 2 = −7. The magnitude of b is √((−1)² + 1²) = √2 ≈ 1.4142. The scalar projection is −7 / 1.4142 ≈ −4.9497. The negative sign tells us the shadow of a falls on the extension of b pointing backward.
The vector projection is −4.9497 × (−1, 1) / 1.4142. The x component is −4.9497 × (−1) / 1.4142 = 3.5, and the y component is −4.9497 × 1 / 1.4142 = −3.5. So the projected vector is (3.5, −3.5). You can check it points along the line of b by noting that (−1, 1) scaled by −3.5 gives exactly (3.5, −3.5), which matches.
One more quick case worth knowing: a = (2, 0) and b = (0, 5). The dot product is 2×0 + 0×5 = 0, so the scalar projection is 0 and the vector projection is (0, 0). Perpendicular vectors project to nothing, which is the geometric meaning of a zero dot product.
Interpreting Your Results
The scalar projection is the number to read first. Its size tells you how much of a lines up with b, and its sign tells you whether it lines up with b or against it. A scalar of zero means the vectors are perpendicular and a has no presence along b at all.
The vector projection is the practical answer in most applications. In physics, the work done by a force along a direction of motion is the scalar projection of the force times the distance. In computer graphics, projecting a point onto a line or plane is how shadows and reflections are computed. In statistics, projecting data onto a direction is the core of finding trends.
The dot product and |b| rows are there so you can follow the chain of reasoning. If a result looks surprising, these intermediate numbers usually reveal why. A tiny magnitude of b, for instance, makes the scalar projection large, because dividing by a small length stretches the answer.
Common Mistakes to Avoid
The biggest mistake is projecting the wrong way round. The projection of a onto b and the projection of b onto a are different vectors with different meanings. Always decide first which vector is the one being shadowed and which one provides the direction, then enter them in the matching boxes.
The second mistake is forgetting to divide by the magnitude of b. The dot product alone is not the scalar projection; it must be scaled by |b|. When b happens to be a unit vector with length 1, the dot product and the scalar projection are the same number, which is why working with unit vectors simplifies so many formulas.
Finally, remember that the zero vector cannot serve as b. It has no direction, so “the projection onto it” is undefined. If your b comes out as (0, 0) from some earlier calculation, something went wrong upstream, and the calculator’s message is your cue to check the inputs.
Frequently Asked Questions
1. What is a vector projection?
A vector projection finds the part of one vector that points along another vector. Geometrically, it is the shadow that vector a casts onto the line of vector b when the light shines perpendicular to b. The result is always a vector parallel to b.
2. What is the difference between scalar and vector projection?
The scalar projection is a single number: the signed length of a’s shadow along b. The vector projection is an actual vector with that length pointing along b. The scalar is computed as (a · b) / |b|, and the vector is the scalar multiplied by the unit vector of b.
3. How do you calculate the projection of a onto b?
Compute the dot product a · b, compute the magnitude |b|, divide to get the scalar projection, then multiply the scalar by b / |b|. For a = (3, 4) and b = (1, 0), the dot product is 3, |b| is 1, the scalar is 3, and the projected vector is (3, 0).
4. What does a negative scalar projection mean?
It means the shadow of a falls in the direction opposite to b. This happens when the angle between the vectors is greater than 90 degrees, so their dot product is negative. The projected vector still lies on the line of b, just pointing backward along it.
5. What happens when the vectors are perpendicular?
The projection is the zero vector (0, 0). Perpendicular vectors have a dot product of zero, so the scalar projection is zero too. Geometrically, a vector casts no shadow along a line it is perpendicular to.
6. Why can’t I project onto the zero vector?
The zero vector (0, 0) has no direction and a length of zero. The projection formula divides by |b|, so using the zero vector would mean dividing by zero, which is undefined. This calculator shows an error message and asks for a b that is not (0, 0).
7. Is projecting a onto b the same as projecting b onto a?
No. Projection is not symmetric. Projecting a onto b gives a vector along the line of b, while projecting b onto a gives a vector along the line of a. They coincide only in special cases, such as when the vectors are parallel or one of them is zero.
8. What is the orthogonal component of a vector?
It is what is left of a after you subtract its projection onto b: a − proj(a onto b). This remainder is always perpendicular to b. Splitting a vector into a parallel part and a perpendicular part is a standard technique in physics, for example when resolving forces on an inclined plane.
9. What is a unit vector, and why does it simplify projection?
A unit vector has length 1. If b is a unit vector, then |b| = 1, and the scalar projection is just the dot product a · b, while the vector projection is (a · b) × b. Many textbooks convert b to a unit vector first for exactly this reason.
10. Where is vector projection used in real life?
Physics uses it to find the component of a force along a direction of motion, which determines the work done. Computer graphics uses it for shadows, reflections, and camera projections. Navigation uses it to split velocity into along-track and cross-track parts. Statistics uses it in regression and dimensionality reduction.
11. How is projection related to the angle between vectors?
The dot product equals |a| × |b| × cos(θ), where θ is the angle between the vectors. So the scalar projection of a onto b is also |a| × cos(θ): the adjacent side of the right triangle formed by a and the projection line. This is why the sign of the projection follows the sign of the cosine.
12. Can the scalar projection be larger than the original vector?
No. The scalar projection of a onto b can never exceed the magnitude |a| in absolute value. The largest possible shadow occurs when a points exactly along b, in which case the scalar projection equals |a|. If your result is bigger than |a|, check your inputs.
13. Does this calculator work with three-dimensional vectors?
This version handles two-dimensional vectors with x and y components. The same formulas extend naturally to 3D: the dot product gains a third term (az × bz) and the magnitude gains a third square. For 3D work, apply the formulas by hand or look for a dedicated 3D tool.
14. Why is the dot product shown in the results?
The dot product is the first and most important intermediate step. Showing it lets you verify the calculation chain: dot product, then magnitude, then scalar, then vector. If an answer surprises you, the dot product usually reveals whether the vectors agree or oppose each other.
15. What should I do if I get an error message?
Read the message: it names the exact box that needs attention. The most common trigger is a zero vector for b, meaning both of its components are zero. Enter a b with at least one nonzero component. Empty boxes and non-numeric entries are also flagged so they can be fixed.
Final Thoughts
Vector projection turns an abstract operation into something you can picture: a shadow cast along a direction. Once you see the scalar projection as the signed length of that shadow and the vector projection as the shadow itself, the formulas stop being mysterious. Use this calculator to explore how changing the vectors changes their projection, and the dot product, magnitude, and sign will start to feel like old friends.