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 ซึ่งแทนรูปสี่เหลี่ยมผืนผ้าของจำนวนเชิงซ้อน |
---|---|
เวอร์ชันหลาม: | 2.6 |