Home Syllabus Class Schedule Lab Schedule People Assignments Texts Resources

CPSC 1070

Programming Methodology

Fall 2019

Planting Trees

Homework Assignment 2

Due by midnight: Sunday Sept. 22

For this assignment, you are to develop a program that will place trees on the screen, and provide some size and shape information via mouse interaction. The trees should be drawn using a recursive algorithm. The video below shows you how the interface is supposed to work, and what the resulting trees might look like.

Demonstration of a working version of the tree planting program

To design a tree, the user clicks in four points. The first is where the tree is rooted, the second is at the top of the main tree trunk, the third determines the direction and length of a branch to one side, and the fourth the direction and length of a branch to the other side. When the user presses the left mouse button, a point is displayed as a red dot at the cursor location. As long as the mouse button is held down, this point can be moved around. When the button is released, the point is frozen in place. Each of the four points works in this way, but the 2nd, 3rd, and 4th points are displayed like a rubber band attached to the point they are connected to.

The recursive approach to tree drawing works like this: A tree is a trunk, and two subtrees branching from it. When a subtree is small enough it is simply a leaf, which can be drawn as a circle. The branching angles are determined by the user's mouse clicks of the 3rd and 4th point. The ratio of subtree length to trunk length is determined by the ratio of the lengths of the lines from the top of the trunk to the 3rd and 4th points to the length of the trunk. We will go over this in class, and you can examine this broccoli program example to get a clearer idea of how this should work.

You must write your program in C using EZ_Draw to do the graphics and interaction. Note, that you should now have the ezdraw.h and libezdraw.a files in a separate directory so that they don't need to be copied for every program you build. Refer to the Makefile Lab on Sept. 9. Remember that your program must be compiled and tested on the School of Computing Linux system using your Makefile before turning it in. I cannot support grading programs done in an IDE, since I use scripts to prepare your assignments for testing.

Grading Rubric

Click here for the grading rubric that will be used.

Turn-in Procedure

You are to turn in this assignment via the web interface at: http://handin.cs.clemson.edu.

On this page you will be able to log in, and go to the help pages for all information on how to submit an assignment. Our course is CPSC 1070-001 or CPSC 1070-002. This homework project is called "planting trees" on the course page.

Before turning in your work, please follow these instructions. This is very important, since we process your assignments via an automated script.

  1. Make a directory named with your Clemson username in lower case. Do not add any additional text, and do not include any spaces in the filename!
  2. If you have done anything in your program that deviates from the problem statement, please include a plain text README document (not .pdf or .docx) that gives any instructions needed to run the program, or understand what it is doing.
  3. Place all of your work in a flat-structured directory. There should be no subdirectories. Delete all .o and executable files, and any IDE project files. All that should be there are your Makefile, any .c or .h files you used to build your program, and a README file (if you needed one). Note, that you should not include the ezdraw.h and libezdraw.a files.
  4. tar and gzip your directory, or zip your directory. If your username were monty, then your zipped file would be named either monty.tar.gz, or monty.tgz, or monty.zip
  5. Turn in only this zipped directory.