3 galaxy, mkgalaxy \- galactic n-body simulator
26 is an n-body simulator that uses a Barnes-Hut quad-tree
27 to calculate gravitational interactions.
28 Typical usage is to read a galaxy file (see
33 command-line option or from a
37 option. If no file is read then the simulator starts with an empty
41 Holding mouse button 1 while dragging repositions the visible region of
42 the galaxy. Holding mouse button 2 while dragging up or down zooms the
43 visible region of the galaxy in or out, respectively.
44 Mouse button 3 opens a menu with the following options:
47 Creates a new galactic body.
48 Holding button 1 positions the body.
49 Holding a button 1-2 chord changes the mass/size
50 of the body. Holding a button 1-3 chord
51 changes the initial velocity of the body. Releasing button 1
52 restarts the simulator with the new body in motion. When new
53 bodies are created, the simulator maintains the Galilean (inertial)
54 reference frame where the center of mass of the galaxy is at rest.
57 Prompts for a floating point value to change the speed of
58 the simulation. E.g. a value of 2 will double the speed
59 of the simulation and a value of 0.5 will
60 halve the speed. Accuracy is sacrificed for greater speed.
63 Prompts for a floating point value to change the gravitational
64 constant. E.g. a value of 2 will double the force exerted by
65 gravity and a value of 0.5 will halve it.
68 Prompts for a file name to save the current galaxy as a
73 Prompts for a file name to load the galaxy from the
80 The following keys are recognized as commands:
83 Show accelerations as vectors.
86 Show velocities as vectors.
89 Show statistics such as the number of bodies being
90 simulated, the maximum depth of the quad-tree, and the
91 average number of calculations made per body.
97 Pause and unpause the simulator.
101 .SS Command-line options
102 Certain aspects of the galaxy simulator are controlled by
103 the following options:
106 Sets the gravitational constant to
108 The default value is 1.
111 Reads the galaxy file
117 Reads a galaxy file from standard input.
120 Specifies the number of extra processes to use in order
121 to calculate the gravitational force on each body in
127 Causes the process that calculates forces to relinquish
130 milliseconds after each calculation.
135 factor to prevent gravitational singularities during
136 collisions or near-collisions. The default value is 500.
139 is a utility to create galaxies for simulation.
140 Galaxies can be assembled incrementally by reading an
141 existing galaxy file from standard input with the
143 command-line option or from a
147 option. Mkgalaxy then writes to standard output a
149 file with a galaxy of the given
151 together with the previously read galaxy.
152 Galaxies generated by mkgalaxy have characteristics
153 determined by the following options:
157 determines the spacing between bodies.
158 The default value is 100.
161 Bodies have the given
163 The default value is 25.
166 Bodies have the given
168 in a random direction.
169 The default value is 0.
171 .BI -av " angular velocity"
172 Bodies have the given
173 .I "angular velocity"
174 relative to the center of mass of the new galaxy being generated.
175 The default value is 0.
178 The entire galaxy being generated is given the directional velocity determined
181 The default value is (0, 0).
184 The entire galaxy being generated is offset by the vector
186 The default value is (0, 0).
189 The galaxy being generated is a square. Without this option, the galaxy
198 arguments have the form
202 where s and r are double-precision floating point numbers.
204 is the base value and
206 if given determines a range in which the value will vary randomly
209 Two rotating circles destroy each other:
212 games/mkgalaxy -av 100 -d 60±50 -v 10 2000 |
213 games/mkgalaxy -i -av -70 -d 80±50 -v 10 -o 6000,2000 -gv -80,40 3000 |
217 Cool patterns made by a square galaxy:
220 games/mkgalaxy -sq -av 20 5000 | games/galaxy -i
223 .B /sys/src/games/galaxy
225 J. Barnes & P. Hut (December 1986). "A hierarchical O(N log N) force-calculation algorithm".
234 first appeared in 9front (Feb, 2017).