import math import time # Определение вершин куба vertices = [ [-1, -1, -1], [-1, 1, -1], [1, 1, -1], [1, -1, -1], [-1, -1, 1], [-1, 1, 1], [1, 1, 1], [1, -1, 1] ] # Определение ребер куба edges = [ [0, 1], [1, 2], [2, 3], [3, 0], [4, 5], [5, 6], [6, 7], [7, 4], [0, 4], [1, 5], [2, 6], [3, 7] ] # Определение угла вращения куба theta = 0 while True: # Очистка экрана print("\033c", end="") # Изменение угла вращения theta += 0.05 # Создание матрицы вращения rotation_matrix = [ [math.cos(theta), -math.sin(theta), 0], [math.sin(theta), math.cos(theta), 0], [0, 0, 1] ] # Применение матрицы вращения к вершинам куба rotated_vertices = [] for vertex in vertices: rotated_vertex = [0, 0, 0] for i in range(3): for j in range(3): rotated_vertex[i] += rotation_matrix[i][j] * vertex[j] rotated_vertices.append(rotated_vertex) # Проекция вершин на экран projected_vertices = [] for vertex in rotated_vertices: x = int(vertex[0] * 10 / vertex[2] + 50) y = int(vertex[1] * 10 / vertex[2] + 25) projected_vertices.append([x, y]) # Отрисовка ребер куба for edge in edges: start = projected_vertices[edge[0]] end = projected_vertices[edge[1]] print(f"\033[{start[1]};{start[0]}H+", end="") print(f"\033[{end[1]};{end[0]}H+") # Ожидание time.sleep(0.05)