CS 1401 Introduction to Computer Science
Fall 2014, Lab 9

Motivation: to practice classes and objects.

Background. While computers have been originally designed for a serious task of processing data, nowadays a large amount of computer resources is spent on playing computer games. One of the many things that attracts people to computer games is their ability to compute realistic images of 3-D scenes.

Many graphics algorithms behind these games use 3-D vectors. Let us therefore practice simple operations with vectors.

Assignment for Lab 9. Define a class of vectors. Let us start with an implementation in which each instance of this class has three real-valued fields: the three coordinates x1, x2, and x3 of the vector. Define a constructor, appropriate set-methods (modifiers) and get-methods, operations on vectors (see below), and a method that prints the vector as a triple (x1, x2, x3). Use the main method to test your class. For example, show how you can use your methods to normalize a given vector, i.e., to divide it by its length.

The following operations should be defined for vectors:

For extra credit:

When it is due. The program is due at the beginning of the second lab section on the week of November 10, i.e.: