At my work, I have come across code with the following way of calculating the angle between two vectors.
$$\theta = 2 \sin^{-1}\left(\frac{1}{2}\left\|\hat{A}-\hat{B} \right\|\right)$$
(Note the physics convention: $\hat{v}$ indicates the normalization of $v$; ie, $\hat{v}:=v/\|v\|$).
I've spent some time, but I can't think of how this was derived using typical methodologies (law of sines, law of cosines, dot product, cross product). It is pretty different. So my questions is,
How could this have been derived?
This works when $A$ and $B$ are unit vectors.
You have $$ \|A-B\|^2=(A-B)\cdot(A-B)=\|A\|^2+\|B\|^2-2\,A\cdot B=2-2\cos\theta=4\sin^2\tfrac\theta2. $$ Solving, $$ \theta=2\arcsin\tfrac{\|A-B\|}2. $$