27 | 06 | 2017

ArcTan, ArcCos, ArcSin

Visual Basic does not have a function to calculate ArcTan, ArcSin or ArcCos. Vb.Net has. 

In Vb.Net the arc functions are places in the System.Math namespace.

Import the name space and use the functions below.

ASin()
ACos()
ATan()

 

 

For VBA use:

 

Public Function Arccos(X) As Double

If Round(X, 8) = 1# Then Arccos = 0#: Exit Function
If Round(X, 8) = -1# Then Arccos = PI: Exit Function
Arccos = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1)

End Function

Public Function Arcsin(X As Double) As Double
If (Sqr(1 - X * X) <= 0.000000000001) And (Sqr(1 - X * X) >= -0.000000000001) Then
Arcsin = PI / 2
Else
Arcsin = Atn(X / Sqr(-X * X + 1))
End If
End Function

 
 
Public Function ArcTan(ByVal X As Double, ByVal Y As Double) As Double
If X = 0 And Y = 0 Then
Arctan= 0
Else
If X = 0 Then X = 0.00000000001
Arctan = Atn(Y / X) - PI * (X < 0)
End If
End Function

Download the source code for an arc calculator below (registered users only). 
 
 Calculate Arc functions
Login

Sign up now and upload your code to the website.

Help us to continue.....
Statistics
Articles View Hits
2288634
Latest Articles