Calculate the vector projection, scalar projection, and rejection of one vector onto another in 2D or 3D.
Vector Projection Formula
The vector projection of vector a onto vector b is the part of a that points in the direction of b. It is found by scaling the unit vector of b by the scalar projection.
proj_b(a) = (a . b / |b|^2) * b
The scalar projection (also called the component of a along b) is the signed length of that shadow.
comp_b(a) = a . b / |b|
The vector rejection is the part of a left over once the projection is removed. It is perpendicular to b.
rej_b(a) = a - proj_b(a)
- a is the vector being projected.
- b is the vector you are projecting onto (the direction).
- a . b is the dot product of a and b. In 2D it equals ax*bx + ay*by, and in 3D it equals ax*bx + ay*by + az*bz.
- |b| is the magnitude (length) of b, equal to the square root of b . b.
- proj_b(a) is the vector projection, a vector pointing along b.
- comp_b(a) is the scalar projection, a single signed number.
- rej_b(a) is the vector rejection, perpendicular to b.
Choose your solve-for mode to return any one of these results, or use the full report to see them together. The dot product drives every result: when it is positive the two vectors point the same general way, when it is negative they point opposite ways, and when it is zero the vectors are perpendicular and the projection is zero.
Projection Quantities at a Glance
The table below summarizes what each output is, its formula, and the type of value you get back.
| Quantity | Formula | Result type |
|---|---|---|
| Scalar projection | a . b / |b| | Single number (signed length) |
| Vector projection | (a . b / |b|^2) * b | Vector along b |
| Vector rejection | a - proj_b(a) | Vector perpendicular to b |
The sign of the scalar projection tells you the geometric relationship between the two vectors, which the next table interprets.
| Scalar projection | Angle between a and b | Meaning |
|---|---|---|
| Positive | Less than 90 degrees | a leans in the same direction as b |
| Zero | Exactly 90 degrees | a is perpendicular to b, projection is the zero vector |
| Negative | More than 90 degrees | a leans opposite to b, projection points against b |
Example Problems
Example 1 (2D). Project a = (3, 4) onto b = (1, 0).
- Dot product: a . b = 3*1 + 4*0 = 3.
- Magnitude squared: |b|^2 = 1^2 + 0^2 = 1.
- Scalar projection: 3 / 1 = 3.
- Vector projection: (3 / 1) * (1, 0) = (3, 0).
- Vector rejection: (3, 4) - (3, 0) = (0, 4).
Example 2 (3D). Project a = (2, 1, 2) onto b = (0, 3, 4).
- Dot product: a . b = 2*0 + 1*3 + 2*4 = 11.
- Magnitude squared: |b|^2 = 0^2 + 3^2 + 4^2 = 25, so |b| = 5.
- Scalar projection: 11 / 5 = 2.2.
- Vector projection: (11 / 25) * (0, 3, 4) = (0, 1.32, 1.76).
- Vector rejection: (2, 1, 2) - (0, 1.32, 1.76) = (2, -0.32, 0.24).
Frequently Asked Questions
What is the difference between scalar projection and vector projection?
The scalar projection is a single signed number that gives the length of a along the direction of b. The vector projection takes that length and attaches a direction to it, producing a vector that lies along b. The scalar projection answers how much, while the vector projection answers how much and in which direction.
What is vector rejection?
The vector rejection is whatever is left of a after you subtract the vector projection. It is the component of a that is perpendicular to b. Adding the projection and the rejection back together always reconstructs the original vector a.
Can you project a vector onto the zero vector?
No. The formulas divide by the magnitude of b, and the zero vector has a magnitude of zero, which makes the division undefined. The vector you project onto must have a length greater than zero, so it points in a definite direction.
