Question: Make a python code for Fractals: the Dragon curve Make a python code Main topics: recursive functions, plots Fractals are geometric shapes which are highly

Make a python code for Fractals: the Dragon curve Make a python code
Main topics: recursive functions, plots
Fractals are geometric shapes which are highly detailed and look similar at different scales.
Typically you will see similar shapes when you zoom in. For more information on fractals
see: Wikipedia page on fractals.
In this project the idea is to make a script to generate the Dragon fractal curve: Wikipedia
page on Dragon_curve. Especially have a look at the construction on this Wikipedia page.
The output would be something as in the figure below:
Figure 3: Example output of the Dragon fractal for the 17th iteration.
To generate the Dragon curve you should use recursive functions, i.e. a function which
calls itself (this is just an example of a recursive function):
Realize that the stopping criterium for the recursive function is necessary, otherwise it
would keep calling itself an infinite amount of times. Let's see another example of a
recursive function:
Notice the order of the printed lines, it depends on whether we print before or after the
function calls itself. We can also make multiple calls within a recursive function:
Hints to get started:
The dragon curve starts with a single line connecting two points.
choose your maximum depth relatively small: a depth equal to 16 is already a lot,
start with less
At each step you divide a line in two different line pieces, which are either becoming
a corner pointing above the line or below. So at each step you would call the
function twice. To make a "corner" of a line piece you can use the following idea:
Make a python code for Fractals: the Dragon curve

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!