当前位置: C语言 -- 标准库 -- <math.h> -- atan2f

atan2f函数


概要:
#include <math.h>
float atan2f(float y,float x);

描述:

atan2f

该函数计算y/x的反正切值,使用两个参数的符号确定返回值的象限。

如果两个参数均为0,将可能发生域错误。


参数:
float y

参数为一个float类型的浮点数。

float x

参数为一个float类型的浮点数。


返回值:

函数返回y/x的反正切值,返回值为区间[-π,+π]内的弧度值。


范例:
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
/*函数atan2f范例*/

#include <math.h>
#include <stdio.h>

int main(void)
{
    float y = 1.0f, x = 1.0f;
    float angle;

    angle = atan2f(y,x)*180.0f/3.14f;
    printf("The arc tangent of %.2f/%.2f is %d degrees.\n", y, x, (int)angle);

    return 0;
}

输出:

The arc tangent of 1.00/1.00 is 45 degrees.


相关内容:
atan2 double类型y/x的反正切函数。
atan2l long double类型y/x的反正切函数。