Cos Function

計算一個角度的餘弦值,角度以弧度為單位定義,結果在 -1 到 1 之間。

Using the angle Alpha, the Cos function calculates the ratio of the length of the side that is adjacent to the angle, divided by the length of the hypotenuse in a right-angled triangle.

Cos(Alpha) = Adjacent/Hypotenuse


Cos (Number As Double) As Double

Return value:



Number:數值型表示式,用於指定要計算餘弦值的角度 (以弧度為單位)。

若要將度轉換成弧度,可將度乘以 pi/180;若要將弧度轉換成度,則將弧度乘以 180/pi。

度 = (弧度*180) /pi

弧度 = (度*pi)/180

Pi is here the fixed circle constant with the rounded value 3.14159...


5 無效的程序呼叫


REM 以下示例以直角三角形為例,要求輸入
REM 依據鄰邊和角度 (以度為單位),並計算三角形斜邊的長度:
Sub ExampleCosinus
REM 捨入後的 PI = 3.14159
Dim d1 As Double, dAngle As Double
    d1 = InputBox$ (""Enter the length of the adjacent side:","Adjacent")
    dAngle = InputBox("Enter the angle Alpha (in degrees):","Alpha")
    Print "The length of the hypothenuse is"; (d1 / cos (dAngle * Pi / 180))
End Sub

Please support us!