2D Vector Projection Calculator

Project vector A onto vector B in two dimensions.
Returns scalar projection, vector projection, perpendicular component, and angle between vectors.

Vector Projection

The projection of vector A onto vector B answers: how much of A points in the direction of B?

Scalar projection (component of A along B):

comp = (A dot B) / |B|

This is a signed number. Positive means A and B point in roughly the same direction. Negative means they point in roughly opposite directions. The absolute value is the length of the vector projection.

Vector projection:

proj = (A dot B / |B|^2) x B

This is a vector pointing in the direction of B with magnitude equal to the scalar projection. It is the “shadow” of A cast onto the line through B.

Perpendicular component:

A_perp = A - proj

This is the part of A orthogonal to B. Together, the projection and the perpendicular component reconstruct A: proj + A_perp = A.

Angle between vectors:

theta = arccos( (A dot B) / (|A| x |B|) )

Common uses. In physics, projections decompose forces along and perpendicular to a surface. Finding the component of gravity acting down a ramp is the standard first example. In machine learning, dot products and projections turn up in neural network activations and in principal component analysis (PCA). In computer graphics, a projection is how you work out how much light lands on a surface.

If the scalar projection is zero, the vectors are orthogonal and their dot product is zero. If it equals |A|, then A lies entirely along B.

A worked example

Take A = (3, 4) and B = (1, 0). B points straight along the x-axis, so the projection should simply pick off A’s x-component.

  • A · B = 3(1) + 4(0) = 3
  • |B| = 1, so the scalar projection is 3/1 = 3
  • proj = (3/1²)(1, 0) = (3, 0)
  • A_perp = (3, 4) − (3, 0) = (0, 4)
  • Check: (3, 0) + (0, 4) = (3, 4) = A ✓

The angle works out at arccos(3 / (5 × 1)) = 53.13°, and cos(53.13°) × 5 = 3, which is the scalar projection again. That is not a coincidence: the scalar projection is |A| cos θ, and the whole subject is that one fact written four different ways.

One thing worth watching. Projecting A onto B is not the same as projecting B onto A. The dot product is symmetric but the divisor is not, so swapping the two inputs gives a different vector unless |A| and |B| happen to be equal.


How we build and check this calculator

This calculator runs entirely in your browser, so the numbers you enter stay on your device. The math behind it is written by hand and tested against worked examples and standard references before the page goes live.

SuperGlobalCalculator is independently built and maintained. See how we build and verify our calculators.


Embed This Calculator

Copy the code below and paste it into your website or blog.
The calculator will work directly on your page.