Vector Projection Calculator
Project one vector onto another in 2D or 3D. Returns the projection vector, the signed scalar projection, the perpendicular rejection and the full working.
Vector Projection Calculator
Background.
The Quanta vector projection calculator splits one vector into two pieces: the part that lies along a second vector, and the part left over at right angles to it. Enter vector a and vector b in 2D or 3D and it returns the projection vector proj_b a, the signed scalar projection, the perpendicular rejection a − proj_b a, the distance from the tip of a to the line through b, and the two intermediate quantities the formula runs on — the dot product a·b and the magnitude ‖b‖. With the default vectors a = (2, 2, 6) and b = (1, 2, 2), the calculator returns a dot product of 18, a magnitude of 3 for b, a scalar projection of 6, and a projection vector of 2i + 4j + 4k.
Projection is the operation behind an enormous amount of applied mathematics, usually under a different name. When a physics problem asks for the component of a force along an inclined plane, that component is a projection. When mechanical work is computed as W = F·d, the useful part of the force is its projection onto the displacement, which is exactly why the dot product appears in the definition. In statistics, ordinary least-squares regression is the projection of the observed response vector onto the column space of the design matrix, and the residuals are the rejection — the geometry is not an analogy, it is the same computation. In computer graphics, sliding a character along a wall means removing the component of its motion that points into the wall, which is subtracting a projection. Gram-Schmidt orthogonalisation, the QR decomposition and every orthogonal-basis construction repeat this one step.
Two things about the result surprise people, so both are stated beside the answer rather than buried. First, the scalar projection is signed. If the angle between a and b is more than 90°, the dot product is negative and so is the scalar projection, meaning the projection vector points in the opposite direction to b. That is the correct answer, not a sign error. Second, the operation is not symmetric: proj_b a and proj_a b are different vectors, because only b appears in the denominator. This calculator labels the fields explicitly — a is the vector being projected, b is the direction it is projected onto — so the order is never ambiguous.
The rejection is worth as much as the projection in practice. Because it is perpendicular to b by construction, its magnitude is the shortest distance from the tip of a to the infinite line through b, which is how a point-to-line distance is computed in any number of dimensions. The two pieces always add back to the original: proj + rej = a. That reconstruction is the single best check on a hand computation, and this calculator preserves it exactly by never rounding the scale factor before multiplying it through b.
The one rejected input is a zero vector b. There is no direction to project onto, and the formula divides by ‖b‖², so the calculator raises a field error instead of returning a misleading result. A zero vector a is perfectly legal — its projection is the zero vector.
What is vector projection calculator?
The vector projection of a onto b, written proj_b a, is the vector that points along b and represents 'how much of a goes in b's direction'. OpenStax Calculus Volume 3, §2.3 'The Dot Product', gives it as Equation 2.6: proj_v u = ((u·v)/‖v‖²)v, and the companion scalar projection as Equation 2.7: comp_v u = (u·v)/‖v‖. Wolfram MathWorld's 'Projection' entry states the identical formula in its Equation 1. The scalar projection is the signed length of that vector — positive when a and b point broadly the same way, negative when the angle between them exceeds 90°, and zero exactly when the two are perpendicular, which by Theorem 2.5 of the same OpenStax section is precisely the condition a·b = 0. The vector rejection, a − proj_b a, is the remainder: the component of a that is perpendicular to b. Together the two pieces reconstruct the original vector, a = proj_b a + rej_b a, which is the orthogonal decomposition of a with respect to the direction b. Because the rejection is perpendicular to b, its magnitude equals the shortest distance from the tip of a to the line through the origin in the direction of b. The operation is asymmetric — proj_b a and proj_a b generally differ, since only the vector being projected onto appears in the denominator — and it is undefined when b is the zero vector, which has no direction.
How to use this calculator.
- Choose 2D or 3D. In 2D the z fields are ignored and treated as exactly 0.
- Enter vector a — the vector you want to split up.
- Enter vector b — the direction you want to project onto. Order matters: swapping a and b gives a different answer.
- Read the projection vector proj_b a at the top. That is the part of a that lies along b.
- Read the scalar projection if you need the signed length rather than the vector. A negative value means the projection points opposite to b, which happens whenever the angle between a and b is greater than 90°.
- Read the rejection components for the leftover perpendicular part, and its magnitude for the shortest distance from the tip of a to the line through b.
- Check your own working by adding the projection and the rejection component by component: the total must be exactly vector a.
The formula.
The calculator computes two numbers first: the dot product a·b = axbx + ayby + azbz, and the squared magnitude ‖b‖² = bx² + by² + bz². Dividing one by the other gives a single dimensionless scale factor, and multiplying that factor through the components of b gives the projection vector. This is OpenStax Calculus Volume 3, Equation 2.6, and the same identity appears as Equation 1 of Wolfram MathWorld's 'Projection' entry.
For the worked example a = (2, 2, 6) and b = (1, 2, 2): the dot product is (2)(1) + (2)(2) + (6)(2) = 2 + 4 + 12 = 18, and ‖b‖² = 1 + 4 + 4 = 9, so the scale factor is 18/9 = 2 exactly. Multiplying b by 2 gives the projection 2i + 4j + 4k. The magnitude ‖b‖ is the single square root of 9, which is 3, so the scalar projection is 18/3 = 6.
Why the two forms differ: the scalar projection divides by ‖b‖ once and answers 'how long is the shadow'; the vector projection divides by ‖b‖ twice — once to normalise b to a unit direction and once to convert the dot product into a length along that direction — and answers 'what is the shadow, as a vector'. Written with the unit vector b̂ = b/‖b‖, the two collapse to comp_b a = a·b̂ and proj_b a = (a·b̂)b̂, which is the form most often used in proofs.
The rejection is then simple subtraction: rej = a − proj = (2−2, 2−4, 6−4) = (0, −2, 2). It is orthogonal to b by construction, and you can verify that here: (0)(1) + (−2)(2) + (2)(2) = −4 + 4 = 0, which is exactly the orthogonality condition of Theorem 2.5. Its magnitude is √(0 + 4 + 4) = √8 = 2.8284271247, the shortest distance from the tip of a to the line through b.
Sign convention: the dot product carries the sign of cos θ, so the scalar projection is negative whenever the angle between a and b exceeds 90°. The sign flips exactly at a·b = 0, where the projection collapses to the zero vector and the rejection equals a in full. Nothing on this page is sorted into bands or grades, so no threshold is affected by display rounding.
Rounding stage: every intermediate is carried at 40 significant digits in Decimal arithmetic and rounded once, at the return boundary, to 10 decimal places. In particular the scale factor (a·b)/‖b‖² is never rounded before it is multiplied through b — rounding it there is what makes the reconstruction proj + rej = a fail in the last digits. The projection shown in î/ĵ/k̂ notation is a display label trimmed to 6 decimal places; the exact components are listed underneath it.
A worked example.
A cable anchored along the direction b = (1, 2, 2) is asked to carry a load whose force vector is a = (2, 2, 6) kilonewtons, and an engineer needs to know how much of that load acts along the cable and how much tries to bend it sideways. The dot product is a·b = (2)(1) + (2)(2) + (6)(2) = 2 + 4 + 12 = 18. The cable direction has magnitude ‖b‖ = √(1 + 4 + 4) = √9 = 3, so ‖b‖² = 9 and the scale factor is 18/9 = 2 exactly. Multiplying the direction vector by 2 gives the projection 2i + 4j + 4k — that is the part of the load carried along the cable, and its signed length, the scalar projection, is 18/3 = 6 kilonewtons. Because the value is positive, the load pulls along the cable rather than against it. Subtracting the projection from the original load leaves the rejection (0, −2, 2): the sideways component that the cable cannot resist. It is genuinely perpendicular to the cable, which you can confirm from (0)(1) + (−2)(2) + (2)(2) = 0, and its magnitude is √(0 + 4 + 4) = 2.8284271247 kilonewtons — also the shortest distance from the tip of the load vector to the line of the cable. The two pieces add back exactly to the original load: (2, 4, 4) + (0, −2, 2) = (2, 2, 6).
Frequently asked questions.
What is the difference between the scalar projection and the vector projection?
Why is my scalar projection negative?
Is projecting a onto b the same as projecting b onto a?
What is the vector rejection, and why would I want it?
Why can't I project onto the zero vector?
How does projection relate to the dot product and to work in physics?
Does this work for vectors with more than three components?
References& sources.
- [1]OpenStax, Calculus Volume 3 (2016 ed., web revision retrieved 2026-07-29), §2.3 ‘The Dot Product’ — Equation 2.6 (vector projection proj_v u = ((u·v)/‖v‖²)v), Equation 2.7 (scalar projection comp_v u = (u·v)/‖v‖), Theorem 2.4 (u·v = ‖u‖‖v‖cos θ), Theorem 2.5 (orthogonality iff u·v = 0). Open access.
- [2]Wolfram Research, MathWorld — ‘Projection’ (live revision retrieved 2026-07-29), Equation 1: proj_u a = ((a·u)/|u|²)u. Independent statement of the same identity with different symbols.
- [3]OpenStax, University Physics Volume 1 (2016 ed.), §2.4 ‘Products of Vectors’ — Equation 2.27 (A·B = AB cos φ) and Equation 2.33 (component form AxBx + AyBy + AzBz), the dot product on which the projection formula is built, stated in a physics register.
- [4]Paul Dawkins, Paul's Online Notes (Lamar University), Calculus II — ‘Dot Product’, Example 5: projecting ⟨1, 0, −2⟩ onto ⟨2, 1, −1⟩ gives ⟨4/3, 2/3, −2/3⟩. Used as the independent cross-check for this page's projection output; the values agree to 10 decimal places.
In this category
Embed
Quanta Pro
Paid features are coming later.
- All 977 calculators remain free
- No billing is enabled