CS 371
Computer Graphics
Spring 2005


Assignment 1: Trying out C++

Due by BEGINNING OF CLASS on 2/14/05

This assignment consists of 2 short programming assignments:

Details

I suggest you approach this in 3 steps. First write the calculator without the projection operator. This does not involve editing the Point3Df class. Then add the projection operator. Finally, modify the calculator to include the projection operator.

As far as error-catching is concerned, you should catch illegal operators, as well as handle special cases of the projection method. If you use the overloaded >> method to read the vectors (as Point3Df objects), you don't have much control over a badly formatted vector. If that bothers you, you can parse the vectors yourself to get better error-handling of input.

This is a short assignment the goals of which are to give you experience writing simple C++ code, to get you comfortable with the Unix environment, and to get you to start working!

How to Enter, Compile, and Run Programs

I assume that you all know the most basic Unix commands--if not, now would be a good time to learn them! Emacs is a good choice for entering/editing your programs. Although slightly antiquated by now, it supports source level debugging, and many other nice features. From within emacs, you can learn a lot about the Unix environment by typing Ctrl-h i (control-h followed by i). This brings up the emacs info system. You might use it to learn a bit about emacs first--like how to quit emacs. 8-)

To compile the class Point3Df, enter the Point3Df directory and type:

g++ -c Point3Df.cc

This will produce a compiled class file (object code) called Point3Df.o. To compile your program Calc.cc, type:

g++ -c Calc.cc

This will create an object file called Calc.o.

However, these commands only check for internal consistency during compilation. To create an executable program Calc that uses your Calc.o and Point3Df object code, type:

g++ -o Calc Calc.o Point3Df.o

This produces an executable file called Calc, which you can run by typing

Calc, or, depending on your system, ./Calc

Note: If you want to try using gdb, the debugging system for C/C++ programs, you should compile your code with the "-g" option, as in

g++ -g -c Calc.cc, or g++ -g -o Calc Calc.o Point3Df.o

What to turn in

You only need to hand in the modified Point3Df.h (and .cc) files, as well as your calculator source code (call it Calc.cc). You might also include a README file if there is anything you'd like me to know about your assignment, such as extra features, how to use it, and so on. The files in your directory should be correctly set up so that I can compile and run them without having to make changes.

Note: A General Principle: A user should never need to read your source code to know how to use your program!

There will be a "turn-in" directory available into which you can drop your work. To turn in your work, create a directory containing all of the files mentioned above. Call your directory LastnameCalc (eg: StewartCalc). From the directory containing LastnameCalc, type

tar cvf LastnameCalc.tar LastnameCalc

(replacing "Lastname" with your own last name!) to create a single "tar" file. Then drop the tar file off in the drop-off directory, by running the program

/usr/cs-local/bin/turnin LastnameCalc.tar.

The first time you use it, you will be asked if you want a directory created for your turned-in files. Say "yes".

For more information...

The course home page contains links to many useful resources. In particular, there are on-line tutorials on C and C++, as well as guides to using Unix and Emacs. There are also links to the source code for the programs that we have been discussing in class. And, of course, there's me.

A Note on Scheduling Your Time

This assignment is due on a Monday morning. The morning an assignment is due is not the time to come with questions. I encourage you to work on this early, in particular, get started on it before the weekend so that you can easily contact me. Have fun!
lenhart@cs.williams.edu