ATAN2 函数
两个数值的反正切,即四象限反正切。ATAN2(y,x) 返回两个数值 x 和 y 的反正切。它类似于计算 y / x 的反正切,但会根据两个参数的符号来确定结果所在的象限。
结果是以弧度表示的角度。要将弧度转换为度,请使用 DEGREES 函数。
用标准反正切函数表示,atan2 可以写成:
$$ \operatorname{atan2}(y,x) =
\begin{cases}
\arctan(\frac y x) &\text{if } x > 0 \\
\arctan(\frac y x) + \pi &\text{if } x < 0 \text{ and } y \ge 0 \\
\arctan(\frac y x) - \pi &\text{if } x < 0 \text{ and } y < 0 \\
+\frac{\pi}{2} &\text{if } x = 0 \text{ and } y > 0 \\
-\frac{\pi}{2} &\text{if } x = 0 \text{ and } y < 0 \\
\text{undefined} &\text{if } x = 0 \text{ and } y = 0
\end{cases}$$
注意,在 Excel 中参数 y 和 x 的顺序是相反的。