Widget: rotazione asse z

Il cursore seleziona l’angolo di rotazione intorno all’asse z

Web VPython 3.2
#-------------------------------------------------------- binding
def bind_slider(evt):
    gradi        = evt.value
    radianti     = radians(gradi)
    freccia.axis = rotate(vector(1,0,0),
                          radianti,
                          vector(0, 0, 1))
    testo.text   = str(gradi) + "°"
#-------------------------------------------------------- scena
sphere(color = color.yellow, pos = vector(+1,0,0), radius = 0.1)
sphere(color = color.yellow, pos = vector(0,+1,0), radius = 0.1)
sphere(color = color.yellow, pos = vector(-1,0,0), radius = 0.1)
sphere(color = color.yellow, pos = vector(0,-1,0), radius = 0.1) 
freccia = arrow()
#-------------------------------------------------------- i/o
scene.append_to_caption("\nAngolo: ")
cursore = slider(bind = bind_slider,
                 max = 360,
                 min = 0,
                 step = 1)
scene.append_to_caption("  ")
testo = wtext(text = str(cursore.value) + "°")

Lascia un commento