matrix3.hpp

Go to the documentation of this file.
00001 /*
00002 **    3ETI Projet CPE Lyon
00003 **    Copyright (C) 2011 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 #ifndef _MATRIX3_HPP_
00021 #define _MATRIX3_HPP_
00022 
00023 #include <iostream>
00024 #include <vector>
00025 
00026 namespace cpe
00027 {
00028     class v3;
00029 
00030     class matrix3
00031     {
00032 
00033     public:
00034 
00035         // ********************************************* //
00036         // ********************************************* //
00037         //  CONSTRUCTORS
00038         // ********************************************* //
00039         // ********************************************* //
00040 
00042         matrix3();
00044         matrix3(const double& x00,const double& x01,const double& x02,
00045                 const double& x10,const double& x11,const double& x12,
00046                 const double& x20,const double& x21,const double& x22);
00047 
00048         // ********************************************* //
00049         // ********************************************* //
00050         //  Special initialization
00051         // ********************************************* //
00052         // ********************************************* //
00053 
00055         static matrix3 identity();
00057         static matrix3 zeros();
00059         static matrix3 rotation(const v3& axis,const double& angle);
00061         static matrix3 scale(const double& s);
00063         static matrix3 scale(const double& s_x,const double& s_y,const double& s_z);
00064 
00065 
00066         // ********************************************* //
00067         // ********************************************* //
00068         //  Element access
00069         // ********************************************* //
00070         // ********************************************* //
00071 
00073         const double& operator()(const size_t& k1,const size_t& k2) const;
00075         double& operator()(const size_t& k1,const size_t& k2);
00076 
00079         const double* pointer() const;
00082         double* pointer_unprotected();
00083 
00084 
00085 
00086         // ********************************************* //
00087         // ********************************************* //
00088         //  Math operator
00089         // ********************************************* //
00090         // ********************************************* //
00091 
00093         friend matrix3 operator+(const matrix3& m1,const matrix3& m2);
00095         friend matrix3 operator+(const double& s,const matrix3& m);
00097         friend matrix3 operator+(const matrix3& m,const double& s);
00098 
00100         friend matrix3 operator-(const matrix3& m1,const matrix3& m2);
00102         friend matrix3 operator-(const double& s,const matrix3& m);
00104         friend matrix3 operator-(const matrix3& m,const double& s);
00105 
00107         friend matrix3 operator*(const double& s,const matrix3& m);
00109         friend matrix3 operator*(const matrix3& m,const double& s);
00111         friend v3 operator*(const matrix3& m,const v3& v);
00113         friend matrix3 operator*(const matrix3& m1,const matrix3& m2);
00115         friend matrix3 operator/(const matrix3& m,const double& s);
00116 
00117 
00119         matrix3& operator+=(const matrix3& m);
00121         matrix3& operator+=(const double& s);
00123         matrix3& operator-=(const matrix3& m);
00125         matrix3& operator-=(const double& s);
00127         matrix3& operator*=(const double& s);
00129         matrix3& operator/=(const double& s);
00130 
00132         matrix3 operator-() const;
00133 
00137         matrix3 product_compontentwise(const matrix3& m) const;
00142         matrix3& product_compontentwise_internal(const matrix3& m);
00143 
00144 
00145 
00146 
00147         // ********************************************* //
00148         // ********************************************* //
00149         //  Output
00150         // ********************************************* //
00151         // ********************************************* //
00152 
00154         friend std::ostream& operator<<(std::ostream& stream,const matrix3& m);
00155 
00156 
00157 
00158 
00159         // ********************************************* //
00160         // ********************************************* //
00161         //  Projection matrix
00162         // ********************************************* //
00163         // ********************************************* //
00164 
00166         std::vector<double> to_4d() const;
00167 
00168     private:
00169 
00170         // ********************************************* //
00171         // ********************************************* //
00172         //  Internal parameters
00173         // ********************************************* //
00174         // ********************************************* //
00175 
00177         double m[9];
00178 
00179 
00180         // ********************************************* //
00181         // ********************************************* //
00182         //  Helper
00183         // ********************************************* //
00184         // ********************************************* //
00185 
00187         void assert_size(const size_t& k1,const size_t& k2) const throw(std::exception);
00188 
00189     };
00190 }
00191 
00192 #endif
Generated on Fri Apr 1 17:22:40 2011 by  doxygen 1.6.3