Tan Function

決定一個角度的正切值,角度以弧度做為單位指定。

以 Alpha 角為例,在直角三角形中 Tan 函式計算 Alpha 的對邊與鄰邊長度之比。

Tan(Alpha) = 對邊/鄰邊

語法

Tan (Number)

傳回值類型

Double

參數:

Number:要計算正切值的任意數值型表示式 (以弧度為單位)。

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

度 = (弧度*180)/Pi

弧度 = (度*Pi)/180

Pi 的近似值是 3.141593。

錯誤代碼:

5 無效的程序呼叫

示例:

REM 在此示例中,以下條目均可用於直角三角形:

REM 角的對邊和角度 (以度為單位),並計算角的鄰邊長度:

Sub ExampleTangens

REM 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