matrix4.hpp

Go to the documentation of this file.
00001 /*
00002 **    TP 4ETI CPE Lyon
00003 **    Copyright (C) 2012 Damien Rohmer
00004 **
00005 **    This program is free software: you can redistribute it and/or modify
00006 **    it under the terms of the GNU General Public License as published by
00007 **    the Free Software Foundation, either version 3 of the License, or
00008 **    (at your option) any later version.
00009 **
00010 **   This program is distributed in the hope that it will be useful,
00011 **    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 **    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 **    GNU General Public License for more details.
00014 **
00015 **    You should have received a copy of the GNU General Public License
00016 **    along with this program.  If not, see <http://www.gnu.org/licenses/>.
00017 */
00018 
00019 #ifndef _MATRIX4_HPP_
00020 #define _MATRIX4_HPP_
00021 
00022 #include <iostream>
00023 #include <vector>
00024 
00025 namespace cpe
00026 {
00027 class v4;
00028 class v3;
00029 
00030 class matrix4
00031 {
00032 
00033     public:
00034 
00035         // ********************************************* //
00036         // ********************************************* //
00037         //  CONSTRUCTORS
00038         // ********************************************* //
00039         // ********************************************* //
00040 
00042         matrix4();
00044         matrix4(const double& x00,const double& x01,const double& x02,const double& x03,
00045                 const double& x10,const double& x11,const double& x12,const double& x13,
00046                 const double& x20,const double& x21,const double& x22,const double& x23,
00047                 const double& x30,const double& x31,const double& x32,const double& x33);
00048 
00049         // ********************************************* //
00050         // ********************************************* //
00051         //  Special initialization
00052         // ********************************************* //
00053         // ********************************************* //
00054 
00056         static matrix4 identity();
00058         static matrix4 zeros();
00060         static matrix4 rotation(const v3& axis,const double& angle);
00062         static matrix4 scale(const double& s);
00064         static matrix4 scale(const double& s_x,const double& s_y,const double& s_z,const double& s_w);
00065 
00066 
00067         // ********************************************* //
00068         // ********************************************* //
00069         //  Element access
00070         // ********************************************* //
00071         // ********************************************* //
00072 
00074         const double& operator()(const size_t& k1,const size_t& k2) const;
00076         double& operator()(const size_t& k1,const size_t& k2);
00077 
00080         const double* pointer() const;
00083         double* pointer_unprotected();
00084 
00085 
00086 
00087         // ********************************************* //
00088         // ********************************************* //
00089         //  Math operator
00090         // ********************************************* //
00091         // ********************************************* //
00092 
00094         friend matrix4 operator+(const matrix4& m1,const matrix4& m2);
00096         friend matrix4 operator+(const double& s,const matrix4& m);
00098         friend matrix4 operator+(const matrix4& m,const double& s);
00099 
00101         friend matrix4 operator-(const matrix4& m1,const matrix4& m2);
00103         friend matrix4 operator-(const double& s,const matrix4& m);
00105         friend matrix4 operator-(const matrix4& m,const double& s);
00106 
00108         friend matrix4 operator*(const double& s,const matrix4& m);
00110         friend matrix4 operator*(const matrix4& m,const double& s);
00112         friend v4 operator*(const matrix4& m,const v4& v);
00114         friend v4 operator*(const v4& v,const matrix4& m);
00116         friend matrix4 operator*(const matrix4& m1,const matrix4& m2);
00118         friend matrix4 operator/(const matrix4& m,const double& s);
00119 
00120 
00122         matrix4& operator+=(const matrix4& m);
00124         matrix4& operator+=(const double& s);
00126         matrix4& operator-=(const matrix4& m);
00128         matrix4& operator-=(const double& s);
00130         matrix4& operator*=(const double& s);
00132         matrix4& operator/=(const double& s);
00133 
00135         matrix4 operator-() const;
00136 
00140         matrix4 product_compontentwise(const matrix4& m) const;
00145         matrix4& product_compontentwise_internal(const matrix4& m);
00146 
00148         double scalar_product(const v4& a,const v4& b) const;
00149 
00151         matrix4 transposed() const;
00152 
00153 
00154         // ********************************************* //
00155         // ********************************************* //
00156         //  Output
00157         // ********************************************* //
00158         // ********************************************* //
00159 
00161         friend std::ostream& operator<<(std::ostream& stream,const matrix4& m);
00162 
00163 
00164 
00165 
00166 
00167     private:
00168 
00169         // ********************************************* //
00170         // ********************************************* //
00171         //  Internal parameters
00172         // ********************************************* //
00173         // ********************************************* //
00174 
00176         double m[16];
00177 
00178 
00179         // ********************************************* //
00180         // ********************************************* //
00181         //  Helper
00182         // ********************************************* //
00183         // ********************************************* //
00184 
00186         void assert_size(const size_t& k1,const size_t& k2) const throw(std::exception);
00187 
00188 };
00189 }
00190 
00191 #endif
Generated on Mon Feb 27 18:30:05 2012 by  doxygen 1.6.3