home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
f
/
fractal112
/
!Fractal
/
Help
/
L-Systems
< prev
next >
Wrap
Text File
|
1995-09-05
|
14KB
|
314 lines
________________________________________________________________________
/ \
| !Fractal : Help On L-Systems |
| |
| September 1995 |
\________________________________________________________________________/
L-System : Turtle graphics as used for drawing plants etc.
--------
The L-system uses a LOGO like turtle language to describe shapes as a series
of movements, and was introduced by A. Lindenmayer to help describe plants.
Refer to the book The Algorithmic Beauty of Plants for full details of the
work by Prusinkiewicz and Lindenmayer. Up to 80 definitions are stored
internally, and can be saved as a text file, or a new file may be loaded.
Each shape definition is made up of the following components:
Name: 1-19 character name for identification.
Iterations: the number of times the algorithm is recursively expanded.
Angles: Rather than describing the amount of each turn as so many degrees,
each turn is expressed as a fraction of a circle. Thus 6=60° (360°/6). The
number should be even if you plan to use the '|' command to allow turns of
180°.
Axiom: a string of 1-255 characters incorporating turtle commands and rules.
Rules: a single letter identifier and 0-255 characters consisting of further
rules or turtle commands. Note that the case of letters is significant.
The routine starts by taking the axiom string and then replaces each rule
character in it by the equivalent rule string. This process is repeated
for the number of iterations specified.
Thus if the axiom is F-F and the rule F=F+F, after the first expansion we
get : F+F-F+F, then F+F+F+F-F+F+F+F, and so on.
After expansion the string is interpreted as a series of turtle commands,
any rule characters being ignored.
The key to the routine is this recursive expansion, and often the use of
F as a rule and turtle command (which is somewhat confusing I admit, but
very important).
Drawing
-------
Because the size of the image is unknown at the outset, the plot has to be
repeated, with the image being correctly scaled to fit on the screen on the
second pass. However you can use zooming or turn off Auto Scaling (see
later), in which case only a single plot is performed.
Use Adjust to stop a plot. Note that currently it is not possible to restart
a plot after Adjust is pressed. You are advised to start at low iterations
and work up.
Basic Turtle Commands
---------------------
The characters used are those in standard use. Note that 'F' is different
from 'f'. (Fractint uses 'G' for 'f' since it is case insensitive).
Initially the unit line length is 1 and the direction is along the x-axis.
F : draw a line forwards in the current direction and length.
D : same as F, ie. draw a line forwards.
f : move forwards without drawing a line.
- : turn anti-clockwise 1 angle (see definition of angle above).
+ : turn clockwise 1 angle.
| : turn 180°. Note - angle must be even for this to work correctly.
Advanced Turtle Commands
------------------------
To get more complex displays requires the use of one or more these commands.
[ : stack the current position, angle, line length, width and colour.
] : unstack the turtle details.
! : reverse meaning of '+' and '-'.
cn : Set colour to n where n=0-255. See below for colour numbering.
>n : increment colour by n where n is one or more digits.
<n : decrement colour by n.
@n : multiply the line length by n. The initial length is 1. 'n' is 1 or
more decimal digits and may contain a decimal place.
To divide precede the number by I (for inverse). eg. @I3 divides by 3,
or use @0.333.
Precede the number by 'Q' for the square root, eg. @Q2 = length * 1.414
#n : Multiply the line width by n - the initial width is a single pixel.
Numbers may be specified as for line length.
{sprite} : Plots a sprite of this name at the current position and rotation.
The sprite is plotted the same size as the current line size.
See below for full details.
{sprite,n} : As above but plots at the scale specified as 'n'.
Colour
------
The initial colour is 255 (white in the default palette). To get a sensible
progression of colours use the RGB palette.
If the colour exceeds 255 it wraps around. If a colour falls between 0-7
when using < or >, then it is incremented/decrmented by 8, since colours 0-7
are assumed to be too dark to be seen.
Menu Options
============
The menu options are described next.
Data Entry Panel
----------------
Use this panel to update the L-system data, or select a new L-system. To
move the caret around the icons use !Fractal's standard editing keys. The
various icons are:
Input: You must click on this for your changes to take effect.
Re-draw: This is the same as Input followed by a re-draw request.
Store: This takes the data and stores it in the internal file. If you move
to another L-system without using this option your updates will be lost!
Restore: Refreshes the data on display from the copy in the internal file.
This lets you back out changes without having to re-load the file.
Copy: Takes a copy of the current L-system so that you can edit it without
modifying the original. You should give the copy a new name to avoid
confusion.
Delete: Deletes the current L-system from the internal file.
Name: the 1-19 character identifier for this L-system.
Item: click on the left or right arrows to move to a different L-system.
Remember to use Store if you want to keep any changes to the current
L-system.
Iterations: Use the arrows to change or click on the number to key in a new
value. Higher iterations give more complex patterns but will take much
longer to draw.
Angle: determines the amount of turn for '+' and '-'.
Axiom: the 1-31 character string that is the initial rule.
Rules: Each rule must have a unique character for identification. Up to 9
rules may be use, each of 0-79 characters. A null rule can be used to strip
out turtle commands during expansion (see Cesaro for example). Remember to
click Input or Redraw to enter your values.
L-System List Panel
-------------------
This panel lists all the L-systems that are held internally, showing the
first 11 characters of their name with the current name being highlighted.
Click on a name to select one. The predefined shapes all assume that the
Default palette is in use - this is mainly of importance when plotting the
plant shaped images.
Save
----
The internal file of L-system definitions can be saved as a text file by
dragging the text icon to a filer window. The associated sprites will be
saved in the same directory if not already present. Saved definitions can be
reloaded at any time - !Fractal will automatically select L-system if it is
not the current fractal. Three files of definitions are supplied - click on
Misc->Resouces to open a Filer window showing the files available.
You can edit the text file, but be careful to keep to the format which is:
L-System
sprite filename
Name=l-system name } for each
Iter=iterations } L-System
Angles=no. angles }
Axiom=axiom string }
ruleid=rule text } 1 for each rule
The supplied definitions come from the Science of Fractals, Algorithmic
Beauty of Plants, Fractint, and John Greening. Please send in more functions
to AFG so we can all see them. I have added colour and sprites to some of
the shapes.
Auto Scaling
------------
When on this ensures that the image is automatically scaled to the maximum
displayable size. Turn it off if you want to manually position the image -
this is useful if you want to plot multiple shapes and place each at a
certain position. To do this turn Image->Redraw->Clear off and manually set
the x0/y0 (bottom left coords) and width/height values in the Image->Data
panel. Remember that a unit length is 1 and plotting begins at 0,0. The best
way to determine the values required for a shape is to draw the shape with
auto sc