atan2 atan

atan2 definition

In terms of the standard arctan function, whose range is (−π/2, π/2), it can be expressed as follows:

\operatorname{atan2}(y, x) = \begin{cases}
\arctan\left(\frac y x\right) & \qquad x > 0 \\
\arctan\left(\frac y x\right) + \pi& \qquad y \ge 0 , x < 0 \\
\arctan\left(\frac y x\right) - \pi& \qquad y < 0 , x < 0 \\
+\frac{\pi}{2} & \qquad y > 0 , x = 0 \\
-\frac{\pi}{2} & \qquad y < 0 , x = 0 \\
\text{undefined} & \qquad y = 0, x = 0
\end{cases}

Notes:

  • This produces results in the range (−π, π], which can be mapped to [0, 2π) by adding  to negative results.
  • Traditionally, atan2(0, 0) is undefined.
    • The C function atan2, and most other computer implementations, are designed to reduce the effort of transforming cartesian to polar coordinates and so always define atan2(0, 0). On implementations without signed zero, or when given positive zero arguments, it is normally defined as 0. It will always return a value in the range [−π, π] rather than raising an error or returning a NaN (Not a Number).
    • Systems supporting symbolic mathematics normally return an undefined value for atan2(0,0) or otherwise signal that an abnormal condition has arisen.
  • For systems implementing signed zeroinfinities, or Not a Number (for example, IEEE floating point), it is common to implement reasonable extensions which may extend the range of values produced to include −π and −0. These also may return NaN or raise an exception when given a NaN argument.
  • For systems implementing signed zero (for example, IEEE floating point), atan2(-0, x), x < 0 returns the value −π. atan2(+0, x), x < 0 still returns +π.

 atan

    interval is (-pi/2,pi/2) 

 

posted @ 2014-04-30 22:46  代码学习者coding  阅读(507)  评论(0编辑  收藏  举报