Udostępnij za pośrednictwem


ATAN, atanf, funkcja 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
);

Parametry

  • x, y
    Dowolne liczby.

Wartość zwracana

atanZwraca arcus tangens x w zakresie –π/2 π/2 radianów.atan2Zwraca arcus tangens y/x w –π zakresie π radiany.If x is 0, atan returns 0.Jeśli oba parametry z atan2 są równe 0, funkcja zwraca wartość 0.Wszystkie wyniki są wyświetlane w radianach.

atan2używa oznaki oba parametry, aby określić Ćwiartka zwracanej wartości.

Dane wejściowe

Wyjątek SEH

Wyjątek Matherr

± QNAN,IND

Brak

_DOMAIN

Uwagi

atan Funkcja oblicza tangens z x.atan2Oblicza tangens z y/x (Jeśli x jest równa 0, atan2 zwraca π/2, jeśli y jest dodatnia, - π / 2 Jeśli y jest negatywny, lub 0, jeśli y jest równa 0.)

atanjest implementacja używa Streaming SIMD Extensions 2 (SSE2).Zobacz _set_SSE2_enable informacji i ograniczenia dotyczące korzystania z implementacji SSE2.

C++ zezwala na przeciążenie, więc można wywoływać przeciążenia atan i atan2.W programie c atan i atan2 zawsze podjąć i powrócić w grze.

Wymagania

Rozpoczęto wykonywanie procedury

Wymaganego nagłówka

atan, atan2, atanf, atan2f

<math.h>

Przykład

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

Odpowiednik w programie .NET Framework

Zobacz też

Informacje

Wsparcie zmiennoprzecinkowe

ACOS, acosf

ASIN, asinf

COS, cosf, cosh, coshf

_matherr

sin, sinf, sinh, sinhf

TAN, tanf, tanh, tanhf

_CIatan

_CIatan2