What this calculator does
Projecting a onto b asks how much of a points along b. The answer comes in two forms: a scalar giving the length of that component, and a vector giving the component itself.
The extremes make it clear. Projecting (3, 4, 0) onto the x-axis gives (3.000, 0, 0), keeping only the x part, while projecting (0, 4, 0) onto the same axis gives the zero vector, since nothing of it points that way.
The formula
The dot product of a and b divided by the magnitude of b gives the scalar projection. Dividing instead by the squared magnitude and multiplying by b gives the vector projection.
| Term | Meaning |
|---|---|
| Scalar projection | The signed length of the component of a along b. |
| Vector projection | That component as a vector, pointing along b. |
| Orthogonal component | What remains of a after the projection is removed. |
The inputs explained
| Field | What to enter |
|---|---|
| a: x | Vector a, x component. |
| a: y | Vector a, y component. |
| a: z | Vector a, z component. |
| b: x | Vector b, x component. This is the direction being projected onto. |
| b: y | Vector b, y component. |
| b: z | Vector b, z component. |
When to use it
Resolving a force
Splitting a force into components along and across a surface is a projection.
Computer graphics
Reflections and shadows both rely on projecting vectors onto directions.
Least squares fitting
Regression is projection onto a subspace, and this is the simplest case.
Worked examples
Every figure in the tables below is produced by this page’s own calculator at build time, so the numbers and the tool always agree. Select any row to load that scenario.
How much of each vector lies along the x-axis?
Three vectors projected onto the same direction.
| Vector a x component (y = 4) | Vector projection | Scalar projection |
|---|---|---|
| (0, 4, 0) | (0, 0, 0) | 0 |
| (3, 4, 0) | (3.000, 0, 0) | 3.000 |
| (5, 4, 0) | (5.000, 0, 0) | 5.000 |
Questions
Why are there two kinds of projection?
Because sometimes you want the length and sometimes the vector. The scalar tells you how far along b the shadow of a falls; the vector tells you where that shadow actually sits in space.
Can the scalar projection be negative?
Yes, when the angle between the vectors exceeds 90 degrees. A negative value means the component points opposite to b rather than along it, which the vector projection reflects by pointing backwards.
Why does the magnitude of b not matter for the vector projection?
Because dividing by the squared magnitude and multiplying by b cancels the scale. Only the direction of b affects the result, which is why projecting onto (5, 0, 0) and (1, 0, 0) gives the same answer.
What is the orthogonal component?
Whatever is left after subtracting the projection from a. The two components together reconstruct a, and they are perpendicular to each other, which is the basis of orthogonal decomposition.
For the dot product behind it, see the dot product calculator. For vector length, see the vector magnitude calculator.