/************************************************************************ * * * Program: Vector3Test.cpp * * * * Author: Robb T. Koether * * * * Date: Oct 8, 2003 * * * * Purpose: This program will test the Vector3 class * * * ************************************************************************/ #include #include #include "point3.h" #include "vector3.h" using namespace std; /************************************************************************ * * * Function: main * * * ************************************************************************/ int main() { // Create a default vector cout << "Create a default vector" << endl; Vector3 u; cout << "u = " << u << endl; // Create the vector [1, 2, 3] cout << endl << "Create vector <1, 2, 3>" << endl; Vector3 v(1, 2, 3); cout << "v = " << v << endl; // Create the vector [4, 5, 6] cout << endl << "Create another vector <4, 5, 6>" << endl; u.set(4, 5, 6); cout << "u = " << u << endl; // Take the dot product cout << endl << "Take the dot product" << endl; cout << "u.dot(v) = " << u.dot(v) << endl; // Take the cross product cout << endl << "Take the cross product" << endl; cout << "u.cross(v) = " << u.cross(v) << endl; // Test addition cout << endl << "Add u and v" << endl; cout << "u + v = " << u + v << endl; // Test subtraction cout << endl << "Subtract u from v" << endl; cout << "v - u = " << v - u << endl; // Test difference of points cout << endl << "Set v equal the difference of two points" << endl; Point3 p(3, 6, 4); Point3 q(1, 8, 2); cout << "p = " << p << ", q = " << q << endl; v.setDiff(p, q); cout << "v = " << v << endl; // Add a point to a vector cout << endl << "Add q to v" << endl; cout << "v + q = " << v + q << endl; // Test the length cout << endl << "Find the length of v" << endl; cout << "Length of v = " << v.length() << endl; // Test negation cout << endl << "Negate v" << endl; cout << "-v = " << -v << endl; // Normalize a vector cout << endl << "Normalize v" << endl; v = v.normalize(); cout << "v = " << v << endl; cout << endl << "Good-bye" << endl; return 0; }