import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
a, b, c = 150, 75, 50
vertices = np.array([
[-a, -b, -c],
[-a, -b, c],
[-a, b, -c],
[-a, b, c],
[ a, -b, -c],
[ a, -b, c],
[ a, b, -c],
[ a, b, c]
])
edges = [
[0, 1], [0, 2], [0, 4], # Edges from Vertex 1
[1, 3], [1, 5], # Edges from Vertex 2
[2, 3], [2, 6], # Edges from Vertex 3
[3, 7], # Edges from Vertex 4
[4, 5], [4, 6], # Edges from Vertex 5
[5, 7], # Edges from Vertex 6
[6, 7] # Edges from Vertex 7
]
fig = plt.figure(figsize=(8, 6))
ax = fig.add_subplot(111, projection='3d')
for edge in edges:
v1 = vertices[edge[0]]
v2 = vertices[edge[1]]
ax.plot([v1[0], v2[0]], [v1[1], v2[1]], [v1[2], v2[2]], 'b-', linewidth=2)
ax.set_box_aspect([1, 1, 1]) # Equal aspect ratio
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
ax.set_title('Cuboid using vertices/edges')
plt.grid()
plt.show()
To embed this project on your website, copy the following code and paste it into your website's HTML: