ECE 538 Assignment 3

Do the following exercises using the language of your choice, except where indicated

  1. Write a program to calculate the vector cross product (3D vectors). Show various test cases. Input two 3D vectors from the command line.

  2. Write a program to calculate the greatest common divisor of two integers. (See discussion of Lazlo on class CDROM) This is used to reduce fractions such as 14/42 to standard form (i.e., 1/3).

  3. Design a class representing a two-dimensional “ball” in a plane. Write a member function that calculates the intersection of a ball object with a “wall” denoted by an arbitrary line ax+by+c=0. See collide1 demo for a preview of where this exercise is headed.

  4. Modify small2 so that fill color is a data member of point2. Demonstrate by having the three displayed points be yellow, red, and blue.

  5. Using vec2 as a guide develop and test another “numeric” class. Examples could be a 3D vector class, a rational number class (fractions), a polynomial class, or a quaternion class. There may be other suitable examples, something for which arithmetic operations arise naturally. Discuss your design considerations in developing the class.

Your submission should include source-code files, high-lighted documents, and a general document reporting your work and including validation tests. Try to improve your documentation skills.


Maintained by John Loomis, last updated 27 May 2010