Using numpy, you can define the following:
import numpy as np
def cart2pol(x, y):
rho = np.sqrt(x**2 + y**2)
phi = np.arctan2(y, x)
return(rho, phi)
def pol2cart(rho, phi):
x = rho * np.cos(phi)
y = rho * np.sin(phi)
return(x, y)
More Related Contents:
- Convert Axis ⇔ Data coordinates systems
- Relative imports for the billionth time
- Truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()
- How to unnest (explode) a column in a pandas DataFrame, into multiple rows
- How to bind self events in Tkinter Text widget after it will binded by Text widget?
- How do I handle the window close event in Tkinter?
- How to overcome TypeError: unhashable type: ‘list’
- Pandas Timedelta in Days
- Not all parameters were used in the SQL statement (Python, MySQL)
- Matplotlib y axis values are not ordered [duplicate]
- How to install 2 Anacondas (Python 2 and 3) on Mac OS
- bash: pip: command not found
- What do the python file extensions, .pyc .pyd .pyo stand for?
- Why do “Not a Number” values equal True when cast as boolean in Python/Numpy?
- OverflowError: (34, ‘Result too large’)
- How to integrate Flask & Scrapy?
- What does “ mean in Python?
- How to read class attributes in the same order as declared?
- Integer division by negative number [duplicate]
- How to Download a File after POSTing data using FastAPI?
- How to disable Django’s CSRF validation?
- How to include external Python code to use in other files?
- better way to drop nan rows in pandas
- Python win32print changing advanced printer options
- Python pandas cumsum() reset after hitting max
- Dump stacktraces of all active Threads
- Permission to view, but not to change! – Django
- Matplotlib / python clickable points
- run python script directly from command line
- How to click on Load More button within Google Trends and print all the titles through Selenium and Python