terican

Last verified · v1.0

Calculator · math

Angle Between Two Vectors Calculator

Find the angle between two vectors in 2D or 3D using the dot product formula. Enter components and get results in degrees or radians instantly.

FreeInstantNo signupOpen source

Inputs

Angle Between Vectors

Explain my result

0/3 free

Get a plain-English breakdown of your result with practical next steps.

Angle Between Vectors°

The formula

How the
result is
computed.

What Is the Angle Between Two Vectors?

The angle between two vectors quantifies the rotational separation between two directional quantities in 2D or 3D space. Denoted theta (θ), this angle always falls between 0° (parallel, same direction) and 180° (antiparallel, opposite directions) — regardless of the vectors' lengths. The angle between two vectors calculator applies the dot product method, the standard approach in linear algebra and analytic geometry, to deliver precise results in degrees or radians.

The Dot Product Formula

The geometric definition of the dot product links the angle between two vectors to their magnitudes:

A · B = |A| × |B| × cos(θ)

Rearranging to solve for θ yields the working formula:

θ = arccos( A · B / (|A| × |B|) )

Expanding into Cartesian components for A = (a₁, a₂, a₃) and B = (b₁, b₂, b₃), this becomes:

θ = arccos( (a₁b₁ + a₂b₂ + a₃b₃) / ( √(a₁² + a₂² + a₃²) × √(b₁² + b₂² + b₃²) ) )

This derivation is covered in depth by Khan Academy's linear algebra series on defining the angle between vectors and is formalized in Whitman College's Calculus textbook, Section 12.3: The Dot Product.

Variable Definitions

  • a₁ (Vector A — x component): The component of vector A along the x-axis (horizontal direction).
  • a₂ (Vector A — y component): The component of vector A along the y-axis (vertical direction).
  • a₃ (Vector A — z component): The component of vector A along the z-axis (depth direction). Set to 0 for 2D problems.
  • b₁ (Vector B — x component): The component of vector B along the x-axis.
  • b₂ (Vector B — y component): The component of vector B along the y-axis.
  • b₃ (Vector B — z component): The component of vector B along the z-axis. Set to 0 for 2D problems.
  • θ (theta): The output angle between the two vectors, selectable in degrees or radians.

Step-by-Step Calculation

  • Step 1 — Compute the dot product: Multiply matching components and sum the results: a₁b₁ + a₂b₂ + a₃b₃.
  • Step 2 — Find magnitude |A|: Take the square root of (a₁² + a₂² + a₃²).
  • Step 3 — Find magnitude |B|: Take the square root of (b₁² + b₂² + b₃²).
  • Step 4 — Apply arccos: Divide the dot product by |A| × |B|, then take the inverse cosine to get θ.

Worked Examples

2D Example

Find the angle between A = (3, 4) and B = (1, 2), with z = 0 for both vectors.

  • Dot product: (3 × 1) + (4 × 2) = 3 + 8 = 11
  • |A| = √(9 + 16) = √25 = 5
  • |B| = √(1 + 4) = √5 ≈ 2.236
  • cos(θ) = 11 / (5 × 2.236) ≈ 0.9839
  • θ = arccos(0.9839) ≈ 10.3°

3D Example

Find the angle between A = (1, 2, 3) and B = (4, 5, 6).

  • Dot product: (1 × 4) + (2 × 5) + (3 × 6) = 4 + 10 + 18 = 32
  • |A| = √(1 + 4 + 9) = √14 ≈ 3.742
  • |B| = √(16 + 25 + 36) = √77 ≈ 8.775
  • cos(θ) = 32 / (3.742 × 8.775) ≈ 32 / 32.839 ≈ 0.9744
  • θ = arccos(0.9744) ≈ 12.93°

Real-World Applications

The angle between vectors appears across numerous disciplines:

  • Physics: Work equals force times displacement times cos(θ), where θ is the angle between the force and displacement vectors. A force applied at 60° to displacement contributes only 50% of its magnitude as useful work.
  • Computer Graphics: Phong and Lambertian shading models compute the angle between the incoming light direction and a surface normal vector to determine pixel brightness per the formula I = I₀ cos(θ).
  • Machine Learning: Cosine similarity — the cos(θ) term in this formula — measures the directional similarity of word or document embedding vectors, powering search engines, recommendation systems, and large language model retrieval.
  • Robotics: Joint angle computations and steering angle calculations in autonomous vehicles rely directly on vector angle geometry.
  • Chemistry: Molecular bond angles are calculated as the angle between position vectors drawn from a central atom to its bonded neighbors.

Reference

Frequently asked questions

What does the angle between two vectors represent?
The angle between two vectors represents the rotational separation between their directions when both vectors originate from the same point. A value of 0° means the vectors are parallel and point in exactly the same direction; 90° means they are perpendicular (orthogonal); and 180° means they point in exactly opposite directions. The result depends only on direction, not on the vectors' lengths or magnitudes.
How do you calculate the angle between two 2D vectors?
For 2D vectors, set the z components to zero and apply the formula: theta = arccos((a1*b1 + a2*b2) / (sqrt(a1^2 + a2^2) * sqrt(b1^2 + b2^2))). For example, A = (1, 0) and B = (1, 1) give a dot product of 1, |A| = 1, |B| = sqrt(2) ≈ 1.414, so theta = arccos(1 / 1.414) = arccos(0.707) ≈ 45°. The calculator handles this automatically when z is left at 0.
Can the angle between two vectors be greater than 180 degrees?
No. By mathematical convention, the angle between two vectors is always in the range 0° to 180° (0 to pi radians). This constraint comes from the arccos function, whose output is inherently limited to that interval. If a signed or directed angle beyond 180° is required — for instance in 2D rotation tracking — the two-argument arctangent function (atan2) is used instead of the dot product formula.
What is the difference between using the dot product and the cross product to find the angle between vectors?
The dot product method, theta = arccos(A·B / (|A||B|)), returns angles across the full 0° to 180° range and works in both 2D and 3D. The cross product method uses |A × B| = |A||B|sin(theta), but since sine is non-negative between 0° and 180°, it cannot distinguish angles above 90° without additional sign logic. The dot product approach is the standard for angle calculations; the cross product is preferred in 3D problems where the rotation axis is also needed.
What does it mean when the dot product of two vectors equals zero?
A dot product of zero means the two vectors are perpendicular, forming a 90° angle — since arccos(0) = 90°. This property is foundational across mathematics and engineering: linear algebra uses it to verify orthogonality between basis vectors, computer graphics uses it to check whether a surface faces a light source, and signal processing uses it to confirm that two signals carry completely independent (uncorrelated) information.
How does the angle between two vectors relate to cosine similarity used in machine learning?
Cosine similarity is defined as cos(theta) = A·B / (|A||B|), which is exactly the expression inside the arccos in the angle formula. A cosine similarity of 1 corresponds to theta = 0° (identical direction), 0 corresponds to theta = 90° (orthogonal, unrelated), and -1 corresponds to theta = 180° (opposite directions). Natural language processing systems use this to compare word and document embedding vectors, making the angle between two vectors a core concept behind modern search and recommendation engines.