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
Dependencies
C: "km.h"
Examples
C interface:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | // 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: Trigonometric Functions