### Professor Harriet Fell

#### Introduction

There are two parts to this assignment.
1. You will choose a programming platform for the quarter and familiarize yourself with RGB color and the ppm format. In part, this assignment is to ensure that you have a method of submitting you work so that I can:
• compile (or interpret) the code
• run the code to produce a file in ppm format.

2. You will write your own 3D vector tools (e.g. as a JAVA class) that you will use for your later programming assignments.

#### Part 1: RGB Triangle

Write a program that generates a picture of a triangle in arbitrary position, such that the color at each pixel within the triangle is the blend of the colors of the vertices of the triangle as determined by the barycentric coordinates of the pixel. The color must be generated one pixel at a time and written to a ppm file.

Here are some triangles that were generated by such a program.

• Your program should work with any triangle in your graphics space, e.g. with all vertex coordinates between 0 and 300.
• Your program should work with any RGB colors assigned to the vertices.
• You can get the data for your triangles by:
• reading the information from a file, or
• generating appropriate random numbers.
• You must ouput your image to a ppm file.
Resources
See /course/csg140/codeSamples for code samples.

#### Part 2: Vector Tools

Write a (Java) class for handling 3D vectors of doubles. You should also write a driver that tests your class. Your class should allow you to:
• Set and Get the x, y, and z components of a vector.
• Subtract one vector from another
• Multiply vector by scalar
• Divide a vector by a non-zero scalar
• Determine whether a vector is zero
• Test whether two vectors are equal
• Compute the dot product of two vectors
• Compute the cross product of two vectors
• Compute the length of a vector
• Normalize a vector
• Compute the angle between two vectors

What to submit
A zipped folder containing one folder for each part of this assignment.

• Triangle Folder
• instructions on how to run your program
• what to expect as output
• data file(s) if required
• how I can change the triangles and their colors
• anything that causes your program to crash
• NOTHING ELSE
• Vector Folder
• instructions on how to run your program
• what to expect as output
• anything that causes your program to crash

How to submit
Email your zipped work as an attachment to fell@ccs.neu.edu with Subject: CSG140SP07-prog0.

Due
By midnight Tuesday, January 23

These grading guidelines will be used for all programming assignments:

• correctness (60%).
• style of your program (10%) (20% for part 2)
• documentation:
• quality of the resulting image(s). (10%) (0% for part 2)

Some points may be subtracted (up to 10%) if you need substantial help from the TA or professor to make your program run.

The penalty for a late homework is 5% per calendar day for up to one week late.
No homework will be accepted later than that.

Harriet Fell
College of Computer Science, Northeastern University
360 Huntington Avenue #202WVH,
Boston, MA 02115
email: fell@ccs.neu.edu
Phone: (617) 373-2198 / Fax: (617) 373-5121

Last Updated:
The URL for this document is: http://www.ccs.neu.edu/home/fell/CSG140/Assignments/CSG140SP2007prog0.html