★ CODING ★ LISTINGS ★ The dragon curves on ... ★ |
Dragon Curves 2 (Computing with the Amstrad) | Coding Listings |
IN the March 1987 issue of Computing with the Amstrad an article by Ian Sharpe showed how to produce a dragon curve using a recursive technique. The members of a different kind of dragon curve can be generated using the short program given here. Each curve in the series can be represented by a string of 1s and Os, where 1 defines a 90 degree curve to the right and 0 defines a 90 degree curve to the left. You can see the idea in Figure I. The program first generates the Os and 1s for the chosen curve, putting them in the array j1. Then the curve is plotted. As the order of the curve increases, so the curve becomes more complex, snaking all over the screen. Amazingly, it never crosses itself. The curve is plotted a second time, beginning at the same starting point but rotated through 90 degrees. The second curve fits snugly against the first, interlocking like a jigsaw puzzle. Two more plots can be drawn, each rotated through 90 degrees to complete the pattern. Curves with an order between 6 and 10 produce the best pictures. Higher order curves take a long time to finish and spill off the edges of the screen.
|