MC_v3d.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_V3D_HPP
00022 #define MC_V3D_HPP
00023
00024 #include <iostream>
00025 #include <cmath>
00026
00027
00028
00029
00030
00031 namespace mesh_conv
00032 {
00033
00034 class MC_v3d_vector;
00035 class MC_matrix;
00036 class MC_quaternion;
00037
00039
00041 class MC_v3d
00042 {
00043 public:
00044
00045
00046
00047
00048
00049
00050
00052 MC_v3d();
00054 MC_v3d(const double& x,const double& y,const double& z);
00056 MC_v3d(const MC_v3d& _v);
00060 MC_v3d(const double* _v);
00065 MC_v3d(const std::string& s);
00066
00068 MC_v3d(const MC_matrix& M);
00069
00071 MC_v3d(const MC_v3d_vector& vec);
00072
00074 ~MC_v3d();
00075
00076
00077
00078
00079
00080
00081
00082
00084 MC_v3d& operator=(const MC_matrix& M);
00085
00086
00087
00088
00089
00090
00091
00095 MC_v3d operator-() const;
00096
00100 friend MC_v3d operator+(const MC_v3d& vec,const double& to_add);
00104 friend MC_v3d operator-(const MC_v3d& vec,const double& to_sub);
00108 friend MC_v3d operator*(const MC_v3d& vec,const double& to_mult);
00112 friend MC_v3d operator*(const double& to_mult,const MC_v3d& vec);
00116 friend MC_v3d operator/(const MC_v3d& vec,const double& to_subdiv);
00117
00118
00122 friend MC_v3d operator+(const MC_v3d& vec,const MC_v3d& to_add);
00126 friend MC_v3d operator-(const MC_v3d& vec,const MC_v3d& to_sub);
00127
00128
00130 MC_v3d& operator+=(const double& to_add);
00132 MC_v3d& operator-=(const double& to_sub);
00134 MC_v3d& operator*=(const double& to_mult);
00136 MC_v3d& operator/=(const double& to_subdiv);
00137
00139 MC_v3d& operator+=(const MC_v3d& to_add);
00141 MC_v3d& operator-=(const MC_v3d& to_sub);
00142
00146 MC_v3d& scale(const double& sx,const double& sy,const double& sz);
00150 MC_v3d& scale(const MC_v3d& scaling);
00154 MC_v3d& scale(const double& scaling);
00155
00159 MC_v3d scaled(const MC_v3d& scaling) const;
00163 MC_v3d scaled(const double& scaling) const;
00164
00165
00169 MC_v3d mask(const double& sx,const double& sy,const double& sz) const;
00173 MC_v3d mask(const MC_v3d& scaling) const;
00177 MC_v3d scale(const double& scaling) const;
00178
00180 double dot(const MC_v3d& vec) const;
00182 MC_v3d cross(const MC_v3d& vec) const;
00184 double norm() const;
00188 MC_v3d normalized() const;
00189
00190
00192 MC_v3d& operator*=(const MC_matrix& M);
00193
00196 friend MC_v3d operator*(const MC_quaternion& q,const MC_v3d& vec);
00199 MC_v3d& operator*=(const MC_quaternion& q);
00200
00201
00203 friend bool operator==(const MC_v3d& a1,const MC_v3d& a2);
00205 friend bool operator!=(const MC_v3d& a1,const MC_v3d& a2);
00206
00207
00211 static double area(const MC_v3d& v0,const MC_v3d& v1);
00212
00216 static double cotan(const MC_v3d& u0,const MC_v3d& u1);
00217
00221 static double angle(const MC_v3d& u0,const MC_v3d& u1);
00222
00227 MC_v3d project_on_plane(const MC_v3d& normal) const;
00228
00229
00230
00231
00232
00233
00234
00235 std::pair <MC_v3d,MC_v3d_vector> normalized_with_gradient() const;
00236
00237
00238
00239
00240
00241
00242
00243
00245 const double& operator()(const int& k_dim) const;
00247 double& operator()(const int& k_dim);
00249 const double& operator[](const int& k_dim) const;
00251 double& operator[](const int& k_dim);
00252
00254 const double* pointer() const;
00258 double* pointer_unprotected();
00259
00260
00261
00262
00263
00264
00265
00267 friend std::ostream& operator<<(std::ostream& stream,const MC_v3d& v);
00268
00270 friend MC_v3d& operator>>(std::istream& stream,MC_v3d& v);
00271
00272 private:
00273
00275 double v[3];
00276 };
00277
00278
00280 class MC_v3d_less
00281 {
00282 public:
00283 bool operator ()(const MC_v3d& v0,const MC_v3d& v1) const
00284 {
00285
00286 double epsilon=0.000001;
00287 if( fabs(v0[0]-v1[0])<epsilon && fabs(v0[1]-v1[1])<epsilon && fabs(v0[2]-v1[2])<epsilon )
00288 return false;
00289
00290
00291 if(v0[0]<v1[0])
00292 return true;
00293 else if ( !(v1[0]<v0[0]) && v0[1]<v1[1] )
00294 return true;
00295 else if ( !(v1[0]<v0[0]) && !(v1[1]<v0[1]) && v0[2]<v1[2] )
00296 return true;
00297
00298
00299 return false;
00300 }
00301 };
00302
00303 }
00304
00305 #endif // MC_V3D_HPP