メインコンテンツまでスキップ
バージョン: 26.x

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