from visual import *
scene = display(width=800, height=800,center=(1, 1, 0),
background=(0.5,0.5,0))
Xaxis=arrow(pos=(0,0,0), axis=(10,0,0), shaftwidth=0.1, color=(1,0,0))
Yaxis=arrow(pos=(0,0,0), axis=(0,10,0), shaftwidth=0.05, color=(1,0,1))
ball1 = sphere(pos=(2,0,0), radius = 0.4, color=color.yellow, make_trail=True)
ball2 = sphere(pos=(3,0,0), radius = 0.4, color=color.red, make_trail=True)
ball3 = sphere(pos=(7,0,0), radius = 0.4, color=color.blue, make_trail=True)
ball4 = sphere(pos=(8,0,0), radius = 0.4, color=color.black, make_trail=True)
t=0.; #初始時間歸零
dt=0.1; #時間的微量間隔
r=2.; #半徑
w=1. #角速率
while t<20.:
rate(10)
t=t+dt
ball1.pos=vector(2.*cos(w*t),2.*sin(w*t),0) #時間增加球的位置也跟隨改變
ball2.pos=vector(3.*cos(0.5*w*t),3.*sin(0.5*w*t),0)
ball3.pos=vector(7.*cos(w*t),4.*sin(w*t),0)
ball4.pos=vector(8,4.*sin(w*t),0)