Programming Assignment Checklist: Recursive Graphics

Frequently Asked Questions

What preparation do I need before beginning this assignment? Read Sections 2.1–2.3 of the textbook.

I forget how to do geometry. Any hints? Here are the coordinates of the critical endpoints. Click the image for a bigger version.

Sierpinski triangle geometry

How do I draw a filled equilateral triangle? Use StdDraw.filledPolygon() with appropriate parameters.

May I use a different color from black to fill in the triangles? Yes, you may use any color that contrasts with the white background.

How can I create colors that aren't predefined in standard drawing? It requires using objects that we'll learn about in Chapter 3. In the meantime, you can use this color guide.

How should I go about doing the artistic part of the assignment? This part is meant to be fun, but here are some guidelines in case you're not so artistic. A very good approach is to first choose a self-referential pattern as a target output. Check out the graphics exercises in Section 2.3. Here are some of our favorite student submissions from Fall '10. See also the Famous Fractals in Fractals Unleashed for some ideas. Here is a list of fractals, by Hausdorff dimension. Some pictures are harder to generate than others (and some require trig); consult a preceptor for advice if you're unsure.

What will cause me to lose points on the artistic part? We will deduct points if your picture is too similar to Htree, Sierpinski or Brownian. To be "different enough" from those algorithms, you need to change the recursive part of the program. For example, it is not sufficient to simply substitute squares for triangles in Sierpinski. You will also lose points if your artwork can be more easily created without recursion. This is indicated by a tail-recursive function, e.g., a recursive function that calls itself as its last action or only calls itself once (like the factorial method we wrote in precept).

May I use .gif, .jpg, or .png in my artistic creation? Yes. If so, be sure to submit them along with your other files. Make it clear in your readme.txt what part of the design is yours and what part is borrowed from the image file.

My function for takes several parameters, but the assignment says that I can only read in one command-line argument N. What should I do? Choose a few of the best parameter values and do something like the following:

if      (N == 1) { x = 0.55; y = 0.75; n = 3; }
else if (N == 2) { x = 0.55; y = 0.75; n = 5; }
else if (N == 3) { x = 0.32; y = 0.71; n = 8; }
else if ...

May I use the mouse to control input values? Check with your preceptor.

Testing and Submission

Submission. If you don't follow these instructions, you risk annoying your grader and losing a significant number of points.

Possible Progress Steps

These are purely suggestions for how you might make progress. You do not have to follow these steps. Note that your final program should not be very long (no longer than Htree, not including comments and blank lines).

Challenge for the bored

Consider using our StdDraw3D library instead of StdDraw to create a three-dimensional fractal design! (Note: This is not for extra credit nor for submission.) You can find documentation on the booksite.

To check that you have downloaded StdDraw3D when running the installer, go to the command prompt and type:

java StdDraw3D