/***************************************************************************************
*****	                  CLASS VECTOR HEADER                                      *****
****************************************************************************************
** Author: Peter Stuart
** Email:  chester@selway.umt.edu
** Date:   3/7/98
** Description: This class implements a four dimensional vector. Operations include
**   scalar product (dot product), vector product (cross product), magnitude, direction,
**   projection on another vector, angle between two vectors, and vector arithmetic.
**
** NOTE: The matrices, vectors, and points use homogeneous coordinates
** 	
***************************************************************************************/

#include 
#include 

#ifndef __GGVECTOR__
#define __GGVECTOR__

#ifndef FALSE
#define FALSE 0
#endif

#ifndef TRUE
#define TRUE !FALSE
#endif

class Vector {
private:
   /* Private variables:
   _x: x component
   _y: y component
   _z: z component
   _w: w component (should be one for homogeous coordinates)
   */

   double _x;
   double _y;
   double _z;
   double _w;

public:
   // Constructors, Copy Constructor, and Destructor
   Vector(const double xin = 0.0, const double yin = 0.0, 
          const double zin = 0.0, const double win = 1.0);

   Vector(const double p1x, const double p1y, const double p1z, 
          const double p2x, const double p2y, const double p2z, 
          const double pw  = 1.0);

   Vector(const Vector&);
   virtual ~Vector();

   // basic vector operations
   Vector  cross(const Vector&) const;
   double  dot(const Vector&) const;
   double  magnitude() const;
   Vector  direction();
   Vector  projection(const Vector&);
   double  angle(const Vector&);   // angle between vectors in radians

   // Assignment operator, arithmetic operators, relational operators, ouput stream	
          Vector&  operator =  (const Vector&);
   friend Vector   operator +  (const Vector&, const Vector&);   // vector addition
   friend Vector   operator -  (const Vector&, const Vector&);   // vector subtraction
   friend Vector   operator -  (const Vector&);
   friend Vector   operator *  (const Vector&, const double);    // scalar multiplication
   friend Vector   operator *  (const double, const Vector&);    // scalar multiplication
   friend Vector   operator *  (const Vector&, const Vector&);   // vector cross product
   friend Vector   operator /  (const Vector&, const double);    // scalar division
          Vector&  operator += (const Vector&);
          Vector&  operator -= (const Vector&);
          Vector&  operator *= (const double);
          Vector&  operator /= (const double);
   friend int      operator == (const Vector&, const Vector&);
   friend int      operator != (const Vector&, const Vector&);
   friend ostream& operator << (ostream&, const Vector&);

   // variable access
   double x (void) const { return _x; };
   double y (void) const { return _y; };
   double z (void) const { return _z; };
   double w (void) const { return _w; };
   void	  x (const double xin) { _x = xin; };
   void   y (const double yin) { _y = yin; };
   void   z (const double zin) { _z = zin; };
   void	  w (const double win) { _w = win; };
};

// common vector declarations
const Vector zeroVector(0.0, 0.0, 0.0);
const Vector xVector(1.0, 0.0, 0.0);
const Vector yVector(0.0, 1.0, 0.0);
const Vector zVector(0.0, 0.0, 1.0);
const Vector xyzVector(1.0, 1.0, 1.0);

#endif

    Source: geocities.com/collegepark/4206

               ( geocities.com/collegepark)