#C 语言标准库函数 atan2pil
#include <math.h>
long double atan2pil(long double y, long double x);
说明
按两个直角坐标求方向角,并将结果表示为 π 的倍数。
参数次序为竖直坐标在前。符号参与象限选择。
自 C23 起提供。
参数
y- 竖直坐标。x- 水平坐标。
返回值
- 返回 [-1, 1] 中的方向角,示例为 0.75。
#示例
使用 GCC 时,在链接命令末尾添加 -lm。
#include <math.h>
#include <stdio.h>
int main(void)
{
long double computed = atan2pil(1.0L, -1.0L);
printf("%Lg\n", (long double)computed);
return !(computed == 0.75);
}
运行结果。
0.75
#相关接口
- 接口变体 atan2pi、atan2pif、atan2pid32、atan2pid64、atan2pid128
- 类型通用分派 atan2pi(类型通用宏)
- 相关操作 atanl、atan2l、atanpil