Sierpiński arrowhead curve

See Wikipedia.

Sierpiński curves are a recursively defined sequence of continuous closed plane fractal curves discovered by Wacław Sierpiński, which in the limit n completely fill the unit square: thus their limit curve, also called the Sierpiński curve, is an example of a space-filling curve. Because the Sierpiński curve is space-filling, its Hausdorff dimension (in the limit n is 2

The Euclidean length of the nth iteration curve Sn is

l n = 2 3 ( 1 + 2 ) 2 n - 1 3 ( 2 - 2 ) 1 2 n

i.e., it grows exponentially with n beyond any limit, whereas the limit for n of the area enclosed by Sn is 512 that of the square (in Euclidean metric).

This is the second line fractal I created using the production rules. I created a function that can be passed a formula to execute. See Rewriting and L-system.

The production rules for this curve is:

                Alphabet: F, G, X
                Constants: F, G, +, −
                Axiom: F−−XF−−F−−XF
                Production rules:
                    X → XF+G+XF−−F−−XF+G+X

                Angle: 45

Here, both F and G mean "draw forward", + means "turn left 45°", and − means "turn right 45°" (see turtle graphics). The curve is usually drawn with different lengths for F and G.