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]/[] 第一个模板函数的。

  • _Left [ " ]/第二个模板函数的 _Right。

  • _Left 或 _Right [] 第三个模板函数的。

备注

返回的元素数大单位以弧度为单位。

此函数使关于组件的符号信息。标准切线函数丢失的参数,并且,这些知识象限的允许分配的返回值。+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;
}
  

要求

Header: <valarray>

命名空间: std