Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015년 7월.
Math.atan2() 정적 메서드는 Math.atan2(y, x)에 대해 양의 x축과 (0, 0)에서 (x, y)점까지의 광선 사이의 평면 각도(라디안 단위)를 반환합니다.
점의 y좌표.
x점의 x좌표.
양의 x축과 (0, 0)에서 (x, y) 지점까지의 광선 사이의 각도(-π와 π 사이, 포함)를 라디안 단위로 표시합니다.
Math.atan2() 메서드는 양수 x축과 점 (x, y) 사이의 시계 반대 방향 각도 θ를 라디안 단위로 측정합니다. 이 함수의 인수는 y 좌표를 먼저 전달하고 x 좌표를 두 번째로 전달합니다.
Math.atan2()는 별도의 x 및 y 인수를 전달하는 반면, Math.atan()은 이 두 인수의 비율을 전달합니다. 다음과 같은 경우 Math.atan2(y, x)는 Math.atan(y / x)와 다릅니다.
| Infinity | Infinity | π / 4 | NaN |
| Infinity | -Infinity | -π / 4 | NaN |
| -Infinity | Infinity | 3π / 4 | NaN |
| -Infinity | -Infinity | -3π / 4 | NaN |
| 0 | 0 | 0 | NaN |
| 0 | -0 | -0 | NaN |
| < 0 (including -0) | 0 | π | 0 |
| < 0 (including -0) | -0 | -π | 0 |
| -Infinity | > 0 | π | -0 |
| -0 | > 0 | π / 2 | -π / 2 |
| -Infinity | < 0 | -π | 0 |
| -0 | < 0 | -π / 2 | π / 2 |
또한 두 번째 및 세 번째 사분면(x < 0)에 있는 점의 경우 Math.atan2()는 -π2-\frac{\pi}{2}보다 작거나 π2\frac{\pi}{2}보다 큰 각도를 출력합니다.
atan2()는 Math의 정적 메서드이므로, 생성한 Math 객체의 메서드가 아니라 항상 Math.atan2()로 사용합니다(Math는 생성자가 아닙니다).
아래 스크립트는 Math.atan2(y, x)과 Math.atan(y / x)의 차이를 출력합니다.
출력 결과는 아래와 같습니다.
| x | y | atan2 | atan | |-------|-------|-------|-------| | -∞ | -∞ | -3π/4 | NaN | | -∞ | -1 | -π | 0 | | -∞ | -0 | -π | 0 | | -∞ | 0 | π | -0 | | -∞ | 1 | π | -0 | | -∞ | ∞ | 3π/4 | NaN | | -1 | -∞ | -π/2 | π/2 | | -1 | -1 | -3π/4 | π/4 | | -1 | -0 | -π | 0 | | -1 | 0 | π | -0 | | -1 | 1 | 3π/4 | -π/4 | | -1 | ∞ | π/2 | -π/2 | | -0 | -∞ | -π/2 | π/2 | | -0 | -1 | -π/2 | π/2 | | -0 | -0 | -π | NaN | | -0 | 0 | π | NaN | | -0 | 1 | π/2 | -π/2 | | -0 | ∞ | π/2 | -π/2 | | 0 | -0 | -0 | NaN | | 0 | 0 | 0 | NaN | | ∞ | -∞ | -π/4 | NaN | | ∞ | ∞ | π/4 | NaN || ECMAScript® 2027 Language Specification # sec-math.atan2 |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025년 2월 11일 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.