' arc tangent of Y/X - returns values in all four quadrantsFunction Atn2(x As Double, y As Double) As Double If x = 0 Then Atn2 = Sgn(y) * 1.5707963267949 ElseIf x > 0 Then Atn2 = Atn(y / x) Else Atn2 = Atn(y / x) + 3.14159265358979 * Sgn(y) End IfEnd Function