Audited 29 Jul 2026·Last updated 31 Jul 2026·4 citations·Tier 2·0 uses

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

Vector dimension
Vector a is the vector being projected. The order matters: projecting a onto b is not the same as projecting b onto a.
Used only in 3D mode.
Vector b is the direction being projected onto. It must not be the zero vector.
Used only in 3D mode.
Projection proj_b a
2i + 4j + 4k
The part of a that lies along b, written in î/ĵ/k̂ notation. Shown to 6 decimal places; exact components are listed below. Projecting a onto b is not symmetric — swapping the two inputs gives a different vector.
Scalar projection comp_b a
6
Projection x component
2
Projection y component
4
Projection z component
4
Rejection x component
0
Rejection y component
-2
Rejection z component
2
Distance from a to the line through b
2.8284
Dot product a·b
18
Magnitude ‖b‖
3

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.

  1. Choose 2D or 3D. In 2D the z fields are ignored and treated as exactly 0.
  2. Enter vector a — the vector you want to split up.
  3. Enter vector b — the direction you want to project onto. Order matters: swapping a and b gives a different answer.
  4. Read the projection vector proj_b a at the top. That is the part of a that lies along b.
  5. 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°.
  6. 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.
  7. Check your own working by adding the projection and the rejection component by component: the total must be exactly vector a.

The formula.

proj_b a = ( (a·b) ⁄ ‖b‖² ) b , comp_b a = (a·b) ⁄ ‖b‖

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.

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).

bx1
ax2
by2
ay2
bz2
az6
dimension3

Frequently asked questions.

What is the difference between the scalar projection and the vector projection?
The scalar projection comp_b a = (a·b)/‖b‖ is a single signed number: the length of the shadow a casts on b, positive if the shadow points the same way as b and negative if it points the other way. The vector projection proj_b a = ((a·b)/‖b‖²)b is that same shadow expressed as a vector, so it carries both the length and the direction. The relationship between them is proj_b a = comp_b a × b̂, where b̂ is the unit vector along b. Use the scalar when you only need a magnitude — for example the component of a force along a ramp — and the vector when you need to subtract it from something, as in Gram-Schmidt orthogonalisation or in sliding a character along a wall.
Why is my scalar projection negative?
Because the angle between your two vectors is greater than 90°. The scalar projection carries the sign of the dot product, and the dot product is ‖a‖‖b‖cos θ, which goes negative once θ passes 90°. Geometrically it means the shadow of a falls on the opposite side of the origin from b, so the projection vector points against b. This is a correct result, not an error, and the sign is often the most useful part of the answer: in a physics problem a negative component along the direction of motion is exactly what identifies a decelerating or resisting force. If you want the unsigned length of the projection, take the absolute value.
Is projecting a onto b the same as projecting b onto a?
No. Only the vector being projected onto appears in the denominator, so the two results generally differ in both length and direction — proj_b a points along b, while proj_a b points along a. For the default inputs, projecting a = (2, 2, 6) onto b = (1, 2, 2) gives 2i + 4j + 4k, but projecting b onto a gives a much shorter vector pointing along a. The only quantity that is symmetric here is the dot product itself, a·b = b·a. This is why the input fields on this page are labelled explicitly rather than being called 'first vector' and 'second vector'.
What is the vector rejection, and why would I want it?
The rejection is what is left of a after the projection is removed: rej_b a = a − proj_b a. It is perpendicular to b by construction, so the pair gives you an orthogonal decomposition of a into 'along b' and 'across b'. Its magnitude is the shortest distance from the tip of a to the line through the origin in the direction of b, which is the standard way to compute a point-to-line distance in two, three or any number of dimensions. In least-squares regression the rejection is the residual vector; in collision handling it is the part of a velocity that survives sliding along a surface; in Gram-Schmidt it is the new orthogonal basis vector before normalisation.
Why can't I project onto the zero vector?
Two reasons, and they are the same reason from different angles. Algebraically, the formula divides by ‖b‖², which is 0 for the zero vector, so the expression is undefined. Geometrically, the zero vector points nowhere, so 'the component of a in the direction of b' has no meaning — there is no line to cast a shadow on. This calculator raises a field error rather than returning zeros, because silently returning the zero vector would hide the real problem, which is almost always upstream: two coincident points, a degenerate edge, or a direction that cancelled out. Projecting the zero vector a onto a non-zero b is fine, though, and correctly returns the zero vector.
How does projection relate to the dot product and to work in physics?
The dot product is the projection with the normalisation left in. Since a·b = ‖a‖‖b‖cos θ, dividing by ‖b‖ isolates ‖a‖cos θ — the length of a in b's direction, which is the scalar projection. That is why mechanical work is written W = F·d: the only part of a force that does work is its projection onto the displacement, and the dot product computes exactly that, multiplied by the displacement's length. The same reasoning explains why a force perpendicular to the motion does no work at all — its projection onto the displacement is the zero vector, and the dot product is zero.
Does this work for vectors with more than three components?
The formula does — proj_b a = ((a·b)/‖b‖²)b is dimension-agnostic and is used routinely on vectors with thousands of components in statistics and machine learning. This page's input form is limited to 2D and 3D, because those are the cases people work by hand and the ones that appear in calculus, mechanics and graphics courses. If you are working with high-dimensional vectors and want a direction-only comparison rather than a decomposition, the cosine similarity calculator takes arbitrary-length lists and normalises both vectors for you.

In this category

Embed

Quanta Pro

Paid features are coming later.

  • All 977 calculators remain free
  • No billing is enabled
Coming soon