0

This is my little Python programm Using Vpython I want to rotate a box. I want to use the boxes axis and not the one of the scene. so for example if its rotated to the right and then i want to get the "nose" down, i want to do this in the view of the box... imagine i was a jet ;) BTW: I´m a python 3

from visual import *
a=box(size=(5,1,3),axis=(1,0,0))
def tasten():
    "Looooopings "
    if scene.kb.keys:    #action on keyboard?
      druck=scene.kb.getkey() #save to cache
      if druck=='left':
        a.rotate(angle=-1/100, axis=(1,0,0)) #links drehen
      if druck=='right':
        a.rotate(angle=1/100,  axis=(1,0,0)) #rechts drehen
      if druck=='up':
        a.rotate(angle=-1,axis=(0,0,1))  #nose down

while True:
     tasten()
4

1 回答 1

1

I would recommend creating a box class that stores the orientation, as martineau is suggesting. The class would have a vector that stores its orientation, then a method to rotate it in whatever way required.

于 2013-07-24T01:07:24.400 回答