From: Stef M. <s.m...@ru...> - 2008-12-05 10:14:35
|
hello Bruce, thanks for your fast respones. Bruce Sherwood wrote: > I think you need to give more information. I don't know what I'm > supposed to do to see the "weird behavior", nor do I know in what way > it is "weird". Sorry for the confusion, by "weird" I mean not as I expect, so probably I don't use the right algorithm to fulfill my expectation. Below is piece of code, showing my problem. I've two boxes, a normal box, blue and the same box, but green, in a frame. Now I want to rotate the box in the frame, and thus the whole frame, exactly the same as the free box. (I've taken the axis of the boxes in such a way, that represent physical properties, so I rather not want to change that) In the beginning, when the frame is positioned at the origin, the rotation behavior of free-box and frame are the same. But when free-box and frame are shifted, this not anymore the case. So the problem must be in the line that rotates the frame: test_frame.rotate ( angle = -pi/2, axis = Y_AXIS, origin = test_frame.pos + box_frame.pos ) apparently it's not enough to add the frame position and the relative position of the box in the frame. cheers, Stef # for reference, display origin and floor org = visual.sphere ( pos=(0,0,0), radius = 0.4 ) l = 10. floor = visual.box ( pos=(l/2,-1,l/2), axis=(1,0,0), color=(1,0,0), length=l, width=l, height=2 ) # create a normal box box_free = visual.box ( color=(0,0,1), pos=(2,3,3), length = 4, width = 2, height = 1 ) # create the same box in a frame test_frame = frame () box_frame = visual.box ( frame=test_frame, color=(0,1,0), pos=(2,1,3), length = 4, width = 2, height = 1 ) # rotate free_box and test_frame, works as expected Y_AXIS = ( 0, 1, 0 ) box_free .rotate ( angle = pi/2, axis = Y_AXIS ) test_frame.rotate ( angle = pi/2, axis = Y_AXIS, origin = test_frame.pos + box_frame.pos ) # now move the box and the frame in the z-direction box_free.z += 2 test_frame.z += 2 # rotate box and frame back box_free .rotate ( angle = -pi/2, axis = Y_AXIS ) test_frame.rotate ( angle = -pi/2, axis = Y_AXIS, origin = test_frame.pos + box_frame.pos ) Het UMC St Radboud staat geregistreerd bij de Kamer van Koophandel in het handelsregister onder nummer 41055629. The Radboud University Nijmegen Medical Centre is listed in the Commercial Register of the Chamber of Commerce under file number 41055629. |