I need an efficient way to compare the measures of two angles in $\mathbb{R^2}$ that ideally relies on the smallest number of arithmetic operations and no trigonometric operations (no $\arccos$) or square roots. Given two angles $\angle{p_1p_0p_2}$ and $\angle{p_3p_0p_4}$ whose measures are in the range $\big(0,{\pi}\big)$ radians with vertex $p_0$ at the origin, what is the fastest way to compare the measures of the angles (i.e. find which angle has the largest measure/which one has the smallest measure)?
I understand that the $z$ component of the cross product of two or more pairs of vectors can be used to compare angles where $\theta \in \big(0,\frac{\pi}{2}\big)$ radians. As stated above, however, I need to compare angles with $\theta \in \big(0,{\pi}\big)$.
Any ideas?
Let $\theta$ be the angle between $p_1$ and $p_2$, and $\phi$ the one between $p_3$ and $p_4$. Since $p_1 \cdot p_2 = |p_1| |p_2| \cos \theta$, the sign (positive or negative) of $p_1 \cdot p_2$ tells you whether $\theta \in [0, \pi/2)$ or $(\pi/2, \pi)$. Similarly for $\phi$, and so you may already be able to tell which is larger.
If both dot products have the same sign, then define $$ r_\theta := (p_1 \cdot p_2)^2 |p_3|^2 |p_4|^2 = |p_1|^2 |p_2|^2 |p_3|^2 |p_4|^2 \cos^2 \theta$$ and $$ r_\phi := (p_3 \cdot p_4)^2 |p_1|^2 |p_2|^2 = |p_1|^2 |p_2|^2 |p_3|^2 |p_4|^2 \cos^2 \phi$$ and so comparing $r_\theta$ and $r_\phi$ tells you which has the largest cosine squared, from which you can figure out what is the larger angle. At worst, this takes 6 dot products, 4 multiplications, and 4 comparisons.