std::atan2,std::atan2f,std::atan2l (3) - Linux Man Pages
Defined in header <cmath>
float atan2 ( float y, float x );
float atan2f( float y, float x ); (since C++11)
double atan2 ( double y, double x ); (1) (2)
long double atan2 ( long double y, long double x );
long double atan2l( long double y, long double x ); (3) (since C++11)
Promoted atan2 ( Arithmetic1 y, Arithmetic2 x ); (4) (since C++11)
1-3) Computes the arc tangent of y/x using the signs of arguments to determine the correct quadrant.
4) A set of overloads or a function template for all combinations of arguments of arithmetic type not covered by 1-3). If any argument has integral_type, it is cast to double. If any argument is long double, then the return type Promoted is also long double, otherwise the return type is always double.
x, y - values of floating-point or integral_types
If no errors occur, the arc tangent of y/x (arctan(
If a domain error occurs, an implementation-defined value is returned (NaN where supported)
If a range error occurs due to underflow, the correct result (after rounding) is returned.
Errors are reported as specified in math_errhandling.
Domain error may occur if x and y are both zero.
If the implementation supports IEEE floating-point arithmetic (IEC 60559),
* If x and y are both zero, domain error does not occur
* If x and y are both zero, range error does not occur either
* If y is zero, pole error does not occur
* If y is ±0 and x is negative or -0, ±π is returned
* If y is ±0 and x is positive or +0, ±0 is returned
* If y is ±∞ and x is finite, ±π/2 is returned
* If y is ±∞ and x is -∞, ±3π/4 is returned
* If y is ±∞ and x is +∞, ±π/4 is returned
* If x is ±0 and y is negative, -π/2 is returned
* If x is ±0 and y is positive, +π/2 is returned
* If x is -∞ and y is finite and positive, +π is returned
* If x is -∞ and y is finite and negative, -π is returned
* If x is +∞ and y is finite and positive, +0 is returned
* If x is +∞ and y is finite and negative, -0 is returned
* If either x is NaN or y is NaN, NaN is returned
std::atan2(y, x) is equivalent to std::arg(std::complex<double>(x,y))
POSIX_specifies that in case of underflow, y/x is the value returned, and if that is not supported, and implementation-defined value no greater than DBL_MIN, FLT_MIN, and LDBL_MIN is returned.
// Run this code
asinl computes arc sine (arcsin(x))
acosl computes arc cosine (arccos(x))
atanl computes arc tangent (arctan(x))