00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef FXMAT4D_H
00024 #define FXMAT4D_H
00025
00026
00027 namespace FX {
00028
00029
00030 class FXMat3d;
00031
00032
00033
00034 class FXAPI FXMat4d {
00035 protected:
00036 FXVec4d m[4];
00037 public:
00038
00039
00040 FXMat4d(){}
00041
00042
00043 FXMat4d(const FXMat4d& other);
00044
00045
00046 FXMat4d(const FXMat3d& other);
00047
00048
00049 FXMat4d(FXdouble w);
00050
00051
00052 FXMat4d(FXdouble a,FXdouble b,FXdouble c,FXdouble d);
00053
00054
00055 FXMat4d(FXdouble a00,FXdouble a01,FXdouble a02,FXdouble a03,
00056 FXdouble a10,FXdouble a11,FXdouble a12,FXdouble a13,
00057 FXdouble a20,FXdouble a21,FXdouble a22,FXdouble a23,
00058 FXdouble a30,FXdouble a31,FXdouble a32,FXdouble a33);
00059
00060
00061 FXMat4d(const FXVec4d& a,const FXVec4d& b,const FXVec4d& c,const FXVec4d& d);
00062
00063
00064 FXMat4d& operator=(const FXMat4d& other);
00065 FXMat4d& operator=(const FXMat3d& other);
00066 FXMat4d& operator=(FXdouble w);
00067
00068
00069 FXMat4d& set(const FXMat4d& other);
00070
00071
00072 FXMat4d& set(const FXMat3d& other);
00073
00074
00075 FXMat4d& set(FXdouble w);
00076
00077
00078 FXMat4d& set(FXdouble a,FXdouble b,FXdouble c,FXdouble d);
00079
00080
00081 FXMat4d& set(FXdouble a00,FXdouble a01,FXdouble a02,FXdouble a03,
00082 FXdouble a10,FXdouble a11,FXdouble a12,FXdouble a13,
00083 FXdouble a20,FXdouble a21,FXdouble a22,FXdouble a23,
00084 FXdouble a30,FXdouble a31,FXdouble a32,FXdouble a33);
00085
00086
00087 FXMat4d& set(const FXVec4d& a,const FXVec4d& b,const FXVec4d& c,const FXVec4d& d);
00088
00089
00090 FXMat4d& operator+=(const FXMat4d& w);
00091 FXMat4d& operator-=(const FXMat4d& w);
00092 FXMat4d& operator*=(const FXMat4d& w);
00093 FXMat4d& operator*=(FXdouble w);
00094 FXMat4d& operator/=(FXdouble w);
00095
00096
00097 FXVec4d& operator[](FXint i){return m[i];}
00098 const FXVec4d& operator[](FXint i) const {return m[i];}
00099
00100
00101 operator FXdouble*(){return m[0];}
00102 operator const FXdouble*() const {return m[0];}
00103
00104
00105 FXMat4d operator-() const;
00106
00107
00108 FXMat4d operator+(const FXMat4d& w) const;
00109 FXMat4d operator-(const FXMat4d& w) const;
00110 FXMat4d operator*(const FXMat4d& w) const;
00111
00112
00113 FXVec4d operator*(const FXVec4d& v) const;
00114 FXVec3d operator*(const FXVec3d& v) const;
00115
00116
00117 FXbool operator==(const FXMat4d& a) const;
00118 FXbool operator!=(const FXMat4d& a) const;
00119
00120 friend FXAPI FXbool operator==(const FXMat4d& a,FXdouble n);
00121 friend FXAPI FXbool operator==(FXdouble n,const FXMat4d& a);
00122
00123 friend FXAPI FXbool operator!=(const FXMat4d& a,FXdouble n);
00124 friend FXAPI FXbool operator!=(FXdouble n,const FXMat4d& a);
00125
00126
00127 friend FXAPI FXMat4d operator*(FXdouble x,const FXMat4d& a);
00128 friend FXAPI FXMat4d operator*(const FXMat4d& a,FXdouble x);
00129 friend FXAPI FXMat4d operator/(const FXMat4d& a,FXdouble x);
00130 friend FXAPI FXMat4d operator/(FXdouble x,const FXMat4d& a);
00131
00132
00133 FXMat4d& identity();
00134
00135
00136 FXbool isIdentity() const;
00137
00138
00139 FXMat4d& setOrtho(FXdouble xlo,FXdouble xhi,FXdouble ylo,FXdouble yhi,FXdouble zlo,FXdouble zhi);
00140
00141
00142 void getOrtho(FXdouble& xlo,FXdouble& xhi,FXdouble& ylo,FXdouble& yhi,FXdouble& zlo,FXdouble& zhi) const;
00143
00144
00145 FXMat4d& setInverseOrtho(FXdouble xlo,FXdouble xhi,FXdouble ylo,FXdouble yhi,FXdouble zlo,FXdouble zhi);
00146
00147
00148 FXMat4d& setFrustum(FXdouble xlo,FXdouble xhi,FXdouble ylo,FXdouble yhi,FXdouble zlo,FXdouble zhi);
00149
00150
00151 void getFrustum(FXdouble& xlo,FXdouble& xhi,FXdouble& ylo,FXdouble& yhi,FXdouble& zlo,FXdouble& zhi) const;
00152
00153
00154 FXMat4d& setInverseFrustum(FXdouble xlo,FXdouble xhi,FXdouble ylo,FXdouble yhi,FXdouble zlo,FXdouble zhi);
00155
00156
00157 FXMat4d& left();
00158
00159
00160 FXMat4d& rot(const FXMat3d& r);
00161
00162
00163 FXMat4d& rot(const FXQuatd& q);
00164
00165
00166 FXMat4d& rot(const FXVec3d& v,FXdouble c,FXdouble s);
00167
00168
00169 FXMat4d& rot(const FXVec3d& v,FXdouble phi);
00170
00171
00172 FXMat4d& xrot(FXdouble c,FXdouble s);
00173 FXMat4d& xrot(FXdouble phi);
00174
00175
00176 FXMat4d& yrot(FXdouble c,FXdouble s);
00177 FXMat4d& yrot(FXdouble phi);
00178
00179
00180 FXMat4d& zrot(FXdouble c,FXdouble s);
00181 FXMat4d& zrot(FXdouble phi);
00182
00183
00184 FXMat4d& look(const FXVec3d& from,const FXVec3d& to,const FXVec3d& up);
00185
00186
00187 FXMat4d& trans(FXdouble tx,FXdouble ty,FXdouble tz);
00188 FXMat4d& trans(const FXVec3d& v);
00189
00190
00191 FXMat4d& scale(FXdouble sx,FXdouble sy,FXdouble sz);
00192 FXMat4d& scale(FXdouble s);
00193 FXMat4d& scale(const FXVec3d& v);
00194
00195
00196 FXdouble det() const;
00197
00198
00199 FXMat4d transpose() const;
00200
00201
00202 FXMat4d invert() const;
00203
00204
00205 friend FXAPI FXStream& operator<<(FXStream& store,const FXMat4d& m);
00206
00207
00208 friend FXAPI FXStream& operator>>(FXStream& store,FXMat4d& m);
00209 };
00210
00211 extern FXAPI FXMat4d operator*(FXdouble x,const FXMat4d& a);
00212 extern FXAPI FXMat4d operator*(const FXMat4d& a,FXdouble x);
00213
00214 extern FXAPI FXMat4d operator/(const FXMat4d& a,FXdouble x);
00215 extern FXAPI FXMat4d operator/(FXdouble x,const FXMat4d& a);
00216
00217 extern FXAPI FXbool operator==(const FXMat4d& a,FXdouble n);
00218 extern FXAPI FXbool operator==(FXdouble n,const FXMat4d& a);
00219
00220 extern FXAPI FXbool operator!=(const FXMat4d& a,FXdouble n);
00221 extern FXAPI FXbool operator!=(FXdouble n,const FXMat4d& a);
00222
00223 extern FXAPI FXStream& operator<<(FXStream& store,const FXMat4d& m);
00224 extern FXAPI FXStream& operator>>(FXStream& store,FXMat4d& m);
00225
00226 }
00227
00228 #endif