Advertisement
Guest User

Untitled

a guest
Dec 17th, 2012
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 0.67 KB | None | 0 0
  1. Func _ATAN2(Const $NY, Const $NX)
  2.     Const $NPI = 3.14159265358979
  3.     Local $NRESULT
  4.     If IsNumber($NY) = 0 Then
  5.         SetError(1)
  6.         Return 0
  7.     ElseIf IsNumber($NX) = 0 Then
  8.         SetError(1)
  9.         Return 0
  10.     EndIf
  11.     If $NX = 0 Then
  12.         If $NY > 0 Then
  13.             $NRESULT = $NPI / 2
  14.         ElseIf $NY < 0 Then
  15.             $NRESULT = 3 * $NPI / 2
  16.         Else
  17.             SetError(2)
  18.             Return 0
  19.         EndIf
  20.     ElseIf $NX < 0 Then
  21.         $NRESULT = ATan($NY / $NX) + $NPI
  22.     Else
  23.         $NRESULT = ATan($NY / $NX)
  24.     EndIf
  25.     While $NRESULT < 0
  26.         $NRESULT += 2 * $NPI
  27.     WEnd
  28.     Return $NRESULT
  29. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement