ATAN, atanf, atan2, atan2f

Calculates the arctangent of x (atan or atanf) or the arctangent of y/x (atan2 or atan2f).

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 
);
float atan2f(
   float y,
   float x
);

Parâmetros

  • x, y
    Todos os números.

Valor de retorno

atanRetorna o arco tangente de x no intervalo de –π/2 a π/2 radianos.atan2Retorna o arco tangente de y/x na –π intervalo em radianos π.If x is 0, atan returns 0.Se ambos os parâmetros do atan2 são 0, a função retornará 0.Todos os resultados estão em radianos.

atan2usa os sinais de ambos os parâmetros para determinar o quadrante de valor de retorno.

Entrada

Exceção SEH

Exceção de Matherr

± QNAN,IND

Nenhum

_DOMAIN

Comentários

O atan função calcula o arco tangente de x.atan2Calcula o arco tangente de y/x (se x é igual a 0, atan2 retorna π/2 se y for positivo, - π / 2 se y é negativo ou 0 se y é 0.)

atantem uma implementação que usa o Streaming SIMD Extensions 2 (SSE2).Consulte _set_SSE2_enable para obter informações e restrições usando a implementação do SSE2.

C++ permite sobrecarga, portanto, você pode chamar métodos sobrecarregados de atan e atan2.Em um programa em C, atan e atan2 sempre usam e retornam o doubles.

Requisitos

Rotina

Cabeçalho necessário

atan, atan2, atanf, atan2f

<math.h>

Exemplo

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

Equivalência do .NET Framework

Consulte também

Referência

Suporte de ponto flutuante

ACOS, acosf

ASIN, asinf

CoS, cosf, cosh, coshf

_matherr

sin, sinf, sinh, sinhf

Tan, tanf, tanh, tanhf

_CIatan

_CIatan2