(programming required) The reason that sn is called the “Fibonacci word fractal” is that it’s possible to visualize these “words” (strings) as a geometric fractal by interpreting 0s and 1s as “turn” and “go straight,” respectively. Specifically, here’s the algorithm: start pointing east. For the ith symbol in sn, for i = 1, 2, . . . , |sn|: if the symbol is 1 then do not turn; if the symbol is a 0 and i is even, turn 90◦ to the right; and if the symbol is a 0 and i is odd, turn 90◦ to the left. In any case, proceed in your current direction by one unit. (See Figure 5.28.) Write a program to draw a bitstring using these rules; then implement the recursive definition of the Fibonacci word fractal and “draw” the strings s1,s2, . . . ,s16. (For efficiency’s sake, you may want to compute sn with a loop instead of recursively; see Figure 6.41 in Chapter 6 for some ideas.)
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here