Skip to main content

Vector Projection Calculator

Project vector a onto vector b in 2D, 3D, or any dimension: get the vector projection projb(a), the orthogonal component, the scalar projection length, step-by-step working, a 2D diagram, and batch mode — all computed instantly in your browser.

projb(a) = ((a·b) / (b·b)) · b    |    a = projb(a) + orthb(a)
Enter components separated by commas or spaces, e.g. "1, 2, 3". Both vectors need the same number of components. Try the examples: (3,4) onto (1,0), or (1,2,3) onto (1,1,1).

Scope boundary

This page is the projection specialist: the vector-valued projection projb(a), the orthogonal decomposition with a = proj + orth verification, a 2D diagram, and batch mode. For the full dot-product workup — a·b, the angle between vectors, magnitudes, and scalar projections in both directions with per-component show-your-work — use our dot product calculator. For comparing vector magnitudes and norm types, see the vector norm calculator.

Frequently asked questions

What is the vector projection of a onto b?
The vector projection of a onto b, written proj_b(a), is the "shadow" that vector a casts along the direction of vector b. It is a vector that points along b (or exactly opposite to b) and tells you how much of a lies in b's direction. It is computed as proj_b(a) = ((a·b)/(b·b))·b, where a·b is the dot product. The part of a that is left over, perpendicular to b, is called the orthogonal component.
What is the formula for vector projection?
The vector projection formula is proj_b(a) = ((a·b)/(b·b)) × b. In words: first compute the dot product a·b, then compute b·b (the squared length of b), divide to get the scalar factor k = (a·b)/(b·b), and finally multiply every component of b by k. For example, with a = (3, 4) and b = (1, 0): a·b = 3, b·b = 1, k = 3, so proj = 3 × (1, 0) = (3, 0).
What is the difference between scalar projection and vector projection?
The scalar projection is a single number: the signed length of a's shadow along b, computed as (a·b)/|b|. The vector projection is an actual vector: the scalar projection multiplied by b's unit vector, computed as ((a·b)/(b·b))·b. For a = (3, 4) and b = (1, 0), the scalar projection is 3 and the vector projection is (3, 0). The length of the vector projection always equals the absolute value of the scalar projection.
What is the orthogonal component of a vector?
The orthogonal component (also called the perpendicular component) is the part of a that is left after removing its projection onto b: orth_b(a) = a − proj_b(a). It is always perpendicular to b, and together with the projection it reconstructs the original vector exactly: a = proj_b(a) + orth_b(a). For a = (3, 4) and b = (1, 0), the projection is (3, 0) so the orthogonal component is (0, 4).
How do you find the projection of (3, 4) onto (1, 0)?
Step 1: compute a·b = 3×1 + 4×0 = 3. Step 2: compute b·b = 1×1 + 0×0 = 1. Step 3: k = 3/1 = 3. Step 4: proj = 3 × (1, 0) = (3, 0). The orthogonal component is a − proj = (3 − 3, 4 − 0) = (0, 4), and the scalar projection is 3/1 = 3. Check: (3, 0) + (0, 4) = (3, 4), which is the original vector a.
What is the projection of (1, 2, 3) onto (1, 1, 1)?
Step 1: a·b = 1×1 + 2×1 + 3×1 = 6. Step 2: b·b = 1 + 1 + 1 = 3. Step 3: k = 6/3 = 2. Step 4: proj = 2 × (1, 1, 1) = (2, 2, 2). The orthogonal component is (1 − 2, 2 − 2, 3 − 2) = (−1, 0, 1). The scalar projection is 6/√3 = 2√3 ≈ 3.4641. Verification: (2, 2, 2) + (−1, 0, 1) = (1, 2, 3), and the dot product (2, 2, 2)·(−1, 0, 1) = 0, confirming they are perpendicular.
How can I verify that a = proj + orth?
Add the projection and the orthogonal component component-wise: every component of a must equal the sum of the matching components of proj_b(a) and orth_b(a). As a second check, the dot product of the projection and the orthogonal component must be exactly zero, because a true projection is perpendicular to what is left over. This calculator runs both checks automatically and shows the residual, which should be zero up to floating-point rounding.
Can you project a vector onto the zero vector?
No. The projection formula divides by b·b, and for the zero vector b·b = 0, so the projection is undefined — the zero vector has no direction to project onto. This calculator detects a zero b vector and shows an honest error instead of a meaningless number. Projecting the zero vector a onto a nonzero b is fine, though: the result is simply the zero vector with scalar projection 0.
Is vector projection commutative?
No. In general proj_b(a) is not equal to proj_a(b), because the result always points along the second vector. For example, projecting (3, 4) onto (1, 0) gives (3, 0), but projecting (1, 0) onto (3, 4) gives k = 3/25 = 0.12, so the projection is (0.36, 0.48) — a completely different vector pointing along (3, 4). Order matters: the vector after "onto" sets the direction.
What does a negative scalar projection mean?
A negative scalar projection means the angle between a and b is over 90 degrees, so a points partly against b's direction and its shadow falls on the opposite ray. For example, projecting (−3, 4) onto (1, 0): a·b = −3, b·b = 1, k = −3, giving proj = (−3, 0) and scalar projection −3. The negative sign is meaningful — it is not an error — and the length of the projection is still 3.
Can I compute vector projections in more than 3 dimensions?
Yes. The formula proj_b(a) = ((a·b)/(b·b))·b works in any number of dimensions because the dot product is defined component-wise for 2D, 3D, 4D, and beyond. This calculator accepts vectors of any length as long as a and b have the same number of components. The 2D diagram tab is only available for two-component vectors, but the numeric projection, orthogonal component, and scalar projection work for every dimension.
Is there a shortcut when b is a unit vector?
Yes. If b is a unit vector, meaning its length |b| = 1, then b·b = 1 and the formula simplifies to proj_b(a) = (a·b)·b: just take the dot product and multiply it into b. The scalar projection also simplifies to (a·b) directly. This shortcut is common in graphics and physics, where directions are often normalized first. The calculator handles unit and non-unit b identically, so you never need to normalize by hand.
Where is vector projection used in real life?
In physics, mechanical work is the scalar projection of a force along the displacement, W = F·d, and the vector projection gives the effective force component. In computer graphics, projections compute shadows, reflections, and camera-space coordinates. In machine learning and linear algebra, the Gram-Schmidt process builds orthogonal bases by repeatedly subtracting projections, and PCA projects data onto principal directions. Anywhere a quantity must be split into "along this direction" and "perpendicular to it", projection is the tool.
How is this different from the dot product calculator?
This page is the projection specialist: it returns the vector-valued projection proj_b(a), the orthogonal component with an automatic a = proj + orth verification, a 2D SVG diagram, and a batch mode for projecting many vectors onto one direction. The dot product calculator is the a·b specialist: the dot product itself, the angle between the vectors, magnitudes, scalar projections in both directions, and per-component show-your-work. The two tools complement each other and link both ways.
How accurate are the results?
All computation happens 100 percent client-side in your browser using double-precision arithmetic — nothing is sent to any server. The engine was verified against an independent high-precision oracle using exact rational arithmetic: every test vector satisfies a = proj + orth exactly and proj·orth = 0 exactly. The worked anchors on this page, (3, 4) onto (1, 0) giving (3, 0) and (1, 2, 3) onto (1, 1, 1) giving (2, 2, 2), were recomputed independently from the formula and match the engine bit for bit.

Free tool by NRTechStudio