def setup(): size(900, 450) def draw(): t = 0.01*frameCount g = 9.8 L = 2.0 degree = PI/180 amplitude = 20*degree omega = sqrt(g/L) theta = amplitude * sin(omega*t) xbob = L * sin(theta) ybob = L * cos(theta) # convert coordinates into pixel coordinates xpixel_pivot = 0.5*width ypixel_pivot = 0.1*height scale = 100.0 # pixels per meter xpixel_bob = xpixel_pivot + scale*xbob ypixel_bob = ypixel_pivot + scale*ybob # clear the screen for each new frame of animation background(128) # draw the string line(xpixel_pivot, ypixel_pivot, xpixel_bob, ypixel_bob) # draw the bob ellipse(xpixel_bob, ypixel_bob, 20, 20)