atan2d
Compute the degree corresponding to the arctangent of y/x.
Interface Definition
C interface:
float atan2df(float y, float x);
double atan2d(double y, double x);
long double atan2dl(long double y, long double x);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
x |
|
Floating-point value of the input data. |
Input |
y |
|
Floating-point value of the input data. |
Input |
Return Value
- Normal range: The degree corresponding to the arctangent of y/x is returned, that is, atan2d(y/x) = atan2(y/x) * 180/π.
- Special values: See the following table.
Input Value (y)
Input Value (x)
Output Value (result)
+0
+0
+0
+0
-0
180
+0
inf
+0
+0
-inf
180
+0
NaN
NaN
-0
+0
-0
-0
-0
-180
-0
inf
-0
-0
-inf
-180
-0
NaN
NaN
inf
+0
90
inf
-0
90
inf
inf
45
inf
-inf
135
inf
NaN
NaN
-inf
+0
-90
-inf
-0
-90
-inf
inf
-45
-inf
-inf
-135
-inf
NaN
NaN
NaN
+0
NaN
NaN
-0
NaN
NaN
inf
NaN
NaN
-inf
NaN
NaN
NaN
NaN
Dependency
C: "km.h"
Example
C interface:
// typical usage
float x1 = -1.0, x2 = 1.0, x3 = 0.5, x4 = -0.5;
// special handling
float a = 0.0, b = INFINITY, c = -INFINITY, d = NAN;
// print result
printf("atan2d(1.0, 1.0) = %.15f\n", atan2d(x1, x1));
printf("atan2d(-1.0, -1.0) = %.15f\n", atan2d(x2, x2));
printf("atan2d(0.5, 0.5) = %.15f\n", atan2d(x3, x3));
printf("atan2d(-0.5, -0.5) = %.15f\n", atan2d(x4, x4));
printf("atan2d(0.0, 0.0) = %.15f\n", atan2d(a, a));
printf("atan2d(-0.0, -0.0) = %.15f\n", atan2d(-a, -a));
printf("atan2d(INFINITY, INFINITY) = %.15f\n", atan2d(b, b));
printf("atan2d(-INFINITY, -INFINITY) = %.15f\n", atan2d(c, c));
printf("atan2d(NAN, NAN) = %.15f\n", atan2d(d, d));
/*
* atan2d(1.0, 1.0) = -135.000000000000000
* atan2d(-1.0, -1.0) = 45.000000000000000
* atan2d(0.5, 0.5) = 45.000000000000000
* atan2d(-0.5, -0.5) = -135.000000000000000
* atan2d(0.0, 0.0) = 0.000000000000000
* atan2d(-0.0, -0.0) = -180.000000000000000
* atan2d(INFINITY, INFINITY) = 45.000000000000000
* atan2d(-INFINITY, -INFINITY) = -135.000000000000000
* atan2d(NAN, NAN) = nan
*
* */
Parent topic: Function Syntax