atan2d
计算y/x的反正切的角度值。
接口定义
C interface:
float atan2df(float y, float x);
double atan2d(double y, double x);
long double atan2dl(long double y, long double x);
参数
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
x |
|
表示输入数据的浮点值。 |
输入 |
y |
|
表示输入数据的浮点值。 |
输入 |
返回值
- 正常区间:返回y/x的反正切的角度值,即atan2d(y/x) = atan2(y/x) * 180 / π。
- 特殊区间:如下所示。
输入值(y)
输入值(x)
输出值(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
依赖
C: "km.h"
示例
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 * * */
父主题: 三角函数