programming-examples/python/Math/Convert Polar coordinates to rectangular coordinates.py

10 lines
331 B
Python
Raw Normal View History

2019-11-15 12:59:38 +01:00
view plaincopy to clipboardprint?
import cmath
cn = complex(3,4)
# get polar coordinates
print("Polar Coordinates: ",cmath.polar(cn))
# polar to rectangular. Format for input is (length, angle in radians).
#Returns a complex number
cn1 = cmath.rect(2, cmath.pi)
print("Polar to rectangular: ",cn1)