Compartilhar via


ATAN, atanf, atan2, atan2f

Calcula o arco tangente de x (atan ou atanf) ou o arco tangente de y/x (atan2 ou 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
    Os números.

Valor de retorno

atan Retorna o arco tangente de x no intervalo de –π/2 a π/2 radianos. atan2 Retorna o arco tangente de y/x em –π intervalo em π radianos. If x é 0, atan Retorna 0. Se ambos os parâmetros de atan2 0, a função retornará 0. Todos os resultados estão em radianos.

atan2 usa os sinais de ambos os parâmetros para determinar o quadrante do valor retornado.

Entrada

Exceção SEH

Exceção Matherr

± QNAN,IND

Nenhum

_DOMAIN

Comentários

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

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

C++ permite sobrecarga, para que você possa telefonar sobrecargas de atan e atan2. Em um programa C, atan e atan2 sempre usam e retornam duplicatas.

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

Arctangent of 5.000000: 1.373401 Arctangent of 0.500000 / 5.000000: 0.099669

Equivalente 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