Here is the algorithm of the generation of the Sierpinski
triangle using the chaos game.
If we note (xi,yi) for i=1,2,3 the coordinates of the
different vertices of the triangle and (x,y) the coordinates of the moving
point, we can write the algorithm of the geometrical construction as follows
FOR the number of iterations DO
I have written the program in Matlab language.
- roll the die, it means choose randomly
the direction to a vertex noted a
- construct the new point (x,y) using :
x(n+1) = x(n) + 0.5
* [xa - x(n)]
- plot this point (x,y)
y(n+1) = y(n) + 0.5 * [ya
You can choose the original triangle vertices, the
seed coordinates and the number of iterations.
Here is the program listing :
The table presents the generation of the Sierpinski triangle
for different number of iterations. I don't have rejected the beginning
points on the graphs in order to see the "attraction" of the orbit to the
Sierpinski triangle even if the seed is chosen very far from the triangle
(it is particularly easy to observe it for the 5,000 iterations graph).
The parameters for all these graphs are the same :
(x1 , y1) = (1 , 1)
(x2 , y2) = (0 , 0)
(x3 , y3) = (2 , 0)
(x0 , y0) = (0.5 , 1.5)
and the number of iterations moves from 50 to 50,000