import numpy as np
import matplotlib.pyplot as plt
a = 150
b = 75
theta1 = np.linspace(-np.arctan(b/a), np.arctan(b/a), 100)
theta2 = np.linspace(np.arctan(b/a), np.pi - np.arctan(b/a), 100)
theta3 = np.linspace(np.pi - np.arctan(b/a), np.pi + np.arctan(b/a), 100)
theta4 = np.linspace(np.pi + np.arctan(b/a), 2*np.pi - np.arctan(b/a), 100)
r1 = a / np.abs(np.cos(theta1))
r2 = b / np.abs(np.sin(theta2))
r3 = a / np.abs(np.cos(theta3))
r4 = b / np.abs(np.sin(theta4))
theta = np.concatenate([theta1, theta2, theta3, theta4])
r = np.concatenate([r1, r2, r3, r4])
x = r * np.cos(theta)
y = r * np.sin(theta)
plt.figure(figsize=(12, 8))
plt.plot(x, y, 'b-', linewidth=2)
plt.axis('equal')
#plt.grid(True)
plt.xlabel('x')
plt.ylabel('y')
plt.title('Rectangle in Polar Coordinates')
plt.show()
To embed this project on your website, copy the following code and paste it into your website's HTML: