|
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 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 codePublic 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 codePublic 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
|
Comments
RSS feed for comments to this post.