Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

CMat4D.h

Go to the documentation of this file.
00001 /* 00002 * CMat4D.h 00003 * $Id: CMat4D.h,v 1.4 2003/06/24 14:50:02 anxo Exp $ 00004 * 00005 * Copyright (C) 1999, 2000 Michael Meissner, Markus Janich, Rainer Jaeger 00006 * 00007 * This program is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 * 00021 * As a special exception to the GPL, the QGLViewer authors (Markus 00022 * Janich, Michael Meissner, Richard Guenther, Alexander Buck and Thomas 00023 * Woerner) give permission to link this program with Qt (non-)commercial 00024 * edition, and distribute the resulting executable, without including 00025 * the source code for the Qt (non-)commercial edition in the source 00026 * distribution. 00027 * 00028 */ 00029 00030 // Description : Class CMat4D 00031 // Purpose : Provides funcionality of a matrix 00032 00033 00034 #ifndef __CMAT4D_H_ 00035 #define __CMAT4D_H_ 00036 00037 00038 // Qt 00040 00041 00042 // System 00044 #if _MSC_VER >= 1200 00045 #include <iostream> 00046 #else 00047 #include <iostream.h> 00048 #endif 00049 #include <math.h> 00050 #include <string.h> 00051 00052 00053 // Own 00055 #include "CV4D.h" 00056 #include "CQuat.h" 00057 #include "CP4D.h" 00058 00059 00060 00062 00085 class CMat4D { 00086 00087 public: 00089 CMat4D(void); 00090 00094 CMat4D(const CV4D&, const CV4D&, const CV4D&, const CV4D&); 00095 00099 CMat4D(const double*); 00100 00102 CMat4D(double, double, double, double, double, double, double, double, 00103 double, double, double, double, double, double, double, double); 00104 00106 CMat4D(const CMat4D&); 00107 00109 static CMat4D PIdentity(void); 00110 00113 static CMat4D PTranslate(const CV4D&); 00114 00116 static CMat4D PTranslate(const CV3D&); 00117 00119 static CMat4D PTranslate(double, double, double); 00120 00123 static CMat4D PScale(const CV4D&); 00124 00126 static CMat4D PScale(const CV3D&); 00127 00129 static CMat4D PScale(double, double, double); 00130 00134 static CMat4D PRotate(const CV4D&, double); 00135 00138 static CMat4D PRotate(const CV3D&, double); 00139 00141 static CMat4D PRotate(CQuat&); 00142 00144 ~CMat4D(void); 00145 00146 00147 00149 // OVERLOADED OPERATORS // 00151 00153 const CMat4D& operator=(const CMat4D&); 00154 00156 const CMat4D& operator=(const double a); 00157 00159 CMat4D& operator+=(const CMat4D &m); 00160 00161 /* Substract matrix from this matrix */ 00162 CMat4D& operator-=(const CMat4D &m); 00163 00165 CMat4D& operator*=(const CMat4D&); 00166 00167 00169 CMat4D operator+(const CMat4D&) const; 00170 00172 CMat4D operator-(const CMat4D&) const; 00173 00175 CMat4D operator*(const CMat4D &m) const; 00176 00178 CMat4D operator*(double scalar) const; 00179 00181 bool operator == (const CMat4D &m) const; 00182 00184 bool operator != (const CMat4D &m) const; 00185 00186 00188 double operator()(int i,int j) const; 00189 00191 CV4D operator[](int i) const; 00192 00194 CV4D operator()(int j) const; 00195 00196 00198 friend CV4D operator*(const CMat4D&, const CV4D&); 00199 00201 friend CP4D operator*(const CMat4D&, const CP4D&); 00202 00204 friend CMat4D operator*(double, const CMat4D&); 00205 00207 friend CMat4D operator*(const CMat4D& M, double rdFactor) { return rdFactor*M; }; 00208 00209 00210 00212 // METHODS // 00214 00216 const double *getArray() { return m_ardValues; }; 00217 00219 void clear(void); 00220 00224 void setValues(double* field); 00225 00227 double getCoeff(int i,int j) const; 00228 00230 void setCoeff(int i,int j, double value); 00231 00233 CMat4D getTransposed(void) const; 00234 00235 // Inverted 00236 CMat4D getInverted(void) const; 00237 00239 bool invert(void); 00240 00242 void transpose(void); 00243 00245 void print(void); 00246 00248 friend ::ostream& operator << (::ostream& s, const CMat4D &m ); 00249 00251 void setIdentity( void ); 00252 00254 CV4D getRow(int); 00255 00257 CV4D getCol(int); 00258 00260 void setRow(int nRow, const CV4D&); 00261 00263 void setCol(int nCol, const CV4D&); 00265 void setRows(const CV4D&, const CV4D&, const CV4D&, const CV4D&); 00266 00268 void setCols(const CV4D&, const CV4D&, const CV4D&, const CV4D&); 00269 00273 void setScaling(const CV4D&); 00274 00278 void setScaling(const CV3D&); 00279 00283 void setScaling(double, double, double); 00284 00288 void setTranslation(const CV4D&); 00289 00293 void setTranslation(const CV3D&); 00294 00298 void setTranslation(double, double, double); 00299 00301 void setRotation(CV4D&, double); 00302 00304 void setRotation(CV3D&, double); 00305 00307 void setRotation(CQuat&); 00308 00309 00310 00311 private: 00313 double* get1DField(void); 00314 00316 double** get2DField(void); 00317 00318 double m_ardValues[16]; // In the array the values of the matrix are saved by columns. 00319 }; 00320 00321 #endif // __CMAT4D_H_

Generated on Fri Aug 13 17:43:12 2004 for QGLViewer by doxygen 1.3.7