Python cmath.rect()メソッド
例
極座標を直交形式に変換します。
#import cmath for complex number operations
import cmath
#convert
a polar coordinate to rectangular form
print(cmath.rect(3.1622776601683795, 1.2490457723982544))
定義と使用法
このcmath.rect()
メソッドは、極座標を複素数の直交形式に変換します。位相とモジュラスを持つ複素数を作成します。
このメソッドは。と同等r * (math.cos(phi) +
math.sin(phi)*1j)
です。
注:半径rはベクトルの長さであり、 phi(位相角)は実軸とのなす角度です。
構文
cmath.rect(r, phi)
パラメータ値
Parameter | Description |
---|---|
r | Required. Represents the modulus of a complex number |
phi | Required. Represents the phase of a complex number |
技術的な詳細
戻り値: | complex 複素数の長方形を表す値 |
---|---|
Pythonバージョン: | 2.62.6 |