Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Func _ATAN2(Const $NY, Const $NX)
- Const $NPI = 3.14159265358979
- Local $NRESULT
- If IsNumber($NY) = 0 Then
- SetError(1)
- Return 0
- ElseIf IsNumber($NX) = 0 Then
- SetError(1)
- Return 0
- EndIf
- If $NX = 0 Then
- If $NY > 0 Then
- $NRESULT = $NPI / 2
- ElseIf $NY < 0 Then
- $NRESULT = 3 * $NPI / 2
- Else
- SetError(2)
- Return 0
- EndIf
- ElseIf $NX < 0 Then
- $NRESULT = ATan($NY / $NX) + $NPI
- Else
- $NRESULT = ATan($NY / $NX)
- EndIf
- While $NRESULT < 0
- $NRESULT += 2 * $NPI
- WEnd
- Return $NRESULT
- EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement