calculate/define 如何在 VBA 中使用 ArcSin 函数?
How to calculate/define ArcSin function in VBA?
如何实现arcsin函数(定义如下)的VBA代码?
定义:反正弦函数是正弦函数的反函数。它 returns 正弦为给定数字的角度。对于每个三角函数,都有一个反向工作的反函数。这些反函数具有相同的名称,但前面带有 'arc'。 (在一些计算器上,arcsin 按钮可能被标记为 asin,有时是 sin-1。)因此 sin 的倒数是 arcsin 等。当我们看到“arcsin A”时,我们将其理解为“sin 为 A 的角”
sin30 = 0.5 Means: The sine of 30 degrees is 0.5
arcsin 0.5 = 30 Means: The angle whose sin is 0.5 is 30 degrees.
以下代码将有助于根据给定的定义实现 ARCSIN 函数:
Option Explicit
Public Const Pi As Double = 3.14159265358979
Private Function ArcSin(X As Double) As Double
If Abs(X) = 1 Then
'The VBA Sgn function returns an integer (+1, 0 or -1),
'representing the arithmetic sign of a supplied number.
ArcSin = Sgn(X) * Pi / 2
Else
'Atn is the inverse trigonometric function of Tan,
'which takes an angle as its argument and returns
'the ratio of two sides of a right triangle
ArcSin = Atn(X / Sqr(1 - X ^ 2))
End If
End Function
我不太明白你的问题。 arcsin 函数已经存在于 VBA 中,您可以将其与 :
一起使用
WorksheetFunction.Asin(myValue)
反正弦函数的使用
Dim myValue As Double
myValue = 0.1234
MsgBox CStr(WorksheetFunction.Asin(myValue))
您可以在此处打印 arcsin 函数的结果作为 Double。
如何实现arcsin函数(定义如下)的VBA代码?
定义:反正弦函数是正弦函数的反函数。它 returns 正弦为给定数字的角度。对于每个三角函数,都有一个反向工作的反函数。这些反函数具有相同的名称,但前面带有 'arc'。 (在一些计算器上,arcsin 按钮可能被标记为 asin,有时是 sin-1。)因此 sin 的倒数是 arcsin 等。当我们看到“arcsin A”时,我们将其理解为“sin 为 A 的角”
sin30 = 0.5 Means: The sine of 30 degrees is 0.5
arcsin 0.5 = 30 Means: The angle whose sin is 0.5 is 30 degrees.
以下代码将有助于根据给定的定义实现 ARCSIN 函数:
Option Explicit
Public Const Pi As Double = 3.14159265358979
Private Function ArcSin(X As Double) As Double
If Abs(X) = 1 Then
'The VBA Sgn function returns an integer (+1, 0 or -1),
'representing the arithmetic sign of a supplied number.
ArcSin = Sgn(X) * Pi / 2
Else
'Atn is the inverse trigonometric function of Tan,
'which takes an angle as its argument and returns
'the ratio of two sides of a right triangle
ArcSin = Atn(X / Sqr(1 - X ^ 2))
End If
End Function
我不太明白你的问题。 arcsin 函数已经存在于 VBA 中,您可以将其与 :
一起使用WorksheetFunction.Asin(myValue)
反正弦函数的使用
Dim myValue As Double
myValue = 0.1234
MsgBox CStr(WorksheetFunction.Asin(myValue))
您可以在此处打印 arcsin 函数的结果作为 Double。