atan, atanf, atanl, atan2, atan2f, atan2l

Calcola l'arcotangente di x (atan, atanf e atanl) o l'arcotangente di y/x (atan2, atan2f e atan2l).

Sintassi

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

Parametri

x, y
Qualsiasi numero.

Valore restituito

atan restituisce l'arcotangente di x nell'intervallo da -π/2 a π/2 radianti. atan2 restituisce l'arcotangente di y/x nell'intervallo -π a π radianti. Se x è 0, atan restituisce 0. Se entrambi i parametri di atan2 sono 0, la funzione restituisce 0. Tutti i risultati sono in radianti.

atan2 usa i segni di entrambi i parametri per determinare il quadrante del valore restituito.

Input Eccezione SEH Eccezione _matherr
± QNaN, IND Nessuno _DOMAIN

Osservazioni:

La funzione atan calcola l'arcotangente (la funzione inversa della tangente) di x. atan2 calcola l'arcotangente di y/x (se x è uguale a 0, atan2 restituisce π/2 se è positivo, -π/2 se yy è negativo o 0 se y è 0.

Se si utilizza la atan macro o atan2 da <tgmath.h>, il tipo dell'argomento determina quale versione della funzione è selezionata. Per informazioni dettagliate, vedere La matematica generica dei tipi.

atan ha un'implementazione che usa SSE2 (Streaming SIMD Extensions 2). Per informazioni e restrizioni sull'uso dell'implementazione di S edizione Standard 2, vedere _set_SSE2_enable.

Poiché C++ consente l'overload, è possibile chiamare overload di atan e atan2 che accettano float o long double argomenti. In un programma C, a meno che non si usi la <tgmath.h> macro per chiamare questa funzione atan e accettare double sempre argomenti e atan2 restituire un oggetto double.

Per impostazione predefinita, lo stato globale di questa funzione è limitato all'applicazione. Per modificare questo comportamento, vedere Stato globale in CRT.

Requisiti

Ciclo Intestazione obbligatoria (C) Intestazione obbligatoria (C++)
atan, atan2, atanf, atan2f, atanl, atan2l <math.h> <cmath> oppure <math.h>
atan, atan2 macro <tgmath.h>

Esempio

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

Vedi anche

Supporto matematico e a virgola mobile
acos, acosf, acosl
asin, asinf, asinl
cos, cosf, cosl
_matherr
sin, sinf, sinl
tan, tanf, tanl
_CIatan
_CIatan2