Я бы хотел анимировать куб от 1 до x градусов (1, 2, 3, 4 ... x). Это вообще возможно с моим кодом? Пробовал с FuncAnimation, но получил все кубы на одном изображении, а не анимацию.
Спасибо за помощь
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.animation as animation
from itertools import product, combinations
from numpy import sin, cos
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.set_aspect("auto")
ax.set_xlim(-10, 10)
ax.set_ylim(-10, 10)
ax.set_zlim(-10, 10)
ax.set_xlabel("Os X")
ax.set_ylabel("Os Y")
ax.set_zlabel("Os Z")
ax.grid(2)
d = [-2, 2]
def rotate():
for x in range(1, 46): #rotate by Z axis
theta = np.radians(x)
for s, e in combinations(np.array(list(product(d,d,d))), 2):
if np.sum(np.abs(s-e)) == d[1]-d[0]:
s_rotated = [s[0] * cos(theta) - s[1] * sin(theta),
s[0] * sin(theta) + s[1] * cos(theta),
s[2]]
e_rotated = [e[0] * cos(theta) - e[1] * sin(theta),
e[0] * sin(theta) + e[1] * cos(theta),
e[2]]
y = ax.plot3D(*zip(s_rotated,e_rotated), color="g")
ani = animation.FuncAnimation(fig, rotate(), interval=1000, blit=False, repeat_delay=1000)
plt.show()