Vector Projection Calculator

Enter two 3D vectors a and b to get the scalar projection, vector projection of a onto b, and the angle between them.

Quick Facts

Scalar projection
comp_b(a) = (a·b) / |b|
The signed length of a's shadow on b.
Vector projection
proj_b(a) = ((a·b) / |b|²) × b
The shadow expressed as a vector pointing along b.
Angle between vectors
θ = cos⁻¹((a·b) / (|a||b|))
Comes from the dot-product definition a·b = |a||b|cosθ.

Your Results

Calculated
Scalar projection comp_b(a)
-
(a·b) / |b|
Vector projection proj_b(a)
-
((a·b) / |b|²) × b
Magnitude of proj_b(a)
-
|proj_b(a)|
Angle between a and b
-
θ = cos⁻¹((a·b) / (|a||b|))

Ready

Enter the components of vectors a and b, then press Calculate.

Formula and Method for Vector Projection

The vector projection of a vector a onto a nonzero vector b is the component of a that points in the direction of b — geometrically, the "shadow" a casts onto the line through b when light falls perpendicular to b. It is built from the dot product: proj_b(a) = ((a·b) / |b|²) × b, where a·b is the dot product of the two vectors and |b|² is the squared magnitude of b. A closely related quantity is the scalar projection (also called the component of a along b), comp_b(a) = (a·b) / |b|, which is just the signed length of that shadow — positive when the angle between the vectors is under 90°, negative when it exceeds 90°.

How the calculation works

Enter the x, y, and z components of vectors a and b (use z = 0 for a 2D problem). The calculator computes the dot product a·b = ax·bx + ay·by + az·bz and the magnitudes |a| = √(ax²+ay²+az²) and |b| = √(bx²+by²+bz²). From these it derives the scalar projection comp_b(a) = (a·b)/|b|, the vector projection proj_b(a) = ((a·b)/|b|²)·b (reported component by component and by its magnitude), and the angle between the vectors θ = cos⁻¹((a·b)/(|a||b|)), which follows directly from the dot-product identity a·b = |a||b|cosθ.

Common mistakes

  • Confusing scalar and vector projection: the scalar projection is a single signed number; the vector projection is a full vector pointing along b, obtained by multiplying that scalar's direction ratio back into b.
  • Projecting onto the zero vector: the formula divides by |b|² (or |b|), which is undefined when b = (0, 0, 0) — the direction to project onto simply does not exist.
  • Ignoring sign: a negative scalar projection is a valid, meaningful result — it means a's shadow points opposite to b, not that something went wrong.

Real-world applications

  • Physics uses vector projection to compute work done by a force along a displacement: W = F·d, which is the magnitude of d times the scalar projection of F onto d.
  • Decomposing a force into components parallel and perpendicular to an inclined plane relies on projecting the force vector onto the slope direction.
  • Gram-Schmidt orthogonalization repeatedly subtracts vector projections to build an orthogonal basis from a set of vectors.
  • Computer graphics uses projections for lighting (Lambert's cosine law), shadow mapping, and camera/view transformations.

Frequently Asked Questions

What is the formula for vector projection?
The vector projection of a onto b is proj_b(a) = ((a·b)/|b|²) × b, where a·b is the dot product and |b|² is the squared magnitude of b. This scales b by how much of a points in b's direction.
What is the difference between scalar projection and vector projection?
Scalar projection (also called the component of a along b) is a single number, comp_b(a) = (a·b)/|b|, representing the signed length of a's shadow on b. Vector projection is that same shadow expressed as a full vector, proj_b(a) = (comp_b(a)/|b|) × b, pointing in the direction of b.
What does a negative projection mean?
A negative scalar projection means the angle between a and b is greater than 90°, so a's shadow on b points in the opposite direction of b rather than the same direction.
What are real-world uses of vector projection?
Vector projection is used to find the work done by a force (W = F·d, the projection of force onto displacement), to decompose forces into parallel and perpendicular components on an incline, in Gram-Schmidt orthogonalization, and in computer graphics for lighting and shadow calculations.