Vector Projection Calculator
Project one vector onto another. Enter the x, y and z components of vector a and vector b to get the vector projection of a onto b, the scalar projection, and the orthogonal rejection.
Example: with a: x 3 · a: y 4 · a: z 0 · b: x 2 · b: y 0 → Projection of a onto b: (3, 0, 0).
- Scalar projection3 (comp of a along b)
- Rejection (a minus projection)(0, 4, 0)
Computed by the calculator below using its default values. Change any input to see your own numbers.
proj_b a = ( (a·b) / |b|² ) b. The scalar projection a·b/|b| is how far a reaches along b; the rejection is what is left over, perpendicular to b.
Shadow along a direction
The projection of a onto b is the shadow a casts along the line of b. Its length is the scalar projection a·b/|b|, and multiplying that by the unit vector of b gives the projection vector itself. Because it depends only on the direction of b, scaling b up or down does not change the projection.
Whatever is left after removing the projection is the rejection: a − proj_b a. It is perpendicular to b by construction, so the projection and the rejection split a into two right-angle pieces. This decomposition is the heart of orthogonal projection, least-squares fitting, and the Gram-Schmidt process.
How it’s calculated
Vector projection proj_b a = ( (a·b) / |b|² ) b, with a·b = axbx+ayby+azbz and |b|² = bx²+by²+bz². The scalar projection (component of a along b) is a·b/|b|. The rejection is a − proj_b a and is orthogonal to b.
b must be nonzero; projecting onto the zero vector is undefined because it has no direction. Sign of the scalar projection is negative when the angle exceeds 90°.
Projections of a onto b
| a | b | proj_b a | scalar |
|---|---|---|---|
| (3, 4) | (2, 0) | (3, 0) | 3 |
| (1, 2) | (0, 1) | (0, 2) | 2 |
| (2, 2) | (1, 0) | (2, 0) | 2 |
| (4, 0) | (0, 5) | (0, 0) | 0 |
Computed with proj_b a = (a·b/|b|²) b and scalar a·b/|b|.
Common mistakes
- Dividing by |b| instead of |b|² in the vector projection formula.
- Confusing the scalar projection (a number) with the vector projection (a vector).
- Projecting onto a without noticing the tool projects a onto b — order matters.
- Forgetting that the scalar projection is negative when the angle between a and b is obtuse.
Frequently asked questions
What is the vector projection formula?
proj_b a = ( (a·b) / |b|² ) b. Divide the dot product by the squared magnitude of b, then scale b by that number.
What is the difference between scalar and vector projection?
The scalar projection a·b/|b| is a single number, the length of a along b. The vector projection multiplies that by the unit vector of b to give an actual vector.
What is the rejection?
The rejection is a minus its projection onto b. It is the part of a perpendicular to b, so the projection and rejection add back up to a at a right angle.
Does projecting a onto b equal projecting b onto a?
No. The two projections generally point in different directions and have different lengths, because each depends on the direction of the vector being projected onto.