Fractal Art
The inimitable 3Blue1Brown does a far better job illustrating space filling curves than I ever could, take a look [youtube]. Just the first 15 seconds of the video is enough to get a sense of what a space filling curve is: a simple rule applied to a line segment that results in self-similar geometry that fills a 2D space (higher dimensions are possible too).
The pattern presented here is a Moore curve. It is one continuous line that snakes its way all over the space and returns to its starting point. The line slowly changes colour along its length, which creates the appearance of distinct regions when viewed from afar.
Keen-eyed readers may have noticed that this is also this website's icon!
The rules that create this pattern are very simple.
Alphabet: L, R
Constants: F, +, −
Axiom: LFL+F+LFL
Production rules:
L → −RF+LFL+FR−
R → +LF−RFR−FL+
These statements produce the instructions necessary to draw out a Moore curve.
-
The
Alphabetare placeholder values that will get replaced according to theProduction rules -
The
Constantsare the drawing instructions:Fmeans forward,+and-mean turn counterclockwise and clockwise 90 degrees, respectively.LandRare not mentioned here, so they are skipped when drawing. -
The
Axiomis the initial instruction. Again,LandRare skipped when drawing. - Every line segment has the same length!
Axiom and
choose up as the initial forward direction, this is what would
happen (remember: keep each line segment the same length)
- Pick any point on the paper as the starting point. The pen will not leave the paper for any instruction.
-
The first letter is
L, this has no drawing instruction associated with it so we don't move. -
The next letter is
F, so draw a line upward. -
Again an
L, don't move. -
Next is a
+, turn counterclockwise 90 degrees. Forward is now leftward. This is only a change in direction, nothing is drawn. -
Now another
F, since forward is leftward draw a line to the left. -
Another
+, turn counterclockwise 90 degrees. Forward is now downward. -
Finally an
F, since forward is now downward draw a line down.
Production rules to the
Axiom as many times as desired, and then follow
the resulting instructions. The production rules substitute the
non-drawing characters L and R with a
new set of characters that include drawing instructions as well
as more L and R, so the production
rules can be applied again and again for more complex outputs.
Applying the production rules once yields (parentheses added
for clarity):
Order 1: L F L +F+ L F L
Order 2: (−RF+LFL+FR−)F(−RF+LFL+FR−)+F+(−RF+LFL+FR−)F(−RF+LFL+FR−)
The poster above was produced with an order 7 Moore curve, so the above process would be repeated 5 more times.
Technical Notes
This work was produced using Python,
numpy and matplotlib were used
for generating the curve and plotting. The palette is
matplotlib's built-in "twilight" color map.