Skip to content
Calculator Collection

Angle Between Vectors Calculator

Compute the angle in degrees between two 2D vectors using cos θ = (v1·v2)/(|v1|·|v2|) and the arccosine function. The result lies in [0°, 180°] regardless of vector orientation.

Last updated: May 2026

Fill in the required fields to see your result.

Compare with similar

About this calculator

The angle θ between two non-zero vectors is defined by the relation v1·v2 = |v1| · |v2| · cos θ. Solving for θ gives θ = arccos((v1·v2) / (|v1|·|v2|)), which this calculator evaluates and converts from radians to degrees by multiplying by 180/π. The dot product in the numerator is v1x·v2x + v1y·v2y for 2D vectors; the magnitudes are |v1| = √(v1x² + v1y²) and |v2| = √(v2x² + v2y²). The arccos function returns values in [0°, 180°], which is the natural range for the angle between two vectors regardless of which side you measure from. Special cases: parallel same-direction vectors give θ = 0° (cos θ = 1); perpendicular vectors give θ = 90° (cos θ = 0); anti-parallel vectors give θ = 180° (cos θ = −1). Edge cases: if either vector is the zero vector, the denominator is zero and the formula returns NaN — the angle is undefined for zero vectors. For nearly-parallel vectors, floating-point round-off in (v1·v2)/(|v1|·|v2|) can produce a value slightly outside [−1, 1], causing arccos to return NaN; robust implementations clamp the cosine to [−1, 1] before applying arccos. The formula gives an unsigned angle; for signed angles (oriented angles in 2D), use atan2 of the cross-product magnitude and the dot product.

How to use

Example 1 — perpendicular vectors. v1 = (1, 0) (along x-axis), v2 = (0, 1) (along y-axis). Inputs: v1x = 1, v1y = 0, v2x = 0, v2y = 1. Step 1: dot product = 1·0 + 0·1 = 0. Step 2: |v1| = √(1+0) = 1, |v2| = √(0+1) = 1. Step 3: cos θ = 0/(1·1) = 0. Step 4: θ = arccos(0) = 90° (or π/2 radians). Verify: the x-axis and y-axis are perpendicular by definition, so 90° is correct ✓. Example 2 — non-perpendicular vectors. v1 = (3, 4), v2 = (4, 3). Inputs: v1x = 3, v1y = 4, v2x = 4, v2y = 3. Step 1: dot product = 3·4 + 4·3 = 12 + 12 = 24. Step 2: |v1| = √(9+16) = 5, |v2| = √(16+9) = 5. Step 3: cos θ = 24/(5·5) = 24/25 = 0.96. Step 4: θ = arccos(0.96) ≈ 0.2838 rad. Step 5: in degrees: 0.2838 · 180/π ≈ 16.26°. Verify: both vectors have magnitude 5 and lie in the first quadrant, with v1 slightly more vertical and v2 slightly more horizontal — they should be close to each other in angle, and 16.26° is a small acute angle as expected ✓.

Frequently asked questions

Why does the formula give an unsigned angle? What if I need a signed (oriented) angle?

The dot-product formula v1·v2 = |v1|·|v2|·cos θ gives only cos θ, and arccos returns a value in [0°, 180°]. Cosine is even (cos(−θ) = cos θ), so the dot product cannot distinguish between rotating from v1 to v2 by +θ versus by −θ — the answer is always the smaller, unsigned angle between the two directions. For 2D vectors where you need a signed angle (e.g., 'how much to rotate v1 counter-clockwise to reach v2'), use atan2(cross(v1, v2), dot(v1, v2)), where the 2D cross product is v1x·v2y − v1y·v2x. The result is in (−180°, 180°], with positive meaning counter-clockwise rotation from v1 to v2 and negative meaning clockwise. For 3D vectors, signed angles require choosing an orientation axis; atan2 alone is not enough.

What happens if one of my vectors is the zero vector?

The angle is undefined — geometrically, the zero vector has no direction, so there's nothing to measure relative to. Mathematically, the formula divides by |v|, and if |v| = 0 you have division by zero. The calculator will return NaN or infinity in that case. In code that uses this formula, always check that both vectors have nonzero magnitude before computing the angle; if either is zero, either skip the computation, return a sentinel value, or raise an error depending on the application. Some libraries return zero for the angle between a zero vector and any other vector as a convention, but this is arbitrary and can mask bugs (a 'zero angle' wrongly suggests the vectors are parallel). For robust code, document the convention and check inputs.

Why might the formula give NaN even for non-zero vectors?

Floating-point round-off. The mathematical value of (v1·v2)/(|v1|·|v2|) lies in [−1, 1] for any non-zero real vectors, but in floating-point arithmetic the computed value can be very slightly outside this range — say 1.0000000000000002 — when the vectors are nearly parallel or anti-parallel. The arccos function is undefined outside [−1, 1] and returns NaN for such inputs. Robust implementations clamp the cosine to [−1, 1] before calling arccos: cos_clamped = max(−1, min(1, cos_raw)), which produces a small angle (0 or 180°) in the edge case. Without clamping, you can see NaN for vectors that are mathematically equal or opposite. This is a classic gotcha in graphics, robotics, and computational geometry; always clamp before arccos.

What are the common mistakes when computing the angle between vectors?

The biggest mistake is forgetting to divide by both magnitudes — using just arccos(v1·v2) gives nonsense unless both vectors happen to be unit vectors. The second is computing the angle in radians and reporting it as degrees (or vice versa); the formula in this calculator multiplies by 180/π to convert, but if you implement it yourself, always check units. The third is treating the formula's unsigned result as signed when direction matters — for 2D rotation problems, use atan2 instead. People also forget to handle zero vectors (division by zero) and near-parallel cases (floating-point round-off causing NaN). Another error is mixing dimensions — this calculator assumes 2D; for 3D you need a 3D dot product and 3D magnitudes (the dedicated angle calculator handles this if it exists, or extend the formula manually). Finally, sign errors in the dot product when components are negative can flip the answer from acute to obtuse; double-check the arithmetic for vectors with mixed-sign components.

When should I not use this calculator?

Do not use it for 3D vectors — the formula only takes 2D inputs (v1x, v1y, v2x, v2y). For 3D, use a 3D angle calculator or extend the formula: include the z components in both the dot product and the magnitudes. It is not appropriate when you need a signed (oriented) angle in 2D — use atan2(v1x·v2y − v1y·v2x, v1x·v2x + v1y·v2y) instead, which returns a value in (−180°, 180°] with sign indicating rotation direction. Do not use it when either vector is the zero vector; the angle is undefined and the formula returns NaN. Avoid it for near-parallel or near-antiparallel vectors without numerical clamping; the cosine can fall slightly outside [−1, 1] due to floating-point, breaking arccos. For 3D rotation problems (axis-angle, quaternions, rotation between two frames), this calculator is insufficient — you need rotation-matrix or quaternion tools. Finally, for angles in non-Euclidean spaces (hyperbolic, spherical, Riemannian manifolds), the formula doesn't apply; use the appropriate inner product for the space.

Sources & references