ATAN2
デスクリプション
'y' / 'x' のアークタンジェントを返します。
Syntax
ATAN2(<y>, <x>)
パラメータ
| Parameter | デスクリプション |
|---|---|
<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 |
+---------------------------------+