00001 /*************************************************************************** 00002 matrix.h - A 3D rotation matrix class 00003 ------------------- 00004 begin : Fri Jul 6 2001 00005 copyright : (C) 2001 by CJP 00006 email : cornware-cjp@users.sourceforge.net 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 #ifndef LIBPLANETCMATRIX_H 00018 #define LIBPLANETCMATRIX_H 00019 00020 #include <libprocter/cvector.h> 00021 00022 namespace libProcTer { 00023 00033 class CMatrix 00034 { 00035 public: 00037 CMatrix(); 00038 00040 CMatrix(CMatrix const &val); 00041 00043 ~CMatrix(); 00044 00046 void reset(); 00047 00049 void setCrossProduct(CVector v); 00050 00056 void setRotation(CVector v); 00057 00062 CVector getRotation() const; 00063 00064 //Matrix-operations: 00066 CMatrix const &operator=(CMatrix const &val); 00068 CMatrix const &operator*=(CMatrix const &val); 00070 CMatrix const &operator*=(double val); 00075 CMatrix const &operator/=(CMatrix const &val); 00077 CMatrix operator*(CMatrix const &val) const; 00082 CMatrix transpose() const; 00083 00084 //Multiplication with a vector 00086 CVector const operator*(CVector val) const; 00091 CVector const operator/(CVector val) const; 00092 00093 //Multiplication with a scalar 00095 CMatrix const operator*(double val) const; 00097 CMatrix const operator/(double val) const; 00098 00099 00100 //Special ways to create the right rotation matrix: 00102 void rotX ( double hoek); 00104 void rotY ( double hoek); 00106 void rotZ ( double hoek); 00111 void targetZ(CVector d, bool normalize=true); 00112 00114 void fixRotationMatrix(); 00115 00117 double Element(int i, int j) const; 00119 void setElement(int i, int j, double e); 00124 const double *gl_mtr() const; 00125 00126 protected: 00127 00129 double *m_M; 00130 }; 00131 00132 } 00133 00134 #endif