Section 4 of 5

The dot product

The dot product multiplies two vectors and produces a number. Multiply matching components and add:

a⋅b=axbx+ayby\mathbf{a} \cdot \mathbf{b} = a_x b_x + a_y b_y

For example, (3,2)⋅(4,−1)=12−2=10(3, 2) \cdot (4, -1) = 12 - 2 = 10.

What it means

The same number can be computed from the lengths and the angle θ\theta between the vectors:

a⋅b=∣a∣ ∣b∣cos⁡θ\mathbf{a} \cdot \mathbf{b} = |\mathbf{a}|\,|\mathbf{b}|\cos\theta

So the dot product measures how much two vectors point the same way:

  • positive when θ<90∘\theta < 90^\circ
  • zero when they are perpendicular, θ=90∘\theta = 90^\circ
  • negative when θ>90∘\theta > 90^\circ

Projection

The dashed line drops a\mathbf{a} straight onto the line of b\mathbf{b}, like a shadow cast by a light shining directly above it. The highlighted segment is the projection of a\mathbf{a} onto b\mathbf{b}, and

a⋅b=∣b∣×(signed length of the shadow)\mathbf{a} \cdot \mathbf{b} = |\mathbf{b}| \times (\text{signed length of the shadow})

Drag the vectors and watch the shadow shrink to nothing as θ\theta reaches 90∘90^\circ, then flip to the other side.

The dot product shows up everywhere: in physics, the work done by a force is W=F⋅dW = \mathbf{F} \cdot \mathbf{d}. In graphics, it decides how brightly light hits a surface.

Quiz Question 1 of 2

Compute (1,2)⋅(3,−1)(1, 2) \cdot (3, -1).

θbaa · b = 10θ = 47.7°