【发布时间】:2013-06-24 17:32:00
【问题描述】:
这是我使用 Vpython 的小 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()
【问题讨论】:
-
您需要跟踪对象的方向——它“指向”的方式——并将其用作旋转轴。