Use a dot product to compare directions

About 3 min

A dot product gives one number. Its sign tells whether a target lies ahead, to the side or behind a facing direction.

A game piece faces along (2, 1): two right and one up. A target lies (−1, 3) from it: one left and three up. Is that ahead or behind? A dot product turns the two vectors into one number whose sign answers that question.

Compare the target with the facing direction

Find the dot product of (2, 1) and (−1, 3).

  1. Multiply the matching parts

    2(−1)=−2;1(3)=32(-1)=-2;\quad1(3)=3

    The target’s leftward part counts against the rightward facing part. Its upward part counts with the upward facing part.

  2. Add the two contributions

    [21]⋅[−13]=−2+3=1\begin{bmatrix}2\\1\end{bmatrix}\cdot\begin{bmatrix}-1\\3\end{bmatrix}=-2+3=1

    Three outweighs minus two, leaving a positive answer. The result is a scalar: one number, not the pair (−2, 3).

  3. Answer the direction question

    1>0⇒ahead1>0\quad\Rightarrow\quad\text{ahead}

    The target lies on the forward side of the facing direction. Ahead does not mean directly on the same line.

The target sits left on screen but ahead of A

A gives the facing direction and B gives the target. The shaded half lies ahead of A. The dashed boundary marks a right angle to A.

Read the forward side of the picture

The boundary crosses the piece at a right angle to its facing direction. A target on that line has zero forward contribution. Targets beyond that line fall on either the ahead side or the behind side.

For two nonzero vectors, a positive dot product means an angle below 90°. A negative result means an angle above 90°. Zero means a right angle, also called perpendicular.

So the sign gives a useful test even when the target sits to the left on the screen. Compare with the facing direction, not just left versus right.

Try it yourself

Work out an answer and explain your reasoning. Then check the explanation.

Detect a right angle

[2−1]⋅[12]\begin{bmatrix}2\\-1\end{bmatrix}\cdot\begin{bmatrix}1\\2\end{bmatrix}

Calculate the one-number result. What angle relationship does its sign reveal?

Show the answerHide the answer
00

The results 2 and −2 add to zero, so these nonzero vectors meet at a right angle.

Return one number

[−12]⋅[34]\begin{bmatrix}-1\\2\end{bmatrix}\cdot\begin{bmatrix}3\\4\end{bmatrix}

Find the single number, rather than a pair. Explain why the two products must combine.

Show the answerHide the answer
55

Work out −1 × 3 + 2 × 4. This gives −3 + 8 = 5.

Use the result for a game decision

[10]⋅[−23]\begin{bmatrix}1\\0\end{bmatrix}\cdot\begin{bmatrix}-2\\3\end{bmatrix}

Is the target ahead, behind or exactly to the side of this facing direction?

Show the answerHide the answer
Behind\text{Behind}

The dot product is minus two. Facing right makes the target’s leftward position count behind. Its upward part does not change that sign.

Why a large result does not mean a smaller angle

The angle stays the same when you double one vector, but the dot product doubles. So the value depends on both lengths. A unit vector has length one. Use unit vectors to remove the length effect.

A zero vector gives a dot product of zero with every vector. But it has no direction, so this case does not show a right angle. The angle rule needs two nonzero vectors.

Try the calculation behind the direction test

The game asks for dot products of small whole-number vectors. Give one number. Use its sign to think about the direction, even though the game asks for the calculation.

2-minute practice · keep going after mistakes · opens in a new tab