Scalar Projection Calculator

Find the signed scalar projection of a onto b, the angle between them and the perpendicular leftover.

Physics and EnergyUpdated 2026-11-183 min read
Scalar Projection Calculator
Scalar projection of a onto b
...
Angle between the vectors...
Length of vector a...
Perpendicular component of a...

What it does

A scalar projection reduces two vectors to a single signed number. It tells you how far vector a reaches in the direction of vector b, measured as a length with a sign. Work is the classic example: the useful part of a pulling force is its scalar projection onto the direction of travel.

The formula divides the dot product a dot b by the length of b. Dividing by the length rather than the squared length is what makes the answer a number instead of a vector. An equivalent view is to take the length of a and multiply by the cosine of the angle between the two arrows.

The sign is not decoration. A positive value means a leans in the same general direction as b, a negative value means it leans the other way, and zero means the arrows are at right angles. Because the sign is kept, the scalar projection can be smaller than zero even though a length cannot.

For the defaults a = (3, 4) and b = (2, 1), the dot product is 10 and |b| is the square root of 5, about 2.236. The scalar projection is 4.472, the angle is 26.6 degrees and the part of a at right angles to b is 2.236. All four rows update together when you change a component.

This page stays in two dimensions and uses unitless components. If the components describe a physical quantity, both vectors must share its units, and the scalar projection then carries those units too.

How to use

  1. Type the x and y components of vector a, the one being measured.
  2. Type the x and y components of vector b, the direction being measured against. It cannot be zero.
  3. Read the scalar projection first. A negative sign means a points partly against b.
  4. Check the angle row to see the separation in degrees, from 0 to 180.
  5. Use the length of a when you need the full size of the original vector.
  6. Use the perpendicular component for the part of a that is at right angles to b.

Formula

comp_b(a) = (a · b)/|b| = |a| cos(theta), with a · b = ax bx + ay by and |b| = square root of (bx squared + by squared). Perpendicular component = square root of (|a| squared minus comp squared).
a
The vector whose component is being found, with components ax and ay.
b
The reference vector, with components bx and by. It cannot be zero.
a · b
Dot product ax bx + ay by, a signed number.
|b|
Length of b, the square root of bx squared + by squared.
comp_b(a)
The signed scalar projection of a along b, also called the component of a in the b direction.
theta
Angle between a and b, from 0 to 180 degrees.

The scalar projection keeps its sign, so it is negative whenever the angle is greater than 90 degrees. The length |a| is found with the same Pythagorean step used for |b|. The perpendicular component comes from the Pythagorean relation |a| squared = comp squared + perp squared, and the tool clamps tiny negative roundoff to zero. If a is the zero vector the angle is undefined and is shown as such.

Worked example

Example: scalar projection of (3, 4) onto (2, 1)

Defaults: a = (3, 4) and b = (2, 1).

  1. Dot product: a · b = 3 x 2 + 4 x 1 = 10.
  2. Length of b: |b| = square root of (4 + 1) = 2.236.
  3. Scalar projection: 10 / 2.236 = 4.472.
  4. Length of a: |a| = square root of (9 + 16) = 5.
  5. Angle: cosine = 10 / (5 x 2.236) = 0.8944, giving 26.6 degrees.
  6. Perpendicular component: square root of (25 minus 4.472 squared) = square root of 5 = 2.236.
  7. The tool shows 4.472, 26.6 deg, 5 and 2.236.

Reference table

Scalar projections for four vector pairs
Vectors a and bScalar projectionAngle and perpendicular
(3, 4) on (2, 1)4.47226.6 deg, 2.236
(6, 2) on (3, 4)5.234.7 deg, 3.6
(1, 0) on (0, 1)090 deg, 1
(-2, 5) on (1, -1)-4.95156.8 deg, 2.121

Limits

  • Limited to two dimensions. Three dimensional vectors need a z term in the dot product and the length.
  • Vector b must be nonzero because its length is the divisor. The tool returns an error for that input.
  • The result is signed, so it is not a geometric length. Use the absolute value if you only want a distance.
  • Values are rounded to three decimals, with the angle to one decimal, so repeating roots are trimmed.

Common mistakes

  • Dividing by |b| squared, which gives the scale of the vector projection rather than the scalar length.
  • Dropping a negative sign. A negative scalar projection is meaningful and says the vectors mostly oppose each other.
  • Using the length of a as the projection, which ignores the angle between the two vectors.
  • Assuming the perpendicular component equals the scalar projection. They are the two legs of a right triangle with a as hypotenuse.
  • Reading the angle from the scalar projection alone without dividing by the length of a.

Try it yourself

Quick checks. Answers sit tucked under each question.

Find the scalar projection of (6, 2) onto (3, 4).

The dot product is 26 and |b| is 5, so the scalar projection is 5.2. The angle is 34.7 deg and the perpendicular component is 3.6.

Find the scalar projection of (-2, 5) onto (1, -1).

The dot product is -7 and |b| is 1.414, so the scalar projection is -4.95. The angle is 156.8 deg and the perpendicular component is 2.121.

When is a scalar projection exactly zero?

When the dot product is zero. For example (1, 0) onto (0, 1) gives 0 at an angle of 90 deg, so neither vector reaches in the other's direction.

Questions

What does a scalar projection represent?

The signed distance you would travel along b to reach the foot of the perpendicular dropped from the tip of a. It is the component of a in the b direction.

Why can the answer be negative?

Because the sign records direction. If the angle between the vectors is greater than 90 degrees the cosine is negative, so the component of a along b points the other way.

How is this linked to the dot product?

The dot product equals the scalar projection times the length of b. Dividing the dot product by |b| isolates the projection.

What is the perpendicular component for?

It is the part of a that is lost when projecting onto b. Together the scalar projection and the perpendicular component rebuild a through Pythagoras.

Is the scalar projection the same as work?

Not by itself. Work is the scalar projection of the force onto the displacement multiplied by the displacement length, so the units and the extra factor matter.

What if the reference vector is very short?

Any nonzero length works. A short b still defines a direction, and dividing by its length simply rescales the same component of a.

Sources

How this page was checked. The formula above was matched against the cited sources, and the worked example was run through the tool on this page before publishing. If you spot an error, contact us so we can fix it and note the correction.