共用方式為


atan、 atanf、 atan2、 atan2f

Calculates the arctangent of x (atan or atanf) or the arctangent of y/x (atan2 or atan2f).

double atan( 
   double x 
);
float atan(
   float x 
);  // C++ only
long double atan(
   long double x
);  // C++ only
double atan2( 
   double y, 
   double x 
);
float atan2(
   float y,
   float x
);  // C++ only
long double atan2(
   long double y,
   long double x
);  // C++ only
float atanf( 
   float x 
);
float atan2f(
   float y,
   float x
);

參數

  • x, y
    任何數字。

傳回值

atan傳回的反正切, x –π/2 π/2 弧度的範圍內。 atan2傳回的反正切, y/x在範圍 –π,為 π 弳度。 If x is 0, atan returns 0. 如果兩個參數的atan2都是 0,則函數會傳回 0。 所有的結果是以弳度為單位。

atan2這兩個參數的徵兆,用於判斷傳回值 」 處理程序。

輸入

SEH 例外狀況

Matherr 例外狀況

± QNAN,IND

_DOMAIN

備註

atan函式計算的反正切, x。 atan2計算的反正切, y/x (如果x等於 0, atan2傳回 π/2,如果y為正值,-π / 2 如果y是負數或 0 y為 0。)

atan已使用資料流 SIMD 延伸模組 2 (SSE2) 的實作。 請參閱 _set_SSE2_enable 的資訊,並使用 SSE2 實作的限制。

C + + 允許多載化,因此您可以呼叫多載的atanatan2。 在某 c 程式, atanatan2一直使用,並傳回雙精度浮點數。

需求

常式

所需的標頭

atan, atan2, atanf, atan2f

<math.h>

範例

// crt_atan.c
// arguments: 5 0.5
#include <math.h>
#include <stdio.h>
#include <errno.h>

int main( int ac, char* av[] ) 
{
   double x, y, theta;
   if( ac != 3 ){
      fprintf( stderr, "Usage: %s <x> <y>\n", av[0] );
      return 1;
   }
   x = atof( av[1] );
   theta = atan( x );
   printf( "Arctangent of %f: %f\n", x, theta );
   y = atof( av[2] );
   theta = atan2( y, x );
   printf( "Arctangent of %f / %f: %f\n", y, x, theta ); 
   return 0;
}
  

.NET Framework 對等用法

請參閱

參考

浮點支援

acos acosf

asin asinf

cos,cosf,cosh、 coshf

_matherr

sin、 sinf、 sinh、 sinhf

tan、 tanf、 tanh、 tanhf

_CIatan

_CIatan2