Python - Methode cmath.rect()
Beispiel
Konvertieren Sie Polarkoordinaten in rechteckige Form:
#import cmath for complex number operations
import cmath
#convert
a polar coordinate to rectangular form
print(cmath.rect(3.1622776601683795, 1.2490457723982544))
Definition und Verwendung
Das cmath.rect()
Verfahren wandelt Polarkoordinaten in die rechteckige Form der komplexen Zahl um. Es erzeugt eine komplexe Zahl mit Phase und Modul.
Diese Methode ist äquivalent zu r * (math.cos(phi) +
math.sin(phi)*1j)
.
Hinweis: Der Radius r ist die Länge des Vektors und phi (Phasenwinkel) ist der Winkel, der mit der reellen Achse gebildet wird.
Syntax
cmath.rect(r, phi)
Parameterwerte
Parameter | Description |
---|---|
r | Required. Represents the modulus of a complex number |
phi | Required. Represents the phase of a complex number |
Technische Details
Rückgabewert: | Ein complex Wert, der die rechteckige Form einer komplexen Zahl darstellt |
---|---|
Python-Version: | 2.6 |