Why does the chaos game generate fractals?
<p dir="auto">My answer fill focus on Sierpiński triangle case, but I think some general conclusions can be drawn from it as well. By no means I'm an expert in the subject, so there will be no mathematical proofs.
<h2>Rules of chaos game
<p dir="auto"><span>The rules of the chaos game (as written by <a href="/@irelandscape">@irelandscape), are very simple:
<ol>
<li>Imagine an area of the screen corresponding to a polygon, such as a triangle, square, pentagon, etc.
<li>Select a fraction number f between 0 and 1 (e.g 1/2).
<li>Pick a random point within that polygon and plot a pixel at that location
<li>Select any vertex (corner) of the polygon at random.
<li>Calculate the distance d between the last plotted pixel and the selected vertex.
<li>Plot a pixel on the imaginary line between the last plotted pixel and the selected vertex at a distance fd from the previously plotted pixel.
<li>Repeat from step 4.
<p dir="auto">Below, I will assume <code>f=0.5
<h2>Restricted regions
<p dir="auto">First let's consider we have already chosen a vertex of triangle.<img src="https://images.hive.blog/768x0/https://i.imgsafe.org/8d/8dcd738042.png" alt="starting area" srcset="https://images.hive.blog/768x0/https://i.imgsafe.org/8d/8dcd738042.png 1x, https://images.hive.blog/1536x0/https://i.imgsafe.org/8d/8dcd738042.png 2x" />
<p dir="auto">Let it be vertex C on the image above. Now if we pick completely random point, anywhere in the triangle, where would next point need to be drawn?<br />
<img src="https://images.hive.blog/768x0/https://i.imgsafe.org/96/963736eea6.png" alt="first triangle" srcset="https://images.hive.blog/768x0/https://i.imgsafe.org/96/963736eea6.png 1x, https://images.hive.blog/1536x0/https://i.imgsafe.org/96/963736eea6.png 2x" />
<p dir="auto">In an area marked with yellow. That's because whatever point we choose, we must cut it's distance in half. So for the farthest points located at the line between A and B vertices, resulting points will land on the line between D and E. The closer we get to C with initial point, the closer will be the resulting one.
<p dir="auto">Now let's see what happens if we mark achievable regions for all vertices:<br />
<img src="https://images.hive.blog/768x0/https://i.imgsafe.org/96/964277742a.png" alt="all vertices" srcset="https://images.hive.blog/768x0/https://i.imgsafe.org/96/964277742a.png 1x, https://images.hive.blog/1536x0/https://i.imgsafe.org/96/964277742a.png 2x" />
<p dir="auto">You can clearly see what I call a "restricted region" - an area that will be occupied only by a first, completely random point. Points drawn in all subsequent iterations will have to be located in the areas marked with yellow.
<p dir="auto">Now, if you think about it, you will notice that to get to some regions of the areas that are currently yellow, you would need to start in the restricted area. So those points will also be restricted.<br />
<img src="https://images.hive.blog/768x0/https://i.imgsafe.org/96/9642a5c1e1.png" alt="restricted areas" srcset="https://images.hive.blog/768x0/https://i.imgsafe.org/96/9642a5c1e1.png 1x, https://images.hive.blog/1536x0/https://i.imgsafe.org/96/9642a5c1e1.png 2x" />
<p dir="auto">This of course scales down for as long as you wish. Now, why do only certain values of <em>f generate such a nice fractals? In case of triangle it works well for values bigger then 0.5, which result in the same pattern but spaced apart. For smaller values, triangles start to overlap until empty regions vanish completely, and you get only chaos.
<p dir="auto">For shapes other then triangle, I think a general rule will be similar: You need to have a set of points that is not achievable in the first iteration. Shape of that area will be replicated over the whole polygon.
<p dir="auto"><strong>StemQ Notice: <em>This post was originally submitted on <a href="http://www.stemq.io" target="_blank" rel="nofollow noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">StemQ.io, a Q&A application for STEM subjects powered by the Steem blockchain.
Thank you so much for sharing this amazing post with us!
Have you heard about Partiko? It’s a really convenient mobile app for Steem! With Partiko, you can easily see what’s going on in the Steem community, make posts and comments (no beneficiary cut forever!), and always stayed connected with your followers via push notification!
Partiko also rewards you with Partiko Points (3000 Partiko Point bonus when you first use it!), and Partiko Points can be converted into Steem tokens. You can earn Partiko Points easily by making posts and comments using Partiko.
We also noticed that your Steem Power is low. We will be very happy to delegate 15 Steem Power to you once you have made a post using Partiko! With more Steem Power, you can make more posts and comments, and earn more rewards!
If that all sounds interesting, you can:
Thank you so much for reading this message!
Congratulations @mactro! You received a personal award!
You can view your badges on your Steem Board and compare to others on the Steem Ranking
Vote for @Steemitboard as a witness to get one more award and increased upvotes!