// cVector.h
// 2/27/04
// Forrest Briggs
// This is a standard 3d vector class with artimetic, dot and 
// cross products, normalize and length.
// Implements all of the functionality in Z's Touple class,
// but has x_, y_, and z_ instead of x_, y_ and z_.
// 3/5/04
// Forrest Briggs
// Added matrix multiplication

#ifndef cvector_h
#define cvector_h

#include <iostream>
using namespace std;

class cVector
{
 public:
        float x_, y_, z_;
        
	// constructors
	cVector() {x_=y_=z_=0;}						// default construcotr
	cVector(const float x, const float y, const float z)		// constructor
		{x_=x, y_=y, z_=z;}
	cVector(const cVector& toCopy);					// copy constructor

	// destructor
	virtual ~cVector() {};

	// operators
	cVector&	operator =	(const cVector& toCopy);	// assignment
	const bool	operator ==	(const cVector& toCompare) const;// equality
	const bool	operator !=	(const cVector& toCompare) const;// inequality
	const cVector	operator +	(const cVector& toAdd) const;	// addition
	cVector&	operator +=	(const cVector& toAdd);		// unary addition
	const cVector	operator -	() const;			// negation 
	const cVector	operator -	(const cVector& toSub) const;	// subtraction
	cVector&	operator -=	(const cVector& toSub);		// unary subtraction
	cVector&	operator *=	(float scaleFactor);		// scalar unary multiplication
	cVector&	operator /=	(float scaleFactor);		// sclar division
        
        float&		operator[]	(const int index);		// index
	const float&	operator[]	(const int index) const;	// read only indexing

	// vector operations
	const float	dot(const cVector& toDot) const;		// dot product
	const cVector 	cross(const cVector& toCross) const;		// cross product
	cVector& 	normalize(void);				// normalize
	const float 	length(void) const;				// compute length
        
        cVector 	matrixMultiply(float m[]);			// compute the product with a 4x4 column-major indexed matrix
};

//  related functions
const cVector	operator *(const cVector& toMultiply, const float& scaleFactor);
const cVector	operator *(const float& scaleFactor, const cVector& toMultiply);
const cVector 	operator /(const cVector& toDivide, const float& scaleFactor);
ostream&	operator<<(ostream &out_file, const cVector& thecVector);


#endif // end define cvector_h