home
Balloting
Simple trig
Logistic map
The Attractor of Henon
Number doubling
Barnsley's Fern
The Sierpinski Triangle
The Sierpinski Triangle (The Sierpinski Gasket)
A simple three part algorithm, which incorporates
randomly selected parts of the algorithm, produces
a triangular lattice of triangles.
To thoroughly fill in the Sierpinski gasket, we need
to supply the algorithm with a [pseudo] infinite database,
which is what the randomness algorithm provides.
Program code is at bottom of this page.
Here are snippets from a couple websites explaining the
algorithm:
http://math.bu.edu/DYSYS/chaos-game/node1.html
One of the most interesting fractals arises from what
Michael Barnsley has dubbed "The Chaos Game". The chaos
game is played as follows: First pick three points at
the vertices of a triangle (any triangle works - right,
equilateral, isosceles, whatever). Color one of the
vertices red, the second blue, and the third green.
Next, take a die and color two of the faces red, two
blue, and two green. Now start with any point in the
triangle. This point is the seed for the game.
(Actually, the seed can be anywhere in the plane,
even miles away from the triangle.) Then roll the
die. Depending on what color comes up, move the seed
half the distance to the appropriately colored vertex.
That is, if red comes up, move the point half the
distance to the red vertex. Now begin again, using the
result of the previous roll as the seed for the next.
That is, roll the die again and move the new point
half the distance to the appropriately colored vertex,
https://thatsmaths.com/2014/05/22/the-chaos-game/
Fix three points in the plane, C1, C2 and C3. For
definiteness, we take the points C1 = (0, 0),
C2 = (1, 0) and C3 = (0.5, v3/2), the corners of an
equilateral triangle.
Pick any point P0 and draw a dot there. This is
our starting point. At each stage, we denote the
current point by Pk and call it the game point.
Roll the dice. If n comes up, draw a point half
way between Pk and Cn. For example, if we roll a 2,
we pick the point half way between the current
point Pk and C2. This is the new game point.
Repeat this procedure many times, drawing a new
point at each step.
===================================================
Here is my Visual BASIC program code:
Private Sub chaosbtn_Click()
ITER = Val(itera.Text)
X1 = 0
Y1 = 0
X2 = 700
Y2 = 0
X3 = 350
Y3 = 606
XS = 280
YS = 490
Randomize Timer
For a = 1 To ITER
RN = Rnd(1)
If RN < 0.3333333 Then GoTo 100
If RN < 0.6666667 Then GoTo 200
GoTo 300
100:
XS = (X1 + XS) / 2
YS = (Y1 + YS) / 2
GoTo 500
200:
XS = (X2 + XS) / 2
YS = (Y2 + YS) / 2
GoTo 500
300:
XS = (X3 + XS) / 2
YS = (Y3 + YS) / 2
500:
TX = XS + 20
TY = -YS + 1050 REM Transforms the y axis
viewport.PSet (TX, TY), RGB(0, 0, 0)
Next a
End Sub
============================================================
home
Balloting
Simple trig
Logistic map
The Attractor of Henon
Number doubling
Barnsley's Fern
The Sierpinski Triangle
|