programming-examples/python/Math/Convert Polar coordinates to rectangular coordinates.py
2019-11-15 12:59:38 +01:00

10 lines
331 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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)