| README | Planet.cc | gnu | gnu10 | gnu11 | sun | Planet2.cc | gnu20 | gnu21 | planet/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 planet. The file sun should be in that directory too. I think the "gnu" files (gnu |
gnu10 |
gnu11)
go in the upper directory. |
|||
[an error occurred while processing this directive] |
gnu is a simple gnuplot file for plotting the output of Planet.cc. It displays the positions and the velocities in a single graph. [an error occurred while processing this directive] 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. [an error occurred while processing this directive] [an error occurred while processing this directive] The file sun contains the coordinates of the sun [an error occurred while processing this directive] | |||
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), "planet/gnu0" should go in the planet 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. |
[an error occurred while processing this directive] |