Fractals

Fractals are patterns that are generated by repeating themselves.


They are recursive:
They start with a simple rule that is replicated at every level of the fractal.
Fractals can be infinitely complex, yet created from a simple rule.

Sierpiński Triangle

The Sierpiński Triangle can be generated by following the rule that every triangle has a smaller triangle drawn on each of its sides.

At each level, triangles are drawn with half the side length of the triangles drawn at the previous level.


See the code that made this.

Another fractal that draws along the outline of the Sierpiński Triangle is the Sierpiński Arrowhead Curve

Sierpiński Arrowhead Curve

The Sierpiński Arrowhead Curve is created by a series of 60° turns. At each level, a line that would be drawn is replaced by 3 lines at 120° angles to each other. Although these 3 lines turn, they end where the line they replaced would have ended. Each level is drawn with lines half the length of the previous level's lines.


The curve can be drawn with 2 substitution rules:
A → B-A-B
B → A+B+A

A and B are functions that call each other recursively until the number of calls reaches the number of levels, at which point a line is drawn.
+ means "turn left 60°", and - means "turn right 60°".



The curve can be defined more formally with a rewrite system.


See the code that made this.

Pythagoras Tree

Level:

The Pythagoras Tree is a fractal created by squares. Each level of squares has 2 smaller squares on the following level with which it encloses a 45°-45°-90° triangle. It is because of these right triangles that the fractal was named after Pythagoras.

The rule to generate each new level is to take each square at the preceding level, scale down its side length by ½√2 and create 2 new squares of that smaller size at its top left and right corners that meet at a 90° angle.
Each level will then have 2 times as many squares as the previous level, and each level's squares will have side lengths that are ½√2 times the size of the previous level's.

See the code that made this.
Now consider a Pythagoras Tree where the lines that make up the squares of the tree are not lines, but replaced with other edges. These edges may curve, but they still end up at the same corners the square's lines would have ended.
I drew some for you.

Level:

The rules that generated these trees were exactly the same, except instead of squares building the tree, other shapes built the tree.


Another way to think of the tree is as an acyclic directed graph, where each square is a node with two child node squares that have side lengths of ½√2 its own side length.