Proof of dot product/cosine rule