A 2-vector (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 .
These parameters obey
the inverse relations are
r and are called polar coordinates.
Calculating the angle in polar coordinates is a bit tricky; the obvious thing to try is atan(y, x) but that is defined only between and , while has a domain of size 2.
Here is something that works:
This gives theta in the range - to . If you want it to have range 0 to 2 you can add if(y < 0,8 * atan(1), 0) to it.