Part 0: A little geometry

You're going to be doing a simple animation that looks something like a moon orbiting a planet which, in turn, orbits a sun. Just 'cause I don't want you to get caught up worrying about the trig of calculating positions in this scheme, the diagram to the right shows how to do it. If you know the coordinates of your "sun", P0 = (x0,y0), you can calculate the coordinates of your planet when it's at angle a0 in its orbit, P1=(x1,x2). Then, when the moon is at angle a1 in its orbit around the planet, you can calculate its position P2=(x2,y2) from P1 and a1.

Part 1: Circles

Your first job is to make this:

Part 2: Animate

Your next job is to augment your Part 1 program so that pushing the start button starts an animation in which the pink point travels around the pink circle which, since the blue circle is centered at the pink point, means that the blue circle travels with it, while at the same time the blue point travels around the blue circle. To "move" these points, simply keep adding some small fixed amount (e.g. 0.01 to the inner and 0.04 to the outer) to the angles (a0 and a1 in the diagram).

Optional Challenge : stopping and restarting

See if you can modify the program so that once started, the button label changes to "stop", and clicking it again stops the animation, and returns the button label to "start". Clicking again should start the animation again, and so on.

Optional Challenge : tracing

See if you can modify the program so that the path of the dot moving around the blue circle is taced out on the screen. Like this :


Demo this lab to your instructor rather than submit it via the submit system.