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 10 exterior faces of the object based on the orthographic views # The object is divided into three sections along the Y-axis (depth): # 1. Front section (Y=0 to 2): Wedge sloping up from Z=3 at X=0 to Z=6 at X=6 # 2. Middle section (Y=2 to 4): Solid block of height Z=6 # 3. Back section (Y=4 to 6): Wedge sloping down from Z=6 at X=0 to Z=3 at X=6 faces = [ # 1. Bottom face [[0,0,0], [6,0,0], [6,6,0], [0,6,0]], # 2. Left face (X=0) - Has a cutout at the front (Y=0 to 2, Z=3 to 6) [[0,0,0], [0,6,0], [0,6,6], [0,4,6], [0,2,6], [0,2,3], [0,0,3]], # 3. Right face (X=6) - Has a cutout at the back (Y=4 to 6, Z=3 to 6) [[6,0,0], [6,6,0], [6,6,3], [6,4,3], [6,4,6], [6,2,6], [6,0,6]], # 4. Front face (Y=0) - Trapezoid showing the front wedge [[0,0,0], [6,0,0], [6,0,6], [0,0,3]], # 5. Back face (Y=6) - Trapezoid showing the back wedge [[0,6,0], [6,6,0], [6,6,3], [0,6,6]], # 6. Top sloped face of the front section [[0,0,3], [6,0,6], [6,2,6], [0,2,3]], # 7. Top flat face of the middle section [[0,2,6], [6,2,6], [6,4,6], [0,4,6]], # 8. Top sloped face of the back section [[0,4,6], [6,4,3], [6,6,3], [0,6,6]], # 9. Exposed vertical triangle between front and middle sections [[0,2,3], [6,2,6], [0,2,6]], # 10. Exposed vertical triangle between middle and back sections [[6,4,3], [6,4,6], [0,4,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 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 front wedge, the middle block, and the right-side cutout ax.view_init(elev=30, azim=-45) # 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()