Notes [#3]
Law of cosines
The law of cosines gives the squared distance $d^2$ between the tips of two arrows from their lengths and the angle at their shared start. The component differences give a second way to compute the same distance.
$$\begin{aligned}
d^2 &= \|\mathbf a\|^2+\|\mathbf b\|^2-2\|\mathbf a\|\,\|\mathbf b\|\cos\theta,\\
d^2 &= (a_x-b_x)^2+(a_y-b_y)^2\\
&= \|\mathbf a\|^2+\|\mathbf b\|^2-2\,\mathbf a\cdot\mathbf b.
\end{aligned}$$
Figure 4 — Equate the two expressions and cancel the squared lengths to recover the dot product’s angle formula.