/************************************************************************ * * * Program: Point3vTest.cpp * * * * Author: Robb T. Koether * * * * Date: Oct 8, 2003 * * * * Purpose: This program will test the Point3v class * * * ************************************************************************/ #include #include #include "point3v.h" #include "vector3v.h" using namespace std; // Function prototypes void print(float* p); /************************************************************************ * * * Function: main * * * ************************************************************************/ int main() { // Create a default point cout << "Create a default point" << endl; Point3v p; cout << "p = " << p << endl; // Create the point (1, 2, 3) cout << endl << "Create point (1, 2, 3)" << endl; Point3v q(1, 2, 3); cout << "q = " << q << endl; // Create the point (4, 5, 6) cout << endl << "Create another point (4, 5, 6)" << endl; p.set(4, 5, 6); cout << "p = " << p << endl; // Create a copy of a point cout << endl << "Create a copy of a point" << endl; Point3v r = p; cout << "r = " << r << endl; // Test subtraction cout << endl << "Subtract q from p" << endl; cout << "p - q = " << p - q << endl; // Test difference of points cout << endl << "Set v equal the difference of two points" << endl; p.set(3, 6, 4); q.set(1, 8, 2); cout << "p = " << p << ", q = " << q << endl; Vector3v v = p - q; cout << "v = " << v << endl; // Test adding a vector to a point cout << endl << "Test adding a vector to a point" << endl; r = p + v; cout << "p + v = " << r << endl; // Test subtracting a vector from a point cout << endl << "Test subtracting a vector from a point" << endl; Point3v s = p - v; cout << "p - v = " << s << endl; // Pass the array of coordinates to a function print(p.v()); cout << endl << "Good-bye" << endl; return 0; } void print(float* v) { cout << "x = " << v[0] << endl; cout << "y = " << v[1] << endl; cout << "z = " << v[2] << endl; return; }