import numpy as np
import matplotlib.pyplot as plt
a, b = 150, 75
vertices = np.array([
[-a, -b],
[-a, b],
[ a, b],
[ a, -b]
])
edges = [
[0, 1],
[1, 2],
[2, 3],
[3, 0]
]
plt.figure(figsize=(12, 8))
for edge in edges:
v1 = vertices[edge[0]]
v2 = vertices[edge[1]]
# Plot the edge
plt.plot([v1[0], v2[0]], [v1[1], v2[1]], 'r-', linewidth=2)
plt.axis('equal')
#plt.grid(True)
plt.xlabel('x')
plt.ylabel('y')
plt.title('Rectangle using vertices')
plt.show()
To embed this project on your website, copy the following code and paste it into your website's HTML: