Udostępnij za pośrednictwem


atan2 (<valarray>)

Zwraca valarray, której elementy są równe arcus tangens kartezjańskimi elementów określonych kombinacji stałych i elementy valarrays.

template<class Type>
   valarray<Type> atan2(
      const valarray<Type>& _Left,
      const valarray<Type>& _Right
   );
template<class Type>
   valarray<Type> atan2(
      const valarray<Type> _Left, 
      const Type& _Right
   );
template<class Type>
   valarray<Type> atan2(
      const Type& _Left, 
      const valarray<Type>& _Right
   );

Parametry

  • _Left
    Dane liczbowe stała typu lub wprowadzania valarray elementów, których dostarczają wartości dla współrzędna y arcus tangens argument.

  • _Right
    Dane liczbowe stała typu lub wprowadzania valarray elementów, których dostarczają wartości dla współrzędną x argument tangens.

Wartość zwracana

Valarray, której elementy I są równe arcus tangens:

  • _Left I / _Right I dla pierwszego funkcji szablonu.

  • _Left I /_Right dla drugiego funkcji szablonu.

  • _Left/ _Right I dla trzecią funkcję szablonu.

Uwagi

Jednostkami zwracane elementy są radiany.

Ta funkcja zachowuje informacje o znaki elementów w argumencie utracone na skutek standardowych funkcji styczną i umożliwia tej wiedzy Ćwiartka wartości zwracanej, aby przypisać unikatowy kąt pomiędzy + pi i –pi.

Jeśli _Left i _Right mają różne liczby elementów, wynik jest niezdefiniowany.

Przykład

// valarray_atan2.cpp
// compile with: /EHsc
#include <valarray>
#include <iostream>
#include <iomanip>

int main( )
{
   using namespace std;
   double pi = 3.14159265359;
   int i;

   valarray<double> va1y ( 1 , 4 ), va1x ( 1 , 4 );
   va1x [ 1 ] = -1;
   va1x [ 2 ] = -1;
   va1y [ 2 ] = -1;
   va1y [ 3 ] = -1;
   valarray<double> va2 ( 4 );

   cout << "The initial valarray for the x coordinate is: ( ";
   for ( i = 0 ; i < 4 ; i++ )
      cout << va1x [ i ] << " ";
   cout << ")." << endl;

   cout << "The initial valarray for the y coordinate is: ( ";
   for ( i = 0 ; i < 4 ; i++ )
      cout << va1y [ i ] << " ";
   cout << ")." << endl;

   va2 = atan2 ( va1y , va1x );
   cout << "The atan2 ( y / x ) of the initial valarrays is:\n";
   for ( i = 0 ; i < 4 ; i++ )
      cout << setw( 10 ) << va2 [ i ]
           << "  radians, which is  "
           << setw( 11 ) << ( 180/pi ) * va2 [ i ]
           << "degrees" << endl;
   cout << endl;
}
  
  
  

Wymagania

Nagłówek: <valarray>

Obszar nazw: std