共用方式為


atan2 (<valarray>)

傳回項目與剖析的元件反正切值相等指定用 valarrays 的組合常數和項目的 valarray。

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

參數

  • _Left
    項目為反正切函數引數的 Y 座標的值 valarray 的常數的數值資料的資料型別或項目。

  • _Right
    項目為反正切函數引數的 X 座標的值 valarray 的常數的數值資料的資料型別或項目。

傳回值

I 項目的反正切值相等 valarray:

  • _Left [ I ]/[ _Right I ] 第一個樣板函式的。

  • _Left [ I ]/第二個樣板函式的 _Right 。

  • _Left / _Right [ I ] 第三個樣板函式的。

備註

要傳回之項目的單位表示)。

這個函式儲存有關元件的資訊在標準正切函式遺漏的引數,然後,象限的這項知識可以傳回值將 +pi 之間的一個唯一的角度和– pi。

如果 _Left 和 _Right 項目有不同的數值,則結果會是未定義。

範例

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

需求

標頭: <valarray>

命名空間: std