Python对象旋转在特定对象上

2024-09-27 22:26:32 发布

您现在位置:Python中文网/ 问答频道 /正文

这是我使用Vpython的小Python程序 我想旋转一个盒子。 我想使用长方体轴,而不是场景的轴。 举个例子,如果它向右旋转,然后我想让“鼻子”朝下,我想在盒子的视图中这样做。。。 想象我是一架喷气式飞机;) 顺便说一句:我是Python3

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()

Tags: 程序ifkb场景scene例子盒子rotate

热门问题