The due date is 10pm on Friday, September 30.
You may talk with other students and instructors about the assignments, but you may not look at or copy code written by others. The penalty for violating this code is an F for the entire semester.
You programming style must follow the ten essential style items listed at www.portmain.com/intro/style.html.
Write a program that uses the orbit_angle, orbit_dist and pixel functions from the previous homework to draw a graphical simulation of at least TWO planets in orbit around a star. The program must:
The difficult step is drawing the planet at the right location. This must be done by a void function that you write:
draw_planet(a, ecc, period, t, and maybe more parameters);
The parameters are:
The function uses Kepler's method to compute the polar coordinates (r, theta) of the planet in astronomical units at time t. It then converts those values to Cartesian coordinates (x = r*cos(theta) and y = r*sin(theta)). Finally, it converts to pixel coordinates before drawing. For this last conversion, you'll have to figure out what you want for your maximum and minimum x and y coordinates in terms of the solar system. What units will be convenient for you to use? Where will the sun be in this coordinate system?
The animation loop must be infinite
(while (true)...), so that the only way to end the
program is to click the close X or press ctrl-C.