VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Visual Basic implementation of the Atn2 function. Calculates the angle in radians between +pi to -p

by Paul D. Cary (1 Submission)
Category: Math/Dates
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 6th August 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Visual Basic implementation of the Atn2 function. Calculates the angle in radians between +pi to -pi given the y,x components (rise/run)

Rate Visual Basic implementation of the Atn2 function. Calculates the angle in radians between +pi to -p



    On Error GoTo DivideError
    Atn2 = Atn(y / x)
    If (x < 0) Then
        If (y < 0) Then Atn2 = Atn2 - vbPI Else Atn2 = Atn2 + vbPI
    End If
    Exit Function
DivideError:
    If Abs(y) > Abs(x) Then   'Must be an overflow
        If y > 0 Then Atn2 = vbPI / 2 Else Atn2 = -vbPI / 2
    Else
        Atn2 = 0   'Must be an underflow
    End If
    Resume Next
End Function


Download this snippet    Add to My Saved Code

Visual Basic implementation of the Atn2 function. Calculates the angle in radians between +pi to -p Comments

No comments have been posted about Visual Basic implementation of the Atn2 function. Calculates the angle in radians between +pi to -p. Why not be the first to post a comment about Visual Basic implementation of the Atn2 function. Calculates the angle in radians between +pi to -p.

Post your comment

Subject:
Message:
0/1000 characters