User Rating 0.0
Total Usage 0 times
Vector A
Vector B
Is this tool helpful?

Your feedback helps us improve.

About

Computing the angle between two vectors is a foundational operation in linear algebra, computer graphics, robotics, and physics simulations. The standard method relies on the dot product identity: θ = arccos(A B|A| |B|). Floating-point arithmetic can push the arccos argument outside the valid domain of [−1, 1], producing NaN results in naive implementations. This calculator clamps the ratio before evaluation. A zero-magnitude vector has no direction; attempting to normalize it causes division by zero. The tool detects this and reports the error explicitly rather than returning a misleading result.

Results are provided in both degrees and radians. The tool also reports the dot product, individual magnitudes, and the unit vectors for verification. Note: the formula returns the smallest angle between the two vectors (0° to 180°). It does not distinguish signed orientation. For signed angles in 2D, the atan2 of the cross product and dot product is required, which this tool also computes when in 2D mode.

angle between vectors dot product vector angle calculator vector math linear algebra 3D vectors 2D vectors

Formulas

The angle between two vectors is derived from the geometric definition of the dot product.

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

Where the dot product in R3 expands to:

A B = a1b1 + a2b2 + a3b3

And the magnitude (Euclidean norm):

|A| = a12 + a22 + a32

For 2D signed angle (counterclockwise positive from A to B):

θsigned = atan2(a1b2 a2b1, A B)

Where θ = angle between vectors, A and B = input vectors, ai and bi = components of A and B, |A| = Euclidean norm of A.

Reference Data

ConfigurationAngleDot Product SignGeometric Meaning
Same direction0°> 0Parallel, co-directional
Perpendicular90°= 0Orthogonal
Opposite direction180°< 0Anti-parallel
Acute angle0° - 90°> 0Vectors point roughly same way
Obtuse angle90° - 180°< 0Vectors point roughly apart
A = 0UndefinedN/AZero vector has no direction
Unit vectorsarccos(A B)Equals cos(θ)Dot product directly gives cosine
2D signed angle−180° to 180°N/AUses atan2(cross, dot)
Common Vector Pairs & Angles
i = (1,0,0), j = (0,1,0)90°0Standard basis, orthogonal
(1,1), (−1,1)90°0Perpendicular diagonals
(1,0), (1,1)45°1Half-quadrant separation
(3,4), (4,3)16.26°24Close but distinct directions
(1,2,3), (−1,−2,−3)180°−14Exact opposites
(1,0,0), (1,1,1)54.74°1Axis vs. space diagonal

Frequently Asked Questions

Floating-point arithmetic can produce dot-product-to-magnitude ratios like 1.0000000000000002 due to rounding errors. The arccos function is defined only on [−1, 1]. Without clamping, the result would be NaN. Clamping ensures the output is always valid. The error introduced is on the order of machine epsilon (≈ 10⁻¹⁶) and has no practical impact on the result.
A zero vector has zero magnitude and no defined direction. The angle calculation involves division by the product of magnitudes, which would be division by zero. The calculator detects this case before computation and returns an explicit error rather than a misleading number.
In 3D, only the unsigned angle (0° to 180°) is meaningful because there is no canonical "counterclockwise" direction without specifying a reference normal. In 2D mode, the calculator also provides the signed angle (−180° to 180°) using atan2, where positive means counterclockwise rotation from vector A to vector B.
Two vectors are perpendicular (orthogonal) when their dot product equals exactly zero, yielding an angle of 90°. Due to floating-point precision, the displayed angle may show 89.99999° or 90.00001° for truly orthogonal vectors with irrational components. Check the dot product value in the detailed results; if it rounds to zero, the vectors are orthogonal within machine precision.
This calculator supports 2D and 3D vectors, which cover the vast majority of physics, engineering, and graphics applications. The dot product formula generalizes to n dimensions, but the visual interpretation and cross product do not. For n-dimensional angle computation, the same arccos(dot / (mag × mag)) formula applies; you would need to extend the input fields accordingly.
The arccos function has very low sensitivity near 0° and 180° (its derivative approaches infinity at ±1). When the cosine of the angle is within floating-point epsilon of 1.0, the clamping step rounds it to exactly 1.0, and arccos(1.0) = 0. For applications requiring sub-degree precision near parallel alignment, consider using atan2 with the cross product magnitude instead, which has better numerical behavior at small angles.