from visual import * print """ Bruce Sherwood Fall 2000 Four parts of program to illustrate rotating vectors: (1) A rotating position vector; for example, planet in circular orbit. (2) Also display momentum vector. (3) On right, display momentum vector with tail at center. (4) On right, display just the momentum vector Click anywhere to advance from one part to the next. The intent is to help in seeing that the momentum in circular motion is itself a rotating vector, so that its rate of change is omega*p. """ scene.x = scene.y = 0 scene.width=800 scene.height = 600 rsphere = 0.08 shaft = 0.06 omega = 0.5 dt = 0.01 R = 1. dx = 1.0*R f1 = frame(pos=(-dx,0,0)) planet = sphere(frame=f1, pos=(R,0,0), radius=rsphere, color=color.green) rvector1 = arrow(frame=f1, pos=(0,0,0), axis=(planet.x,0,0), shaftwidth=shaft, color=color.red) vvector1 = arrow(frame=f1, pos=rvector1.pos+rvector1.axis, axis=(0,omega*R,0), shaftwidth=shaft, color=color.cyan, visible=0) f2 = frame(pos=(dx,0,0)) rvector2 = arrow(frame=f2, pos=(0,0,0), axis=(planet.x,0,0), shaftwidth=shaft, color=color.red, visible=0) vvector2 = arrow(frame=f2, pos=(0,0,0), axis=(0,omega*R,0), shaftwidth=shaft, color=color.cyan, visible=0) scene.range = 1.2*(R+dx) show = 0 # don't show vvector or frame2 initially while 1: if scene.mouse.clicked: scene.mouse.getclick() show = show+1 if show == 1: vvector1.visible = 1 elif show == 2: rvector2.visible = 1 vvector2.visible = 1 elif show == 3: rvector2.visible = 0 vvector2.visible = 1 else: show = 0 vvector1.visible = 0 rvector2.visible = 0 vvector2.visible = 0 rate(100) f1.rotate(axis=(0,0,1), angle=omega*dt) f2.rotate(axis=(0,0,1), angle=omega*dt)