Dot Product and the Angle Between Vectors
The dot product measures how much two vectors point the same way.
a · b = a₁b₁ + a₂b₂ = |a||b| cos θ
It is positive when the angle is under 90°, zero at exactly 90° and negative above 90°.
Divide by the product of the lengths to get cos θ and so the angle.
Calculator
Change a value and the result and picture update instantly.
Result
Dot product a·b
Angle θ (°)
Animated picture
The picture follows your values. Some points and shapes can be dragged.
Use in game development
Is the enemy in front or behind? How bright is a surface under a light (Lambert shading)? Both use the dot product.
Code example (JavaScript)
const facing = dirX * toTargetX + dirY * toTargetY; // > 0: target is in front
What the symbols mean
| Symbol | Meaning |
|---|---|
ax | a: x |
ay | a: y |
bx | b: x |
by | b: y |
dot | Dot product a·b |
deg | Angle θ (°) |
More formulas in this category
- Vector Addition and Length
- Unit Vectors (Normalization)
- Cross Product (2D)
- Matrix–Vector Multiplication and Determinant
- Rotation Matrix
Frequently asked questions
- What is the formula for Dot Product and the Angle Between Vectors?
- The formula for Dot Product and the Angle Between Vectors is a · b = a₁b₁ + a₂b₂ = |a||b| cos θ. The dot product measures how much two vectors point the same way.
Math Formula Quiz Vectors & Matrices
Sources
Checked: 2026-11-29