]> 3.6 Polar Coordinates

3.6 Polar Coordinates

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 r 2 = x 2 + y 2 and tan θ = y x ;
the inverse relations are x = r cos θ , y = r sin θ .
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 π 2 and π 2 , while θ has a domain of size 2 π .

Here is something that works: acos ( x x 2 + y 2 ) * if ( y < 0 , 1 , 1 ) .

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.

figure