计算由一个点,作为原点和正 x 轴形成的角度。
atan2()
最常用于将几何图形定向到鼠标的位置,如 atan2(mouseY, mouseX)
。第一个参数是点的 y 坐标,第二个参数是其 x 坐标。
默认情况下,atan2()
返回的值范围是 -π(约-3.14)到 π(3.14)。如果 angleMode() 设置为 DEGREES
,则返回的值范围是 -180 到 180。
示例
语法
atan2(y, x)
参数
y
数字:
点的 y 坐标。
x
数字:
点的 x 坐标。
返回值
数字: 给定点的反正切。
This page is generated from the comments in src/math/trigonometry.js . Please feel free to edit it and submit a pull request!