MC_v4d.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef MC_V4D_HPP
00022 #define MC_V4D_HPP
00023
00024 #include <iostream>
00025 #include <cmath>
00026
00027
00028
00029
00030
00031 namespace mesh_conv
00032 {
00033
00034 class MC_v3d;
00035 class MC_matrix;
00036
00038
00040 class MC_v4d
00041 {
00042 public:
00043
00044
00045
00046
00047
00048
00049
00051 MC_v4d();
00053 MC_v4d(const double& x,const double& y,const double& z,const double& w);
00055 MC_v4d(const MC_v4d& _v);
00059 MC_v4d(const double* _v);
00064 MC_v4d(const std::string& s);
00065
00067 MC_v4d(const MC_matrix& M);
00068
00070 MC_v4d(const MC_v3d& vec);
00071
00073 ~MC_v4d();
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00087 MC_v4d operator-() const;
00088
00092 friend MC_v4d operator+(const MC_v4d& vec,const double& to_add);
00096 friend MC_v4d operator-(const MC_v4d& vec,const double& to_sub);
00100 friend MC_v4d operator*(const MC_v4d& vec,const double& to_mult);
00104 friend MC_v4d operator*(const double& to_mult,const MC_v4d& vec);
00108 friend MC_v4d operator/(const MC_v4d& vec,const double& to_subdiv);
00109
00110
00114 friend MC_v4d operator+(const MC_v4d& vec,const MC_v4d& to_add);
00118 friend MC_v4d operator-(const MC_v4d& vec,const MC_v4d& to_sub);
00119
00120
00122 MC_v4d& operator+=(const double& to_add);
00124 MC_v4d& operator-=(const double& to_sub);
00126 MC_v4d& operator*=(const double& to_mult);
00128 MC_v4d& operator/=(const double& to_subdiv);
00129
00131 MC_v4d& operator+=(const MC_v4d& to_add);
00133 MC_v4d& operator-=(const MC_v4d& to_sub);
00134
00138 MC_v4d& scale(const double& sx,const double& sy,const double& sz,const double& sw);
00142 MC_v4d& scale(const MC_v4d& scaling);
00146 MC_v4d& scale(const double& scaling);
00147
00151 MC_v4d mask(const double& sx,const double& sy,const double& sz,const double& sw) const;
00155 MC_v4d mask(const MC_v4d& scaling) const;
00159 MC_v4d scale(const double& scaling) const;
00160
00162 double dot(const MC_v4d& vec) const;
00164 double norm() const;
00168 MC_v4d normalized() const;
00169
00170
00172 MC_v4d& operator*=(const MC_matrix& M);
00173
00174
00176 MC_v4d& set_v3d(const MC_v3d& vec);
00177
00178
00179
00180
00181
00182
00183
00184
00186 const double& operator()(const int& k_dim) const;
00188 double& operator()(const int& k_dim);
00190 const double& operator[](const int& k_dim) const;
00192 double& operator[](const int& k_dim);
00193
00197 const double* pointer() const;
00198
00199
00200
00201
00202
00203
00204
00206 friend std::ostream& operator<<(std::ostream& stream,const MC_v4d& v);
00207
00209 friend MC_v4d& operator>>(std::istream& stream,MC_v4d& v);
00210
00211 private:
00212
00214 double v[4];
00215 };
00216
00217
00219 class MC_v4d_less
00220 {
00221 public:
00222 bool operator ()(const MC_v4d& v0,const MC_v4d& v1) const
00223 {
00224
00225 double epsilon=0.000001;
00226 if( fabs(v0[0]-v1[0])<epsilon && fabs(v0[1]-v1[1])<epsilon && fabs(v0[2]-v1[2])<epsilon )
00227 return false;
00228
00229
00230 if(v0[0]<v1[0])
00231 return true;
00232 else if ( !(v1[0]<v0[0]) && v0[1]<v1[1] )
00233 return true;
00234 else if ( !(v1[0]<v0[0]) && !(v1[1]<v0[1]) && v0[2]<v1[2] )
00235 return true;
00236 else if ( !(v1[0]<v0[0]) && !(v1[1]<v0[1]) && v0[2]<v1[2] && v0[3]<v1[3] )
00237 return true;
00238
00239 return false;
00240 }
00241 };
00242
00243 }
00244
00245 #endif // MC_v4d_HPP