matrix3.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 
00020 
00021 #ifndef _MATRIX3_HPP_
00022 #define _MATRIX3_HPP_
00023 
00024 #include <iostream>
00025 #include <vector>
00026 
00027 namespace cpe
00028 {
00029     class v3;
00030 
00031     class matrix3
00032     {
00033 
00034     public:
00035 
00036         // ********************************************* //
00037         // ********************************************* //
00038         //  CONSTRUCTORS
00039         // ********************************************* //
00040         // ********************************************* //
00041 
00043         matrix3();
00045         matrix3(const double& x00,const double& x01,const double& x02,
00046                 const double& x10,const double& x11,const double& x12,
00047                 const double& x20,const double& x21,const double& x22);
00048 
00049         // ********************************************* //
00050         // ********************************************* //
00051         //  Special initialization
00052         // ********************************************* //
00053         // ********************************************* //
00054 
00056         static matrix3 identity();
00058         static matrix3 zeros();
00060         static matrix3 rotation(const v3& axis,const double& angle);
00062         static matrix3 scale(const double& s);
00064         static matrix3 scale(const double& s_x,const double& s_y,const double& s_z);
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 matrix3 operator+(const matrix3& m1,const matrix3& m2);
00096         friend matrix3 operator+(const double& s,const matrix3& m);
00098         friend matrix3 operator+(const matrix3& m,const double& s);
00099 
00101         friend matrix3 operator-(const matrix3& m1,const matrix3& m2);
00103         friend matrix3 operator-(const double& s,const matrix3& m);
00105         friend matrix3 operator-(const matrix3& m,const double& s);
00106 
00108         friend matrix3 operator*(const double& s,const matrix3& m);
00110         friend matrix3 operator*(const matrix3& m,const double& s);
00112         friend v3 operator*(const matrix3& m,const v3& v);
00114         friend matrix3 operator*(const matrix3& m1,const matrix3& m2);
00116         friend matrix3 operator/(const matrix3& m,const double& s);
00117 
00118 
00120         matrix3& operator+=(const matrix3& m);
00122         matrix3& operator+=(const double& s);
00124         matrix3& operator-=(const matrix3& m);
00126         matrix3& operator-=(const double& s);
00128         matrix3& operator*=(const double& s);
00130         matrix3& operator/=(const double& s);
00131 
00133         matrix3 operator-() const;
00134 
00138         matrix3 product_compontentwise(const matrix3& m) const;
00143         matrix3& product_compontentwise_internal(const matrix3& m);
00144 
00146         matrix3 transposed() const;
00147 
00148 
00149         // ********************************************* //
00150         // ********************************************* //
00151         //  Output
00152         // ********************************************* //
00153         // ********************************************* //
00154 
00156         friend std::ostream& operator<<(std::ostream& stream,const matrix3& m);
00157 
00158 
00159 
00160 
00161         // ********************************************* //
00162         // ********************************************* //
00163         //  Projection matrix
00164         // ********************************************* //
00165         // ********************************************* //
00166 
00168         std::vector<double> to_4d() const;
00169 
00170     private:
00171 
00172         // ********************************************* //
00173         // ********************************************* //
00174         //  Internal parameters
00175         // ********************************************* //
00176         // ********************************************* //
00177 
00179         double m[9];
00180 
00181 
00182         // ********************************************* //
00183         // ********************************************* //
00184         //  Helper
00185         // ********************************************* //
00186         // ********************************************* //
00187 
00189         void assert_size(const size_t& k1,const size_t& k2) const throw(std::exception);
00190 
00191     };
00192 }
00193 
00194 #endif
Generated on Mon Feb 27 18:30:05 2012 by  doxygen 1.6.3