calculate angle between two vectors

Vector Angle Calculator

Enter each vector as numbers separated by commas or spaces (works for 2D, 3D, or any matching dimension).

Formula: θ = arccos[(A · B) / (|A||B|)]

How to calculate the angle between two vectors

The angle between two vectors tells you how similar their directions are. If the angle is small, the vectors point mostly the same way. If the angle is close to 180°, they point in opposite directions. This concept appears in geometry, physics, graphics, robotics, statistics, and machine learning.

The core formula

For vectors A and B, the angle θ is:

θ = arccos[(A · B) / (|A||B|)]

  • A · B is the dot product.
  • |A| and |B| are magnitudes (lengths).
  • arccos converts cosine back into an angle.

Step-by-step process

  • Multiply matching components and add them to get the dot product.
  • Compute each vector magnitude: √(x² + y² + z² + ...).
  • Divide dot product by the product of magnitudes.
  • Apply arccos to get the angle in radians, then convert to degrees if needed.

Quick examples

Example 1: perpendicular vectors in 2D

A = (3, 4), B = (4, -3)
Dot product = 3×4 + 4×(-3) = 12 - 12 = 0
Because the dot product is 0, the vectors are orthogonal, so the angle is 90°.

Example 2: acute angle in 3D

A = (1, 2, 2), B = (2, 1, 0)
Dot product = 1×2 + 2×1 + 2×0 = 4
|A| = 3, |B| = √5
cos(θ) = 4 / (3√5) ≈ 0.5963
θ ≈ arccos(0.5963) ≈ 53.4°

How to interpret the result

  • : same direction
  • Between 0° and 90°: generally similar direction (acute)
  • 90°: perpendicular
  • Between 90° and 180°: opposing tendency (obtuse)
  • 180°: opposite direction

Common mistakes to avoid

  • Using vectors with different dimensions (for example, 2D vs 3D).
  • Trying to compute with a zero vector (magnitude is 0, angle is undefined).
  • Forgetting to clamp cosine to [-1, 1] when handling floating-point rounding.
  • Mixing radians and degrees without conversion.

Where this is used

Angle-between-vectors calculations show up everywhere: checking force direction in mechanics, computing similarity between embeddings in machine learning, normal lighting in computer graphics, and orientation control in navigation and robotics.

🔗 Related Calculators