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 |
+---------------------------------+