Partager via


atan, atanf, atanl, atan2, atan2f, atan2l

Calcule l’arc tangente de x (atan, atanf et atanl) ou l’arc tangente de y/x (atan2, atan2f et atan2l).

Syntaxe

double atan( double x );
float atanf( float x );
long double atanl( long double x );
#define atan(X) // Requires C11 or higher

float atan( float x );  // C++ only
long double atan( long double x );  // C++ only

double atan2( double y, double x );
float atan2f( float y, float x );
long double atan2l( long double y, long double x );
#define atan2(Y, X) // Requires C11 or higher

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

Paramètres

x, y
N’importe quels nombres.

Valeur retournée

atan retourne l’arctangente de x la plage -π/2 à π/2 radians. atan2 retourne l’arctangente de y/x la plage -π à π radians. Si x est 0, atan retourne la valeur 0. Si les deux paramètres de atan2 sont 0, la fonction retourne 0. Tous les résultats sont en radians.

atan2 utilise les signes des deux paramètres pour déterminer le quadrant de la valeur de retour.

Entrée Exception SEH Exception _matherr
± QNaN, IND aucune _DOMAIN

Notes

La fonction atan calcule l’arc tangente (fonction tangente inverse) de x. atan2calcule l’arctangente de (si x égal à 0, atan2 retourne π/2 s’il y est positif, -π/2 s’il y est négatif, ou 0 s’il y est 0.)y/x

Si vous utilisez le ou atan2 la atan macro à partir de <tgmath.h>, le type de l’argument détermine la version de la fonction sélectionnée. Pour plus d’informations, consultez les mathématiques génériques de type.

atan présente une implémentation qui utilise SSE2 (Streaming SIMD Extensions 2). Pour plus d’informations et de restrictions sur l’utilisation de l’implémentation SSE2, consultez _set_SSE2_enable.

Étant donné que C++ autorise la surcharge, vous pouvez appeler des surcharges et atanatan2 qui prennent ou long double argumentsfloat. Dans un programme C, sauf si vous utilisez la <tgmath.h> macro pour appeler cette fonction, atan et atan2 toujours prendre double des arguments et retourner un double.

Par défaut, l’état global de cette fonction est limité à l’application. Pour modifier ce comportement, consultez État global dans le CRT.

Spécifications

Routine En-tête requis (C) En-tête requis (C++)
atan, atan2, atanf, atan2f, atanl, atan2l <math.h> <cmath> ou <math.h>
atan, atan2 macros <tgmath.h>

Exemple

// 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;
}
Arctangent of 5.000000: 1.373401
Arctangent of 0.500000 / 5.000000: 0.099669

Voir aussi

Prise en charge mathématique et à virgule flottante
acos, acosf, acosl
asin, asinf, asinl
cos, cosf, cosl
_matherr
sin, sinf, sinl
tan, tanf, tanl
_CIatan
_CIatan2