Vector Projection Calculator (2D & 3D)

Enter two vectors by components, as complete vectors, or by 2D magnitude and direction. Choose which vector to project, then receive the vector and scalar projections, perpendicular rejection, dot product, angle, magnitudes, cross product, areas, and substituted steps.

Enter vectors

Dimensions
Input format
Vector A

Vector B

Decimals, fractions such as 1/2, and roots such as sqrt(3) are accepted.

Try a preset

Choose a relationship to populate and calculate immediately.

2D vector diagram

  • Solid: A
  • Dashed: B
  • Solid red: projection
  • Dotted: perpendicular component

The scale will adjust automatically after calculation.

No vectors are plotted yet. Enter two vectors and calculate.

Advertisement

Enter two vectors, choose the projection direction, and select Calculate projection. Your existing results will stay visible if you need to correct an input.

Vector projection formulas

Let A be the source vector, B the target vector, θ the smaller angle between them, and ‖V‖ the magnitude of vector V. Scalar projection is a signed length; vector projection has both components and direction.

Dot product

2D: A · B = AxBx + AyBy
3D: add AzBz

Magnitude

‖A‖ = √(Ax2 + Ay2 + Az2)

Angle

θ = cos−1((A · B)/(‖A‖‖B‖))

Scalar projection

compB(A) = (A · B)/‖B‖

Projection coefficient

k = (A · B)/‖B‖2

Vector projection

projB(A) = ((A · B)/‖B‖2)B = kB

Rejection

rejB(A) = A − projB(A)

2D determinant

det(A,B) = AxBy − AyBx

3D cross product

A × B = (AyBz − AzBy, AzBx − AxBz, AxBy − AyBx)

Areas

Parallelogram = ‖A × B‖
Triangle = ½‖A × B‖

Worked vector projection examples

1. Project A onto B in 2D

Inputs: A = (3, 4), B = (1, 0).

  1. A · B = (3)(1) + (4)(0) = 3.
  2. ‖B‖ = √(12 + 02) = 1, so k = 3/12 = 3.
  3. projB(A) = 3(1, 0) = (3, 0).
  4. compB(A) = 3/1 = 3; rejection = (3, 4) − (3, 0) = (0, 4).
  5. θ = cos−1(3/(5·1)) = 53.1301°.

The horizontal part of A is 3 units; the remaining 4 units point perpendicular to B.

2. Negative scalar projection

Inputs: A = (−3, 4), B = (2, 0).

  1. A · B = (−3)(2) + (4)(0) = −6.
  2. ‖B‖ = 2, so compB(A) = −6/2 = −3.
  3. k = −6/4 = −1.5 and projB(A) = −1.5(2, 0) = (−3, 0).
  4. Rejection = (−3, 4) − (−3, 0) = (0, 4); θ = 126.8699°.

The negative scalar says A's along-B component points opposite B.

3. Orthogonal vectors

Inputs: A = (2, 1), B = (−1, 2).

  1. A · B = (2)(−1) + (1)(2) = 0.
  2. k = 0/5 = 0, so projB(A) = (0, 0).
  3. Rejection = A − 0 = (2, 1).
  4. θ = cos−1(0) = 90°.

A zero dot product verifies that these nonzero vectors are perpendicular.

4. 3D cross product and area

Inputs: A = (1, 2, 3), B = (4, 5, 6).

  1. A × B = ((2)(6) − (3)(5), (3)(4) − (1)(6), (1)(5) − (2)(4)).
  2. A × B = (−3, 6, −3).
  3. ‖A × B‖ = √(9 + 36 + 9) = √54 = 3√6 ≈ 7.3485.
  4. Triangle area = ½(3√6) = 3√6/2 ≈ 3.6742.

The cross-product vector is perpendicular to both inputs; its magnitude is the parallelogram area.

Calculation method and accuracy

Author and mathematics review: Starlight Tools Editorial Team. Reviewed: 15 July 2026.

The calculator evaluates permitted numeric input locally, computes dot products and magnitudes directly from components, and derives projection and rejection from the standard formulas above. It uses JavaScript double-precision floating-point arithmetic, so very large values and irrational or fractional input may show tiny rounding differences. A zero target vector is handled as an undefined projection instead of dividing by zero; near-zero comparisons use a scale-aware tolerance.

Quick verification: for A = (3, 4) and B = (1, 0), the answer must be projB(A) = (3, 0), because B is the x-axis direction. The rejection (0, 4) is perpendicular to B since (0, 4) · (1, 0) = 0.

Frequently asked questions

What is the difference between scalar and vector projection?

The scalar projection is the signed length of one vector along the other. The vector projection is that scalar length multiplied by a unit vector in the target direction, so its result is a vector.

Is projecting A onto B the same as projecting B onto A?

No. Projection is not commutative because the target direction and denominator change. Use the direction control to choose exactly which vector is projected onto the other.

Why can a scalar projection be negative?

A negative scalar projection means the source vector points partly opposite the target vector. This occurs when the angle between them is greater than 90 degrees and their dot product is negative.

How do I test whether vectors are orthogonal or parallel?

Nonzero vectors are orthogonal when their dot product is zero. They are parallel when the magnitude of their 3D cross product, or the absolute 2D determinant, is zero, allowing for small floating-point error.

Does the cross product exist in 2D?

A full cross-product vector is defined in 3D. For 2D vectors, this calculator reports the signed determinant a_x b_y − a_y b_x, equivalent to the missing z-component after embedding the vectors in 3D.

What happens with a zero vector?

The dot product and determinant or cross product can still be calculated. An angle needs both vectors to be nonzero, and a projection is undefined when its target vector is zero because its squared magnitude is the denominator.

How does rounding work?

Calculations use JavaScript double-precision floating-point numbers. The precision selector changes displayed decimal places only; it does not reduce the precision used in the calculation.

Can I enter fractions or square roots?

Yes. Component and complete-vector modes accept decimals, fractions such as 1/2, and square roots such as sqrt(3). Results are numerical approximations rather than symbolic exact values.

Explore more tools