Math.atan2():靜態方法返回平面中正 x 軸與從 (0, 0) 到點 (x, y) 的射線之間的角度(以弧度為單位)
function calcAngleDegrees(x, y) {
return Math.atan2(y, x) * 180 / Math.PI;
}
console.log(calcAngleDegrees(5, 5));
// Expected output: 45
console.log(calcAngleDegrees(10, 10));
// Expected output: 45
console.log(calcAngleDegrees(0, 10));
// Expected output: 90