angle between 2 vectors calculator

Vector Angle Calculator (2D/3D)

Enter vector components below to calculate the angle between two vectors using the dot product formula. Leave z blank if you are working in 2D.

Vector A

Vector B

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

How this angle between vectors calculator works

This calculator finds the angle between two vectors by combining three key ideas from linear algebra: the dot product, vector magnitude, and the inverse cosine function. It works for both 2D and 3D vectors, and reports results in degrees and radians.

When two vectors point in the same direction, the angle is close to 0°. When they are perpendicular, the angle is 90°. If they point in opposite directions, the angle is 180°.

Formula used

θ = arccos( (A · B) / (|A| |B|) ) Where: A · B = AxBx + AyBy + AzBz |A| = √(Ax2 + Ay2 + Az2) |B| = √(Bx2 + By2 + Bz2)

Because of rounding errors, the calculator safely clamps the cosine value to the range [-1, 1] before applying arccos. This avoids invalid results in edge cases.

Step-by-step example

Example vectors

Let A = (3, 4, 0) and B = (4, 0, 0).

  • Dot product: A · B = (3)(4) + (4)(0) + (0)(0) = 12
  • Magnitude of A: |A| = √(3² + 4²) = 5
  • Magnitude of B: |B| = √(4²) = 4
  • cos(θ) = 12 / (5×4) = 0.6
  • θ = arccos(0.6) ≈ 53.13°

This means vector A is about 53 degrees away from vector B.

Why this is useful

An angle between vectors calculator is valuable in many fields:

  • Physics: analyzing forces, work, and direction of motion.
  • Computer graphics: lighting calculations, normals, and camera orientation.
  • Machine learning: cosine similarity for comparing embeddings and text vectors.
  • Engineering: checking alignment, direction, and projections.
  • Robotics: joint motion and direction planning in 3D space.

Common mistakes to avoid

  • Using a zero vector: if |A| or |B| = 0, the angle is undefined.
  • Mixing units: radians and degrees are different; this tool gives both.
  • Sign errors in components: negative numbers can change the result significantly.
  • Confusing 2D and 3D input: if you only have x and y, leave z blank.

Quick FAQ

Can the angle be negative?

For the standard angle between two vectors, the result is between 0° and 180°, so it is not negative.

What does 90° mean?

It means vectors are orthogonal (perpendicular), and their dot product is zero.

What if vectors are parallel?

If vectors point the same way, angle = 0°. If they point opposite ways, angle = 180°.

Final thoughts

This dot product angle calculator is designed to be fast, accurate, and easy to use for everyday math, physics, engineering, and coding work. Enter your vector components, click calculate, and instantly get the vector angle with the intermediate values shown.

🔗 Related Calculators