00001
00002
00003 #ifndef _VECTOR_H_
00004 #define _VECTOR_H_
00005
00006 #include <stdlib.h>
00007 #include <string.h>
00008 #include <iostream.h>
00009
00010 #include "vuSimpleTypes.h"
00011 #include "vuString.h"
00012
00013 class vuVector;
00014 typedef vuVector* vuVectorPointer;
00015 typedef vuVectorPointer* vuVectorPointerArray;
00016
00017 class vuMatrix;
00018
00020
00028 class vuVector
00029 {
00030 friend class vuMatrix;
00031 public:
00033 vuVector();
00035 vuVector(const vuVector& v);
00037 vuVector(float v1, float v2, float v3);
00039 vuVector(float v1, float v2, float v3, float v4);
00041 vuVector(float v);
00043
00045 vuVector(const float* v);
00047 ~vuVector();
00048
00050 vuVector& operator=(const vuVector& v);
00052 vuVector& operator=(float v);
00054 vuVector& operator=(const float* v);
00055
00057 float norm(void) const;
00059 float norm2(void) const;
00060
00062
00064 vuVector& makeUnit(void);
00066
00068 vuVector& normalize(void);
00069
00071
00074 vuVector inv(void) const;
00076 vuVector& invEq(void);
00078 vuVector mul(const vuVector& rhs) const;
00080 vuVector& mulEq(const vuVector& rhs);
00082 vuVector div(const vuVector& rhs) const;
00084 vuVector& divEq(const vuVector& rhs);
00085
00087 float& operator[](dword index);
00089 const float& operator[](dword index) const;
00090
00092
00098 float* getData(void);
00100 float const* getData(void) const;
00101
00103 friend float dot(const vuVector& v1,const vuVector& v2);
00105 friend vuVector cross(const vuVector& v1,const vuVector& v2);
00107 float dot(const vuVector& v) const;
00109 vuVector cross(const vuVector& v) const;
00110
00112 vuVector operator+(const vuVector& v) const;
00114 vuVector operator-(const vuVector& v) const;
00116 vuVector operator*(const vuMatrix& m) const;
00118 vuMatrix operator*(const vuVector& v) const;
00120 vuVector operator*(float s) const;
00122 vuVector vuVector::operator/(float s) const;
00124 friend const vuVector operator*(float s, const vuVector& v);
00126 vuVector& operator+=(const vuVector& v);
00128 vuVector& operator-=(const vuVector& v);
00130 vuVector& operator*=(const vuMatrix& m);
00132 vuVector& operator*=(float s);
00133
00135 bool operator==(const vuVector& v) const;
00137 bool operator!=(const vuVector& v) const;
00138
00140 int getDominantAxis() const;
00141
00143 void print();
00144
00146
00151 int load (char* load_from);
00153
00154 void save (char* save_to);
00155
00157 friend ostream& operator<<(ostream& out,const vuVector& v);
00159 friend istream& operator>>(istream& in, vuVector& v);
00160
00162 vuString getString();
00163
00164 private:
00166 float val[4];
00167 };
00168
00170 int get_next_comma (char* temp);
00172 int get_next_blank (char* temp);
00174 int clear_blanks (char* temp);
00176 int get_next_return (char* temp);
00177
00178
00179 #endif