Inverse tangent function.
- Parameters
-
Method
1. Reduce y to positive by atan2(y,x)=-atan2(-y,x).
2. Reduce x to positive by (if x and y are unexceptional):
ARG (x+iy) = arctan(y/x) ... if x > 0,
ARG (x+iy) = pi - arctan[y/(-x)] ... if x < 0,
Special cases
ATAN2((anything), NaN ) is NaN;
ATAN2(NAN , (anything) ) is NaN;
ATAN2(+-0, +(anything but NaN)) is +-0 ;
ATAN2(+-0, -(anything but NaN)) is +-pi ;
ATAN2(+-(anything but 0 and NaN), 0) is +-pi/2;
ATAN2(+-(anything but INF and NaN), +INF) is +-0 ;
ATAN2(+-(anything but INF and NaN), -INF) is +-pi;
ATAN2(+-INF,+INF ) is +-pi/4 ;
ATAN2(+-INF,-INF ) is +-3pi/4;
ATAN2(+-INF, (anything but,0,NaN, and INF)) is +-pi/2;
Constants
The hexadecimal values are the intended ones for the following
constants. The decimal values may be used, provided that the
compiler will convert from decimal to binary accurately enough
to produce the hexadecimal values shown.
Definition at line 87 of file atan2.c.
References atan(), fabs(), pi, pi_lo, pi_o_2, pi_o_4, tiny, and zero.
Referenced by clog(), and cpow().
90 int32_t k, m, hx, hy, ix, iy;
97 if (((ix | ((lx | -lx) >> 31)) > 0x7ff00000) ||
98 ((iy | ((ly | -ly) >> 31)) > 0x7ff00000))
100 if (((hx - 0x3ff00000) | lx) == 0)
102 m = ((hy >> 31) & 1) | ((hx >> 30) & 2);
123 if (ix == 0x7ff00000)
125 if (iy == 0x7ff00000)
155 if (iy == 0x7ff00000)
162 else if (hx < 0 && k < -60)
double atan(double x)
Inverse tangent function.
#define GET_HIGH_WORD(i, d)
Get the more significant 32 bit int from a double.
#define EXTRACT_WORDS(ix0, ix1, d)
Get two 32 bit ints from a double.
static const double pi_lo
static const double pi_o_2
static const double pi_o_4
#define SET_HIGH_WORD(d, v)
Set the more significant 32 bits of a double from an int.
double fabs(double x)
Returns the absolute value of x.