Skip to content
Surf Wiki
Save to docs
geography/poland

From Surf Wiki (app.surf) — the open knowledge base

Sierpiński curve

Recursively defined sequence of continuous closed plane fractal curves


Recursively defined sequence of continuous closed plane fractal curves

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 \to \infty 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 \to \infty ) is 2 .

The Euclidean length of the nth iteration curve S_n is : \begin{aligned}l_n&= {2 \over 3} (1+\sqrt 2) 2^n - {1 \over 3} (2-\sqrt 2) {1 \over 2^n},\ &= \frac{2^{7/4}}{3} \sinh(n\log(2)+\mathrm{asinh}(\frac{3}{2^{5/4}}))\end{aligned}

i.e., it grows exponentially with n beyond any limit, whereas the limit for n \to \infty of the area enclosed by S_n is 5/12 , that of the square (in Euclidean metric).

Uses of the curve

The Sierpiński curve is useful in several practical applications because it is more symmetrical than other commonly studied space-filling curves. For example, it has been used as a basis for the rapid construction of an approximate solution to the Travelling Salesman Problem (which asks for the shortest sequence of a given set of points): The heuristic is simply to visit the points in the same sequence as they appear on the Sierpiński curve. To do this requires two steps: First compute an inverse image of each point to be visited; then sort the values. This idea has been used to build routing systems for commercial vehicles based only on Rolodex card files.

A space-filling curve is a continuous map of the unit interval onto a unit square and so a (pseudo) inverse maps the unit square to the unit interval. One way of constructing a pseudo-inverse is as follows. Let the lower-left corner (0, 0) of the unit square correspond to 0.0 (and 1.0). Then the upper-left corner (0, 1) must correspond to 0.25, the upper-right corner (1, 1) to 0.50, and the lower-right corner (1, 0) to 0.75. The inverse map of interior points are computed by taking advantage of the recursive structure of the curve.

Here is a function coded in Java that will compute the relative position of any point on the Sierpiński curve (that is, a pseudo-inverse value). It takes as input the coordinates of the point (x, y) to be inverted, and the corners of an enclosing right isosceles triangle (ax, ay), (bx, by), and (cx, cy). (The unit square is the union of two such triangles.) The remaining parameters specify the level of accuracy to which the inverse should be computed.

    static long sierp_pt2code(double ax, double ay, double bx, double by, double cx, double cy,
        int currentLevel, int maxLevel, long code, double x, double y) 
    {
        if (currentLevel <= maxLevel) {
            currentLevel++;
            if ((sqr(x-ax) + sqr(y-ay)) < (sqr(x-cx) + sqr(y-cy))) {
                code = sierp_pt2code( ax, ay, (ax+cx)/2.0, (ay+cy)/2.0, bx, by,
                    currentLevel, maxLevel, 2 * code + 0, x, y );
            }
            else {
                code = sierp_pt2code(bx, by, (ax+cx)/2.0, (ay+cy)/2.0, cx, cy,
                    currentLevel, maxLevel, 2 * code + 1, x, y);
            }
        }
        return code;    
    }

Representation as Lindenmayer system

The Sierpiński curve can be expressed by a rewrite system (L-system).

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

:**Angle**: 45 Here, both *F* and *G* mean "draw forward", + means "turn left 45°", and *&minus;* means "turn right 45°" (see turtle graphics). The curve is usually drawn with different lengths for F and G. The Sierpiński square curve can be similarly expressed: :**Alphabet**: F, X :**Constants**: F, +, &minus; :**Axiom**: F+XF+F+XF :**Production rules**: ::X &rarr; XF&minus;F+F&minus;XF+F+XF&minus;F+F&minus;X :**Angle**: 90 ## {{anchor|Sierpiński arrowhead curve|Sierpinski arrowhead curve}}Arrowhead curve The **Sierpiński arrowhead curve** is a fractal curve similar in appearance and identical in limit to the Sierpiński triangle. ::figure[src="https://upload.wikimedia.org/wikipedia/commons/a/ae/Arrowhead_curve_1_through_6.png" caption="Evolution of Sierpiński arrowhead curve"] :: The Sierpiński arrowhead curve draws an equilateral triangle with triangular holes at equal intervals. It can be described with two substituting production rules: (A → B-A-B) and (B → A+B+A). A and B recur and at the bottom do the same thing — draw a line. Plus and minus (+ and -) mean turn 60 degrees either left or right. The terminating point of the Sierpiński arrowhead curve is always the same provided you recur an even number of times and you halve the length of the line at each recursion. If you recur to an odd depth (order is odd) then you end up turned 60 degrees, at a different point in the triangle. An alternate construction is given in the article on the de Rham curve: one uses the same technique as the de Rham curves, but instead of using a binary (base-2) expansion, one uses a ternary (base-3) expansion. ### Code Given the drawing functions `void draw_line(double distance);` and `void turn(int angle_in_degrees);`, the code to draw an (approximate) Sierpiński arrowhead curve in [C++](c) looks like this: ::code[lang=cpp] void sierpinski_arrowhead_curve(unsigned order, double length) { // If order is even we can just draw the curve. if (0 == (order & 1)) { curve(order, length, +60); } else /* order is odd */ { turn(+60); curve(order, length, -60); } } :: ::code[lang=cpp] void curve(unsigned order, double length, int angle) { if (0 == order) { draw_line(length); } else { curve(order - 1, length / 2, -angle); turn(angle); curve(order - 1, length / 2, angle); turn(angle); curve(order - 1, length / 2, -angle); } } :: ### Representation as Lindenmayer system ::figure[src="https://upload.wikimedia.org/wikipedia/commons/3/3a/Sierpinski_arrowhead_3d_stage_5.png" caption="Like many two-dimensional fractal curves, the Sierpiński arrowhead curve can be extended to three dimensions"] :: The Sierpiński arrowhead curve can be expressed by a rewrite system (L-system). :**Alphabet**: X, Y :**Constants**: F, +, &minus; :**Axiom**: XF :**Production rules**: ::X &rarr; YF + XF + Y ::Y &rarr; XF &minus; YF &minus; X Here, *F* means "draw forward", + means "turn left 60°", and *&minus;* means "turn right 60°" (see turtle graphics). ## References ## References 1. Weisstein, Eric W.. "Sierpiński Curve". 2. Dickau, Robert M. (1996/7)"[http://mathforum.org/advanced/robertd/lsys2d.html Two-dimensional L-systems]", ''Robert's Math Figures''. MathForum.org. Retrieved 21 January 2019. 3. (1989). "Spacefilling curves and the planar traveling salesman problem". *Journal of the Association for Computing Machinery*. 4. Bartholdi, John J. III. ["Some combinatorial applications of spacefilling curves"](http://www.isye.gatech.edu/~jjb/mow/mow.html). *[[Georgia Institute of Technology]]*. ::callout[type=info title="Wikipedia Source"] This article was imported from [Wikipedia](https://en.wikipedia.org/wiki/Sierpiński_curve) and is available under the [Creative Commons Attribution-ShareAlike 4.0 License](https://creativecommons.org/licenses/by-sa/4.0/). Content has been adapted to SurfDoc format. Original contributors can be found on the [article history page](https://en.wikipedia.org/wiki/Sierpiński_curve?action=history). ::
Want to explore this topic further?

Ask Mako anything about Sierpiński curve — get instant answers, deeper analysis, and related topics.

Research with Mako

Free with your Surf account

Content sourced from Wikipedia, available under CC BY-SA 4.0.

This content may have been generated or modified by AI. CloudSurf Software LLC is not responsible for the accuracy, completeness, or reliability of AI-generated content. Always verify important information from primary sources.

Report