Let us say we have a vector with $x$-component $-2$, and $y$-component $-1$. We have the equation:
$$\tan\theta=\frac{-1}{-2}$$
So if we take the inverse of $\tan$ of $\frac12$ we get $26.565^\circ$. The problem is this is wrong, it's $206.565^\circ$. The problem is apparent; the equation above has multiple solutions. The inverse of $\tan$ occasionally gives us the wrong angle. (Another way to understand the problem is that the magnitude satisfies $c^2 = (-2)^2 + (-1)^2$, which has two solutions, one of which makes $26.565^\circ$ correct).
Of course, you can draw pictures to solve this and figure out which angle is correct. My question is, is there a more direct way to find the angle? Ideally, it should involve any decision making or conditionals, it should be a direct calculation.
I know that what a "direct calculation" constitutes is technically subjective.
The formula $$ \theta=\arctan\left(\frac yx\right)\tag{1} $$ assumes that $x\gt0$. If $x\lt0$, then add or subtract $180^\circ$ as desired.
A formula I use is $$ \theta=2\arctan\left(\frac{y}{x+\sqrt{x^2+y^2}}\right)\tag{2} $$ Just as $(1)$ divides by $0$ when $x=0$, $(2)$ divides by $0$ when $x\le0$ and $y=0$; that is, when $(x,y)$ is on the negative $x$-axis, where $\theta=180^\circ$.