최종 수정: 에
ATAN2
설명
'y' / 'x'의 아크탄젠트를 반환합니다.
구문
ATAN2(<y>, <x>)
매개변수
| 매개변수 | 설명 |
|---|---|
<x> | 원점 (0,0)에서 x축을 따라 잰 수평 거리(좌표)를 나타내는 값입니다. |
<y> | 원점 (0,0)에서 y축을 따라 잰 수직 거리(좌표)를 나타내는 값입니다. |
반환값
매개변수 y / x의 atan2 값입니다.
특수한 경우
y또는x가 NaN이면 NaN을 반환합니다x > 0이고y = ±0.0이면 ±0을 반환합니다(부호는y를 따릅니다)x = 0.0(+0.0 또는 -0.0)이고y > 0이면 π/2(약 1.570796326794897)를 반환합니다x = 0.0(+0.0 또는 -0.0)이고y < 0이면 -π/2(약 -1.570796326794897)를 반환합니다x < 0이고y = +0.0이면 π(약 3.141592653589793)를 반환하며,x < 0이고y = -0.0이면 -π를 반환합니다y = +Infinity이고x가 유한하면 π/2를 반환하며,y = -Infinity이고x가 유한하면 -π/2를 반환합니다y = +Infinity이고x = +Infinity이면 π/4(약 0.7853981633974483)를 반환합니다y = -Infinity이고x = +Infinity이면 -π/4(약 -0.7853981633974483)를 반환합니다y = +Infinity이고x = -Infinity이면 3π/4(약 2.356194490192345)를 반환합니다y = -Infinity이고x = -Infinity이면 -3π/4(약 -2.356194490192345)를 반환합니다x = +Infinity이고 유한한y> 0이면 0을 반환하며, 유한한y< 0이면 -0을 반환합니다x = -Infinity이고 유한한y> 0이면 π를 반환하며, 유한한y< 0이면 -π를 반환합니다y또는x가 NULL이면 NULL을 반환합니다
예제
select atan2(0.1, 0.2);
+---------------------+
| atan2(0.1, 0.2) |
+---------------------+
| 0.46364760900080609 |
+---------------------+
select atan2(1.0, 1.0);
+---------------------+
| atan2(1.0, 1.0) |
+---------------------+
| 0.78539816339744828 |
+---------------------+
select atan2(cast('nan' as double), 1.0);
+----------------------------------+
| atan2(cast('nan' AS DOUBLE), 1.0)|
+----------------------------------+
| NaN |
+----------------------------------+
select atan2(1.0, cast('nan' as double));
+----------------------------------+
| atan2(1.0, cast('nan' AS DOUBLE))|
+----------------------------------+
| NaN |
+----------------------------------+
select atan2(0.0, 1.0);
+----------------+
| atan2(0.0, 1.0)|
+----------------+
| 0 |
+----------------+
select atan2(-0.0, 1.0);
+-----------------+
| atan2(-0.0, 1.0)|
+-----------------+
| -0 |
+-----------------+
select atan2(0.0, -1.0);
+-----------------+
| atan2(0.0, -1.0)|
+-----------------+
| 3.141592653589793|
+------------------+
select atan2(-0.0, -1.0);
+------------------+
| atan2(-0.0, -1.0)|
+------------------+
| -3.141592653589793|
+-------------------+
select atan2(1.0, 0.0);
+----------------+
| atan2(1.0, 0.0)|
+----------------+
| 1.570796326794897 |
+--------------------+
select atan2(-1.0, 0.0);
+-----------------+
| atan2(-1.0, 0.0)|
+-----------------+
| -1.570796326794897 |
+---------------------+
select atan2(cast('inf' as double), cast('-inf' as double));
+--------------------------------------------+
| atan2(cast('inf' AS DOUBLE), cast('-inf' AS DOUBLE)) |
+--------------------------------------------+
| 2.356194490192345 |
+--------------------------------------------+
select atan2(cast('-inf' as double), cast('inf' as double));
+-------------------------------------------+
| atan2(cast('-inf' AS DOUBLE), cast('inf' AS DOUBLE)) |
+-------------------------------------------+
| -0.7853981633974483 |
+-------------------------------------------+
select atan2(1.0, cast('-inf' as double));
+----------------------------------+
| atan2(1.0, cast('-inf' AS DOUBLE))|
+----------------------------------+
| 3.141592653589793 |
+----------------------------------+
select atan2(-1.0, cast('inf' as double));
+---------------------------------+
| atan2(-1.0, cast('inf' AS DOUBLE))|
+---------------------------------+
| -0 |
+---------------------------------+