COSC 286: Computer Graphics

Project 2
Spring 2007

Due: Feb 2 @ 5 P.M.
5 points

a. Using the project template (ProjectTemplate.java) provided on the class web page, code the DDA algorithm from Hearn and Baker's book. Implement Bresenham's line drawing algorithm for the general case. Test the algorithms using the following code:

    ...
    for (i = 0; i <= 100; i+=10) {
      drawLineDDA(g, 50, 50, 0, i);
      drawLineDDA(g, 50, 50, i, 0);
      drawLineDDA(g, 50, 50, 100, i);
      drawLineDDA(g, 50, 50, i, 100);
    } // for
    for (i = 100; i <= 200; i+=10) {
      drawLineBresenham(g, 150, 150, 100, i);
      drawLineBresenham(g, 150, 150, i, 100);
      drawLineBresenham(g, 150, 150, 200, i);
      drawLineBresenham(g, 150, 150, i, 200);
    } // for
    ...

b. Time how long it takes for each algorithm to draw 200 lines with random endpoints. Print the timing results to the screen. To time code in Java, use the Date class. For example:

    Date start = new Date();
    // code to be timed
    Date end = new Date();
    long runtime = end.getTime() - start.getTime();

Create two separate files: p2a.java and p2b.java

Instructions for Submission:

All classes and class members must be documented with Doc comments.

In the header comments, provide the following information:

/**
 * @author <Name> (<E-mail Address>)
 *
 * In accordance with the class policies and Georgetown's Honor Code,
 * I certify that, with the exceptions of the class resources and those
 * items noted below, I have neither given nor received any assistance
 * on this project.
 */
When you are ready to submit your program for grading, create a compressed archive of a directory containing only your project's source, and use the submit program to (you guessed it) submit your project.

The directory's name should be the same as your net ID. For example, assume your net ID is ab123. Assume you're in the directory above the one containing your source code. If the directory p1 contains your project, then rename the directory to ab123.

If you need to include a message, put it in a file named README.

To make the archive smaller, remove any .class files:

% rm ab123/*.class

Use jar to create an archive:

% jar cf ab123.jar ab123

You can also use jar to create an archive containing only the .java files:

% jar cf ab123.jar ab123/*.java

To use the submit command to submit your project, type

% java -jar submit.jar -a <assignment> -f <file>
where <assignment> is the assignment name and <file> is the name of your java-archive file. For instance, continuing the example, to submit, you would type
% java -jar submit.jar -a p1 -f abc123.jar
submit.jar should reside in the directory above your project directory. The first time you run submit, you'll have to provide your name and net ID.

Ideally, you should keep a copy on a university or department machine, such as seva. Make sure that your archive, directory, or files are not readable by others.

Submit your project before 5:00 P.M. on the due date.