| README | Planet.cc | gnu | gnu10 | gnu11 | output/sun | Planet2.cc | gnu20 | gnu21 | output/gnu0 |
Planet.cc is a worked solution for the task:
|
Directories: The first C++ program, Planet.cc, will put its output in a directory called output (provided you first create that directory and then run the program following the instructions written in the comments at the top of Planet.cc). The "gnu" files (gnu |
gnu10 |
gnu11)
go in the upper directory. |
|||
gnu is a simple gnuplot file for plotting the output of Planet.cc. It displays the positions and the velocities in a single graph. gnu10 and gnu11 are a fancier pair of gnuplot files for making a movie from the output of Planet.cc. gnu10 sets things up, then calls gnu11, which does the plot and calls itself recursively. The file sun contains the coordinates of the sun | ||||
Planet2.cc is a much fancier
solution
for the task. It can handle either of two force laws
(inverse square and Hooke law);
and while it is running, it can print out gnuplot commands
to stdout, so if you pipe its output into gnuplot,
it makes a live movie. It can be modified so that it
performs an Euler simulation immediately after a
Leapfrog one.
These extra features are not very elegant.
| Directories: For the second program (Planet2.cc), "output/gnu0" should go in the output directory. The output of the program is written to files in the "/tmp" folder, and commands for gnuplot are written to standard output (stdout). See the head of the cc file for instructions. |