Math.atan()
Baseline
Widely available
This feature is well established and works across many devices and browser versions. Itâs been available across browsers since 2015å¹´7æ.
Math.atan() ã¯éçã¡ã½ããã§ãæ°å¤ã®éæ£æ¥ï¼ã¢ã¼ã¯ã¿ã³ã¸ã§ã³ãï¼ãã©ã¸ã¢ã³åä½ã§è¿ãã¾ãã
試ãã¦ã¿ã¾ããã
// Calculates angle of a right-angle triangle in radians
function calcAngle(opposite, adjacent) {
return Math.atan(opposite / adjacent);
}
console.log(calcAngle(8, 10));
// äºæ³ãããçµæ: 0.6747409422235527
console.log(calcAngle(5, 3));
// äºæ³ãããçµæ: 1.0303768265243125
æ§æ
Math.atan(x)
弿°
x-
æ°å¤ã§ãã
è¿å¤
ï¼ ï½ ã§ä¸¡ç«¯ãå«ãã©ã¸ã¢ã³åä½ã®è§åº¦ã§ããï¼ x ã®éæ£æ¥ï¼ã¢ã¼ã¯ã¿ã³ã¸ã§ã³ãï¼ã§ãã x ã Infinity ã§ããå ´å㯠ãè¿ãã¾ãã x gã -Infinity ã§ããå ´åã ãè¿ãã¾ãã
解説
atan() 㯠Math ã®éçã¡ã½ããã§ãããããçæãã Math ãªãã¸ã§ã¯ãã®ã¡ã½ããã¨ãã¦ã§ã¯ãªãã常㫠Math.atan() ã¨ãã¦ä½¿ç¨ããããã«ãã¦ãã ãã (Math ã¯ã³ã³ã¹ãã©ã¯ã¿ã¼ã§ã¯ããã¾ãã)ã
ä¾
>Math.atan() ã®ä½¿ç¨
Math.atan(-Infinity); // -1.5707963267948966 (-Ï/2)
Math.atan(-0); // -0
Math.atan(0); // 0
Math.atan(1); // 0.7853981633974483 (Ï/4)
Math.atan(Infinity); // 1.5707963267948966 (Ï/2)
// ç´ç· (0,0) -- (x,y) ãç´äº¤åº§æ¨ç³»ã«ãã㦠x 軸ã¨ãªãè§åº¦
const theta = (x, y) => Math.atan(y / x);
ã·ã¼ã¿é¢æ°ãé¿ãã代ããã« Math.atan2() ã使ç¨ãããã¨ããå§ããã¾ããããã¯ãããåºãç¯å²ï¼-Ï ãã Ï ã¾ã§ï¼ãä¿æãã¦ãããx ã 0 ã®å ´åãªã©ã NaN ãåºåããªãããã«ãã¾ãã
仿§æ¸
| Specification |
|---|
| ECMAScript® 2027 Language Specification> # sec-math.atan> |