// GeometryDemo.cpp // NKU CSC 480 // -------------------------------------------------------- // Just a demo of some of the Vector3 and Point3 operations // in Geometry.h. // -------------------------------------------------------- #include "Geometry.h" using namespace std ; using namespace csc480 ; void glSomething3dv( const double* ar ) // A "legacy" C function that expects points or vectors as a C array of doubles. { cout << "glSomething3dv( " << ar[0] << " " << ar[1] << " " << ar[2] << " )" << endl ; } int main() { // Defining vectors and points. Vector3 u(-3,4,1), v(2,3,4) ; Point3 pt(10,4,-1) ; // I/O of vectors. Vector3 w ; cout << "Enter a 3D vector: " ; cin >> w ; cout << "You entered vector " << w << endl << endl ; // I/O of points. Point3 q ; cout << "Enter a 3D point: " ; cin >> q ; cout << "You entered point" << q << endl << endl ; // Element access pt.x= q.x + 2 ; u.dx= v.dx + 2 ; u[2]++ ; // Arithmetic Vector3 a= 2 * (u ^ v ) + ( w *u ) * w ; Vector3 ahat= normalize( a ) ; Point3 r= pt + 2*(u-v) ; cout << "a = " << a << endl ; cout << "ahat = " << ahat << endl ; cout << "r = " << r << endl ; // You can use anonymous constructors as literals. a+= Vector3( 3,4,5 ) ^ Vector3( -9,10,-3) ; // Pass as C array of doubles. glSomething3dv( u.asArray() ) ; glSomething3dv( pt.asArray() ) ; // When you absolutely need to treat a point as a vector cout << q.asVector() << endl ; // When you absolutely need to treat a vector as a point cout << w.asPoint() << endl ; return 0 ; }