函数 atan2 #

计算带两个参数 y/x 的反正切函数。通过提供两个参数,可以确定计算角度的正确象限。

对于矩阵,该函数逐元素求值。

Syntax #

math.atan2(y, x)

Parameters #

Parameter Type Description
y number | Array | Matrix 第二维度
x number | Array | Matrix 第一维度

Returns #

Type Description
number | Array | Matrix 四象限反正切

Throws #

Type | Description —- | ———–

Examples #

math.atan2(2, 2) / math.pi       // returns number 0.25

const angle = math.unit(60, 'deg')
const x = math.cos(angle)
const y = math.sin(angle)
math.atan2(y, x) * 180 / math.pi  // returns 60

math.atan(2)             // returns number 1.1071487177940904

另请参阅 #

tan, atan, sin, cos

Fork me on GitHub