atan2 definition
In terms of the standard arctan function, whose range is (?π/2,
π/2), it can be expressed as follows:
- 0 \\ \arctan\left(\frac y x\right) + \pi& \qquad y \ge 0 , x 0 , x = 0 \\ -\frac{\pi}{2} & \qquad y
-
Notes:
- This produces results in the range (?π,
π], which can be mapped to [0,
2π) by adding 2π 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.
- The C function atan2, and most other computer
- For systems implementing signed
zero, infinities,
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 +π.
- This produces results in the range (?π,
atan
interval is
(-pi/2,pi/2)
atan2 atan,码迷,mamicode.com
时间: 2024-11-04 16:23:55