Generation

generate functionTue, 21 Mar 2023

Crea un programa que utilice las funciones anteriores. El input debe ser un vector v , el eje entorno al cual se debe rotar (x, y o z) y el ángulo de rotación (θ). El output debe ser las componentes del vector rotado v 0 . Represéntalo gráficamente.

def rotate(v, eje, theta): # theta is the angle of rotation around the eje x = v[0] y = v[1] z = v[2] if eje == 'x': v0 = [x, y*cos(theta) - z*sin(theta), y*sin(theta) + z*cos(theta)] elif eje == 'y': v0 = [z*sin(theta) + x*cos(theta), y, z*cos(theta) - x*sin(theta)] elif eje == 'z': v0 = [x*cos(theta) - y*sin(theta), x*sin(theta) + y*cos(theta), z] return v0 v = [1, 1, 1] theta = pi/2 eje = 'z' rotate(v, eje, theta)

Questions about programming?Chat with your personal AI assistant