Tan 函数

计算一个角度的正切值,角度以弧度为单位。

以 Alpha 角为例,在直角三角形中 Tan 函数计算的是 Alpha 的对边与邻边长度之比。

Tan(Alpha) = 对边/邻边

语法:

Tan (Number)

返回值:

双精度型

参数:

Number:要计算正切值的任意数字表达式(以弧度为单位)。

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

度 = (弧度 * 180)/Pi

弧度 = (度 * Pi)/180

Pi 的近似值是 3.141593。

错误代码:

5 无效的过程调用

示例:

' 在此示例中,以下项均针对直角三角形:

' 角的对边和角度(以度为单位),并根据它们来计算角的邻边长度:

Sub ExampleTangens

' Pi = 3.1415926 是预定义变量

Dim d1 As Double

Dim dAlpha As Double

    d1 = InputBox("Enter the length of the side opposite the angle:","opposite")

    dAlpha = InputBox("Enter the Alpha angle (in degrees):","Alpha")

    Print "the length of the side adjacent the angle is"; (d1 / tan (dAlpha * Pi / 180))

End Sub