"""
I have a problem with a VPython script which rotates a frame object about its
Z axis. I do not want to use rotate(), as I want to set the orientation
absolutely, not relative to its current orientation. So I alter the axis
attribute of the frame. The result is that the frame rotates correctly,
but the problem is that for some orientations the frame reverses its Z
direction. What causes it, how can I stop it happening, or is there a
"work around"? Any help would be appreciated. I do not want to use
rotate(). The following script is a distillation of my script, and running
it demonstrates the problem.
========================================"""
import visual as vs
frame1 = vs.frame()
vs.box() # marks frame origin (centre of rotation)
vs.curve( frame=frame1, pos=[(0,0,0),(8,0,0),(8,0,4),(8,2,4)] ) # the "hook"
while True:
for angle in range( 0, 360, 20): # FOR EACH VIDEO FRAME, Degrees
angleR = vs.radians(angle)
frame1.axis = ( vs.cos(angleR), vs.sin(angleR), 0) # set its orientation
if frame1.frame_to_world( (0,0,10)).z < 0:
print "ERROR at",
else: print "OKAY at",
print angle ,"degrees"
vs.scene.waitfor('click')