KDE Turtle - fractal generation through repetitive
rule substitution
Version 0.1, 23 September 1997
Index
Introduction
This application can be used to generate visual representations
of fractals described by an axiom and a rule set to be expanded to a certain
level through repeated rule substitutions into the axiom and making the
result the axiom for the next level. The axiom and rules possibly ( and
most likely if it is to be of any use ) contains embedded commands which
is understood by a turtle which will draw them on a visual pane.
Turtle
The turtle currently understands the following commands
( which are open to suggestions BTW )
-
F - move and draw 1 unit forward
-
B - move and draw 1 unit backwards
-
- - turn 1 arc anti-clockwise
-
+ - turn 1 arc clockwise
-
< - decrease unit length
-
> - increase unit length
-
[ - push turtle state onto stack ( unit length, direction,
position )
-
] - pop state from stack restoring to exact state
as it was with last push
The turtle first renders the fractal in imaginary
space and then uses the result to calculate a scalar by which to scale
all the initial values ( unit length, unit in/decremental, start position
) and then renders again onto a visual canvas. It uses an iterative approach
( in stead of a possible recursive approach ) which results in increased
speed however accompanied by greater memory requirements ( +- 256 KB for
fine grained result ) An example of a possible session might be best described
by the well known Koch fractal. In this case
the starting axiom is F and there is only one rule FF-F++F-F.
The rule syntax is simply a character signaling which character in the
axiom to replace with the rule followed by the replacement string. Thus,
in this case F will be replaced by F-F++F-F. This means
that at level 0 ( first substitution of rule into axiom ), the result is
F-F++F-F
At level 1 we get as result
F-F++F-F-F-F++F-F++F-F++F-F-F-F++F-F
It should be pretty clear that this kind of expansion could result in
pretty rappid growth of the fractal. Level 2 ( which i'm not going to write
down here or anywhere for that matter ) results in
Eventually we end with something like
which is the application's representation of the memory limited maximum
expansion through iterative approach. There are quite a few well known
fractals of this kind ( of which some are included in the distribution
) and you should play with them. The real challenge however is to create
one's own which is easier said ( or typed ) than done. If you create a
nice authentic one, you can send it to me and i will include it in future
distributions with appropriate acknowledgement.
Examples
Following are a couple of examples to try out. They should be available
in .tur files in the archive this application was distributed by. Here
they are presented presented in the following way
-
Description
Directions
Axiom
Rules
.
.
Try them out.
-
Simple plant
14
---F
FF[+F]F[-F]F
-
Simple plant
14
----G
GGFX[+G][-G]
XX[-FFF][+FFF]FX
-
Nice tree
16
----F
FFF+[+F-F-F]-[-F+F+F]
-
A Xmas tree
20
-----SLFFF
G+H[-G]L
H-G[+H]L
L[-FFF][+FFF]F
S[+++G][---G]TS
TTL
-
Stylish tree
32
--------C
CNF[--P]F+C
NNFF
PQ
QC
-
The dragon curve
4
X
XX+YF+
Y-FX-Y
-
Grass in the wind
32
--------C
C[--C]N[++C]N+C
NNNF
-
Another branching pattern
32
--------C
CN[--C]N[++C]N+C
NNNF
-
Hexagonal structure
6
F
FFXF
X[-F+F+F]+F-F-F+
-
Hilberts space-filling curve
4
X
X-YF+XFX+FY-
Y+XF-YFY-FX+
-
The quadratic Koch island
4
F+F+F+F
FF+F-F-FFF+F+F-F
-
Segment of Koch's snow flake. A classic fractal example
6
F
FF-F++F-F
-
Example for iteration: This fractal grows only linearly.
4
-N
LF[-FF[-F]+F]F
NLN
-
Peano's space filling curve
4
X
XXFYFX+F+YFXFY-F-XFYFX
YYFXFY-F-XFYFX+F+YFXFY
Graphical User Interface
The user interface attempts to be straight forward.
A couple of popup menus provides access to the functionality of the application
-
File
-
New - reset axiom, rules, level and direction count
-
Load - load a fractal description ( .tur files )
-
Save - save fractal description for later use
-
Print - print fractal
-
Bitmap - save fractal image as .bmp file
-
Quit - you don't want to use this
-
Edit
-
Edit - edit the fractals axiom, rules and direction
count. The rules should be entered 1 per line where the first character
indicates which character the rule will replace during rule substitution
and the rest of the characters up to the end of the line is the rule and
will replace the character during expansion. The directions indicates into
how many equil arcs should the 360 degree revolution be divided e.g. direction
4, axiom F and single rule F-F-F-F will draw a rectangle
as 360/4=90 degrees
-
View
-
Next Level - render the next rule substitution session
of the fractal
-
Level 1 - 15 - render a specific level of rule replacement
-
Last Level - render the maximum possible level given
the fixed ceiling amount of memory available to the iterative method. The
memory used are limited by the app but experience have shown me that it
is enough for reasonable grained results
-
Help
-
Help - Don't read this. You'll get confused
-
About - Beyond the scope of this document
At any stage of fractal display, you may resize the
window which will result in the fractal being regenerated to fill up as
much as possible of the window without aborting aspect ratio.
Installation
For the following instructions to work, the user
this is done with should have access to developement tools on target host
and write access to installation directory
-
Unpack distribution
-
In distribution root directory do
-
./configure
-
make
-
make install
In you have any problems and/or patch to installation process, please let
me know.
You should have received some sample .tur files in the distribution.
Try them out.
Bugs
-
When starting up, it might happen that the splash
screen is not displayed correctly
-
Linear fractals take a very long time to reach maximum
iteration level which makes it look as if the system hung
Changes
-
23 September 1997 - Version 0.1 released
Acknowledgements
-
The idea stemmed from an application called Fractree
running on the platform of the enemy which I used some 4 years ago and
which I enjoyed playing with a lot ( i mean the app not the OS ;-). It
was written by Michael Schernau. I include some fractals from his original
implementation.
-
The guys at Troll
Tech which created such a nice application framework
which makes it the easiest i've ever experienced to write GUI's
-
The guys at the core of KDE
which spawned such a great project for Linux
-
The Linux team for relieving
me of the agony ( and i'm serious ) of working with a lesser able though
better known OS and providing one in which i feal generally protected...
Pheewww ...
Future
-
In future, this app might inspire me to implement
a seperate Logo
programming environment for KDE
-
I also have in mind adding color variation support to the turtle command
set
-
I want to write a screensaver companion for KDE based on the turtle and
fractal sets as encountered in this app and after color variation was built
in
Copyright
I must admit, i don't understand neither copyright
statements nor their laws. I include a copy of the GNU General Public License
just to have something to put in this section, so your bound to it.
KTurtle is Copyright 1997 by Tiaan Wessels,
tiaan@netsys.co.za
This program is free software; you can redistribute
it and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
This program is distributed in the hope that
it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU
General Public License along with this program; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA
If needed, contact me at tiaan@netsys.co.za