Advertisement
TTpocToXaKep

[OPTIMIZATION] 3D pink donut in 3D room

Feb 6th, 2023
976
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. from mpl_toolkits.mplot3d import Axes3D
  4. from matplotlib.animation import FuncAnimation
  5.  
  6. def update(frame, surface):
  7.     ax.view_init(elev=30, azim=frame)
  8.     return surface,
  9.  
  10. fig = plt.figure()
  11. ax = fig.add_subplot(111, projection='3d')
  12. u, v = np.linspace(0, 2 * np.pi, 10), np.linspace(0, np.pi, 10)
  13. u, v = np.meshgrid(u, v)
  14. x = np.cos(u) * (1 + np.cos(v))
  15. y = np.sin(u) * (1 + np.cos(v))
  16. z = np.sin(v)
  17. surface = ax.plot_surface(x, y, z, color='pink')
  18. ax.set_xlim([-3,3])
  19. ax.set_ylim([-3,3])
  20. ax.set_zlim([-3,3])
  21. ani = FuncAnimation(fig, update, frames=360, fargs=(surface,), interval=20, blit=False,
  22.                     repeat=False, save_count=50)
  23. plt.show(block=False)
  24.  
  25. # Switch to 'gloo' or 'agg' renderer for faster rendering
  26. plt.switch_backend('gloo')
Tags: 3D donut
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement