
A 2vector
$(x,y)$
can be described by two numbers that are not coefficients
in a sum: its length, and the angle its vector makes with the
$x$
axis.
The first of these is usually written as
$r$
, the second as
$\theta $
.
These parameters obey
${r}^{2}={x}^{2}+{y}^{2}$
and
$\mathrm{tan}\theta =\frac{y}{x}$
;
the inverse relations are
$x=r\mathrm{cos}\theta ,y=r\mathrm{sin}\theta $
.
$r$
and
$\theta $
are called polar coordinates.
Calculating the angle $\theta $ in polar coordinates is a bit tricky; the obvious thing to try is $\mathrm{atan}(y,x)$ but that is defined only between $\frac{\pi}{2}$ and $\frac{\pi}{2}$ , while $\theta $ has a domain of size $2\pi $ .
Here is something that works: $\mathrm{acos}\left(\frac{x}{\sqrt{{x}^{2}+{y}^{2}}}\right)*\text{if}(y0,1,1)$ .
This gives theta in the range $\pi $ to $\pi $ . If you want it to have range 0 to $2\pi $ you can add $\text{if}(y0,8*\mathrm{atan}(1),0)$ to it.
