You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: contents/IFS/IFS.md
+43-29
Original file line number
Diff line number
Diff line change
@@ -6,24 +6,24 @@ A few quick notes before we start:
6
6
That is to say that the code presented in this chapter will output another file that can be easily plotted by an external plotter.
7
7
If you like to use a plotter provided by your language of choice, please modify the code provided to do so.
8
8
9
-
2. This chapter is currently a subsection to the plotting chapter, but we may extend the algorithm archive in the future with other fractal generation methods, which would require created a new section on fractals, in particular.
9
+
2. This chapter is currently a subsection to the plotting chapter, but we may extend the algorithm archive in the future with other fractal generation methods, which would require creating a new section on fractals, in particular.
10
10
This would include a chapter with more rigorous definitions on fractals, which is largely missing from the following discussion.
11
11
Please let us know if you are interested!
12
12
13
-
In this chapter, we will show you how to make one of the most famous fractalsvia Iterated Function Systems (IFSs): the Sierpinski triangle.
13
+
In this chapter, we will show you how to make one of the most famous fractals, the Sierpinski triangle, via Iterated Function Systems (IFSs).
14
14
We will also introduce a number of interesting concepts for further exploration, such as chaos games, Hutchinson operators, and attractors.
15
15
16
16
## The Sierpinski Triangle
17
17
18
-
To begin the discussion of Iterated Function Systems (IFSs), we will first discuss what might be one of the most famous fractals currently known, the Sierpinski triangle, shown below:
18
+
To begin the discussion of Iterated Function Systems (IFSs), we will first discuss what might be one of the most famous fractals currently known: the Sierpinski triangle (shown below):
This image is clearly a set of triangles embedded in a larger triangle in such a way that it can be continually cut into three identical pieces and still retain its internal structure.
23
-
This idea is known as self-similarity {{"self-similar" | cite }}, and it is usually the first aspect of fractals that will catch an audience's attention.
23
+
This idea is known as self-similarity {{"self-similar" | cite }}, and it is usually the first aspect of fractals to catch an audience's attention.
24
24
In fact, there are plenty of uses of fractals and their mathematical underpinnings, such as estimating the coastline of Britain {{ "mandelbrot1967long" | cite}}, identifying fingerprints {{ "jampour2010new" | cite }}, and image compression {{ "fractal-compression" | cite }}{{ "saupe1994review" | cite }}.
25
25
In many more rigorous definitions, a fractal can be described as any system that has a non-integer Hausdorff dimension {{ "3b1bfractal" | cite }}{{ "hausdorff" | cite }}{{ "gneiting2012estimators" | cite }}.
26
-
Though this is an incredibly interesting concept, the discussion of this chapter will focus primarily on methods to generate fractal patterns and will refrain from delving into this discussion for now and instead focus on the methods by which fractals can be generated through IFSs.
26
+
Though this is an incredibly interesting concept, the discussion of this chapter will instead focus on methods to generate fractal patterns through iterated function systems.
27
27
28
28
To start, imagine creating a triangle from three points, $$A$$, $$B$$, and $$C$$.
29
29
These points can be arbitrarily chosen, but for this conversation, we will constrict them to the vertices of an equilateral triangle, as shown below:
@@ -40,7 +40,7 @@ f_3(P) &= \frac{P + C}{2}\\
40
40
\end{align}
41
41
$$
42
42
43
-
Each function will input a particular location in space (here, $$P \in \mathbb{R}^2$$) and output a new location that is the midpoint between the input location and $$A$$, $$B$$, or $$C$$ for functions 1, 2, and 3 respectively.
43
+
Each function will read in a particular location in space (here, $$P \in \mathbb{R}^2$$) and output a new location that is the midpoint between the input location and $$A$$, $$B$$, or $$C$$ for $$f_1$$, $$f_2$$, and $$f_3$$ respectively.
44
44
The union of all of these functions (the set of all possible functions available for use) is often notated as the _Hutchinson operator_ {{ "hutchinson-operator" | cite }}{{ "hutchinson1981fractals" | cite}}, and for this case it would look like this:
45
45
46
46
$$
@@ -63,7 +63,7 @@ From here, each new point ($$D$$, $$E$$, and $$F$$) will spawn 3 children, and e
63
63
</div>
64
64
65
65
Here, all red children come from $$D$$, green children come from $$E$$ and blue children come from $$F$$.
66
-
From here, the children will then spawn 3 more children, each of which will move according to a different function.
66
+
At this stage, the children will then spawn 3 more children, each of which will move according to a different function.
67
67
Those children will then spawn more children, who act accordingly.
68
68
As this process continues on and on, we begin to see an interesting pattern form:
69
69
@@ -77,11 +77,11 @@ As this process continues on and on, we begin to see an interesting pattern form
77
77
This is the Sierpinski triangle.
78
78
At first, it might seem like mathematical magic that a simple set of 3 functions can create such a pattern.
79
79
After all, why aren't any of the children migrating to the empty spaces in the structure?
80
-
This will require some thought, but the simplest answer is that no function within the Hutchinson operator allows for children to enter those spaces.
80
+
This will require some thought, but the simplest answer is that no function within the Hutchinson operator allows for children to enter those spaces; therefore, none of the children can enter them.
81
81
82
82
## What about a square?
83
83
84
-
When I learned about this for the first time, I began to wonder about other shapes.
84
+
When I learned about how the Sierpinski triangle could be generated from 3 simple functions, I began to wonder about other shapes.
85
85
Could we create fractal squares? Hexagons? Circles?
86
86
Such shapes _seem_ like natural extensions to the triangular Hutchinson operator provided above, but there's a bit of a hitch...
87
87
@@ -109,20 +109,24 @@ If we then create 5 initial points located between all the vertices and allow th
109
109
</video>
110
110
</div>
111
111
112
-
Well, this is essentially a square of squares.
112
+
We essentially see a square of squares.
113
113
What happened to the self-similar structure we were getting before?
114
114
Why isn't this more interesting?
115
115
116
116
The best answer I have for now is that some Hutchinson operators are interesting and some are not.
117
-
On the other hand, this square is a bit more interesting than it first appears, but I think this is easiest to understand when we use the Hutchinson operator in a slightly different way.
117
+
Still, this square is a bit more interesting than it first appears, but to see why, we need to use the Hutchinson operator in a slightly different way.
118
118
119
119
## Chaos games and attractors
120
120
121
-
Until now, we have been using the Hutchinson operator in a computationally costly way.
121
+
Until now, our visualizations for both the Sierpinski triangle and the square have been computationally costly.
122
122
Every iteration, we generate 3 or 4 new children per child per step of the simulation.
123
123
This scales exponentially and means that we will quickly have millions of children to keep track of!
124
+
In fact, to deal with this, we developed our own method of counting through the tree to more efficiently keep track of everything, but that is a story for another day.
124
125
125
-
A much more computationally feasible method to use the Hutchinson operator comes in the form of the _chaos game_ {{ "chaos-game" | cite }}{{ "chaos-game-wolf" | cite }}.
126
+
The question for now is whether there is a more computationally feasible way of iterating through our Hutchinson operator.
127
+
128
+
As it turns out, there is!
129
+
Rather than keeping track of every possible movement within the Hutchinson operator to draw out a shape, it's actually possible to randomly sample the function set instead through a process known as a _chaos game_ {{ "chaos-game" | cite }}{{ "chaos-game-wolf" | cite }}..
126
130
Here, instead of tracking children of children, we track a single individual that chooses randomly between the Hutchinson functions, as shown here:
127
131
128
132
{% method %}
@@ -138,7 +142,7 @@ Here, instead of tracking children of children, we track a single individual tha
If we set the initial points to the on the equilateral triangle we saw before, we can see the Sierpinski triangle again after a few thousand iterations, as shown below:
145
+
If we set the initial point to the on the equilateral triangle we saw before, we can see the Sierpinski triangle again after a few thousand iterations, as shown below:
142
146
143
147
<divstyle="text-align:center">
144
148
<videostyle="width:100%"controls>
@@ -147,13 +151,14 @@ If we set the initial points to the on the equilateral triangle we saw before, w
147
151
</video>
148
152
</div>
149
153
150
-
That said, there is something peculiar about the way the chaos game starts.
151
-
Essentially, our lone child begins their journey at a random location.
152
-
What if that location is off the triangle?
153
-
Well, let's test that!
154
+
Here, we are plotting 200,000 point locations in sets of 1000, and every set becomes successively more blue as the visualization continues.
155
+
At first glance, this visualization seems bewildering.
156
+
After all, it appears as if the entire triangle just magically comes into view in a few seconds.
157
+
The important thing to remember here is that each of these 200,000 dots is another location that our initial point decided to visit.
154
158
155
-
If we start the point at the center of the triangle, it will eventually find its way onto the triangle, and then all subsequent iterations will be on the fractal.
156
-
Here, I have plotted the first 20 steps where the wanderer is still looking for the correct shape:
159
+
That said, there is something peculiar about the way the chaos game starts.
160
+
We are actually allowed to start the simulation *off* of the Sierpinski triangle.
161
+
As we mentioned earlier, none of the functions for the Sierpinski visualization allow children to enter the empty spaces of the triangle, so let's see what happens if we start the point off at the center of the triangle:
157
162
158
163
<divstyle="text-align:center">
159
164
<videostyle="width:100%"controls>
@@ -162,17 +167,26 @@ Here, I have plotted the first 20 steps where the wanderer is still looking for
162
167
</video>
163
168
</div>
164
169
165
-
It would seem that the wanderer is _attracted_ to the Sierpinski triangle with this set of functions.
166
-
That is actually the case.
167
-
The truth is that the word _attractor_ is a very loaded term in the literature, but for the purposes of our discussion here, the _attractor_ is any shape defined by the iteration through Hutchinson operator functions.
170
+
Here, I have plotted the first 20 steps of the chaos game, and it is clear that the point gets closer and closer to the triangle each iteration.
171
+
Once it lands on the triangle, it can no longer escape and every movement from then on will be on the triangle.
172
+
173
+
In a sense, the wanderin point is _attracted_ to the Sierpinski triangle with this set of functions, and that is actually the case!
174
+
The truth is that the word _attractor_ is a very loaded term in the literature, but for the purposes of our discussion here, an _attractor_ is any shape defined by the iteration through Hutchinson operator functions.
168
175
169
-
So let's go back to the square, which seemed like a somewhat random distribution of points:
176
+
So let's go back to the example with the 4 points along the square and generate the attractor via a chaos game instead of going through every branch of the Hutchinson operator.
177
+
If we do this, we get what seems to be a random distribution of points:
Even with the chaos game, this will not change; however, we now know that the random distribution isn't truly random.
174
-
Rather, it's an attractive plane where our lone wanderer can exist happily within.
175
-
That is to say, the 2-dimensional square is, itself, the attractor for that Hutchinson operator, and if we start our journey person off of the square, they will eventually find themselves within it, similar to the triangle before.
181
+
This kinda boggled my mind a bit when I looked at it for the first time.
182
+
What does a random distribution of points mean in this context?
183
+
184
+
Well, firstly, it's only a random distribution between the square vertices of $$A$$, $$B$$, $$C$$, and $$D$$, but nothing exists outside of these points.
185
+
This means that it's not actually a random distribution of points, but instead an attractive plane that our lone wandering point can exist happily within.
186
+
187
+
This really helped me understand how attractors present themselves in different dimensions.
188
+
The Sierpinski triangle seems like a series of lines (one-dimensional objects) in two-dimensional space, but the square is a truly two-dimensional object.
189
+
In general, this means that an attractor embedded within $$\mathbb{R}^N$$ can be any shape of dimension N or lower.
176
190
177
191
The next obvious question is whether a square can create any more interesting fractally patterns, and the answer is "yes, but only if we restrict the movement a bit."
178
192
Which brings us to another topic entirely: restricted chaos games.
@@ -183,7 +197,6 @@ If you are interested, please let me know and I will be more than willing to add
183
197
184
198
Here is a video describing iterated function systems:
@@ -238,6 +251,7 @@ The text of this chapter was written by [James Schloss](https://github.com/leios
238
251
- The image "[IFS triangle 5](res/IFS_triangle_5.png)" was created by [James Schloss](https://github.com/leios) and is licensed under the [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/legalcode).
239
252
- The image "[IFS square 1](res/IFS_square_1.png)" was created by [James Schloss](https://github.com/leios) and is licensed under the [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/legalcode).
240
253
- The image "[IFS square 2](res/IFS_square_2.png)" was created by [James Schloss](https://github.com/leios) and is licensed under the [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/legalcode).
254
+
- The image "[IFS square 3](res/IFS_square_3.png)" was created by [James Schloss](https://github.com/leios) and is licensed under the [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/legalcode).
241
255
- The image "[Chaos 1](res/chaos_1.png)" was created by [James Schloss](https://github.com/leios) and is licensed under the [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/legalcode).
242
256
- The image "[Chaos 2](res/chaos_2.png)" was created by [James Schloss](https://github.com/leios) and is licensed under the [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/legalcode).
243
257
- The video "[IFS triangle video 1](res/IFS_triangle_vid_1.mp4)" was created by [James Schloss](https://github.com/leios) and is licensed under the [Creative Commons Attribution-ShareAlike 4.0 International License](https://creativecommons.org/licenses/by-sa/4.0/legalcode).
0 commit comments