projection of a vector calculator

Vector Projection Calculator

Find the projection of vector a onto vector b, plus scalar projection, orthogonal component, and angle.

Use comma or space-separated values (2D, 3D, or nD).
Projection is computed as projb(a).

What is projection of a vector?

The projection of one vector onto another tells you how much of the first vector points in the direction of the second. It is a core concept in linear algebra, geometry, physics, graphics, and machine learning.

If you have vectors a and b, the vector projection of a onto b is:

projb(a) = (a · b / ||b||2) b

The scalar projection (sometimes called the component of a in the direction of b) is:

compb(a) = a · b / ||b||

How to use this calculator

  • Enter vector a in the first input box.
  • Enter vector b (the direction vector) in the second box.
  • Choose the number of decimal places you want.
  • Click Calculate Projection.

The calculator returns:

  • Dot product a · b
  • Magnitude values ||a|| and ||b||
  • Vector projection projb(a)
  • Scalar projection compb(a)
  • Orthogonal component a - projb(a)
  • Angle between vectors (in degrees)

Worked example

Example vectors

Suppose a = (3, 4, 0) and b = (1, 2, 2). The dot product is 3·1 + 4·2 + 0·2 = 11. Since ||b||² = 1² + 2² + 2² = 9, the projection factor is 11/9.

So the vector projection is:

projb(a) = (11/9) (1, 2, 2) = (11/9, 22/9, 22/9)

This gives the exact part of a that lies along b. The rest belongs to the perpendicular component.

Why vector projection matters

1) Physics and engineering

Resolve forces into parallel and perpendicular parts, analyze motion on slopes, and model work done by a force along a path.

2) Computer graphics and game development

Used for lighting calculations, collision responses, camera movement, and directional constraints.

3) Data science and machine learning

Projection underpins least squares, PCA intuition, feature decomposition, and geometric interpretations of model fitting.

Common mistakes to avoid

  • Mixing vector dimensions (for example, projecting a 2D vector onto a 3D vector).
  • Using a zero vector for b (projection direction cannot have zero length).
  • Confusing scalar projection with vector projection.
  • Forgetting that projection is directional: projb(a) is not generally equal to proja(b).

Quick FAQ

Can this calculator handle 2D and 3D vectors?

Yes. It also supports any n-dimensional vectors, as long as both vectors have the same number of components.

What if I enter spaces instead of commas?

That works too. You can use either commas or spaces (or both).

What happens if b = 0?

The calculator will show an error because projection onto a zero vector is undefined.

Final note

Vector projection is one of the most practical tools in mathematics. If you understand this operation, you gain a powerful geometric lens for solving real-world problems in science, coding, and analysis.

🔗 Related Calculators