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 製作 []/[ _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