Project 4: Recursive Graphics

Start: Thursday 10/23; Due: Monday 11/3, by the beginning of class


Overview

In this project you will write several programs that draw fractal patterns using the collage method described in class, in which a fractal is generated by pasting together similar sub-fractals.

You should work on this project individually.

Specific tasks

  1. To start out, create the Project4 project and copy the CCurve.java file I showed in class into the project, and then run it with several values to be sure you fully understand how it works. (You will need to get the stdlib library into the Project4 and configure the build path appropriately.) Notice that if you interchange (x0, y0) with (x1, y1) you don't get the same image (unless level is 0). That is because the c-curve depends on the direction from the first point to the second, which is to say that a c-curve has an orientation.

    Your first programming task is to write a new program in Dragon.java that does the same thing as CCurve except that when level>0, it switches the order (orientation) of the second sub-curve. You should get something radically different from the c-curve; be sure you check with the lab instructor that you did the right thing.

  2. Next, create a new class called Sierpinski that will eventually be used to draw a Sierpinski gasket, as described in class. First, however, you will want to write a public static method called triangle that takes six double arguments (x0, y0, x1, y1, x2, and y2) and fills in the triangle between the points (x0, y0), (x1, y1), and (x2, y2). Do this, testing the procedure fully. Be sure to try triangles that aren't equilateral.

  3. Now write a public static method called sierpinski which takes the same six double arguments and an int argument level and draws the Sierpinski gasket of the given level through the given points. Again, test the procedure fully, being sure to test with points that do not form an equilateral triangle. You should see the following images with the given arguments:

  4. Finally, come up with your own fractal pattern using the collage method. I will discuss some possible ideas in class. Alternatively, you could play around with the program IFS.java to see some other self-similar fractals. Karl Knight altered this file slightly so that it will set the number of iterations in main() and will take input from data files in the resources directory. For your convenience, following are the input files that they refer to at the top of the Java file:

What you must hand in

Submit the whole project, which should include the two classes Dragon.java and Sierpinski.java, as well as the class that implements the fractal you create in part 4 above. You must also fill out the following readme.txt file.

Gradesheet

We will use this gradesheet when grading your lab.

Submission

Use the same procedure to submit your code as in the previous project. Submit the zip file via Moodle. This is described in our step by step instruction on submitting code. Be sure to select f-mcs-178-003, which is the lab section.