ES6 - Math.atan2() 函式



此方法返回其引數商的反正切值。atan2 方法返回一個介於 -pi 和 pi 之間的數值,表示 (x, y) 點的角度 θ。

語法

Math.atan2(x,y)       

引數

  • x 和 y − 表示一個數字

示例

console.log("---Math.atan2()---") 
console.log("Math.atan2(0): "+Math.atan2(0,1)) 
console.log("Math.atan2(Math.SQRT1_2): "+Math.atan2(1,1))           

輸出

---Math.atan2()--- 
Math.atan2(0): 0 
Math.atan2(Math.SQRT1_2): 0.7853981633974483       
廣告
© . All rights reserved.