#*********************earth.py*************************
#
# William Baker
#
#  usage:   python earth.py 
#
#*********************************************************

from visual import *
from math import *


def draw():
    sun = sphere(pos=(0,0,0), radius=1, color=color.yellow)
    earth = sphere(pos=(5,0,0), radius=.25, color=color.blue)
    moon = sphere(pos=(5.75,0), radius=.1, color=(.75,.75,.75))
    moonval=0
    scene.autoscale=0
    scene.userzoom=1
            
    while 1:
        rate(50)
        earth.rotate(angle=.001, axis=(0,0,1), origin=sun.pos)
        moon.pos=(earth.pos[0]+.75,earth.pos[1],earth.pos[2])
        moon.rotate(angle=(pi-moonval), axis=(0,0,1), origin=earth.pos)
        moonval+=.06
       
        if moonval>=2*pi:
            moonval=0
   

def main():
   
    draw()

main()

