A formula to calculate the direction of a vector from 0 to 360 degrees.
The formula is working for any value of x and y, is not using any trigonometric function and give the result with an accuracy of one billionth of the degree.
f(x , y)=180/pi()*(pi()/8*sign(x*y)*sign(y^2x^2)+pi()/4*(42*sign(y)sign
(x*y))pi()/2*(1sign(y^2))*(sign(x^2)+sign(x))
n=0
sign(x*y)*Σ(1)^n*((abs(x)*(sqrt(2)1)^(x^2y^2)abs(y)/
n=17
(abs(x)+abs(y)*(sqrt(2)1)^(x^2y^2)))^(2n+1)/(2n+1))
1 comment

Theodore Panagos commented
In order to do some corrections i 'll rewrite the formula.
f(x, y)=180/pi()*(pi()/8*sign(x*y)*sign(y^2x^2)+pi()/4*(42*sign(y)sign(x*y))pi()/2*(1sign(y^2))*(sign(x^2)+sign(x))
n=17
sign(x*y)*(Σ(1)^n*((abs(x)*(sqrt(2)1)^sign(x^2y^2)abs(y))/(abs(x)+abs(y)*(sqrt(2)1)^sign
n=0
(x^2y^2)))^(2*n+1)/(2*n+1The accuracy of the formula is one billionth of a second of a degree.
The following is a version of the formula that is using the trigonometric function ATAN.
f(x, y)=180/pi()*(pi()/8*sign(x*y)*sign(y^2x^2)+pi()/4*(42*sign(y)sign(x*y))pi()/2*(1sign(y^2))*
(sign(x^2)+sign(x))sjgn(x*y)*atan((abs(x)*(sqrt(2)1)^sign(x^2y^2)abs(y))/
(abs(x)+abs(y)*(sqrt(2)1)^sign(x^2y^2))))