Pythoncmath.rect() Method
Example
Convert polar coordinates to rectangular form:
#import cmath for complex number operations
import cmath
#convert a polar coordinate to rectangular form
print(cmath.rect(3.1622776601683795, 1.2490457723982544))
Try it Yourself »import cmath
#convert a polar coordinate to rectangular form
print(cmath.rect(3.1622776601683795, 1.2490457723982544))
Definition and Usage
Thecmath.rect() method converts polar coordinates to rectangular form of the complex number. It creates a complex number with phase and modulus.
This method is equivalent tor * (math.cos(phi) + math.sin(phi)*1j).
Note: The radiusr is the length of the vector, andphi (phase angle) is the angle made with the real axis.
Syntax
cmath.rect(r, phi)
Parameter Values
| Parameter | Description |
|---|---|
| r | Required. Represents the modulus of a complex number |
| phi | Required. Represents the phase of a complex number |
Technical Details
| Return Value: | Acomplex value, representing the rectangular form of a complex number |
|---|---|
| Python Version: | 2.6 |

