atan2pi
Compute the arctangent of y/x and divide the arctangent by π.
Interface Definition
C interface:
float atan2pif(float y, float x);
double atan2pi(double y, 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 result of atan(y/x)/π is returned. res ∈ [-1, +1]
- Special values: See the following table.
Input Value (y)
Input Value (x)
Output Value (result)
+0
+0
+0
+0
-0
+1
+0
inf
+0
+0
-inf
+1
+0
NaN
NaN
-0
+0
-0
-0
-0
-1
-0
inf
-0
-0
-inf
-1
-0
NaN
NaN
inf
+0
0.5
inf
-0
0.5
inf
inf
0.25
inf
-inf
0.75
inf
NaN
NaN
-inf
+0
-0.5
-inf
-0
-0.5
-inf
inf
-0.25
-inf
-inf
-0.75
-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("atan2pi(1.0, 1.0) = %.15f\n", atan2pi(x1, x1));
printf("atan2pi(-1.0, -1.0) = %.15f\n", atan2pi(x2, x2));
printf("atan2pi(0.5, 0.5) = %.15f\n", atan2pi(x3, x3));
printf("atan2pi(-0.5, -0.5) = %.15f\n", atan2pi(x4, x4));
printf("atan2pi(0.0, 0.0) = %.15f\n", atan2pi(a, a));
printf("atan2pi(-0.0, -0.0) = %.15f\n", atan2pi(-a, -a));
printf("atan2pi(INFINITY, INFINITY) = %.15f\n", atan2pi(b, b));
printf("atan2pi(-INFINITY, -INFINITY) = %.15f\n", atan2pi(c, c));
printf("atan2pi(NAN, NAN) = %.15f\n", atan2pi(d, d));
/*
* atan2pi(1.0, 1.0) = -0.750000000000000
* atan2pi(-1.0, -1.0) = 0.250000000000000
* atan2pi(0.5, 0.5) = 0.250000000000000
* atan2pi(-0.5, -0.5) = -0.750000000000000
* atan2pi(0.0, 0.0) = 0.000000000000000
* atan2pi(-0.0, -0.0) = -1.000000000000000
* atan2pi(INFINITY, INFINITY) = 0.250000000000000
* atan2pi(-INFINITY, -INFINITY) = -0.750000000000000
* atan2pi(NAN, NAN) = nan
*
* */
Parent topic: Function Syntax