
Let’s learn how to apply NumPy to change polar coordinates into Cartesian coordinates.
Preparation
We need to install the NumPy package using the following code:
pip install numpy
With the NumPy library installed, we will learn more about converting polar coordinates to cartesian coordinates in the next part.
Convert Polar Coordinates to Cartesian Coordinates
Cartesian and polar coordinates are geometry methods for pinpointing a location on a flat surface. They inform us of the position, location, data, etc. Cartesian coordinates show the horizontal and vertical distance from the origin (x,y).
If we visualize the cartesian, it would be like the image below.

In contrast, polar coordinates represent the distance and angle from the origin. The notation is r, where r is the radius and is theta, representing the measured angle in radians.
We can convert polar coordinates to Cartesian coordinates using the following math formula.
Given the polar coordinates (r, θ):
x = r * cos(θ) y = r * sin(θ)
However, how do you do that in Python with NumPy?
import numpy as np
r = 4
theta = np.deg2rad(90)
x = r * np.cos(theta)
y = r * np.sin(theta)
print(f"(x, y) = ({x:.2f}, {y:.2f})")
Output:
(x, y) = (0.00, 4.00)
Very easy, right? We just need to apply the mathematical equation to the NumPy library.
You can loop the process and convert every Polar Coordinates to Cartesian Coordinates with the following code.
r = np.array([1, 2, 3, 4, 5])
theta_degrees = np.array([0, 30, 45, 60, 90])
theta_radians = np.deg2rad(theta_degrees)
x = r * np.cos(theta_radians)
y = r * np.sin(theta_radians)
# Output polar coordinates
print("Polar Coordinates (r, θ in degrees):")
for radius, angle in zip(r, theta_degrees):
print(f"({radius}, {angle}°)")
# Output Cartesian coordinates
print("\nCartesian Coordinates (x, y):")
for xi, yi in zip(x, y):
print(f"({xi:.2f}, {yi:.2f})")
Output:
Polar Coordinates (r, θ in degrees): (1, 0°) (2, 30°) (3, 45°) (4, 60°) (5, 90°) Cartesian Coordinates (x, y): (1.00, 0.00) (1.73, 1.00) (2.12, 2.12) (2.00, 3.46) (0.00, 5.00)
Mastering this skill would help your work tremendously in geometry analysis.
