这是我使用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()
我建议创建一个存储方向的box类,正如martineau所建议的那样。类将有一个存储其方向的向量,然后有一个方法以任何需要的方式旋转它。在
相关问题 更多 >
编程相关推荐