C++ 复杂库 - Polar


描述

它是由极坐标分量构成的复数,并返回一个复数对象(采用笛卡尔格式),对应于由其极坐标分量 rho 和 theta 定义的复数,其中 rho 是幅度(模数),theta 是相位角。

宣言

以下是 std::polar 的声明。

template<class T> complex<T> polar (const T& rho, const T& theta = 0);

C++11

	
template<class T> complex<T> polar (const T& rho, const T& theta = 0);

参数

  • rho它是复数的量值(模数)。

  • theta是复数的相位角(角度分量)。

  • T它是复杂类型的组件类型。

返回值

它返回与 rho 和 theta 形成的极坐标格式等效的复杂笛卡尔坐标。

例外情况

没有任何

例子

在下面的 std::polar 示例中。

#include <iostream>     
#include <complex>      

int main () {
   std::cout << "The complex whose magnitude is " << 1.0 << '\n';
   std::cout << " and phase angle is " << 0.7 << '\n';
   std::cout << " is " << std::polar (1.0, 0.7) << '\n';

   return 0;
}

示例输出应该是这样的 -

The complex whose magnitude is 1
 and phase angle is 0.7
 is (0.764842,0.644218)
复杂.htm