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 exterior faces of the object based on the orthographic views. # The object can be decomposed into a solid base and three distinct top sections. # Base: Solid block from Z=0 to Z=2. # Region A (Bottom-Right triangle, Y < X): Solid block from Z=2 to Z=4. # Region B (Top-Left, X=0..2, Y > X): Solid block from Z=2 to Z=6. # Region C (Top-Left, X=2..4, Y > X): Empty above Z=2 (just the exposed base). # Region D (Top-Left, X=4..6, Y > X): Solid block from Z=2 to Z=6. faces = [ # --- Base (Z=0 to 2) --- [[0,0,0], [6,0,0], [6,6,0], [0,6,0]], # Bottom face [[0,0,0], [6,0,0], [6,0,2], [0,0,2]], # Front face [[0,6,0], [6,6,0], [6,6,2], [0,6,2]], # Back face [[0,0,0], [0,6,0], [0,6,2], [0,0,2]], # Left face [[6,0,0], [6,6,0], [6,6,2], [6,0,2]], # Right face [[2,2,2], [4,4,2], [4,6,2], [2,6,2]], # Exposed top of Base (Region C) # --- Region A (Y < X, Z=2 to 4) --- [[0,0,4], [6,0,4], [6,6,4]], # Top triangular face [[0,0,2], [6,0,2], [6,0,4], [0,0,4]], # Front face extension [[6,0,2], [6,6,2], [6,6,4], [6,0,4]], # Right face extension [[2,2,2], [4,4,2], [4,4,4], [2,2,4]], # Diagonal vertical face exposed to Region C # --- Region B (X=0..2, Y > X, Z=2 to 6) --- [[0,0,6], [2,2,6], [2,6,6], [0,6,6]], # Top face [[0,6,2], [0,0,2], [0,0,6], [0,6,6]], # Left face extension [[2,6,2], [0,6,2], [0,6,6], [2,6,6]], # Back face extension [[0,0,4], [2,2,4], [2,2,6], [0,0,6]], # Diagonal vertical face exposed above Region A [[2,2,2], [2,6,2], [2,6,6], [2,2,6]], # Right vertical face exposed to Region C # --- Region D (X=4..6, Y > X, Z=2 to 6) --- [[4,4,6], [6,6,6], [4,6,6]], # Top triangular face [[6,6,2], [4,6,2], [4,6,6], [6,6,6]], # Back face extension [[4,4,4], [6,6,4], [6,6,6], [4,4,6]], # Diagonal vertical face exposed above Region A [[4,6,2], [4,4,2], [4,4,6], [4,6,6]] # Left vertical face exposed to Region C ] # 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 6x6x6 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 cutouts, the diagonal, and the varying heights ax.view_init(elev=35, 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()