import numpy as np def rotate(mesh): # Extract vertices and normals vertices = mesh.vertices # Define rotation matrices def rotate_y(vertices, angle): angle_rad = np.radians(angle) rotation_matrix = np.array([ [np.cos(angle_rad), 0, np.sin(angle_rad)], [0, 1, 0], [-np.sin(angle_rad), 0, np.cos(angle_rad)] ]) return np.dot(vertices, rotation_matrix.T) def rotate_x(vertices, angle): angle_rad = np.radians(angle) rotation_matrix = np.array([ [1, 0, 0], [0, np.cos(angle_rad), -np.sin(angle_rad)], [0, np.sin(angle_rad), np.cos(angle_rad)] ]) return np.dot(vertices, rotation_matrix.T) def rotate_z(vertices, angle): angle_rad = np.radians(angle) rotation_matrix = np.array([ [np.cos(angle_rad), -np.sin(angle_rad), 0], [np.sin(angle_rad), np.cos(angle_rad), 0], [0, 0, 1] ]) return np.dot(vertices, rotation_matrix.T) # Rotate vertices to right orientation vertices = rotate_y(vertices, 225) vertices = rotate_x(vertices, 90) vertices = rotate_z(vertices, -90) vertices = rotate_y(vertices, 45) vertices = rotate_z(vertices, 45) vertices = rotate_x(vertices, 45) vertices = rotate_y(vertices, 20) vertices = rotate_x(vertices, -10) # Update the mesh with the modified vertices mesh.vertices = vertices return mesh