import matplotlib.pyplot as plt from mpl_toolkits.mplot3d.art3d import Poly3DCollection def plot_3d_figure(): fig = plt.figure(figsize=(10, 8)) ax = fig.add_subplot(111, projection='3d') # Define the 12 exterior faces of the object based on the orthographic views # Coordinates are defined as [X, Y, Z] faces = [ # 1. Bottom face (U-shape footprint) [[0,0,0], [2,0,0], [2,4,0], [4,4,0], [4,0,0], [6,0,0], [6,6,0], [0,6,0]], # 2. Back face (Flat vertical wall) [[0,6,0], [6,6,0], [6,6,6], [0,6,6]], # 3. Top face of the back wall [[0,4,6], [6,4,6], [6,6,6], [0,6,6]], # 4. Front face of the back wall (visible in the middle gap) [[2,4,0], [4,4,0], [4,4,6], [2,4,6]], # 5. Front face of the left leg (Trapezoid with diagonal top) [[0,0,0], [2,0,0], [2,0,6], [0,0,3]], # 6. Front face of the right leg (Trapezoid with diagonal top) [[4,0,0], [6,0,0], [6,0,3], [4,0,6]], # 7. Top sloped face of the left leg [[0,0,3], [2,0,6], [2,4,6], [0,4,3]], # 8. Top sloped face of the right leg [[4,0,6], [6,0,3], [6,4,3], [4,4,6]], # 9. Leftmost face (L-shape profile) [[0,0,0], [0,6,0], [0,6,6], [0,4,6], [0,4,3], [0,0,3]], # 10. Rightmost face (L-shape profile matching the Right View inner lines) [[6,0,0], [6,6,0], [6,6,6], [6,4,6], [6,4,3], [6,0,3]], # 11. Inner side face of the left leg [[2,0,0], [2,4,0], [2,4,6], [2,0,6]], # 12. Inner side face of the right leg [[4,0,0], [4,4,0], [4,4,6], [4,0,6]] ] # Create the 3D polygon collection poly3d = Poly3DCollection(faces, facecolors='#4C99D1', linewidths=1.5, edgecolors='black', alpha=0.85) ax.add_collection3d(poly3d) # Set axes limits to match the bounding box ax.set_xlim([0, 6]) ax.set_ylim([0, 6]) ax.set_zlim([0, 6]) # Set labels ax.set_xlabel('X (Width)') ax.set_ylabel('Y (Depth)') ax.set_zlabel('Z (Height)') # Set a viewing angle that clearly shows the sloped legs and the U-shape ax.view_init(elev=25, azim=-55) # Force the axes to have equal proportions ax.set_box_aspect([1, 1, 1]) plt.title("3D Reconstruction from Orthographic Views", fontsize=14, pad=20) plt.tight_layout() plt.show() if __name__ == "__main__": plot_3d_figure()