home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
alib
/
d1xx
/
d188
/
fracgen.lha
/
FracGen
/
ReadMe
< prev
next >
Wrap
Text File
|
1989-02-26
|
12KB
|
306 lines
FRACTAL GENERATOR 1.2
Copyright (c)1988 Doug Houck
DISTRIBUTION NOTICE
This Fractal Generator may be freely distributed, so long as this
notice is retained, and no profit is gained from the distribution of
this program. Please be sure to copy the accompanying subdirectories,
with a "copy all" or by using Workbench.
SOURCE CODE
Due to the fact that this program is laced with code that is part
of commercial products (Doug's Math Aquarium, Doug's Color Commander,
both available from Seven Seas Software), the remaining code would be
of little value to you except as examples. So it has been omitted.
BUT WHAT DOES IT DO?
This program grows fractal pictures from seeds you create. It is
meant to be a tool for exploring the world of fractals. It can be
enjoyed on three levels: (1) loading and displaying fractals stored
on disk, (2) modifying existing fractals, and (3) creating your own
fractals.
The main idea of this program is very simple. Take a shape composed
of several line segments, and replace each line segment with a small
copy of the entire shape. Continue doing this until you reach the
resolution limit of your screen. For example: (Koch Snowflake)
/\
Seed / \
____/ \____
__/\__
1st Generation \ /
_/\_/ \_/\_
What you have is a self-similar fractal.
GETTING STARTED
There are a number of fractals stored on disk. To get at them,
just hit Load, and double-click on a filename. It will plot automatically.
Hit the Menu button to return to the editing screen.
If you wish to edit the shape of a fractal seed, select one of
"Add", "Delete" or "Move" from the Edit menu, and manipulate the shape
with the mouse. TIP: Keep the fractal seed simple.
To draw a new fractal, select Draw in the Fractal menu.
For more control of the fractal, select Parameters in the Fractal
menu. See below for more info on Parameters.
================= The Menu options are explained below. ==================
PROJECT
Undo Remove changes since previous Draw.
New Initialize to simplest fractal - a straight line
Load Load fractal seed and colors from disk.
Save Save fractal seed to disk.
Save Pic Save picture in IFF file
Quit Quits program.
EDIT
Add Adds a point in the nearest line segment.
Move Moves the nearest point.
Delete Deletes nearest point.
FRACTAL
Draw Draws fractal using current parameters and options.
Parameters Displays current parameters, allows editing.
See below on Parameters
Detail Length of the shortest allowed line segment.
Make larger (5?) for faster drawing.
Depth Maximum amount of times to replace line segment
with copy. Max 500, less if program stack < 25000.
MORE COMMANDS
<F1> Flip screens
<F2> Detail
<F3> Depth
Arrow keys Push fractal seed around screen
<N> New Fractal
<ESC> Stop plotting
Menu Button Flip screens
<F> Draw Fractal
For ultimate power, you may edit the files in which it saves the
seed formulas with any plain ascii editor.
FEEDBACK
The screen title bar gives feedback information as follows:
Degrees1 Length1 Degrees2 Length2 PixelX PixelY
\/ \/ \/
Line to Left Line to Right Absolute Pixel Coordinates
Degrees is the change in heading relative to the line to the left.
(previous line)
Length is the length of the line in pixels.
Pixel is the absolute screen location, where y increases from top
to bottom.
PARAMETERS
RECURSION LEVELS means the following parameters are applied on
a level by level (generation) basis, where the first character
applies to the first generation, the second character applies
to the second generation... The parameters for the level are
used BEFORE the line segment parameters.
LINE SEGMENTS means the following parameters are applied to
the individual line segments of the seed shape. The first
character applies to the first line segment (starting from the
left), the second character applies to the second line segment...
REPEATING is applied to each string to make it long enough.
For example:
f = 'ffffffffffffffffffff...'
fr = 'frfrfrfrfrfrfrfrfrfr...'
vii = 'viiviiviiviiviiviivi...'
If invalid characters are present, it defaults to the first
character in the 'f/r' (or whatever) specification.
DIRECTION can be forward (f) or reverse (r). Reversing a shape
means to swap end for end.
It converts __/\ to /\__
FLIP can be either normal (n) or flipped (f). Flip means to
flip the shape along the axis formed by the endpoints of the shape.
It converts __/\ to __
\/
Flip and reverse can be combined, ergo
both flip and reverse convert __/\ to __
\/
VISIBLE can be visible (v), invisible (i), or mule (m).
It is applied to each segment of the shape numbered from left
to right (as the shape was created).
- Visible means that the line segment will propogate to the
next level, or show if it is the last one.
- Invisible means that the line segment will not show, or
propogate.
- Mule means that this line segment will show, but not
fractalize. (Mules are sterile.)
For instance, 'viv' converts __/\ to __ \
COLOR controls how often the color register is advanced.
For example, '001' would not increment the color on the first
2 levels of recursion, but would advance by 1 on the third level.
EXPERIMENT with each of these controls with depth set to 2 or 3,
a simple shape, varying one parameter at a time.
============================================================================
'Fractal Will Expand' requester - what it means.
Imagine a line drawn from one endpoint of your shape to the other. If any
one of the lines in your shape is bigger than this imaginary line,
the fractal will expand. The easiest way to fix this is to move your
shape endpoints farther apart, thereby making the component line segments
smaller in comparison.
If you decide to Try It, one of three things may happen.
1. The line drawing routine tries to draw into a far corner of the
Amiga's memory. Corners being what they are, there may be a moron
program there which is confounded by strange new opcodes. (Reader
Problem: Design a program (a la Core Wars) which can withstand the
onslaught of a line drawer gone wild.) The Amiga clips lines that
wander off the edge of the screen, IF they don't wander too far.
2. You wisely chose a small Depth, and made sure the line segments
are only marginally larger than the shape endpoint-to-endpoint
length. Some wild lines appear on your screen, but nothing blows
up.
3. Time is consumed at the following rate where:
lines_per_second = 650 on the Amiga 1000
Time = ((number_of_line_segments)^Depth)/lines_per_second
For example, the shape /\, which is two sides of an
equilateral triangle, if fractalized to a depth of 70,
would take roughly
(2^70)/650 seconds, or 58 billion years!
Not to knock the Amiga, but that's probably longer than the MTBF.
FOR HACKOIDS
You may also enter the seed shapes directly - here's how.
Select Load, and enter the Drawer "Con:0/0/200/50/input". It will
give you some "Drawer not Found"s, but hit OK anyhow. You have
just opened the console file on the workbench screen. Pull
down the FracGen screen part way, and the plotting screen too to
expose the "input" window on Workbench.
Now type commands in the "input" window just like they would appear
in a formula file. The two most useful commands are:
Point x y ; Line to this point.
Angle degrees length ; Turn in this direction, and
; draw a line this long.
; This is relative to your current
; heading, a la Turtle Graphics.
I would suggest a sequence like the following for the Koch Snowflake
Point 100 100 ;. ; define starting point
Angle 0 75 ; __ ; start pointing thisaway-->
Angle 60 75 ; __/
Angle -120 75 ; __/\
Angle 60 75 ; __/\__
Press <CTRL><\> (control and backslash) to terminate input.
Center the seed with the cursor keys.
CHANGING COLORS
There is a drawer named "Palettes", which contains just the color
information of a fractal seed. To try different colors in your picture,
simply load the appropriate color palette, and hit <F1> to flip screens
and see the effect. To create your own palette files, save a fractal
to that directory, then delete all but the color information with an
editor. (Crude, but effective.) Of course, the best way to change
the colors is with Doug's Color Commander, by Yours Truly, published by
Seven Seas Software. (and ought to be available by the time you read this.)
SAVING FRACTALS
Feel free to add your own beautiful fractals to this collection.
Before you save the fractal, select the Parameters window, and enter your
name and some notes about your particular fractal.
IMPLEMENTATION
This was coded in Lattice C, and hacked into Manx C, except for a
custom fixed point multiply in Assembly. I use the Motorola Fast
Floating Point library for all the shape manipulation, then do all
the fractal drawing with fixed point arithmetic, which cooks on
multiplication, and really flies on addition and conversion to integers.
Actually, the hardest part was the routine to find the nearest line
segment in Add point. It requires a rotation of axes before the distance
can be determined. If you have a large number of points (>10) you will
notice a slight delay as it cranks through all the calculations.
FracGen is sensitive to the default screen size, so it should work OK
on PAL screens, and MoreRows systems.
There are limitations imposed because of the granular resolution of
computer screens. For example, a diagonal line may not be exactly 50
units long, as it snaps to the nearest pixel coordinates. I could
have implemented virtual coordinates for the scientific community, but
that would have complicated onscreen editing, which is the key to being
user friendly. (If there is enough interest (read 'money') I may do a
virtual model.) A possible editing scenario is to select the line
segment/point with the mouse, bringing up a bank of slider gadgets, which
lets the user individually change the length/angle/color/direction/etc.
Got a better idea? Let me know.
REFERENCES
As usual, I refer you to Benoit B. Mandelbrot's book, The Fractal
Geometry of Nature, W. H. Freeman and Company, 1977. Look especially
around page 43(?), and at the Koch Snowflake, which inspired this
program. Also, there are numerous shapes spread throughout the book.
August 1987 Byte, Creating Fractals (p. 125) by William A. McWorter and
Jane Morrill Tazelaar. The program described has different capabilities
than FracGen, (I can't do a Hilbert curve), and the formulas are
different, but it should spark your imagination. It is clear that
they were pioneering.
KUDOS
If you derive excessive pleasure from this program, you may send
your appreciation and spare change to:
Doug Houck
922 West Uncas Road
Port Townsend, WA 98368
USA
If this program blows your power supply, crashes your hard disk, or
fails to perform to your expectations, you may send your bills and
criticisms to:
Bit Bucket
Track 81
Daisy Plains, IO 80286
Nomodemsland