00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef VEC4_H
00021 #define VEC4_H
00022
00023
00024
00027 class Matrix4x4;
00028
00029
00030
00037 class Vec4
00038 {
00039 public:
00040 Vec4();
00041 Vec4(float *in);
00042 Vec4(float x, float y, float z, float w);
00043 ~Vec4();
00044
00045 Vec4(const Vec4 &other);
00046 Vec4 &operator=(const Vec4 &other);
00047
00048 inline float &operator()(unsigned int i);
00049 inline float operator ()(unsigned int i) const;
00050
00051 Vec4 operator+(const Vec4& other) const;
00052 Vec4 &operator+=(const Vec4& other);
00053
00054 Vec4 operator-(const Vec4& other) const;
00055 Vec4 &operator-=(const Vec4& other);
00056 Vec4 operator-(void) const;
00057
00058 Vec4 operator/(const float &other) const;
00059 Vec4 &operator/=(const float &other);
00060
00061 Vec4 operator*(const float &other) const;
00062 Vec4 &operator*=(const float &other);
00063
00064 Vec4 operator*(const Matrix4x4 &other) const;
00065 Vec4 &operator*=(const Matrix4x4 &other);
00066
00067 bool operator==(const Vec4 &other) const;
00068 bool operator!=(const Vec4 &other) const;
00070 float v[4];
00071 void Zero(void);
00072 void Print(void);
00073 float Length(void);
00074 inline float SqrLength(void);
00075 void Normalise(void);
00076 void Clean(void);
00077 int mainDir(void);
00078 void rotate(float xin, float yin, float zin);
00079 };
00080
00081 Vec4 cross(Vec4 v1, Vec4 v2);
00082 float dot(Vec4 v1, Vec4 v2);
00083
00084
00085
00091 inline float &Vec4::operator()(unsigned int i)
00092 {
00093 return v[i];
00094 }
00095
00101 inline float Vec4::operator ()(unsigned int i) const
00102 {
00103 return v[i];
00104 }
00105
00111 inline float Vec4::SqrLength(void)
00112 {
00113 return v[0]*v[0] + v[1]*v[1] + v[2]*v[2];
00114 }
00115
00116 #endif
00117
00118
00119
00120
00121
00122
00123