Home C&C++函数库 c++ 语法 程序源码 Linux C库

atan2

函数  <cmath> <ctgmath>

C90 double atan2(double y, double x);
C99 double atan2 (double y , double x);
float atan2f (float y , float x);
long double atan2l (long double y, long double x);
C++98 double atan2 (double y , double x);
float atan2 (float y , float x);
long double atan2 (long double y, long double x);
C++11 double atan2 (double y , double x);
float atan2 (float y , float x);
long double atan2 (long double y, long double x);
double atan2 (Type1 y , Type2 x);     // additional overloads

用两个参数计算反正切
返回y/x的反正切的主值,以弧度表示。
为了计算值,函数考虑了两个参数的符号,以确定象限。

在c++中,这个函数在<valarray>(参见valarray atan2)中重载。

C99 头文件<tgmath.h> 提供了该函数的类型泛型宏版本。
C++98 这个函数在<valarray> 中重载(参见valarray atan2)。
C++11 这个头文件(<cmath>) 为其他算术类型(Type1和Type2)提供了额外的重载: 这些重载在计算前有效地将其实参转换为double, 如果有一个实参是long double类型,两个实参都被转换为long double类型。
这个函数在<valarray> 中也重载(参见valarray atan)。

☲  参数


y
值表示y坐标的部分。
x
值表示x坐标的部分。

☉  返回值



返回y/x的反正切的主值,在[-pi,+pi]弧度内。
一弧度(radian)等于180/PI 角度。
C90(C++98) 如果发生域错误,则将全局变量errno设置为EDOM。
C99(C++11) 如果出现域错误:
-并且math_errhandling设置了MATH_ERRNO: 全局变量errno设置为EDOM。
-并且math_errhandling设置了MATH_ERREXCEPT: 触发FE_INVALID

☣  示例



/* atan2 example */
#include <stdio.h>      /* printf */
#include <math.h>       /* atan2 */

#define PI 3.14159265

int main ()
{
  double x, y, result;
  x = -10.0;
  y = 10.0;
  result = atan2 (y,x) * 180 / PI;
  printf ("The arc tangent for (x=%f, y=%f) is %f degrees\n", x, y, result );
  return 0;
}

输出:
The arc tangent for (x=-10.000000, y=10.000000) is 135.000000 degrees.

🍄  另请参阅



cos 余弦 (function )
sin 正弦 (function )
tan 正切 (function )
atan 反正切 (function )

联系我们 免责声明 关于CandCplus 网站地图