Advertisement
TTpocToXaKep

Pink 3D donut in 3D ROOM

Feb 5th, 2023 (edited)
882
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 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):
  7.     ax.clear()
  8.     ax.set_xlim([-3,3])
  9.     ax.set_ylim([-3,3])
  10.     ax.set_zlim([-3,3])
  11.     u, v = np.linspace(0, 2 * np.pi, 50), np.linspace(0, np.pi, 50)
  12.     u, v = np.meshgrid(u, v)
  13.     x = np.cos(u) * (1 + np.cos(v))
  14.     y = np.sin(u) * (1 + np.cos(v))
  15.     z = np.sin(v)
  16.     ax.plot_surface(x, y, z, color='pink')
  17.     ax.view_init(elev=30, azim=frame)
  18.  
  19. fig = plt.figure()
  20. ax = fig.add_subplot(111, projection='3d')
  21. ani = FuncAnimation(fig, update, frames=360, interval=100)
  22. plt.show()
Tags: 3D donut #donut
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement