First Assignment

"If you please, draw me a fractal tree (*)."

In this assignment you will be asked to draw a Fractal Tree. The drawing of this sort of fractal is based on recursive call to the same method. By recursion we mean something that uses itself to define itself. E.g. "GNU acronym stands for: 'GNU is Not Unix'". That first example is of course a bad hacker joke. More Seriously, you can define the mathematical value of factorial n (which is n(n-1)(n-2)... 2 * 1 ) by :

Here is a general idea of such a drawing

Here is a more precise idea of the algorithm


a,b,c : the angle in radians between a branch and the following one. NB. : following the trigonometric convention, on this example, a and b are positive angles and c is negative.

k1, k2, k3 : by how much the length of the branch is reduced at the next level.
l1 = k1 * L
l2 = k2 * L
l3 = k3 * L

m2, m3 : the factors that define the position (F and G) of the start of new sub-branches from a main one :
OF = m2 * L
OG = m3 * L


The process :

For each branch defined by its end point O, its length L, its direction and its level (Note that this information would perhaps be coded differently in your own program)

Ground Rules for all projects:

To submit a project...

you should put altogether, in a directory called CG_A1_02_UstudentID...

(Where 'studentID' your student ID !... CG_A1_02 means the first assignment in Computer Graphics lecture of the year 2002)

Here is its README.html file template

Use the jar command to put your directory into a single jar file based on the same name and mail this file to

cd .. (go to the directory in which your CG_A1_02_UstudentID is located)
jar cvf CG_A1_02_UstudentID.jar CG_A1_02_UstudentID/

Mail the file (CG_A1_02_UstudentID.jar) as an attached document. Be sure that the title of your mail is 'CG_A1_02_UstudentID''

!!! Your jar file should not be more than 500 kB !!!

The minimum requirements

Your project should be composed of, or respect, at least, the following :

(1) 3 different main classes (there could be of course more, but there should not be more than 15 classes for this size of project). Explain in the README file what the role of the 3 classes are.

(2) One of the classes should be a public class, whose name will be "Assignment", and will contain the "main method" in such a way that, to test your project, I will only need to call 'java Assignment [command line arguments]' to run it. Because yours classes will be well documented, I should be able to write that "Assignment" class by myself without to much work.

(3) You will explain the use of the arguments in your README file but the first two will be levelLimit sizeLimit

E.g. : java Assignment 5 10
will draw the branches up to the 5th level as long as the branch size is not smaller than 10

(4) By default, the opening window should be well positioned (you should see it entirely, but it should not use all the screen space, between half and 2/3rd of the space) whatever is the size of the screen.

(5) Remember that sometimes, users may be dumb and may not use the right number of arguments. You should deal with that sort of situation

(6) Remember that again, users may be dumb and could use a very high Iteration Number. It could be a good idea to have 2 trivial criteria to end the recursion. One is the number of iterations, the other one is...(this is the sort of thing -amongst others- that should appear either in your code comments and in the README file)

(7) One peculiarity of these fractal displays is that the panel should be resizable (whenever the size of the window is changed by the user, the fractal should be redrawn trying -it is not always possible- to fit in the available space when using the default parameters).

(8) Within the main frame or in the second one, it should be possible to change all the parameters of the tree and redraw it when wanted. It should be possible to get back to the set of default parameters that you will have established as producing a good looking tree.

(9) The tree should grow up from the bottom of your frame

(10) The compile classes should be available at the root of your directory. During the marking process, I may :

(Not So) Optional Development:

You should do at least two of the following options to get the maximum mark

Penalties for late submission:

Late submission may be penalised at 10% per day late.

(*) If you didn't know that the original quotation was about a sheep, you should perhaps first read "The little prince" story before beginning to do computer graphics.