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·b5
Angle θ (°)45

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

SymbolMeaning
axa: x
aya: y
bxb: x
byb: y
dotDot product a·b
degAngle θ (°)

More formulas in this category

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