home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ARM Club 1
/
ARM_CLUB_CD.iso
/
contents
/
education
/
a
/
2dwaves
/
!2DWaves
/
!help
next >
Wrap
Text File
|
1992-01-06
|
8KB
|
194 lines
____________________________________
!2DWave by Jan Vlietinck (8-12-1992)
____________________________________
1. Introduction
===============
2DWave is simulation program for two dimensional waves. The program is both
educative and entertaining. The idea is to simulate waves exactly as they
would behave in real live. Such waves are waves on a water surface, acoustic
waves produced by a speaker and even electro magnetical waves. The waves are
calculated according to the correct physical rules described by the Laplace
differential equation, resulting in a smooth colourful animation. On an Arm2
machine, 12.5 full screen frames per second can be displayed. Those frames
are at the full 320x256 resolution of the 256 colours mode 13. Special hand
optimised Arm machine code had to be written to achieve this speed.
2. Workings
===========
Internally the wave plane is represented by a two dimensional array with
each point having two states : height and velocity of a cell. On the screen
each pixel is coloured according to the height of a point on the wave
surface. The calculations resembles those of a cellular automat. The new
height is the old one added with a number proportionally to the velocity.
The new velocity is the previous one multiplied by a viscous damping factor
and incremented proportional to the difference between the average height of
the four surrounding cells and the current height of the cell.
Thus :
h'(x,y) = h(x,y)+a*v(x,y)
v'(x,y) = b*v(x,y)+c*(h(x-1,y)+h(x+1,y)+h(x,y-1)+h(x,y+1)-4*h(x,y))/4
Where h(x,y) and v(x,y) are the height and velocity of a cell on position
(x,y). In the program : a=1, b=1-2^-n, c= 2^-m.
To speed up calculations, interpolation is used. For a full screen 320x256
display, only a 80x64 mesh is calculated. The other points are found by
interpolation.
3. The menu
===========
After starting the program you are presented with the menu screen. The menu
which is surrounded by a rectangle is divided in three submenus : 'actions',
'options' and 'settings'. A selection in this menu can be made by moving the
mouse on one of the entries and clicking the left mouse button.
3.1 Actions submenu
-------------------
The actions submenu is used to enter wave sources in a number of ways before
starting a simulation. The excitation of a source is either generated by the
computer or you can control it with the mouse. The computer controlled
sources produce a sinusoidal excitation of which the amplitude, frequency,
phase and position can be entered.
When selecting 'automatic' a number of random sources are configured and the
wave simulation starts.
Selecting the second entry in the menu leads to the 'semi-automatic' control
screen. On the left top of this screen, the amplitude, frequency, phase and
position of the current source are displayed. A source is represented by a
solid circle, the current source is surrounded by a white circle. Also the
current wave is graphically represented by a sinusoid. By moving the mouse
you can alter the position of the source, clicking the left button enters
the source.
Holding down the right mouse button and moving the mouse allows you to
change the amplitude and frequency of the current source. Horizontal
movements control the frequency while vertical movements alter the
amplitude. The parameters of a source can also be configured by pressing the
'1 2 3' and 'Q W E' keys to increase and decrease the amplitude, frequency
and phase. When you have entered all the required sources the simulation is
started after clicking the middle button.
The third, 'manual', entry in the actions submenu allows you to control a
source with the mouse whilst simulation. Moving the mouse up and down
controls the amplitude of the source. Moving the mouse and clicking the
right button repositions the source. Holding down the left button and moving
the mouse produces an effect similar to that of a boat sailing through the
sea.
The 'continue' entry allows you to continue simulation after suspension.
At any time during simulation the action can be frozen by holding down the
right button. Returning to the menu screen is done by clicking the middle
button.
3.2 Options submenu
-------------------
The 'options' submenu allows you to switch on and off various options.
Clicking on one of the three option switches the option on, another click
switches it back off. The on state is depicted with a mark to the left of
the option.
Setting on the 'projection' option gives you a three dimensional,
perspective, projection of the simulation.
The 'loose edges' option allows you to choose between fixed or loose edges
of the simulated surface. Fixed edges is like the film of a tambour while
loose edges resembles water in a pool.
When the 'colour lookup' option is on, the colour of every pixel is
translated via a lookup table before display, to give a more pretty colour
display of the waves. When this option is off and projection is chosen then
all the points are coloured white to give a look more reminiscent of water
waves.
At any time during simulation the three options can be toggled on and off
with a key to give instant change. To toggle the projection, edge and colour
effect, press the 'P','E' and 'C' key.
3.3 Settings submenu
--------------------
With the 'settings' submenu some physical parameters of the simulated plane
can be reconfigured. To alter the default value click on one of the five
entries, enter a chosen number and press return. Out of range numbers are
automatically constrained to the maximum or minimum value.
With the 'width' and 'height' parameters the physical extent of the plane
may be set. The width may be varied between 10 and 80 while the height is
variable between 10 and 64.
The 'viscosity' and 'time step' value determine the behaviour of the
simulated plane. The viscosity factor may be varied between 1 and 10. A
value of 1 gives a very watery appearance. Entering the maximum of 10 gives
a very viscous, syrupy, simulation. Also the time step factor can be varied
between 1 and 10. 10 is the default, a lower number allows you to slow down
the action by reducing the elapsed simulation time between successive
frames.
Finally the 'base colour' option allows you to shift through the colour
pallet.
4. Saving the screen
====================
At any time during simulation the current frame can be saved. Pressing the
'S' key causes the current screen to be saved. There is no need to enter a
file name; all screens saved are automatically named as Dump0, Dump1,...
Ensure that sufficient space is available on discs before saving!
5. Hints and tips
==================
- Projection is more attractive with loose edges.
- Colour lookup is prettier but it slow down the simulation considerably.
- Simulation with small width and height may execute too fast, therefore you
should reduce the time step.
- When you find that the waves decay to slowly then increase the viscosity
factor.
- Dipole sources are constructed with two very close sources with the same
amplitude and frequency but with a phase difference of pi. To avoid
reflections at the edges which would spoil the effect increase the
viscosity to 7.
- Analogous a swirl may be generated by four sources with the same amplitude
and frequency but with phases 0, 0.5, 1 and 1.5 pi, positioned in a close
cross formation.
- Also watch some sources with low amplitude and high frequency superimposed
on a source with a high amplitude and low frequency.
- Base colour 140 also gives nice colours.
Enjoy the program !
Any comments welcome at :
Jan vlietinck
Essendreef 15
8300 Knokke-Heist
Belgium