I have a 4-coal pyramid. Wrote an animation of rotation around the Oy axis only. I can not write a rotation around the Ox axis and a simultaneous rotation around the Ox and Oy axes.

Code:

from tkinter import * import time from math import cos, sin, radians x_1, y_1 = 400, 50 R = 300 c_x = 400 c_y = 2000 f = 80 SPEED = 0.02 def f_wind1(event): wind_1 = Toplevel() wind_1.title("Y") canvas = Canvas(wind_1, width=800, height=500) canvas.pack() i = 0 while True: i = (i + 1) % 360 canvas.delete(ALL) x_2, y_2 = R * cos(radians(i)) + c_x, R * sin(radians(i)) + c_y x_3, y_3 = R * cos(radians(i + 90)) + c_x, R * sin(radians(i + 90)) + c_y x_4, y_4 = R * cos(radians(i + 180)) + c_x, R * sin(radians(i + 180)) + c_y x_5, y_5 = R * cos(radians(i + 270)) + c_x, R * sin(radians(i + 270)) + c_y y_2 = cos(radians(f)) * y_2 y_3 = cos(radians(f)) * y_3 y_4 = cos(radians(f)) * y_4 y_5 = cos(radians(f)) * y_5 canvas.create_line(x_1, y_1, x_2, y_2) canvas.create_line(x_1, y_1, x_3, y_3) canvas.create_line(x_1, y_1, x_4, y_4) canvas.create_line(x_1, y_1, x_5, y_5) canvas.create_line(x_2, y_2, x_3, y_3) canvas.create_line(x_3, y_3, x_4, y_4) canvas.create_line(x_4, y_4, x_5, y_5) canvas.create_line(x_5, y_5, x_2, y_2) canvas.update() time.sleep(SPEED) def f_wind2(event): wind_2 = Toplevel() wind_2.title("X") canvas = Canvas(wind_2, width=800, height=500) canvas.pack() def f_wind3(event): wind_3 = Toplevel() wind_3.title("Z") canvas = Canvas(wind_3, width=800, height=500) canvas.pack() def f_wind4(event): wind_4 = Toplevel() wind_4.title("Z") canvas = Canvas(wind_4, width=800, height=500) canvas.pack() root = Tk() root.title("Lab6") b_1 = Button(root, text="Навколо осі Y", font="Arial 18") b_1.pack() b_1.bind("<Button-1>", f_wind1) b_2 = Button(root, text="Навколо осі X", font="Arial 18") b_2.pack() b_2.bind("<Button-1>", f_wind2) b_3 = Button(root, text="Навколо осей X та Y", font="Arial 18") b_3.pack() b_3.bind("<Button-1>", f_wind3) b_4 = Button(root, text="Навколо осей Y, Z та X", font="Arial 18") b_4.pack() b_4.bind("<Button-1>", f_wind4) root.mainloop() 

    0