How it works
The dot product multiplies matching components and adds them. A zero result means the vectors are at right angles. Divide by the two lengths to get the cosine of the angle between them. Use 2D by setting z to 0.
Formula
cos(θ) = u · v ÷ (|u| × |v|)
Sources
Example
u = (2, −1, 3) and v = (4, 0, −2). Dot = 8 + 0 − 6 = 2. |u| = √14 = 3.7417 and |v| = √20 = 4.4721. Angle = acos(2 ÷ 16.7332) = 83.14 degrees. Check: cos(83.14°) × 16.7332 = 2.0000.
Frequently asked questions
What does zero mean?
The vectors are perpendicular.
Is the result a vector?
No, it is a single number.
Does the order matter?
No. u · v = v · u.
Can I use 2D vectors?
Yes. Set z = 0.