From: Brunet, C. <Cla...@sp...> - 2003-04-30 15:38:46
|
Thank you Bruce, This was exactly what I was looking for. I guess the documentation does not really explain the "up" attribute/method, or I may have mist it. Regards, and again many thanks for the very rapid response. Claude Brunet -----Original Message----- From: Bruce Sherwood [mailto:bas...@un...] Sent: Tuesday, April 29, 2003 8:20 PM To: Brunet, Claude; vis...@li... Subject: Re: [Visualpython-users] how do we access the state of an object rotated along its own axi s? The short answer is to look at my_frame.up. A longer answer involves me being confused about an aspect of Visual 3D graphics manipulations involving the scene.up direction, typically (0,1,0). In your program you create your frame with its objects with frame axis along (1,0,0), with the red arrow pointing in the (0,1,0) direction. Next you set my_frame.axis = (0,1,0), and your red arrow now points in the (1,0,0) direction, which seems a bit arbitrary to me. At this point if you print my_frame.up it has the surprising value (0,1,0), just as it did before the rotate, which seems odd to me. If you then make a small rotation about (0,1,0), even a zero rotation, my_frame.up suddenly becomes (1,0,0)! Thereafter my_frame.up rotates as you rotate the frame. If on the other hand after creating the objects you execute my_shape.rotate(axis=(0,0,1), angle=pi/2.), the red arrow points in the (-1,0,0) direction and my_frame.up is also (-1,0,0). This seems more understandable. Another way of seeing the strangeness is that after my_frame.axis = (0,1,0) your red arrow points to the right, but if you execute my_frame.axis(0.01,1,0), your red arrow points to the left. My head aches. Bruce Sherwood ----- Original Message ----- From: "Brunet, Claude" <Cla...@sp...> To: <vis...@li...> Sent: Tuesday, April 29, 2003 4:17 PM Subject: [Visualpython-users] how do we access the state of an object rotated along its own axi s? > 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? > > > > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Visualpython-users mailing list > Vis...@li... > https://lists.sourceforge.net/lists/listinfo/visualpython-users > |