欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JavaScript atan2() 方法

定義和用法

atan2() 方法可返回從 x 軸到點(diǎn) (x,y) 之間的角度。

語(yǔ)法

Math.atan2(y,x)
參數(shù) 描述
x 必需。指定點(diǎn)的 X 坐標(biāo)。
y 必需。指定點(diǎn)的 Y 坐標(biāo)。

返回值

-PI 到 PI 之間的值,是從 X 軸正向逆時(shí)針旋轉(zhuǎn)到點(diǎn) (x,y) 時(shí)經(jīng)過(guò)的角度。

提示和注釋

注釋:請(qǐng)注意這個(gè)函數(shù)的參數(shù)順序,Y 坐標(biāo)在 X 坐標(biāo)之前傳遞。

實(shí)例

下面這個(gè)例子可通過(guò) atan2() 方法返回不同 (x,y) 點(diǎn)的角度:

<script type="text/javascript">

document.write(Math.atan2(0.50,0.50) + "<br />")
document.write(Math.atan2(-0.50,-0.50) + "<br />")
document.write(Math.atan2(5,5) + "<br />")
document.write(Math.atan2(10,20) + "<br />")
document.write(Math.atan2(-5,-5) + "<br />")
document.write(Math.atan2(-10,10))

</script>

輸出:

0.7853981633974483
-2.356194490192345
0.7853981633974483
0.4636476090008061
-2.356194490192345
-0.7853981633974483 

TIY

atan2()
如何使用 atan2() 來(lái)返回不同 (x,y) 點(diǎn)的角度。