Vector Projection Calculator
Project vector a onto vector b in 2D or 3D: the projection vector, signed scalar projection, perpendicular rejection and the distance from a to b's line.
Vector Projection Calculator
Background.
Set a 10 kg box on a ramp that rises 3 units for every 4 across, and its weight of 98.1 newtons, pointing straight down, splits into two parts: 58.86 N pulling it down the slope and 78.48 N pressing it into the surface. Finding those parts is a vector projection. You take one vector, a, and ask how much of it lies along a chosen direction, b. Whatever is left over sits at right angles to b.
Enter a and b as components, in the plane or in space, and both parts come back. The projection proj_b a is the piece along b, written in i, j, k notation with each component also listed on its own. The scalar projection is its signed length. The rejection, a − proj_b a, is the perpendicular remainder, and its length is the shortest distance from the tip of a to the line through the origin along b. The dot product a·b and the length ‖b‖ are reported as well, since every other figure is built from those two. The same split drives a game character sliding along a wall instead of stopping dead, and the Gram–Schmidt process building an orthogonal basis one vector at a time.
Two properties of the answer are easy to misread. The scalar projection is signed, so it comes out negative whenever a and b are more than 90° apart; on the ramp, a b pointing uphill gives −58.86 N. And the operation is not symmetric: projecting a onto b and projecting b onto a give different vectors, so check which set of fields each one goes in.
What is vector projection calculator?
The vector projection of a onto b is the vector running from the origin to the point on b's line nearest the tip of a, which is where a perpendicular dropped from the tip of a meets that line. Its signed length, called the scalar projection or the component of a along b, equals ‖a‖ cos θ, where θ is the angle between the two vectors: positive below 90°, zero at exactly 90°, negative beyond. Only the direction of b enters the result. Doubling b, or swapping it for a unit vector pointing the same way, leaves everything unchanged; reversing b keeps the projection vector the same but flips the sign of the scalar projection, because that length is measured along b.
How to use this calculator.
- Choose 2D or 3D. In 2D the z boxes are ignored and both vectors are taken to lie in the xy-plane.
- Enter a, the vector you want to split, in the first set of fields: a force, a velocity, a column of data, or the position of a point measured from somewhere on the line.
- Enter b, the direction, in the second set. Its length does not matter, so (1, 2, 2) and (2, 4, 4) give the same projection, but at least one component must be non-zero.
- Read proj_b a for the part along b and the scalar projection for its signed length. A negative scalar means the projection points opposite to b.
- For a point-to-line distance read the rejection magnitude. To check hand working, add the projection and rejection component by component; the sum must be a.
The formula.
Everything rests on the dot product, a·b = axbx + ayby + azbz, which also equals ‖a‖‖b‖ cos θ (OpenStax Calculus Volume 3, section 2.3). Dividing it once by ‖b‖ = √(bx² + by² + bz²) leaves ‖a‖ cos θ, the scalar projection: comp_b a = (a·b) ⁄ ‖b‖. Multiplying that length by the unit vector b ⁄ ‖b‖ turns it into a vector, which gives proj_b a = ((a·b) ⁄ ‖b‖²) b. The fraction in front is a plain number, the scale factor, and it says what multiple of b the projection is: 2 means twice b, −0.5 means half of b turned around.
The rejection is r = a − proj_b a. Its dot product with b is a·b − ((a·b) ⁄ ‖b‖²)(b·b) = 0 for any inputs, so it is always perpendicular to b, and its length √(rx² + ry² + rz²) is the shortest distance from the tip of a to the line through b. By Pythagoras, comp² + ‖r‖² = ‖a‖². When a and b are perpendicular the dot product is zero, the projection shrinks to the zero vector and the rejection is all of a; when a is parallel to b the rejection vanishes. The one input with no answer is b = 0, since ‖b‖² would sit in the denominator as zero and a zero vector has no direction. A zero a is allowed and simply projects to zero.
A worked example.
With a = (2, 2, 6) and b = (1, 2, 2), begin with the dot product: 2 × 1 + 2 × 2 + 6 × 2 = 2 + 4 + 12 = 18. The squared length of b is 1² + 2² + 2² = 9, so ‖b‖ = 3. The scale factor is 18 ÷ 9 = 2, and twice b is (2, 4, 4), so the projection is 2i + 4j + 4k. Its signed length is 18 ÷ 3 = 6, positive because the vectors are only about 25.2° apart (cos θ = 18 ÷ (3 × √44) ≈ 0.9045). The rejection is a minus the projection: (2 − 2, 2 − 4, 6 − 4) = (0, −2, 2). Dotting it with b gives 0 × 1 + (−2) × 2 + 2 × 2 = 0, which confirms the right angle, and its length is √(0 + 4 + 4) = √8 = 2.8284. The tip of a therefore sits 2.8284 units from the line through b. The pieces fit together exactly: (2, 4, 4) + (0, −2, 2) = (2, 2, 6), and 6² + 8 = 44 = ‖a‖².
Frequently asked questions.
My scalar projection is negative. Did I enter something wrong?
How do I get the distance from a point to a line that does not pass through the origin?
Is projecting a onto b the same as projecting b onto a?
Does it matter how long I make the direction vector b?
How does projection connect to the work done by a force?
What does projection have to do with least-squares fitting?
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.
How this page was produced
- Published by
- Quanta Calculator
- Overseen by
- Daniel, Quanta Calculator Researcher
- Primary sources
- 4 cited below
- Method
- proj_b a = ( (a·b) ⁄ ‖b‖² ) b , comp_b a = (a·b) ⁄ ‖b‖
- Published
- Last verified
Built with AI assistance and verified by automated tests against the cited sources — every worked example on this page is computed by the same code that runs the calculator. How we build and check calculators.
In this category
Embed
Quanta Pro
Paid features are coming later.
- All 1560 calculators remain free
- No billing is enabled