atan, atanf, atanl, atan2, atan2f, atan2l

Berechnet den Arkustangens von x (atan, atanf und atanl) oder den Arkustangens von y/x (atan2, atan2f und atan2l).

Syntax

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

Parameter

x, y
Alle Zahlen.

Rückgabewert

atan gibt den Arkutangens des x Bereichs -π/2 bis π/2 Bogenmaß zurück. atan2 gibt den Arkustangens des y/x Bereichs -π zurück, um Bogenmaße zu π. Wenn x gleich 0 ist, gibt atan 0 zurück. Wenn beide Parameter von atan2 0 sind, gibt die Funktion 0 zurück. Alle Ergebnisse sind in Bogenmaß.

atan2 verwendet die Zeichen beider Parameter, um den Quadranten des Rückgabewerts zu bestimmen.

Eingabe SEH-Ausnahme _matherr-Ausnahme
± QNaN, IND Keine _DOMAIN

Hinweise

Die atan-Funktion berechnet den Arkustangens (die umgekehrte Tangensfunktion) von x. atan2 berechnet den Arkustangens von y/x (wenn x gleich 0 ist, gibt atan2 π/2 zurück, wenn y positiv ist, –π/2, wenn y negativ ist, oder 0, wenn y 0 ist.)

Wenn Sie das Argument oder atan2 das atan Makro <tgmath.h>verwenden, bestimmt der Typ des Arguments, welche Version der Funktion ausgewählt ist. Ausführliche Informationen finden Sie unter "Typgenerika" .

atan ist eine Implementierung, die SIMD-Streamingerweiterungen 2 (SSE2) verwendet. Informationen und Einschränkungen zur Verwendung der SSE2-Implementierung finden Sie unter _set_SSE2_enable.

Da C++ Überladungen zulässt, können Sie Überladungen aufrufen und atan2 diese atan annehmen float oder long double Argumente. In einem C-Programm, es sei denn, Sie verwenden das <tgmath.h> Makro, um diese Funktion aufzurufen, atan und atan2 nehmen double immer Argumente und geben eine zurück double.

Standardmäßig gilt der globale Zustand dieser Funktion für die Anwendung. Informationen zum Ändern dieses Verhaltens finden Sie im Global state in the CRT.

Anforderungen

Routine Erforderlicher Header (C) Erforderlicher Header (C++)
atan, atan2, atanf, atan2f, atanl, atan2l <math.h> <cmath> oder <math.h>
atan, atan2 Makros <tgmath.h>

Beispiel

// 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

Siehe auch

Mathematische und Gleitkommaunterstützung
acos, acosf, acosl
asin, asinf, asinl
cos, cosf, cosl
_matherr
sin, sinf, sinl
tan, tanf, tanl
_CIatan
_CIatan2