Angle Between Two Vectors Calculator - 2D & 3D

Find the angle between any two vectors in 2D or 3D space using the dot product formula. Results in both degrees and radians.

Choose 2D or 3D mode, enter the components of both vectors, and click Calculate to get the angle, dot product, and vector magnitudes.

Angle Between Two Vectors Calculator - 2D & 3D
Find the angle between any two vectors in 2D or 3D space using the dot product formula. Results in both degrees and radians.

About the angle between two vectors calculator

The angle between two vectors is a fundamental quantity in linear algebra and geometry that expresses the angular separation between two directional quantities placed tail-to-tail at a common origin. Unlike angles between lines in classical Euclidean geometry, the angle between vectors is always the smaller of the two possible angles, constrained to the range from 0° to 180° (or 0 to π radians). This convention ensures a unique, unambiguous result for any pair of non-zero vectors. The calculation rests on the dot product, one of the most important operations in linear algebra. For two vectors A and B, the dot product is defined algebraically as the sum of the products of their corresponding components: A · B = Ax·Bx + Ay·By in two dimensions, or A · B = Ax·Bx + Ay·By + Az·Bz in three dimensions. The dot product also has a geometric interpretation: A · B = |A| × |B| × cos(θ), where |A| and |B| are the Euclidean magnitudes (lengths) of the vectors and θ is the angle between them. Combining these two definitions and solving for θ gives the fundamental formula: θ = arccos((A · B) / (|A| × |B|)). This formula has several elegant properties. If the dot product is zero, then cos(θ) = 0, which means θ = 90°, and the vectors are perpendicular (orthogonal). If the dot product equals the product of the magnitudes, then cos(θ) = 1 and θ = 0°, meaning the vectors point in the same direction (parallel). If the dot product equals the negative product of magnitudes, then cos(θ) = −1 and θ = 180°, meaning the vectors point in opposite directions (antiparallel). The formula generalises naturally to n-dimensional spaces simply by extending the component sums. Angles between vectors arise throughout physics and engineering. In classical mechanics, the work done by a force F over a displacement d is W = F · d = |F| × |d| × cos(θ), where θ is the angle between the force and displacement vectors. When θ = 0° the force is fully aligned with the motion and does maximum work; when θ = 90° the force is perpendicular to motion and does zero work. In computer graphics, surface lighting uses the angle between the surface normal and the incoming light direction to compute how brightly a surface is illuminated via Lambert's cosine law. In machine learning, the cosine similarity between two feature vectors is directly related to the angle between them and measures how similar their directions are regardless of magnitude. Numerically, the arccos function can lose precision when its argument is very close to 1 or −1 (corresponding to nearly parallel or antiparallel vectors). In high-precision software, this is handled by clamping the cosine argument to the valid range [−1, 1] before passing it to arccos, which this calculator does automatically. For 2D problems where a signed angle is needed (distinguishing clockwise from anticlockwise), the atan2 function with the cross product is preferred over the dot product approach, though this calculator reports the unsigned angle consistent with the mathematical definition.

Angle between vectors examples

Classic vector pairs illustrating perpendicular, parallel, and general angle results.

VectorsAngleExplanation
A=(1,0), B=(0,1)90°Perpendicular unit vectors along the x and y axes. Dot product = 0, confirming a right angle.
A=(3,4), B=(4,3)≈16.26°Both vectors have magnitude 5. Dot product = 3×4 + 4×3 = 24. cos(θ) = 24/25 = 0.96.
A=(1,0,0), B=(0,1,0)90°Orthogonal unit vectors in 3D. Dot product = 0, so the angle is exactly 90°.
A=(1,1,1), B=(1,0,0)≈54.74°3D vectors. Dot product = 1, |A| = √3, |B| = 1. cos(θ) = 1/√3 ≈ 0.577.

How to use the angle between two vectors calculator

  1. Select the dimension: choose '2D Vectors' if your vectors have x and y components, or '3D Vectors' if they also have a z component.
  2. Enter the component values for Vector A (Ax, Ay, and optionally Az) and Vector B (Bx, By, and optionally Bz). Use decimals or negative numbers as needed.
  3. Click 'Calculate Angle'. The calculator instantly displays the angle in degrees and radians, plus the dot product, vector magnitudes, and cosine value.
  4. Verify results using known special cases: perpendicular vectors always give 90°, identical direction vectors always give 0°, opposite directions always give 180°.
  5. Click Reset to clear all inputs and perform a new calculation.

Angle between vectors FAQ

Why is the angle between vectors always between 0° and 180°?
The arccos function used in the formula has a range of [0°, 180°], and the cosine of any angle in that range is in [−1, 1]. The dot-product formula gives only the smaller of the two supplementary angles that two vectors could form, which by convention is the angle between vectors. If a directed (signed) angle is needed, the atan2 function combined with the cross product is used instead.
What does a dot product of zero mean for the angle?
A dot product of zero means the cosine of the angle is zero, which corresponds to an angle of exactly 90°. The two vectors are orthogonal (perpendicular). This property is widely used to test for perpendicularity: if A · B = 0 then A ⊥ B, without needing to compute the actual angle.
Does the magnitude (length) of the vectors affect the angle?
No. The formula divides the dot product by the product of the magnitudes, so scaling either vector up or down cancels out and does not change the angle. Vectors (1,0) and (100,0) both make a 0° angle with the x-axis regardless of their lengths.
How do I extend this to n-dimensional vectors?
The formula θ = arccos((A · B) / (|A| × |B|)) works in any number of dimensions. Extend the dot product to sum all n component products: A · B = Σ Ai·Bi. The magnitude is |A| = √(Σ Ai²). The cosine similarity used in natural language processing and machine learning is exactly this ratio applied to high-dimensional word or document vectors.
What happens if one vector is a zero vector?
A zero vector has magnitude 0, so the denominator (|A| × |B|) becomes 0 and the angle is undefined — you cannot divide by zero. Geometrically, a zero vector has no direction, so there is no meaningful angle to compute. The calculator detects this case and reports an error before attempting the calculation.
How is this angle used in lighting calculations in 3D graphics?
In the Phong and Lambert lighting models, surface brightness is proportional to cos(θ), where θ is the angle between the surface normal vector N and the incoming light direction vector L. When the light hits the surface head-on (θ = 0°), cos(θ) = 1 and the surface is at full brightness. When the light grazes the surface (θ → 90°), cos(θ) → 0 and the surface is in shadow. Negative cosine values (θ > 90°) are clamped to zero to avoid negative light contributions.