Home AutoCad VB ArcTan, ArcCos, ArcSin
23 | 02 | 2012
Main Menu
Search
Paypal Donation
So we can continue and expand this site
Content View Hits : 469522
ArcTan, ArcCos, ArcSin PDF Print E-mail
Tutorials

Visual Basic does not have a function to calculate ArcTan, ArcSin or ArcCos. The functions below can do it for you.

Show/Hidden vbnet code

View source
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


Show/Hidden vbnet code
View source
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

 
 
Show/Hidden vbnet code
View source
Public Function ArcTan(ByVal X As Double, ByVal Y As Double) As Double
 
	If X = 0 And Y = 0 Then
 
	Atan2 = 0
 
	Else
 
	If X = 0 Then X = 0.00000000001
 
	Atan2 = Atn(Y / X) - PI * (X < 0)
 
	End If
 
	End Function
 
 
 

Add comment


Security code
Refresh

Advertising

LOGON
Sponsored Links