v4.hpp

Go to the documentation of this file.
00001 /*
00002 **    TP ETI5 CPE Lyon
00003 **    Copyright (C) 2010 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 _V4_HPP_
00021 #define _V4_HPP_
00022 
00023 #include <iostream>
00024 
00025 namespace cpe
00026 {
00027 
00028     class v3;
00029 
00031     class v4
00032     {
00033     public:
00034 
00035         // ********************************************* //
00036         // ********************************************* //
00037         //  CONSTRUCTORS
00038         // ********************************************* //
00039         // ********************************************* //
00040 
00042         v4();
00044         v4(const double& x,const double& y,const double& z,const double& w);
00046         v4(const v3& xyz,const double& w);
00047 
00048         // ********************************************* //
00049         // ********************************************* //
00050         //  Get/set
00051         // ********************************************* //
00052         // ********************************************* //
00053 
00055         const double& x() const;
00057         double& x();
00059         const double& y() const;
00061         double& y();
00063         const double& z() const;
00065         double& z();
00067         const double& w() const;
00069         double& w();
00070 
00072         const double& operator[](const size_t& k) const;
00074         double& operator[](const size_t& k);
00076         const double& operator()(const size_t& k) const;
00078         double& operator()(const size_t& k);
00079 
00080 
00082         void set_zero();
00083 
00084 
00085         // ********************************************* //
00086         // ********************************************* //
00087         //  Math operation
00088         // ********************************************* //
00089         // ********************************************* //
00090 
00092         double dot(const v4& p) const;
00093 
00095         double norm() const;
00097         double norm2() const;
00098 
00099 
00100 
00101 
00102 
00103 
00104         // ********************************************* //
00105         // ********************************************* //
00106         //  Operator +-*/
00107         // ********************************************* //
00108         // ********************************************* //
00109 
00111         friend v4 operator+(const v4& p1,const v4& p2);
00113         friend v4 operator+(const double& s,const v4& p);
00115         friend v4 operator+(const v4& p,const double& s);
00116 
00118         friend v4 operator-(const v4& p1,const v4& p2);
00120         friend v4 operator-(const double& s,const v4& p);
00122         friend v4 operator-(const v4& p,const double& s);
00123 
00125         friend v4 operator*(const double& s,const v4& p);
00127         friend v4 operator*(const v4& p,const double& s);
00129         friend v4 operator/(const v4& p,const double& s);
00130 
00132         v4& operator+=(const v4& p);
00134         v4& operator+=(const double& s);
00136         v4& operator-=(const v4& p);
00138         v4& operator-=(const double& s);
00140         v4& operator*=(const double& s);
00142         v4& operator/=(const double& s);
00143 
00145         v4 operator-() const;
00146 
00150         v4 product_compontentwise(const v4& p) const;
00155         v4& product_compontentwise_internal(const v4& p);
00156 
00157 
00158         // ********************************************* //
00159         // ********************************************* //
00160         //  Output
00161         // ********************************************* //
00162         // ********************************************* //
00163 
00165         std::string to_string() const;
00166 
00168         friend std::ostream& operator<<(std::ostream& stream,const v4& p);
00169 
00170 
00171 
00172     private:
00173 
00174         // ********************************************* //
00175         // ********************************************* //
00176         //  Internal parameters
00177         // ********************************************* //
00178         // ********************************************* //
00179 
00181         double internal_x;
00183         double internal_y;
00185         double internal_z;
00187         double internal_w;
00188 
00189 
00190         // ********************************************* //
00191         // ********************************************* //
00192         //  Helper
00193         // ********************************************* //
00194         // ********************************************* //
00195 
00197         void assert_size(const size_t& k) const throw(std::exception);
00198 
00199 
00200     };
00201 
00202 }
00203 
00204 #endif
Generated on Tue Dec 28 10:12:04 2010 by  doxygen 1.6.3