If we are given three points $P(a,b), Q(c,d), R(e, f)$, what is the acute angle $\angle PQR$?
Rearranging the dot product formula, we have \begin{align} \cos\theta &= \frac{(a-c,b-d)\cdot(e-c,f-d)}{\sqrt{(a-c)^2+(b-d)^2}\sqrt{(e-c)^2+(f-d)^2}}\\ &=\frac{(a-c)(e-c)+(b-d)(f-d)}{\sqrt{(a-c)^2(e-c)^2+(b-d)^2(f-d)^2+(b-d)^2(e-c)^2+(a-c)^2)(f-d)^2}} \end{align}
Is it possible for this expansion to be written in a direct and compact form, perhaps using matrices, in terms of $a,b,c,d,e,f$?
What if the three points are in 3D space?
Given three points $P=(P_x,P_y), Q=(Q_x,Q_y), R=(R_x,R_y)$
Using distance formula:
$$a=\sqrt{(P_x-Q_x)^2+(P_y-Q_y)^2}\\ b=\sqrt{(P_x-R_x)^2+(P_y-R_y)^2}\\ c=\sqrt{(Q_x-R_x)^2+(Q_y-R_y)^2}$$
Using law of cosines:
$$a^2=b^2+c^2-2bc\cos\alpha\\ b^2=a^2+c^2-2ac\cos\beta\\ c^2=a^2+b^2-2ab\cos\gamma$$