Toolbox
Dot product: calculating the angle between two vectors
Determine the angle between two nonzero vectors in 2D or 3D. The calculation also gives their dot product, magnitudes and the cosine of the angle, which lies between 0° and 180° without a direction of rotation.
Dot product: calculating the angle between two vectors
Signed component of u on the x-axis, in the orthonormal coordinate system shared by the vectors.
Signed component of u on the y-axis, in the orthonormal coordinate system shared by the vectors.
Signed component of v on the x-axis, in the orthonormal coordinate system shared by the vectors.
Signed component of v on the y-axis, in the orthonormal coordinate system shared by the vectors.
Initial values are examples.
Results
Substitution in SI units
Both vectors must be nonzero in this combined calculation.
The unsigned angle between u and v
Estimated reading time : 5 min · 868 words
Calculation details
The sign of the dot product indicates the angle: positive below 90°, zero at 90°, negative above it. The resulting angle is unoriented and gives no direction of rotation.
02 · Magnitude of u
03 · Magnitude of v
04 · Cosine of the angle
05 · Unsigned angle
From the dot product to the angle between vectors
The dot product sums the products of corresponding components. It relates the magnitudes to the angle between the two vectors and returns a number. For nonzero vectors, its sign distinguishes an acute, right or obtuse angle. The calculated angle does not describe any direction of rotation: it remains between 0 and 180 degrees.
Formulas and symbols
The following relationships use the symbols defined below.
(dot product)
(magnitude of u)
(magnitude of v)
(cosine of the angle)
(unsigned angle)
(dot product)
(magnitude of u)
(magnitude of v)
(cosine of the angle)
(unsigned angle)
- u and v: unitless vectors in the same orthonormal coordinate system.
- ux, uy, uz and vx, vy, vz: components.
- ‖u‖ and ‖v‖: magnitudes.
- u·v: dot product.
- θ: unoriented angle. The ratio of the dot product to the product of the magnitudes is numerically clamped between −1 and 1 before arccos to prevent rounding from pushing it outside this range.
Sign and angle for nonzero vectors
| Dot product | Angle | Interpretation |
|---|---|---|
| Positive | From 0° inclusive to 90° exclusive | Acute angle or identical directions |
| Zero | 90° | Orthogonality |
| Negative | From 90° exclusive to 180° inclusive | Obtuse angle or opposite directions |
| +‖u‖‖v‖ | 0° | Same direction and sense |
| −‖u‖‖v‖ | 180° | Same line, opposite senses |
OpenStax — dot product and angle ; Wolfram MathWorld — Dot Product.
Worked examples
Example 1: Two orthogonal vectors in 2D
For u = (3 ; 4) and v = (4 ; −3), the dot product is 12 − 12, or 0. Both magnitudes are 5 and the angle is 90°.
Example 2: Two vectors in space
For u = (1 ; 2 ; 2) and v = (2 ; 0 ; 1), the dot product is 4. The magnitudes are 3 and ; the cosine is about 0,596285 and the angle about 53,40°.
Example 3: Two vectors pointing in opposite directions
For (1 ; 0) and (−2 ; 0), the dot product is −2, the cosine is −1 and the angle is 180°.
Assumptions and limitations
Both vectors must be nonzero in this combined calculation. The dot product with a zero vector is indeed zero, but the angle would be undefined, so such inputs are rejected here. Orthonormal coordinate system and unitless components. This page does not calculate oriented angles, vector projections or forces.
Common mistakes
Do not add the magnitudes in the denominator: multiply them. The angles 0° and 180° describe collinear vectors pointing, respectively, in the same and opposite senses. A zero dot product indicates orthogonality only after zero vectors have been excluded.
Frequently asked questions
What does a negative dot product mean?
For two nonzero vectors, their unoriented angle exceeds 90°. If the cosine is −1, the vectors point in opposite senses along the same direction.
Why is the angle with the zero vector undefined?
The zero vector has no direction, and its magnitude makes the denominator in the angle formula zero. Even though its dot product with any vector is zero, this combined calculation rejects a zero vector to avoid assigning it an angle.
Is the dot product a projection length?
Divide the dot product by the target vector’s norm to obtain a signed scalar projection. Its absolute value is a length.
Does scaling change the angle?
Positive scaling preserves the angle. Negative scaling reverses one vector and gives the supplementary angle; zero makes the angle undefined.