Fractals. Koch curve Procedures for obtaining fractal sets

home / Love

Three copies of the Koch curve, constructed (with their points outward) on the sides of a regular triangle, form a closed curve of infinite length called Koch's snowflake.

This figure is one of the first fractals studied by scientists. It comes from three copies Koch curve, which first appeared in a paper by Swedish mathematician Helge von Koch in 1904. This curve was invented as an example of a continuous line that cannot be tangent to any point. Lines with this property were known before (Karl Weierstrass built his example back in 1872), but the Koch curve is remarkable for the simplicity of its design. It is no coincidence that his article is called “On a continuous curve without tangents, which arises from elementary geometry.”

The drawing and animation perfectly show how the Koch curve is constructed step by step. The first iteration is simply the initial segment. Then it is divided into three equal parts, the central one is completed to form a regular triangle and then thrown out. The result is the second iteration - a broken line consisting of four segments. The same operation is applied to each of them, and the fourth step of construction is obtained. Continuing in the same spirit, you can get more and more new lines (all of them will be broken lines). And what happens in the limit (this will already be an imaginary object) is called the Koch curve.

Basic properties of the Koch curve

1. It is continuous, but nowhere differentiable. Roughly speaking, this is exactly why it was invented - as an example of this kind of mathematical “freaks”.

2. Has infinite length. Let the length of the original segment be equal to 1. At each construction step, we replace each of the segments that make up the line with a broken line, which is 4/3 times longer. This means that the length of the entire broken line is multiplied by 4/3 at each step: the length of the line with number n equal to (4/3) n-1 . Therefore, the limit line has no choice but to be infinitely long.

3. Koch's snowflake limits the finite area. And this despite the fact that its perimeter is infinite. This property may seem paradoxical, but it is obvious - a snowflake fits completely into a circle, so its area is obviously limited. The area can be calculated, and you don’t even need special knowledge for this - formulas for the area of ​​a triangle and the sum of a geometric progression are taught in school. For those interested, the calculation is listed below in fine print.

Let the side of the original regular triangle be equal to a. Then its area is . First the side is 1 and the area is: . What happens as the iteration increases? We can assume that small equilateral triangles are attached to an existing polygon. The first time there are only 3 of them, and each next time there are 4 times more of them than the previous one. That is, on n the th step will be completed Tn= 3 4 n-1 triangles. The length of the side of each of them is one third of the side of the triangle completed in the previous step. So it is equal to (1/3) n. Areas are proportional to the squares of the sides, so the area of ​​each triangle is . For large values n By the way, this is very little. The total contribution of these triangles to the area of ​​the snowflake is Tn · S n= 3/4 · (4/9) n · S 0 . Therefore after n-step, the area of ​​the figure will be equal to the sum S 0 + T 1 · S 1 + T 2 · S 2 + ... +Tn S n = . A snowflake is obtained after an infinite number of steps, which corresponds to n→ ∞. The result is an infinite sum, but this is the sum of a decreasing geometric progression; there is a formula for it: . The area of ​​the snowflake is .

4. Fractal dimension is equal to log4/log3 = log 3 4 ≈ 1.261859... . Accurate calculation will require considerable effort and detailed explanations, so here is rather an illustration of the definition of fractal dimension. From the power law formula N(δ ) ~ (1/δ )D, Where N- number of intersecting squares, δ - their size, and D is the dimension, we get that D= log 1/ δ N. This equality is true up to the addition of a constant (the same for all δ ). The figures show the fifth iteration of constructing the Koch curve; the grid squares that intersect with it are shaded green. The length of the original segment is 1, so in the upper figure the side length of the squares is 1/9. 12 squares are shaded, log 9 12 ≈ 1.130929... . Not very similar to 1.261859 yet... . Let's look further. In the middle picture, the squares are half the size, their size is 1/18, shaded 30. log 18 30 ≈ 1.176733... . Already better. Below, the squares are still half as large; 72 pieces have already been painted over. log 72 30 ≈ 1.193426... . Even closer. Then you need to increase the iteration number and at the same time decrease the squares, then the “empirical” value of the dimension of the Koch curve will steadily approach log 3 4, and in the limit it will completely coincide.

Options

The Koch snowflake “on the contrary” is obtained if we construct Koch curves inside the original equilateral triangle.

Cesaro lines. Instead of equilateral triangles, isosceles triangles with a base angle from 60° to 90° are used. In the figure, the angle is 88°.

Square option. Here the squares are completed.





Snowflake Koch

canvas(
border: 1px dashed black;
}

var cos = 0.5,
sin = Math.sqrt(3) / 2,
deg = Math.PI / 180;
canv, ctx;

function rebro(n, len) (
ctx.save(); // Save the current transformation
if (n == 0) ( // Non-recursive case - draw a line
ctx.lineTo(len, 0);
}
else(
ctx.scale(1 / 3, 1 / 3); // Zoom out by 3 times
rebro(n-1, len); //RECUURSION on edge
ctx.rotate(60 * deg);
rebro(n-1, len);
ctx.rotate(-120 * deg);
rebro(n-1, len);
ctx.rotate(60 * deg);
rebro(n-1, len);
}
ctx.restore(); // Restore the transformation
ctx.translate(len, 0); // go to the end of the edge
}

function drawKochSnowflake(x, y, len, n) (
x = x - len / 2;
y = y + len / 2 * Math.sqrt(3)/3;
ctx.save();
ctx.beginPath();
ctx.translate(x, y);
ctx.moveTo(0, 0);
rebro(n, len); ctx.rotate(-120 * deg); //RECUUUURSION is already a triangle
rebro(n, len); ctx.rotate(-120 * deg);
rebro(n, len); ctx.closePath();
ctx.strokeStyle = "#000";
ctx.stroke();
ctx.restore();
}

function clearcanvas())( //clear the canvas
ctx.save();
ctx.beginPath();

// Use the identity matrix while clearing the canvas
ctx.setTransform(1, 0, 0, 1, 0, 0);
ctx.clearRect(0, 0, canvas1.width, canvas1.height);

// Restore the transform
ctx.restore();
}

function run() (
canv = document.getElementById("canvas1");
ctx = canv.getContext("2d");
var numberiter = document.getElementById("qty").value;
drawKochSnowflake(canv.width/2, canv.height/2, 380, numberiter);

Ctx.stroke(); //rendering
}




Koch's snowflake - example









It was an unusually warm winter in Boston, but we still waited for the first snowfall. Watching the snow fall through the window, I thought about snowflakes and how their structure is not at all easy to describe mathematically. There is however one special kind of snowflake, known as the Koch snowflake, which can be described relatively simply. Today we'll look at how its shape can be built using the COMSOL Multiphysics Application Builder.

The Making of Koch's Snowflake

As we already mentioned in our blog, fractals can be used in . Snowflake Koch is a fractal, which is notable in that there is a very simple iterative process to construct it:

  • Let's start with an equilateral triangle, which is actually the zeroth iteration of the Koch snowflake.
  • Let's find the center point on each edge of the current snowflake.
  • In the center of each edge, add an equilateral triangle protruding outwards with a side equal to 1/3 of the length of the current edge.
  • Let's define the next iteration of the Koch snowflake to be on the outside of the previous snowflake and all the added triangles.
  • Repeat steps 2-4 as many times as necessary.
  • This procedure is illustrated in the figure below for the first four iterations of drawing a snowflake.

    The first four iterations of the Koch snowflake. Image by Wxs - Own work. Licensed under CC BY-SA 3.0, via Wikimedia Commons.

    Construction of the Koch snowflake geometry

    Since we now know which algorithm to use, let's look at how to create such a structure using the COMSOL Multiphysics Application Builder. We'll open a new file and create a 2D object geometry part at the node Global definitions. For this object, we will set five input parameters: the length of the side of an equilateral triangle; X- And y– coordinates of the midpoint of the base; and components of the normal vector directed from the middle of the base to the opposite vertex, as shown in the figures below.


    Five parameters used to set the size, position, and orientation of an equilateral triangle.


    Setting the input parameters of the geometric part.
    A polygon primitive is used to construct an equilateral triangle.


    The object can rotate around the center of the bottom edge.


    An object can be moved relative to the origin.

    Now that we have defined the geometric part, we use it once in the section Geometry. This single triangle is equivalent to the zeroth iteration of the Koch snowflake, and now let's use the Application Builder to create more complex snowflakes.

    App UI Markup in the Application Builder

    The application has a very simple user interface. It contains only two components that the user can interact with: Slider (Slider)(marked as 1 in the figure below), with which you can set the number of iterations needed to create a snowflake, and Button(label 2), by clicking which the resulting geometry is created and displayed. There are also Text inscription(label 3) and Display (Display) of data(label 4), which show the number of specified iterations, as well as the window Charts(label 5), which displays the final geometry.


    The application has one single form with five components.

    The application has two Definitions, one of which defines an integer value called Iterations, which defaults to zero but can be changed by the user. A 1D array of doubles called Center is also defined. The single element in the array has a value of 0.5, which is used to find the center point of each edge. This value never changes.


    Settings for two Definitions.

    The Slider component in the UI controls the value of the integer, Iterations parameter. The screenshot below shows the settings for the "Slider" and the values, which are set as integers in the range between 0 and 5. The same source (as for the slider) is also selected for the component Data Display to display the number of specified iterations on the application screen. We limit the potential user to five iterations because the algorithm used is suboptimal and not very efficient, but is simple enough to implement and demonstrate.


    Settings for the "Slider" component.

    Next, let's look at the settings for our button, shown in the screenshot below. When the button is pressed, two commands are executed. First, the CreateSnowFlake method is called. The resulting geometry is then displayed in the graphics window.


    Button settings.

    We have now looked at the user interface of our application and we can see that the creation of any snowflake geometry must happen through a method called. Let's look at the code for this method, with line numbering added to the left and string constants highlighted in red:

    1 model.geom("geom1" ).feature().clear(); 2 model.geom("geom1" ).create("pi1" , "PartInstance" ); 3 model.geom("geom1" ).run("fin" ); 4 for (int iter = 1; iter "geom1" ).getNEdges()+1; 6 UnionList = "pi" + iter; 7 for (int edge = 1; edge "geom1" ).getNEdges(); edge++) ( 8 String newPartInstance = "pi" + iter + edge; 9 model.geom("geom1" ).create(newPartInstance, "PartInstance" ).set("part" , "part1" ); 10 with(model. geom("geom1" ).feature(newPartInstance)); 11 setEntry("inputexpr" , "Length" , toString(Math.pow(1.0/3.0, iter))); 12 setEntry("inputexpr" , "px" , model.geom("geom1" ).edgeX(edge, Center)); 13 setEntry("inputexpr" , "py" , model.geom("geom1" ).edgeX(edge, Center)); 14 setEntry("inputexpr " , "nx" , model.geom("geom1" ).edgeNormal(edge, Center)); 15 setEntry("inputexpr" , "ny" , model.geom("geom1" ).edgeNormal(edge, Center)) ; 16 endwith(); 17 UnionList = newPartInstance; 18 ) 19 model.geom("geom1" ).create("pi" +(iter+1), "Union" ).selection("input" ).set(UnionList ); 20 model.geom("geom1" ).feature("pi" +(iter+1)).set("intbnd" , "off" ); 21 model.geom("geom1" ).run("fin" ); 22)

    Let's go through the code line by line to understand what function each line performs:

  • Clearing all existing geometric sequences so we can start from scratch.
  • We create one instance of the object - our "triangle", using the default size, orientation and location. This is our zeroth order snowflake with identifier label pi1.
  • Let's finalize the geometry. This operation is required to update all geometry indexes.
  • Let's begin the process of iterating through all given iterations of the snowflake, using the Iterations definition as a stopping condition.
  • We define an empty array of strings, UnionList. Each element of the array contains an identifier of various geometric objects. The length of this array is equal to the number of edges in the last iteration plus one.
  • We define the first element in the UnionList array. It is an identifier of the result of the previous iteration. Keep in mind that iteration zero has already been created in lines 1-3. The integer value iter is automatically converted to a string and appended to the end of the string "pi" .
  • We go through the number of edges in the previously generated snowflake.
  • We set an identifier label for a new instance of an object accessing from the “triangle” part instance that is created on this edge. Note that the integer values ​​iter and edge are sequentially added to the end of the string pi , the object instance's identifier label.
  • We create an instance of the "triangle" object and assign it the identifier label that was just specified.
  • We indicate that lines 11-15 refer to the current instance of the object (part instance) using the with()/endwith() statement.
  • Determine the length of the side of the triangle. The zeroth order has a side length of one, so the nth iteration has a side length of (1/3)n. The toString() function is required to cast (convert) data types - a floating point number to a string.
  • We set x-coordinate of the new triangle, as the center point of the side of the last iteration. The edgeX method is documented in . Recall that Center is set to 0.5.
  • We set y-coordinate.
  • We set x-component of the normal vector of the triangle. The edgeNormal method is also documented in COMSOL Programming Reference Manual.
  • We set y-component of the normal vector.
  • We close the with()/endwith() statement.
  • Add a label-identifier of the current triangle to the list of all objects.
  • We close the search of all edges.
  • We create a Boolean Union (logical union) of all objects into a geometric sequence. We assign a new value pi to the label N, where N is the number next iterations. Parentheses are required around (iter+1) so that the incremented iter value is converted to a string.
  • We indicate that the internal boundaries of the final object are not preserved.
  • Let's finalize the geometry. The last operation updates all geometry indexes for the next iteration of the snowflake.
  • We close the cycle of iterations of creating a snowflake.
  • Thus, we have covered all aspects and elements of our application. Let's look at the results!


    Our simple application for constructing the Koch snowflake.

    We could extend our application to write geometry to a file, or even perform additional analyzes directly. For example, we could design a fractal antenna. If you are interested in the design of the antenna, check out our example, or even make its layout from scratch.

    Try it yourself

    If you want to build this application yourself, but have not yet completed the Application Builder, you may find the following resources helpful:

    • Download the guide Introduction to the Application Development Environment in English
    • Watch these videos and learn how to use
    • Read these topics to become familiar with how simulation applications are used in

    Once you've covered this material, you'll see how the app's functionality can be expanded to resize a snowflake, export created geometry, estimate area and perimeter, and much more.

    What kind of application would you like to create in COMSOL Multiphysics? for help.

    The fractal snowflake, one of the most famous and mysterious geometric objects, was described by Helga von Koch at the beginning of our century. According to tradition, in our literature it is called Koch’s snowflake. This is a very “spiky” geometric figure, which can be metaphorically seen as the result of the Star of David being repeatedly “multiplied” by itself. Its six main rays are covered with an infinite number of large and small “needles” vertices. Every microscopic fragment of a snowflake’s contour is like two peas in a pod, and the large beam, in turn, contains an infinite number of the same microscopic fragments.

    At an international symposium on the methodology of mathematical modeling in Varna back in 1994, I came across the work of Bulgarian authors who described their experience of using Koch’s snowflakes and other similar objects in high school lessons to illustrate the problem of the divisibility of space and the philosophical aporias of Zeno. In addition, from an educational point of view, in my opinion, the very principle of constructing regular fractal geometric structures is very interesting - the principle of recursive multiplication of the basic element. It’s not for nothing that nature “loves” fractal forms. This is explained precisely by the fact that they are obtained by simple reproduction and changing the size of a certain elementary building block. As you know, nature does not overflow with a variety of reasons and, where possible, makes do with the simplest algorithmic solutions. Look closely at the contours of the leaves, and in many cases you will find a clear relationship with the shape of the contour of a Koch snowflake.

    Visualization of fractal geometric structures is possible only with the help of a computer. It is already very difficult to construct a Koch snowflake above the third order manually, but you really want to look into infinity! Therefore, why not try to develop an appropriate computer program. In RuNet you can find recommendations for building a Koch snowflake from triangles. The result of this algorithm looks like a jumble of intersecting lines. It is more interesting to combine this figure from “pieces”. The contour of a Koch snowflake consists of equal-length segments inclined at 0°, 60°, and 120° with respect to the horizontal x-axis. If we denote them 1, 2 and 3 respectively, then a snowflake of any order will consist of successive triplets - 1, 2, 3, 1, 2, 3, 1, 2, 3... etc. Each of these three types of segments can be attached to the previous one at one or the other end. Taking this circumstance into account, we can assume that the contour of a snowflake consists of segments of six types. Let's denote them 0, 1, 2, 3, 4, 5. Thus, we get the opportunity to encode a contour of any order using 6 digits (see figure).

    A higher-order snowflake is obtained from a lower-order predecessor by replacing each edge with four, connected like folded palms (_/\_). Edge type 0 is replaced by four edges 0, 5, 1, 0 and so on according to the table:

    0 0 1 5 0
    1 1 2 0 1
    2 2 3 1 2
    3 3 4 2 3
    4 4 5 3 4
    5 5 0 4 5

    A simple equilateral triangle can be thought of as a zero-order Koch snowflake. In the described encoding system, it corresponds to the entry 0, 4, 2. Everything else can be obtained by the described replacements. I will not provide the procedure code here and thereby deprive you of the pleasure of developing your own program. When writing it, it is not at all necessary to use an explicit recursive call. It can be replaced with a regular cycle. In the process of work, you will have another reason to think about recursion and its role in the formation of quasi-fractal forms of the world around us, and at the end of the path (if, of course, you are not too lazy to go through it to the end) you will be able to admire the complex pattern of the contours of a fractal snowflake, and also look finally in the face of infinity.

    Topic: Fractals.

    1. Introduction. Brief historical background on fractals. 2. Fractals are elements of geometry in nature.

    3. Objects with fractal properties in nature. 4. Definition of the terminology “fractals”.

    5.Classes of fractals.

    6.Description of fractal processes. 7.Procedures for obtaining fractal sets.

    8.1 Broken Kokha (obtaining procedure).

    8.2 Koch Snowflake (Koch Fractal).

    8.3 Menger sponges.

    9. Examples of using fractals.

    Introduction. Brief historical background on fractals.

    Fractals are a young branch of discrete mathematics.

    In 1904, the Swede Koch came up with a continuous curve that has no tangent anywhere - the Koch curve.

    In 1918, the Frenchman Julia described a whole family of fractals.

    In 1938, Pierre Levy published the article “Plane and spatial curves and surfaces consisting of parts similar to the whole.”

    In 1982, Benoit Mandelbrot published the book “The Fractal Geometry of Nature.”

    Using simple constructions and formulas, images are created. “Fractal painting” appeared.

    Since 1993, World Scientific has published the journal “Fractals”.

    Fractals are elements of geometry in nature.

    Fractals are a means for describing objects such as models of mountain ranges, rugged coastlines, circulatory systems of many capillaries and vessels, tree crowns, cascading waterfalls, frosty patterns on glass.

    Or these: fern leaf, clouds, blot.

    Images of such objects can be represented using fractal graphics.

    Objects with fractal properties in nature.

    CoralsStarfish and UrchinsSea Shells

    Flowers and plants (broccoli, cabbage) Fruits (pineapple)

    Crowns of trees and leaves of plants Circulatory system and bronchi of people and animals In inanimate nature:

    Borders of geographical objects (countries, regions, cities) Coastlines Mountain ranges Snowflakes Clouds Lightning

    Patterns formed on glass Crystals Stalactites, stalagmites, helictites.

    Definition of terminology "fractals".

    Fractals are geometric shapes that satisfy one or more of the following properties:

    It has a complex non-trivial structure at any magnification (on all scales); It is (approximately) self-similar.

    It has a fractional Hausdorff (fractal) dimension or exceeds the topological one; Can be constructed by recursive procedures.

    For regular figures such as a circle, ellipse, or the graph of a smooth function, a small fragment on a very large scale is similar to a fragment of a straight line. For a fractal, increasing the scale does not lead to a simplification of the structure; for all scales we will see equally complex pictures.

    Fractal classes

    A fractal is a structure consisting of parts (substructures) similar to the whole.

    Some fractals, as elements of nature, can be classified as geometric (constructive) fractals.

    The rest can be classified as dynamic fractals (algebraic).

    Procedures for obtaining fractal sets.

    This is a simple recursive procedure for obtaining fractal curves: specify an arbitrary broken line with a finite number of links - a generator. Next, each segment of the generator is replaced in it. Then each segment in it is again replaced by a generator, and so on ad infinitum.

    Shown: division of a unit segment into 3 parts (a), a unit square area into 9 parts (b), a unit cube into 27 parts (c) and 64 parts (d). The number of parts is n, the scaling factor is k, and the dimension of space is d. We have the following relations: n = kd,

    if n = 3, k = 3, then d = 1; if n = 9, k = 3, then d = 2; if n = 27, k = 3, then d = 3.

    if n = 4, k = 4, then d = 1; if n = 16, k = 4, then d = 2; if n = 64, k = 4, then d = 3. The dimension of space is expressed in integers: d = 1, 2, 3; for n = 64, the value of d is

    Five steps of constructing a Koch polyline are shown: a segment of unit length (a), divided into three parts (k = 3), from four parts (n = 4) - a broken line (b); each straight segment is divided into three parts (k2 = 9) and of 16 parts (n2 = 16) - a broken line (c); the procedure is repeated for k3 = 27 and n3 = 64 – broken line (g); for k5 = 243 and n5 = 1024 – broken line (d).

    Dimension

    This is a fractional or fractal dimension.

    The Koch polyline, proposed by Helg von Koch in 1904, acts as a fractal that is suitable for modeling the ruggedness of a coastline. Mandelbrot introduced an element of randomness into the coastline construction algorithm, which, however, did not affect the main conclusion regarding the length of the coastline. Because the limit

    The length of the coastline tends to infinity due to the endless ruggedness of the coast.

    The procedure for smoothing the coastline when moving from a more detailed scale to a less detailed one, i.e.

    Koch snowflake (Koch fractal)

    As a basis for construction, you can take not segments of unit length, but an equilateral triangle, to each side of which you can extend the procedure of multiplying the irregularities. In this case, we get a Koch snowflake (Fig.), and of three types: the newly formed triangles are directed only outward from the previous triangle (a) and (b); only inside (in); randomly either outward or inward (d) and (e). How can you set the procedure for constructing a Koch fractal.

    Rice. Snowflake Koch

    In Fig. two vector diagrams are shown; The numbers above the arrows will probably raise the question: what do they mean? Vector 0 coincides with the positive direction of the abscissa axis, since its phase factor exp (i2πl/6) at l = 0 retains its direction. Vector 1 is rotated relative to vector 0 by an angle of 2π/6, when l= 1. Vector 5 has a phase factor exp (i2π5/6), l = 5. The last vector has the same phase factor as the first (l = 0). Integers l characterize the angle of the phase factor of the unit vector.

    The first step (Fig.) specifies a recursive procedure for all subsequent steps and, in particular, for the second step (Fig.). How to go from a set of numbers φ1 = (0 1 5 0) to φ2 = (0 1 5 0 1 2 0 1 5 0 4 5 0 1 5 0)? Answer: through direct matrix multiplication, when each element of one matrix is ​​multiplied by the original matrix. Since in this case we are dealing with a one-dimensional array, i.e. Since matrices are vectors, each element of one matrix-vector is multiplied by all elements of another matrix-vector. In addition, the elements of the matrix-vector φ1 consist of exponential functions exp (i2πl/6), therefore, 10 when multiplying the number h it will be necessary to add according to mod (6), and not multiply.

      The geometric shape of the Koch snowflake looks like this

      How to draw a Koch snowflake

      And there is also the Koch pyramid

      You can find out in more detail how to draw a Koch snowflake from the video below. Someone may understand, I gave up.

      First, let's look at this Koch snowflake. The diagram below will best show us.

      That is, to draw a given snowflake, you need to use individual geometric shapes, which make up this geometric fractal.

      The basis of our drawing is an equilateral triangle. Each side is divided into three segments, from which the next, smaller, equilateral triangles are built. The same operation is performed with the resulting triangles several times.

      Koch's snowflake is one of the first fractals studied by scientists. A snowflake is obtained from three copies of the Koch curve, information about this discovery appeared in 1904 in an article by the Swedish mathematician Helge von Koch. Essentially, a curve was invented as an example of a continuous line to which a tangent line cannot be drawn at any point. The Koch curve is simple in its design.

      An example, a photo-drawing of a picture of a Koch snowflake with step-by-step drawing.

      In this diagram you can examine in detail the lines that will later make a Koch snowflake.

      And this is an interpretation of a new snowflake based on Koch’s snowflake.

      Before you understand how to draw a Koch snowflake, you need to determine what it is.

      So, a Koch snowflake is a geometric image - a fractal.

      The full definition of Koch's snowflake is given in the picture below.

    © 2024 skudelnica.ru -- Love, betrayal, psychology, divorce, feelings, quarrels