Main Page | Class Hierarchy | Class List | File List | Class Members

vuVector.h

00001 /* Written by Steven Kilthau */
00002 
00003 #ifndef _VECTOR_H_
00004 #define _VECTOR_H_
00005 
00006 #include <iostream>
00007 
00008 #include "vuSimpleTypes.h"
00009 
00010 class vuVector; //forward declaration.
00011 typedef vuVector* vuVectorPointer;
00012 typedef vuVectorPointer* vuVectorPointerArray;
00013 
00014 class vuMatrix;
00015 
00017 
00025 class vuVector
00026 {
00027 friend class vuMatrix;
00028 public:
00030     vuVector();
00032     vuVector(const vuVector& v);
00034     vuVector(double v1, double v2, double v3);
00036     vuVector(double v1, double v2, double v3, double v4);
00038     vuVector(double v);
00040 
00042     vuVector(const double* v);
00044     ~vuVector();
00045 
00047     vuVector& operator=(const vuVector& v);
00049     vuVector& operator=(double v);
00051     vuVector& operator=(const double* v);
00052 
00054     double norm(void) const;
00056     double norm2(void) const;
00057 
00059 
00061     vuVector& makeUnit(void);
00063 
00065     vuVector& normalize(void);
00066 
00068 
00071     vuVector inv(void) const;
00073     vuVector& invEq(void);
00075     vuVector mul(const vuVector& rhs) const;
00077     vuVector& mulEq(const vuVector& rhs);
00079     vuVector div(const vuVector& rhs) const;
00081     vuVector& divEq(const vuVector& rhs);
00082 
00084     double& operator[](dword index);
00086     const double& operator[](dword index) const;
00087 
00089 
00095     double* getData(void);
00097     double const* getData(void) const;
00098     
00100     friend double dot(const vuVector& v1,const vuVector& v2);
00105     friend vuVector cross(const vuVector& v1,const vuVector& v2);
00107     double dot(const vuVector& v) const;
00112     vuVector cross(const vuVector& v) const;
00113 
00115     vuVector operator+(const vuVector& v) const;
00117     vuVector operator-(const vuVector& v) const;
00119     vuVector operator*(const vuMatrix& m) const;
00121     vuMatrix operator*(const vuVector& v) const;
00123     vuVector operator*(double s) const;
00125     vuVector vuVector::operator/(double s) const;
00127     friend const vuVector operator*(double s, const vuVector& v);
00129     vuVector& operator+=(const vuVector& v);
00131     vuVector& operator-=(const vuVector& v);
00133     vuVector& operator*=(const vuMatrix& m);
00135     vuVector& operator*=(double s);
00136 
00138     bool operator==(const vuVector& v) const;
00140     bool operator!=(const vuVector& v) const;
00141 
00143     int getDominantAxis() const;
00144 
00146     friend std::ostream& operator<<(std::ostream& out,const vuVector& v);
00148     friend std::istream& operator>>(std::istream& in, vuVector& v);
00149 
00150 private:
00152     double val[4];
00153 };
00154 
00155 #endif

Generated on Thu Apr 13 04:55:56 2006 by  doxygen 1.4.4