| 33 | |
| 34 | |
| 35 | def plot_floor(ax, minx, maxx, miny, maxy, minz): |
| 36 | from mpl_toolkits.mplot3d.art3d import Poly3DCollection |
| 37 | # Plot a plane XZ |
| 38 | verts = [ |
| 39 | [minx, miny, minz], |
| 40 | [minx, maxy, minz], |
| 41 | [maxx, maxy, minz], |
| 42 | [maxx, miny, minz] |
| 43 | ] |
| 44 | xz_plane = Poly3DCollection([verts], zorder=1) |
| 45 | xz_plane.set_facecolor((0.5, 0.5, 0.5, 1)) |
| 46 | ax.add_collection3d(xz_plane) |
| 47 | |
| 48 | # Plot a bigger square plane XZ |
| 49 | radius = max((maxx - minx), (maxy - miny)) |
| 50 | |
| 51 | # center +- radius |
| 52 | minx_all = (maxx + minx) / 2 - radius |
| 53 | maxx_all = (maxx + minx) / 2 + radius |
| 54 | |
| 55 | miny_all = (maxy + miny) / 2 - radius |
| 56 | maxy_all = (maxy + miny) / 2 + radius |
| 57 | |
| 58 | verts = [ |
| 59 | [minx_all, miny_all, minz], |
| 60 | [minx_all, maxy_all, minz], |
| 61 | [maxx_all, maxy_all, minz], |
| 62 | [maxx_all, miny_all, minz] |
| 63 | ] |
| 64 | xz_plane = Poly3DCollection([verts], zorder=1) |
| 65 | xz_plane.set_facecolor((0.5, 0.5, 0.5, 0.5)) |
| 66 | ax.add_collection3d(xz_plane) |
| 67 | return ax |
| 68 | |
| 69 | |
| 70 | def update_camera(ax, root, radius=1.5): |