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

返回值:

Double

参数:

数字」: 用于指定要计算余弦值的角度的数字表达式,以弧度为单位。

要将度转换为弧度,可将度乘以 pi/180;而要将弧度转换为度,则将弧度乘以 180/pi。

度=(弧度*180)/pi

弧度= (度*pi) /180

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

错误代码:

5 无效的过程调用

示例:


' 以下示例以直角三角形为例,要求输入
' 邻边和角度 (以度为单位),并通过它们来计算三角形斜边的长度:
Sub ExampleCosinus
' 舍入后的 Pi = 3.14159
Dim d1 As Double, dAngle As Double
    d1 = InputBox("请输入邻边的长度Adjacen:  ","Adjacent")
    dAngle = InputBox("请输入角度Alpha (度): ","Alpha")
    Print "斜边的长度为: "; (d1 / cos (dAngle * Pi / 180))
End Sub

请支持我们!