atan、atanf、atanl、atan2、atan2f、atan2l


很久不發博客了,今天在園中計算各種角,於是復習下fan正切函數
計算 x的反正切值 (atanatanf和 atanl) 或y/x 的反正切值 (atan2atan2f和 atan2l)。
 
 
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 
);
long double atanl(
   long double x
);
float atan2f(
   float y,
   float x
);
long double atan2l(
   long double y,
   long double x
);

 

參數
 
x, y

任何數量。

返回值

 
atan 返回 x –π/2 到π/2弧度范圍內的反正切值。 atan2 返回 y/x –π/2 到π/2弧度范圍內的反正切值。如果 x 為0,則 atan返回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 具有使用Streaming SIMD Extensions 2(SSE2)的實現。 有關使用SSE2實現的信息和限制,請參見_set_SSE2_enable

由於 C++ 允許重載,可以調用 atanatan2重載函數。 在 C 程序中,atan 和 atan2 始終采用並返回兩個。

 

要求
 
 

例程

必需的標頭

atanatan2atanfatan2fatanlatan2l

<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;
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM