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 July 2015.
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));
// Expected output: 0.6747409422235527
console.log(calcAngle(5, 3));
// Expected output: 1.0303768265243125
구문
js
Math.atan(x)
매개변수
x
-
숫자
반환 값
x
의 역 탄젠트 ( 이상 이하의 라디안 단위의 각도).
만약 x
가 Infinity
라면 를 반환합니다.
만약 x
가 -Infinity
라면 를 반환합니다.
설명
atan()
은 Math
의 정적 메서드이므로, 생성한 Math
객체의 메서드가 아니라 항상 Math.atan()
으로 사용합니다(Math
는 생성자가 아닙니다).
예제
Math.atan() 사용하기
js
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);
theta
함수를 피하고 대신 범위가 더 넓고(-π와 π 사이) x
가 0
일 경우 NaN
을 출력하지 않는 Math.atan2()
를 사용하는 것이 좋습니다.
명세서
Specification |
---|
ECMAScript® 2025 Language Specification # sec-math.atan |
브라우저 호환성
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
atan |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.