home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
o
/
orbits
/
!orbits
/
Doc
< prev
next >
Wrap
Text File
|
1991-11-24
|
10KB
|
195 lines
Orbits
------
A many body orbital mechanics simulation for RISC OS computers.
By Neil Hoggarth.
Introduction
------------
Orbits simulates the movement of an arbitary number of objects under
the effects of their mutual gravitational attraction. The main program
itself takes control of the machine for the duration of the run. However a
multitasking desktop front end is provided so that the program can be
started and controlled from within the desktop environment. The program is
Public Domain and may be copyed subject to certain conditions. Please see
the section "Copying" below and the license agreement.
Running the program
-------------------
The program is started by double clicking the !Orbits application
directory in the normal way. An Orbits icon is installed on the icon bar.
The icon menu has six options.
Info - displays the usual 'information about program' box.
Intro - displays this file in a text window.
License - displays the program's license conditions in a text
window.
Trail - selectable option. When this is ticked the bodies in the
simulation leave a trail behind them, marking out the
orbit.
Input - opens a filer window for the sub-directory containing the
example input files.
Quit - terminates the program.
A simulation is started by draging a text file with the appropriate
format to the Orbits icon. The simulation program then takes over the
machine for the duration of the simulation. Whilst the program is running
the following control keys can be used.
f1 - toggle the trail option on/off.
f2 - clear the screen. This is useful if the screen has become
cluttered with orbit trails.
f12 - terminate simulation.
The simulation runs until the user presses f12, after which it stops
and the computer returns to the desktop environment.
Input format
------------
The simulation operates on a series of "bodies". Each body has
the following attributes.
mass
position ("x" and "y" co-ordinates)
velocity (rate of change of "x" and rate of change of "y")
The co-ordinate system used is the same as the graphics co-ordinate
system used by BBC BASIC but with the origin (the 0,0 point) shifted into
the middle of the screen. Co-ordinate 0,0 is in the centre, the x axis runs
horizontally from -640 on the left hand edge to +640 on the right and the y
axis runs vertically from -512 at the bottom edge to +512 at the top.
Hopefully the following diagram makes this clear (co-ordinates are given as
x,y).
-640, 512 -------------------- 0,512 ------------------------- 640, 512
| |
| |
| |
| |
| |
-640, 0 0,0 640, 0
| |
| |
| |
| |
| |
-640,-512 -------------------- 0,512 ------------------------- 640,-512
Bodies can be outside of the co-ordinate ranges given, but thay will no
appear on the screen.
Input files consist of a series of lines, each one of which is the
specification of a body. These take the following form.
mass / x , y / rate-of-change-of-x , rate-of-change-of-y
The properties are specified as decimal numbers. The "/" and "," punctuation
is required. The "rate-of-change-of..." properties state how many pixels the
body is shifted by in the relevent direction each time the simulator runs
through its main loop and therefore govern how quickly the body moves
around. If you violate the input format the program responds with the (not
very helpful!) error message "parse error at line xxxx".
Comments can be introduced using a "#" character. Everything from a
"#" to the end of a line is treated as a comment and is ignored. Blank lines
are also allowed.
A number of example input files (with comments) are provided and
studying these is proberbly the best way to get a feel for the sizes of
parameter which work. These are supplied in a sub-directory 'input'. A
filer window for this directory can be opened by clicking on "Input" in the
main icon bar menu.
Running from the command line
-----------------------------
Although the casual user does not need to know it, the application
actually consists of two programs. "!RunImage" is the multitasking front end
and "orbits" is the simulation. The !RunImage program invokes orbits in
response to the user draging an input file to the icon. If you are the sort
of person who doesn't like windows, desktops and rodents then you can use
the orbits program directly. Simply copy "orbits" out of the application
directory into your normal "library" directory. You can now use "orbits" as
a command from the "*" prompt.
*orbits [-t] [-h] [<input file>]
The -t switch indicates that the program should trail orbits. The -h
switch causes the program to print a short help message. If the name of an
input file is omitted the program attempts to read from the standard input,
usualy the keyboard. Terminate keyboard input by typing <CTRL>-D.
Bugs
----
The simulation is non-relativistic. Anyone who understands the
General Theory is invited to rectify this and then explain to me how it
works!
In the real universe (on the scale we are interested in!) time and
space are continuous things. Unfortunatly the simulation runs in discrete
steps. This has no major effect most of the time. However I am effectively
making the assumption that each time the simulator moves on a step things
don't change very much. This falls down when bodies get very close to each
other. In such cases the gravitational gradiant can change very sharply. If
two bodies pass very close together they get a massive kick due to the
inverse square law. By the next discrete time interval they are far appart
again and so only weakly interact. The result of this is that when two
bodies almost collide then they tend to fly off at high speed never to be
seen again. Similarly if a body orbits another and the low point of its
orbit is very low then the orbit is distorted.
Notes to programmers
--------------------
The programs are written in C language and the source files are
distributed within the application directory. The programs were developed
with release 4 of the Acorn ANSI C compiler and have been tested with both
release 3 and release 4 (supplied with Desktop C). The module "c.RunImage"
makes a call to RISC_OSlib which is only supported by release 4. You
therefore require Desktop C to recompile RunImage. All the other files can
be compiled under release 3. For distribution to the PD libraries I have
compiled everything except RunImage under release 3. I have linked RunImage
with ANSIlib rather than the shared C library. This is because programs
compiled under release 4 require version 3.75 of the CLIB module which most
users will not have yet.
The C source files are in the sub-directory "c". The files
"c.orbpar" and "c.orblex", which control the reading of the input file, were
generated automatically by software development tools called "bison" and
"flex" from the files in the "y" and "l" sub-directories. If you don't have
bison and flex (or similar programs) then you can't rebuild the programs
from scratch. You can however change the other source files and re-link with
the exi