summaryrefslogtreecommitdiff
path: root/sys/man/1/galaxy
blob: 3743df6afc0230b29ab594d5dd962653c90e31e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
.TH GALAXY 1
.SH NAME
galaxy, mkgalaxy \- galactic n-body simulator
.SH SYNOPSIS
.B games/galaxy
[
.I options
] [
.B -i
] [
.I file
]
.br
.B games/mkgalaxy
[
.I options
] [
.B -i
] [
.B -f
.I file
]
.I size
.SH DESCRIPTION
.I Galaxy
is an n-body simulator that uses a Barnes-Hut quad-tree
to calculate gravitational interactions.
Typical usage is to read a galaxy file (see
.IR galaxy (6))
from standard input
using the
.B -i
command-line option or from a
.I file
using the
.B -f
option. If no file is read then the simulator starts with an empty
universe.
.SS Mouse commands
.PP
Holding mouse button 1 while dragging repositions the visible region of
the galaxy. Holding mouse button 2 while dragging up or down zooms the
visible region of the galaxy in or out, respectively.
Mouse button 3 opens a menu with the following options:
.TP
.B "new body"
Creates a new galactic body.
Holding button 1 positions the body.
Holding a button 1-2 chord changes the mass/size
of the body. Holding a button 1-3 chord
changes the initial velocity of the body. Releasing button 1
restarts the simulator with the new body in motion. When new
bodies are created, the simulator maintains the Galilean (inertial)
reference frame where the center of mass of the galaxy is at rest.
.TP
.B speed
Prompts for a floating point value to change the speed of
the simulation. E.g. a value of 2 will double the speed
of the simulation and a value of 0.5 will
halve the speed. Accuracy is sacrificed for greater speed.
.TP
.B gravity
Prompts for a floating point value to change the gravitational
constant. E.g. a value of 2 will double the force exerted by
gravity and a value of 0.5 will halve it.
.TP
.B save
Prompts for a file name to save the current galaxy as a
.IR galaxy (6)
file.
.TP
.B load
Prompts for a file name to load the galaxy from the
.IR galaxy (6)
file.
.TP
.B exit
Exits the simulator.
.SS Keyboard commands
The following keys are recognized as commands:
.TP
.B a
Show accelerations as vectors.
.TP
.B v
Show velocities as vectors.
.TP
.B s
Show statistics such as the number of bodies being
simulated, the maximum depth of the quad-tree, and the
average number of calculations made per body.
.TP
.B q
Exit the simulator.
.TP
.B space
Pause and unpause the simulator.
.TP
.B del
Exit the simulator.
.SS Command-line options
Certain aspects of the galaxy simulator are controlled by
the following options:
.TP
.BI -G " gravity"
Sets the gravitational constant to
.I gravity.
The default value is 1.
.TP
.BI -f " file"
Reads the galaxy file
.I file
(see
.IR galaxy (6)).
.TP
.B -i
Reads a galaxy file from standard input.
.TP
.BI -p " procs"
Specifies the number of extra processes to use in order
to calculate the gravitational force on each body in
parallel.
The default value is
.BR $NPROC-1 .
.TP
.BI -t " throttle"
Causes the process that calculates forces to relinquish
the processor for
.I throttle
milliseconds after each calculation.
.TP
.BI -ε " softening"
Sets the
.I softening
factor to prevent gravitational singularities during
collisions or near-collisions. The default value is 500.
.SS Mkgalaxy
.I Mkgalaxy
is a utility to create galaxies for simulation.
Galaxies can be assembled incrementally by reading an
existing galaxy file from standard input with the
.B -i
command-line option or from a
.I file
with the
.B -f
option. Mkgalaxy then writes to standard output a
.IR galaxy (6)
file with a galaxy of the given
.I size
together with the previously read galaxy.
Galaxies generated by mkgalaxy have characteristics
determined by the following options:
.TP
.BI -d " distance"
.I Distance
determines the spacing between bodies.
The default value is 100.
.TP
.BI -s " size"
Bodies have the given
.IR size .
The default value is 25.
.TP
.BI -v " velocity"
Bodies have the given
.I velocity
in a random direction.
The default value is 0.
.TP
.BI -av " angular velocity"
Bodies have the given
.I "angular velocity"
relative to the center of mass of the new galaxy being generated.
The default value is 0.
.TP
.BI -gv " x,y"
The entire galaxy being generated is given the directional velocity determined
by the vector
.RI ( x,y ).
The default value is (0, 0).
.TP
.BI -o " x,y"
The entire galaxy being generated is offset by the vector
.RI ( x,y ).
The default value is (0, 0).
.TP
.B -sq
The galaxy being generated is a square. Without this option, the galaxy
will be circular.
.PP
The arguments to the
.BR -d ,
.BR -s ,
.BR -v ,
and
.B -av
arguments have the form
.B s
or
.B s±r
where s and r are double-precision floating point numbers.
.B S
is the base value and
.B r
if given determines a range in which the value will vary randomly
from the base.
.SH EXAMPLES
Two rotating circles destroy each other:
.IP
.EX
games/mkgalaxy -av 100 -d 60±50 -v 10 2000 |
games/mkgalaxy -i -av -70 -d 80±50 -v 10 -o 6000,2000 -gv -80,40 3000 |
games/galaxy -i
.EE
.PP
Cool patterns made by a square galaxy:
.IP
.EX
games/mkgalaxy -sq -av 20 5000 | games/galaxy -i
.EE
.SH SOURCE
.B /sys/src/games/galaxy
.SH SEE ALSO
J. Barnes & P. Hut (December 1986). "A hierarchical O(N log N) force-calculation algorithm".
.IR Nature .
324 (4): 446–449.
.PP
.IR galaxy (6)
.SH HISTORY
.I Galaxy
and
.I mkgalaxy
first appeared in 9front (Feb, 2017).