|
From: Brunet, C. <Cla...@sp...> - 2003-04-29 20:17:50
|
VPython group,
I just started using VPython to test some ideas for a 3D project. Found it
is a great environment to work with. I stumble accross the following
problem:
If one creates a frame and then rotates this object arround its own axis,
how can we access the rotation state of that object since neither the
".axis" nor the ".pos" methods provide any usefull information? Obviously
the state of the object is logged within VPython's internal since successive
rotate operations perform as expected.
In the little example below, how can I get (which method) the actual
direction of the arrow "pointer_1" (red) after any rotation operation to
my_shape?
Many thanks,
Claude Brunet
Manager Software & Ground Segment
Canadian Space Agency
tel : (450) 926-4462
Fax: (450) 926-4449
# little example of my problem
from visual import *
scene.exit = 0
scene.title = "rotation test"
scene.height = 600
scene.width = 600
scene.range = (18,18,18)
scene.background = color.white
scene.center = (0,2,0)
scene.visible=1
for obj in scene.objects:
obj.visible=0
# show the reference axis
arrow(pos=(0,0,0), axis=(10,0,0), shaftwidth=.1)
arrow(pos=(0,0,0), axis=(0,10,0), shaftwidth=.1)
arrow(pos=(0,0,0), axis=(0,0,10), shaftwidth=.1)
#define a frame object my_shape
my_shape = frame(pos=(0.,0.,0.), axis=(1.,0.,0.))
box_main=box(frame=my_shape,
pos=(0.,0.,0.), axis=(1.,0.,0.),
length=10., height=1., width=1., color=color.yellow)
box(frame=my_shape,
pos=(4.5,1.,0.), axis=(1.,0.,0.),
length=1., height=1., width=1., color=color.green)
pointer_1=arrow(frame=my_shape,pos=(5.1,-.5,0),axis=(0,3,0))
pointer_1.color=(1,0,0)
# align it along the Y axis
my_shape.pos=(0,0,0)
my_shape.axis=vector(0,1,0)
twopi_over_360=2*3.1416/360.
# rotate the frame object alomg the Y axis
for i in range(0,360):
my_shape.rotate(angle=(twopi_over_360))
rate(30)
# How can I know (which method to use) where the pointer_1 (red arrow)
points after any rotation operation?
|