| phi = arctan2(y/x) // phi =< —π,π].  // Normally arcan gives phi =< —π/2,π/2] {  | 
                        |||
| if(y=>0) | |||
| { | |||
| if(x>0) | |||
| { | |||
| phi=arctan(y/x) //First Quadrant | |||
| { | |||
| elseif(x<0) | |||
| { | |||
| phi=π + arctan(y/x) //Second Quadrant | |||
| } | |||
| else | |||
| { | |||
| phi = π/2 //x=0, y=1) | |||
| } | |||
| } | |||
| elseif(y<0) | |||
| { | |||
| if(x<0) | |||
| { | |||
| phi = —π + arctan(y/x) //Third Quadrant | |||
| } | |||
| elseif(x>0) | |||
| { | |||
| phi = arctan(y/x) //Fourth Quadrant | |||
| } | |||
| else | |||
| { | |||
| phi = —π/2 //(x=0, y=-1) | |||
| } | |||
| } | |||
| else | |||
| { | |||
| if(x=-1) | |||
| { | |||
| phi = π //(x=-1, y=0) | |||
| } | |||
| else | |||
| { | |||
| phi =0 //(x=1, y=-0) | |||
| } | |||
| } | |||
| } | |||