Home ↓
CalculatorsVerified

Math & Geometry

Vector Calculator: Magnitude, Dot Product, Cross Product and Angle

Work with two vectors in two or three dimensions. A vector has both size and direction and is written by its components along the x, y and z axes, such as (1, 2, 3). Vectors describe forces, velocities, displacements, electric fields and directions in computer graphics and games, so a few standard operations come up again and again. The magnitude is the length of the vector, found with Pythagoras’ theorem. Adding and subtracting vectors works component by component. The dot product multiplies matching components and adds them; it measures how much two vectors point the same way, is zero when they are perpendicular and is used to calculate work done by a force. The cross product, defined in three dimensions, gives a new vector perpendicular to both, whose length equals the area of the parallelogram they span; it is used for torque, normals to surfaces and rotation. From the dot product you can also find the angle between the vectors and the projection of one onto the other. For 2D vectors, simply enter 0 for the z components. For a = (1, 2, 3) and b = (4, 5, 6), the dot product is 32, the cross product (−3, 6, −3) and the angle about 12.93 degrees.

How to use this calculator

  1. Enter the x, y and z components of vector a.
  2. Enter the components of vector b.
  3. For 2D vectors, leave z as 0.
  4. Read the dot and cross products, magnitudes and angle.
  5. Use the projection and unit vector for direction problems.

Dot and cross products

The dot product is a single number; the cross product is a vector. Swapping the order leaves the dot product unchanged but reverses the direction of the cross product.

The direction of a × b follows the right-hand rule: point your fingers along a, curl them towards b, and your thumb points along the cross product.

Uses

In physics, work equals the dot product of force and displacement, and torque equals the cross product of the lever arm and the force. In 3D graphics, dot products set lighting brightness and cross products give surface normals.

Unit vectors, of length 1, describe pure direction and are often used to normalise data before comparing directions.

Formula & method

Magnitude |a| = √(x² + y² + z²)Dot product a · b = aₓbₓ + a_yb_y + a_zb_zCross product a × b = (a_yb_z − a_zb_y, a_zbₓ − aₓb_z, aₓb_y − a_ybₓ)Angle θ = arccos(a · b ÷ (|a| |b|)); scalar projection of a on b = a · b ÷ |b|

|a| = √(aₓ² + a_y² + a_z²). a ± b = (aₓ ± bₓ, a_y ± b_y, a_z ± b_z). a · b = aₓbₓ + a_yb_y + a_zb_z = |a||b| cos θ. a × b = (a_yb_z − a_zb_y, a_zbₓ − aₓb_z, aₓb_y − a_ybₓ), with |a × b| = |a||b| sin θ. Angle θ = arccos(a · b ÷ (|a||b|)). Scalar projection of a onto b = a · b ÷ |b|. Unit vector of a = a ÷ |a|. The angle and projection are not defined if either vector is zero.

Worked example

a = (1, 2, 3), b = (4, 5, 6)

  1. a · b = 4 + 10 + 18 = 32.
  2. a × b = (2×6 − 3×5, 3×4 − 1×6, 1×5 − 2×4) = (−3, 6, −3).
  3. |a| = 3.742, |b| = 8.775, so θ = arccos(32 ÷ 32.83) ≈ 12.93°.

Answer: Dot product 32, cross product (−3, 6, −3), angle 12.93°.

Frequently asked questions

How do I find the magnitude of a vector?

Take the square root of the sum of the squared components.

What is the dot product?

The sum of the products of matching components.

What does a zero dot product mean?

The vectors are perpendicular.

What is the cross product?

A vector perpendicular to both inputs, with length equal to the parallelogram area.

Can I use 2D vectors?

Yes, enter 0 for the z components.

How do I find the angle between vectors?

θ = arccos(a · b ÷ (|a| × |b|)).