cmath是用於複數數學的Python 內置模塊。 cmath模塊具有方法rect(),該方法用於將極坐標轉換為矩形形式。
用法: cmath.rect(r, phi)
參數:它有兩個參數。第一個參數r表示複數的模數,第二個參數表示相位。這兩個參數都是必需的。沒有是可選的。
返回:返回模數為r且相位為phi的複數Z。
注意:r *(math.cos(phi)+ math.sin(phi)* 1j)等效於此方法。
範例1:
Python3
# Import the Library
import cmath
# Printing the result
print (cmath.rect(3,10))
輸出:
(-2.517214587229357-1.6320633326681093j)
範例2:在該示例中,模量被視為零。
Python3
# Import the Library
import cmath
# Printing the result
print (cmath.rect(0,1))
輸出:
0j
範例3:在此示例中,相位為零
Python3
# Import the Library
import cmath
# Printing the result
print (cmath.rect(1,0))
輸出:
(1+0j)
相關用法
- Python set()用法及代碼示例
- Python next()用法及代碼示例
- Python os.dup()用法及代碼示例
- Python sympy.S()用法及代碼示例
- Python sympy.lcm()用法及代碼示例
- Python os.sysconf()用法及代碼示例
- Python Pytorch eye()用法及代碼示例
- Python os.fchdir()用法及代碼示例
- Python sympy.ff()用法及代碼示例
- Python os.fchmod()用法及代碼示例
- Python os.confstr()用法及代碼示例
- Python PIL putpixel()用法及代碼示例
- Python PIL getpixel()用法及代碼示例
- Python os.times()用法及代碼示例
- Python PIL eval()用法及代碼示例
- Python sympy.rf()用法及代碼示例
- Python os.unlink()用法及代碼示例
- Python os.fstat()用法及代碼示例
注:本文由純淨天空篩選整理自aman neekhara大神的英文原創作品 Python – cmath.rect() method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。