Vector Calculator

Add, subtract and scale vectors in 2D or 3D, with dot product, cross product, magnitude, unit vector, angle and projection.

How to use this calculator

  1. 1Choose 2D or 3D, then enter the components of each vector.
  2. 2Read the dot product and angle at the top; the cross product, magnitudes, unit vector and projection follow.
  3. 3The operations table shows sums, differences and scalar multiples for the same pair.

How the calculation works

a · b = axbx + ayby + azbz |a| = √(ax² + ay² + az²) cos θ = (a · b) ÷ (|a||b|) a × b = (aybz − azby, azbx − axbz, axby − aybx)
a · b
Dot (scalar) product — a single number, equal to |a||b|cos θ
a × b
Cross (vector) product — a vector perpendicular to both, with length |a||b|sin θ. 3D only
|a|
Magnitude, or length, of vector a
θ
Angle between the two vectors, from 0° to 180°
â
Unit vector: a ÷ |a|, same direction, length exactly 1

The dot product returns a scalar and the cross product returns a vector. That difference is the single most common source of confusion, and it is why they are also called the scalar and vector products.

A zero dot product means the vectors are perpendicular. A zero cross product means they are parallel. Neither test requires computing the angle first.

The cross product exists only in three dimensions. In 2D the useful analogue is the scalar axby − aybx, which is the signed area of the parallelogram the two vectors span and tells you their relative orientation.

The angle uses arccos, which returns 0° to 180° — the unsigned angle between the directions. It never reports a reflex angle, because the angle between two directions is conventionally the smaller one.

Worked example

Two 3D vectors

  1. 1.a = (3, −2, 5), b = (1, 4, 2).
  2. 2.Dot product: 3×1 + (−2)×4 + 5×2 = 3 − 8 + 10 = 5.
  3. 3.|a| = √(9 + 4 + 25) = √38 ≈ 6.164414.
  4. 4.|b| = √(1 + 16 + 4) = √21 ≈ 4.582576.
  5. 5.cos θ = 5 ÷ (6.164414 × 4.582576) = 5 ÷ 28.24889 = 0.177003, so θ ≈ 79.81°.
  6. 6.Cross product: ((−2)(2) − (5)(4), (5)(1) − (3)(2), (3)(4) − (−2)(1)) = (−4 − 20, 5 − 6, 12 + 2) = (−24, −1, 14).

Result: a · b = 5, θ ≈ 79.81°, a × b = (−24, −1, 14)

Perpendicular vectors in 2D

  1. 1.a = (3, 4), b = (−4, 3).
  2. 2.Dot product: 3×(−4) + 4×3 = −12 + 12 = 0.
  3. 3.A zero dot product means the vectors are exactly perpendicular, so θ = 90° with no further work.
  4. 4.|a| = √(9 + 16) = 5, and |b| = √(16 + 9) = 5 as well.
  5. 5.2D cross (z component): 3×3 − 4×(−4) = 9 + 16 = 25, which is the area of the square they span — 5 × 5.

Result: a · b = 0, θ = 90°

Two products, two different kinds of answer

Vectors have two multiplications, and they return different types of thing. The dot product takes two vectors and gives back a single number. The cross product takes two vectors and gives back another vector. Mixing them up is the most common error in early vector work, which is why they are also called the scalar product and the vector product — names that state the output.

The dot product measures agreement of direction: a · b = |a||b|cos θ. It is largest when the vectors point the same way, zero when they are perpendicular, and negative when they point more than 90° apart. This is why it appears everywhere work and energy are calculated — force applied at right angles to motion does no work, and the dot product returns exactly zero for it.

The cross product measures the failure to be parallel: its magnitude is |a||b|sin θ, the area of the parallelogram the vectors span, and it points perpendicular to both. It is zero for parallel vectors. Torque, angular momentum and surface normals in graphics are all cross products.

Why the cross product only exists in 3D

The cross product asks for a vector perpendicular to two given vectors. In three dimensions that request has exactly one answer up to sign, which is what makes the operation well defined. In two dimensions there is no room — any vector perpendicular to two independent 2D vectors would have to leave the plane. In four dimensions and above the request is ambiguous, because a whole plane of directions is perpendicular to both.

What survives in 2D is the z component, axby − aybx. It is a scalar, sometimes called the perp-dot product or the 2D cross, and it is genuinely useful: its sign tells you whether b lies clockwise or anticlockwise from a. Computational geometry uses that sign constantly, for point-in-polygon tests and convex hulls.

Its magnitude is the signed area of the parallelogram, which is also twice the area of the triangle formed by the origin and the two points — the shoelace formula in its smallest case.

Projection: the shadow one vector casts on another

The projection of a onto b answers "how much of a points along b?". Geometrically it is the shadow a would cast on b's line if light fell perpendicular to b. The scalar version is a · b ÷ |b|, and multiplying that by the unit vector of b gives the projected vector itself.

Note the asymmetry: projecting a onto b is not the same as projecting b onto a, even though the dot product in the numerator is identical. The divisor differs, because you are measuring along a different direction each time.

Projection is how a vector gets split into a part along a direction and a part perpendicular to it — the decomposition behind resolving forces onto a slope, and behind least-squares fitting, where the best fit is the projection of the data onto the space the model can reach.

What this assumes, and where it stops

Assumptions

  • Vectors are given in Cartesian components relative to the same orthonormal basis.
  • The angle reported is the unsigned angle between directions, from 0° to 180°, as arccos returns.
  • The cross product follows the right-hand rule, the standard orientation convention.

Limitations

  • Cross product is defined only in three dimensions. In 2D mode the calculator reports the scalar z component instead, and says so.
  • Angle, unit vector and projection are undefined when either vector is zero, because a zero vector has no direction. The calculator reports this rather than returning a misleading number.
  • Handles two vectors at a time. Triple products, and operations on larger sets, are not covered.
  • Components are Cartesian only — polar, cylindrical and spherical inputs must be converted first.

Common questions

What is the difference between dot product and cross product?

The dot product returns a single number measuring how much two vectors point the same way, and equals zero when they are perpendicular. The cross product returns a vector perpendicular to both, whose length is the area of the parallelogram they span, and which is zero when they are parallel. Dot works in any dimension; cross is three-dimensional only.

How do I find the angle between two vectors?

Divide the dot product by the product of the magnitudes, then take the inverse cosine: θ = arccos((a · b) ÷ (|a||b|)). The result is between 0° and 180°. If the dot product is zero the angle is exactly 90°, and no arccos is needed.

What does a negative dot product mean?

The vectors point more than 90° apart — broadly in opposing directions. Since a · b = |a||b|cos θ and the magnitudes are always positive, the sign comes entirely from cos θ, which is negative for angles above 90°.

Can you take the cross product of 2D vectors?

Not as a vector, because no direction in the plane is perpendicular to both. What is normally used instead is the scalar axby − aybx — the z component you would get by treating the vectors as 3D with z = 0. It gives the signed area of the parallelogram and tells you the vectors' relative orientation.

Sources

Formula and content last reviewed on .

Results are estimates for information only, not professional advice.

Report an error

Tools people commonly use alongside the vector calculator.

See all math calculators →