Converting angles to the range $ -180$ deg through $180$ deg Is there a direct formula to transform a set of angles to $-180$ through $180$ deg? For instance, $181$ deg and $541$ deg should be translated to $-179$, while $-182$ deg and $-542$ deg should be translated to $178$. I know that for an angle $X$ which is not on any axis ($0, 90, 270, 360, ...$), when $\text{mod}(a,b)$ is the remainder of division of $a$ by $b$, we can write use $k = \lfloor(\frac{\text{mod}(X,360)}{90})\rfloor$ to determine the quadrant where angle $X$ resides since $k = 0, 1, 2, 3$ corresponds to quadrants $1, 2, 3, 4$ respectively. So for angle $X$:

$k = 0$ or $1$: $\text{mod}(X,360)$ gives the $0$ through $180$ range.
$k = 2$ or $3$: $\text{mod}(X,360)-360$ gives $-180$ through $0$ range.

Is there a way to make this simpler?

In your notation, $\operatorname{mod}(x,360)$ would put it in the range $0$ to $360$, and therefore, we can get what you need by $\operatorname{mod}(x+180,360)-180$, sending $x$ to the range $-180$ to $180$.
