Project 3: Recursive Graphics
Started: Tuesday 3/1; Due: Friday 3/4, by the beginning of class
In this project you will do several programs that draw fractal patterns.
You should work on this project individually.
To start out, create "Project3" folder and copy the
CCurve.javafile into it, and then compile and run it with several different argument values to be sure you fully understand how it works. Notice that if you interchange
(x1, y1)you don't get the same image (provided
level>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.javathat does the same thing as
CCurveexcept that for
level>0, is switches the order (orientation) on the second half of the 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.
Next, create a new class called
Sierpinskithat 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
trianglethat takes six double arguments
x0 y0 x1 y1 x2 y2and draws the triangle between the points
(x1, y1), and
(x2, y2). Do this, testing the procedure fully. Be sure to try triangles that aren't equilateral.
Now write a public static method called
sierpinskiwhich takes six double arguments
x0 y0 x1 y1 x2 y2and an
leveland draws the Sierpinski 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:
Sierpinski 0 0 1 0 .5 .866 0
Sierpinski 0 0 1 0 .5 .866 1
Sierpinski 0 0 1 0 .5 .866 2
Sierpinski 0 0 1 0 .5 .866 3
Sierpinski 0 0 1 0 .5 .866 4
Sierpinski 0 0 1 0 .5 .866 5
Finally, come up with your own fractal pattern. I will discuss some possible ideas in class. Otherwise, you could play around with the program
IFS.javato see some other self-similar fractals. For your convenience, following are the input files that they refer to at the top of the files:
What you must hand in
The whole project, of course which should include the two classes
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.
We will use this gradesheet when grading your lab.
Use the procedure described in our instructions on submitting code document.