Graphics Reference
In-Depth Information
Figure 1.10.
The chaos game.
To make the picture look nicer, draw the segments on the back faces of the cube with dashed
lines. To generate paths use a procedure like the polyspiral procedure in project 1.3.
1.5.5
The Chaos game ([Barn87])
To play this game add the following item to the main menu:
Let the user pick four points on the screen. For example, Figure 1.10 shows points marked
“heads,” “tails,” “side,” and “ p 1 .” Now generate points p i , i ≥ 2, as follows: “Toss a coin.” If the
coin comes up heads, p i is the point half way from p i-1 to the point marked “heads.” If the coin
comes up tails, p i is the point half way from p i-1 to the point marked “tails.” If the coin ends up
on its side, p i is the point half way from p i-1 to the point marked “side.” Analyze the patterns of
points that are generated in this fashion. Tossing a coin simply translates into generating a
random integer from {0,1,2}.
Search WWH ::




Custom Search