跳到主要内容

ATAN2

返回指定 x 和 y 坐标的反正切值,以弧度表示,范围在 -Pi 和 Pi 之间,不包括 -Pi。

语法

expression.ATAN2(arg1, arg2);

expression - 表示 ApiWorksheetFunction 类的变量。

参数

名称必需/可选数据类型默认值描述
arg1必需ApiRange | ApiName | number点的 x 坐标。
arg2必需ApiRange | ApiName | number点的 y 坐标。

返回值

number

示例

计算电子表格中由 x 和 y 坐标定义的点的反正切。

// Get the angle in radians from a pair of coordinates in a spreadsheet.

// Determine direction from the origin to a specific point in a spreadsheet.

let worksheet = Api.GetActiveSheet();
let func = Api.WorksheetFunction;
worksheet.GetRange("A1").SetValue(func.ATAN2(1, -9));