Due: Tuesday, December 14th by 11:59 PM
Start by importing the file CS201_Assign7.zip into Eclipse: File->Import->Existing Projects into Workspace, click Select archive file, select CS201_Assign7.zip from the file selection dialog, and then click the Finish button. You should see a project called CS201_Assign7 in the Package Explorer.
In this assignment you will define recursive methods for drawing several kinds of simple fractals using turtles. A fractal is a geometric object that is irregular at all levels of detail. The fractals in this assignment are also self-similar, in that the structure of the fractal is similar at all levels of detail. The Turtle interface defines the operations of turtle objects. A turtle has a location (x and y coordinates) and an orientation (which way it is facing). When you move the turtle d units of distance, it draws a line from its current location to a point d units away, in the direction indicated by the turtle's orientation.
The turtle's orientation is specified by an angle (in radians) starting from 0, at which point the turtle is facing straight up. As the angle increases, the turtle rotates clockwise. At 2 pi radians, the turtle has rotated through a full circle and is pointing up again. The following diagram explains how the orientation works:
The Turtle interface contains the following methods:
The move and turn methods allow you to draw a continuous path without any splits. If you want to split the path you are drawing, you will need to call the branch method to create a duplicate of the current turtle. The new turtle returned by branch may then be turned and moved independently of the original.
Your task will be to implement code to draw several kinds of fractals: "Trees", "Ferns", and (if you have time) "H-Trees". These fractals are drawn by the Tree, and Fern, HTree classes. The general idea is as follows: at each step
The fractals are drawn according to the following rules:
In each case
Each fractal-drawing method will have a minimum segment length to serve as a base case for the recursion. Once the distance passed to the method falls below the minimum, it should return without drawing anything.
(Click any of the above images to see full-size image)
Tree is the simplest fractal. It is just a straight segment, with two sub-trees branching off of it. In the Tree class, you will see constants defining the angle to turn for each branch, and the factor by which to decrease the segment distance for the recursively-drawn branches.
Fern is a more compex fractal. It consists of a main "spine", with smaller "branch" sub-ferns branching off the side of the spine. The spine of the fern curves: the right branch curves to the left, and the left branch curves to the right. The spine of the main fern also curves (as indicated by a parameter to the method that draws the fern.) In the Fern class, you will see constants indicating how to generate the branches and the continuation of the spine as recursive calls. (Both the branches and the continuation of the spine are recursive sub-ferns, but the branches are significantly smaller.)
The H-Tree fractal is a way to compactly lay out a binary tree on a two-dimensional surface so that none of the edges (lines) cross. It consists of interlocking shapes that look like the letter "H", where each generation of shapes is half the size of the original. The HTree class is set up so that you only need to draw half of one of the "H" shapes, which will look like a "T". A method called reflect takes care of calling the method that draws the "T" shape twice in opposite directions in order to form an "H".
Your grade will be determined as follows:
Export your project as a zip file (File->Export...->Archive File) and upload it to the submission server as assign7. The URL of the server is
IMPORTANT: after uploading, you should download a copy of your submission and double-check it to make sure that it contains the correct files. You are responsible for making sure your submission is correct. You may receive a grade of 0 for an incorrectly submitted assignment.