Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

/home/jeroen/FOX/fox/fox-1.7.33/include/FXMat4f.h
00001 /********************************************************************************
00002 *                                                                               *
00003 *            S i n g l e - P r e c i s i o n   4 x 4   M a t r i x              *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1994,2012 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or modify          *
00009 * it under the terms of the GNU Lesser General Public License as published by   *
00010 * the Free Software Foundation; either version 3 of the License, or             *
00011 * (at your option) any later version.                                           *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                 *
00016 * GNU Lesser General Public License for more details.                           *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public License      *
00019 * along with this program.  If not, see <http://www.gnu.org/licenses/>          *
00020 ********************************************************************************/
00021 #ifndef FXMAT4F_H
00022 #define FXMAT4F_H
00023 
00024 
00025 namespace FX {
00026 
00027 
00028 class FXQuatf;
00029 class FXMat3f;
00030 
00031 
00033 class FXAPI FXMat4f {
00034 protected:
00035   FXVec4f m[4];
00036 public:
00037 
00039   FXMat4f(){}
00040 
00042   FXMat4f(FXfloat s);
00043 
00045   FXMat4f(const FXMat3f& s);
00046 
00048   FXMat4f(const FXMat4f& s);
00049 
00051   FXMat4f(const FXfloat s[]);
00052 
00054   FXMat4f(FXfloat a,FXfloat b,FXfloat c,FXfloat d);
00055 
00057   FXMat4f(FXfloat a00,FXfloat a01,FXfloat a02,FXfloat a03,
00058           FXfloat a10,FXfloat a11,FXfloat a12,FXfloat a13,
00059           FXfloat a20,FXfloat a21,FXfloat a22,FXfloat a23,
00060           FXfloat a30,FXfloat a31,FXfloat a32,FXfloat a33);
00061 
00063   FXMat4f(const FXVec4f& a,const FXVec4f& b,const FXVec4f& c,const FXVec4f& d);
00064 
00066   FXMat4f(const FXQuatf& quat);
00067 
00069   FXMat4f& operator=(FXfloat s);
00070 
00072   FXMat4f& operator=(const FXMat3f& s);
00073   FXMat4f& operator=(const FXMat4f& s);
00074 
00076   FXMat4f& operator=(const FXQuatf& quat);
00077 
00079   FXMat4f& operator=(const FXfloat s[]);
00080 
00082   FXMat4f& set(FXfloat s);
00083 
00085   FXMat4f& set(const FXMat3f& s);
00086 
00088   FXMat4f& set(const FXMat4f& s);
00089 
00091   FXMat4f& set(const FXfloat s[]);
00092 
00094   FXMat4f& set(FXfloat a,FXfloat b,FXfloat c,FXfloat d);
00095 
00097   FXMat4f& set(FXfloat a00,FXfloat a01,FXfloat a02,FXfloat a03,
00098                FXfloat a10,FXfloat a11,FXfloat a12,FXfloat a13,
00099                FXfloat a20,FXfloat a21,FXfloat a22,FXfloat a23,
00100                FXfloat a30,FXfloat a31,FXfloat a32,FXfloat a33);
00101 
00103   FXMat4f& set(const FXVec4f& a,const FXVec4f& b,const FXVec4f& c,const FXVec4f& d);
00104 
00106   FXMat4f& set(const FXQuatf& quat);
00107 
00109   FXMat4f& operator+=(const FXMat4f& s);
00110   FXMat4f& operator-=(const FXMat4f& s);
00111   FXMat4f& operator*=(const FXMat4f& s);
00112   FXMat4f& operator*=(FXfloat s);
00113   FXMat4f& operator/=(FXfloat s);
00114 
00116   FXVec4f& operator[](FXint i){return m[i];}
00117   const FXVec4f& operator[](FXint i) const {return m[i];}
00118 
00120   operator FXfloat*(){return m[0];}
00121   operator const FXfloat*() const {return m[0];}
00122 
00124   FXMat4f operator-() const;
00125 
00127   FXMat4f& identity();
00128 
00130   FXbool isIdentity() const;
00131 
00133   FXMat4f& setOrtho(FXfloat xlo,FXfloat xhi,FXfloat ylo,FXfloat yhi,FXfloat zlo,FXfloat zhi);
00134 
00136   void getOrtho(FXfloat& xlo,FXfloat& xhi,FXfloat& ylo,FXfloat& yhi,FXfloat& zlo,FXfloat& zhi) const;
00137 
00139   FXMat4f& setInverseOrtho(FXfloat xlo,FXfloat xhi,FXfloat ylo,FXfloat yhi,FXfloat zlo,FXfloat zhi);
00140 
00142   FXMat4f& setFrustum(FXfloat xlo,FXfloat xhi,FXfloat ylo,FXfloat yhi,FXfloat zlo,FXfloat zhi);
00143 
00145   void getFrustum(FXfloat& xlo,FXfloat& xhi,FXfloat& ylo,FXfloat& yhi,FXfloat& zlo,FXfloat& zhi) const;
00146 
00148   FXMat4f& setInverseFrustum(FXfloat xlo,FXfloat xhi,FXfloat ylo,FXfloat yhi,FXfloat zlo,FXfloat zhi);
00149 
00151   FXMat4f& left();
00152 
00154   FXMat4f& rot(const FXMat3f& r);
00155 
00157   FXMat4f& rot(const FXQuatf& q);
00158 
00160   FXMat4f& rot(const FXVec3f& v,FXfloat c,FXfloat s);
00161 
00163   FXMat4f& rot(const FXVec3f& v,FXfloat phi);
00164 
00166   FXMat4f& xrot(FXfloat c,FXfloat s);
00167   FXMat4f& xrot(FXfloat phi);
00168 
00170   FXMat4f& yrot(FXfloat c,FXfloat s);
00171   FXMat4f& yrot(FXfloat phi);
00172 
00174   FXMat4f& zrot(FXfloat c,FXfloat s);
00175   FXMat4f& zrot(FXfloat phi);
00176 
00178   FXMat4f& look(const FXVec3f& from,const FXVec3f& to,const FXVec3f& up);
00179 
00181   FXMat4f& trans(FXfloat tx,FXfloat ty,FXfloat tz);
00182   FXMat4f& trans(const FXVec3f& v);
00183 
00185   FXMat4f& scale(FXfloat sx,FXfloat sy,FXfloat sz);
00186   FXMat4f& scale(const FXVec3f& v);
00187   FXMat4f& scale(FXfloat s);
00188 
00190   FXfloat det() const;
00191 
00193   FXMat4f transpose() const;
00194 
00196   FXMat4f invert() const;
00197 
00199   FXMat4f affineInvert() const;
00200 
00202   FXMat4f rigidInvert() const;
00203 
00205   FXMat3f normalMatrix() const;
00206   
00208  ~FXMat4f(){}
00209   };
00210 
00211 
00213 extern FXAPI FXVec3f operator*(const FXMat4f& m,const FXVec3f& v);
00214 extern FXAPI FXVec4f operator*(const FXMat4f& m,const FXVec4f& v);
00215 
00217 extern FXAPI FXVec3f operator*(const FXVec3f& v,const FXMat4f& m);
00218 extern FXAPI FXVec4f operator*(const FXVec4f& v,const FXMat4f& m);
00219 
00221 extern FXAPI FXMat4f operator+(const FXMat4f& a,const FXMat4f& b);
00222 extern FXAPI FXMat4f operator-(const FXMat4f& a,const FXMat4f& b);
00223 
00225 extern FXAPI FXMat4f operator*(const FXMat4f& a,const FXMat4f& b);
00226 
00228 extern FXAPI FXMat4f operator*(FXfloat x,const FXMat4f& a);
00229 extern FXAPI FXMat4f operator*(const FXMat4f& a,FXfloat x);
00230 extern FXAPI FXMat4f operator/(const FXMat4f& a,FXfloat x);
00231 extern FXAPI FXMat4f operator/(FXfloat x,const FXMat4f& a);
00232 
00234 extern FXAPI FXbool operator==(const FXMat4f& a,const FXMat4f& b);
00235 extern FXAPI FXbool operator!=(const FXMat4f& a,const FXMat4f& b);
00236 extern FXAPI FXbool operator==(const FXMat4f& a,FXfloat n);
00237 extern FXAPI FXbool operator!=(const FXMat4f& a,FXfloat n);
00238 extern FXAPI FXbool operator==(FXfloat n,const FXMat4f& a);
00239 extern FXAPI FXbool operator!=(FXfloat n,const FXMat4f& a);
00240 
00242 extern FXAPI FXStream& operator<<(FXStream& store,const FXMat4f& m);
00243 
00245 extern FXAPI FXStream& operator>>(FXStream& store,FXMat4f& m);
00246 
00247 }
00248 
00249 #endif

Copyright © 1997-2011 Jeroen van der Zijp