Compartir a través de


atan, atanf, atanl, atan2, atan2f, atan2l

Calcula el arco tangente de x (atan, atanf y atanl), o el arco tangente de y/x (atan2, atan2f y 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
);

Parámetros

  • x, y
    Cualquier número.

Valor devuelto

atan devuelve el arco tangente de x en el intervalo comprendido entre –π/2 y π/2 radianes. atan2 devuelve el arco tangente de y/x en el intervalo comprendido entre –π y π radianes. Si x es 0, atan devuelve 0. Si los dos parámetros de atan2 son 0, la función devuelve 0. Todos los resultados están en radianes.

atan2 utiliza los signos de los dos parámetros para determinar el cuadrante del valor devuelto.

Entrada

Excepción SEH

Excepción de Matherr

± QNAN,IND

ninguno

_DOMAIN

Comentarios

La función atan calcula el arco tangente (función tangente inversa) de x. atan2 calcula el arco tangente de y/x (si x es igual a 0, atan2 devuelve π/2 si y es positivo, devuelve - π/2 si y es negativo, y devuelve 0 si y es 0).

atan tiene una implementación que usa las Extensiones SIMD de transmisión por secuencias 2 (SSE2). Para obtener información y las restricciones sobre el uso de la implementación de SSE2, vea _set_SSE2_enable.

Dado que C++ admite sobrecargas, puede llamar a sobrecargas de atan y atan2. En un programa de C, atan y atan2 siempre toman y devuelven valores double.

Requisitos

Rutina

Encabezado necesario

atan, atan2, atanf, atan2f, atanl, atan2l

<math.h>

Ejemplo

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

Equivalente en .NET Framework

Vea también

Referencia

Compatibilidad con el punto flotante

acos, acosf, acosl

asin, asinf, asinl

cos, cosf, cosl, cosh, coshf, coshl

_matherr

sin, sinf, sinl, sinh, sinhf, sinhl

tan, tanf, tanl, tanh, tanhf, tanhl

_CIatan

_CIatan2