Basic class for 4D vector. More...
#include <MC_v4d.hpp>

Public Member Functions | |
| MC_v4d () | |
| empty constructor of zero vector | |
| MC_v4d (const double &x, const double &y, const double &z, const double &w) | |
| direct constructor from x,y,z,w | |
| MC_v4d (const MC_v4d &_v) | |
| copy constructor | |
| MC_v4d (const double *_v) | |
| constructor from pointer to double | |
| MC_v4d (const std::string &s) | |
| constructor from a string "(x,y,z,w)" | |
| MC_v4d (const MC_matrix &M) | |
| constructor from a matrix only if size=(4,1) or (1,4) | |
| MC_v4d (const MC_v3d &vec) | |
| constructor from a MC_v3d (add 1 at the end) | |
| ~MC_v4d () | |
| destructor | |
| MC_v4d | operator- () const |
| change the opposite sign of the current vector (unary negation) | |
| MC_v4d & | operator+= (const double &to_add) |
| internal addition with a double | |
| MC_v4d & | operator-= (const double &to_sub) |
| internal substraction with a double | |
| MC_v4d & | operator*= (const double &to_mult) |
| internal multiplication with a double | |
| MC_v4d & | operator/= (const double &to_subdiv) |
| internal divide with a double | |
| MC_v4d & | operator+= (const MC_v4d &to_add) |
| internal addition | |
| MC_v4d & | operator-= (const MC_v4d &to_sub) |
| internal substraction | |
| MC_v4d & | scale (const double &sx, const double &sy, const double &sz, const double &sw) |
| internal scaling the vector | |
| MC_v4d & | scale (const MC_v4d &scaling) |
| internal scaling the vector | |
| MC_v4d & | scale (const double &scaling) |
| internal homogeneous scaling the vector | |
| MC_v4d | mask (const double &sx, const double &sy, const double &sz, const double &sw) const |
| apply a pointwise mask to the vector (do not change it) | |
| MC_v4d | mask (const MC_v4d &scaling) const |
| apply a pointwise mask the vector | |
| MC_v4d | scale (const double &scaling) const |
| apply a pointwise mask to the vector | |
| double | dot (const MC_v4d &vec) const |
| dot product between two vectors | |
| double | norm () const |
| norm of the vector | |
| MC_v4d | normalized () const |
| get the normalized vector. | |
| MC_v4d & | operator*= (const MC_matrix &M) |
| internal application of a matrix to the vector of MC_v4d (does the product x'=M*x) | |
| MC_v4d & | set_v3d (const MC_v3d &vec) |
| set only the 3d part without changing the 4th component | |
| const double & | operator() (const int &k_dim) const |
| get operator (k_dim must be 0,1,2 or 3) | |
| double & | operator() (const int &k_dim) |
| get operator (k_dim must be 0,1,2 or 3) | |
| const double & | operator[] (const int &k_dim) const |
| get operator (k_dim must be 0,1,2 or 3) | |
| double & | operator[] (const int &k_dim) |
| get operator (k_dim must be 0,1,2 or 3) | |
| const double * | pointer () const |
| get the pointer on the vector | |
Private Attributes | |
| double | v [4] |
| internal struct | |
Friends | |
| MC_v4d | operator+ (const MC_v4d &vec, const double &to_add) |
| add a double value to the vector | |
| MC_v4d | operator- (const MC_v4d &vec, const double &to_sub) |
| substract a double value to the vector | |
| MC_v4d | operator* (const MC_v4d &vec, const double &to_mult) |
| multiply a double value to the vector | |
| MC_v4d | operator* (const double &to_mult, const MC_v4d &vec) |
| multiply a double value to the vector | |
| MC_v4d | operator/ (const MC_v4d &vec, const double &to_subdiv) |
| divide a double value to the vector | |
| MC_v4d | operator+ (const MC_v4d &vec, const MC_v4d &to_add) |
| add a v4d to the vector | |
| MC_v4d | operator- (const MC_v4d &vec, const MC_v4d &to_sub) |
| substract a v4d to the vector | |
| std::ostream & | operator<< (std::ostream &stream, const MC_v4d &v) |
| write the vector under the form (x,y,z,w) | |
| MC_v4d & | operator>> (std::istream &stream, MC_v4d &v) |
| read the vector from a istream under the form (x,y,z,w) | |
Basic class for 4D vector.
Internal structure is a static table of double[4]
Definition at line 40 of file MC_v4d.hpp.
| mesh_conv::MC_v4d::MC_v4d | ( | ) |
empty constructor of zero vector
Definition at line 14 of file MC_v4d.cpp.
References v.
Referenced by mask(), mesh_conv::MC_quaternion::MC_quaternion(), normalized(), and operator-().

| mesh_conv::MC_v4d::MC_v4d | ( | const double & | x, | |
| const double & | y, | |||
| const double & | z, | |||
| const double & | w | |||
| ) |
| mesh_conv::MC_v4d::MC_v4d | ( | const MC_v4d & | _v | ) |
| mesh_conv::MC_v4d::MC_v4d | ( | const double * | _v | ) |
| mesh_conv::MC_v4d::MC_v4d | ( | const std::string & | s | ) |
constructor from a string "(x,y,z,w)"
exemple of degenerated cases "(5,;x 4,g,8)"->MC_v4d(5,4,0,8)
Definition at line 118 of file MC_v4d.cpp.
References mesh_conv::MC_string_tokenizer::tokenize(), and v.
00119 { 00120 std::vector <std::string> v_s=mesh_conv::MC_string_tokenizer::tokenize(s," (),;"); 00121 00122 int number_ok=0; 00123 for(unsigned int k=0;number_ok<3 && k<v_s.size();k++) 00124 { 00125 bool is_converted=false; 00126 double temp_value=MC_string_converter::value_of<double>(v_s[k],&is_converted); 00127 if(is_converted==true) 00128 v[number_ok++]=temp_value; 00129 } 00130 00131 }

| mesh_conv::MC_v4d::MC_v4d | ( | const MC_matrix & | M | ) |
constructor from a matrix only if size=(4,1) or (1,4)
Definition at line 185 of file MC_v4d.cpp.
References mesh_conv::MC_matrix::size_1(), mesh_conv::MC_matrix::size_2(), and v.
00186 { 00187 if( ( M.size_1()==4 && M.size_2()==1) || 00188 ( M.size_2()==4 && M.size_1()==1) ) 00189 {v[0]=M(0);v[1]=M(1);v[2]=M(2);v[3]=M(3);} 00190 }

| mesh_conv::MC_v4d::~MC_v4d | ( | ) |
| double mesh_conv::MC_v4d::dot | ( | const MC_v4d & | vec | ) | const |
dot product between two vectors
Definition at line 166 of file MC_v4d.cpp.
References v.
Referenced by norm(), and mesh_conv::MC_quaternion::slerp().

| MC_v4d mesh_conv::MC_v4d::mask | ( | const double & | sx, | |
| const double & | sy, | |||
| const double & | sz, | |||
| const double & | sw | |||
| ) | const |
| double mesh_conv::MC_v4d::norm | ( | ) | const |
norm of the vector
Definition at line 168 of file MC_v4d.cpp.
References dot().
Referenced by mesh_conv::MC_quaternion::inverted(), normalized(), and mesh_conv::MC_quaternion::quat_interp().
00169 {return sqrt(dot(*this));}


| MC_v4d mesh_conv::MC_v4d::normalized | ( | ) | const |
get the normalized vector.
Definition at line 170 of file MC_v4d.cpp.
References MC_v4d(), and norm().
00171 { 00172 double epsilon=0.000001; 00173 double n=norm(); 00174 if(n<epsilon) 00175 {std::cout<<"Warning in MC_v4d::normalized(), norm is "<<n<<std::endl; return MC_v4d(0,0,1,0);} 00176 return (*this)/n; 00177 }

| double & mesh_conv::MC_v4d::operator() | ( | const int & | k_dim | ) |
get operator (k_dim must be 0,1,2 or 3)
Definition at line 28 of file MC_v4d.cpp.
References v.
00029 { 00030 if(k_dim<0 || k_dim>3) 00031 {std::cout<<"Error in MC_v4d("<<k_dim<<"), size must be 0,1,2 or 3"<<std::endl;} 00032 return v[k_dim]; 00033 }
| const double & mesh_conv::MC_v4d::operator() | ( | const int & | k_dim | ) | const |
get operator (k_dim must be 0,1,2 or 3)
Definition at line 22 of file MC_v4d.cpp.
References v.
00023 { 00024 if(k_dim<0 || k_dim>3) 00025 {std::cout<<"Error in const MC_v4d("<<k_dim<<"), size must be 0,1 or 2"<<std::endl;} 00026 return v[k_dim]; 00027 }
internal application of a matrix to the vector of MC_v4d (does the product x'=M*x)
Definition at line 182 of file MC_v4d.cpp.
References mesh_conv::MC_matrix::internal_product().

| MC_v4d & mesh_conv::MC_v4d::operator*= | ( | const double & | to_mult | ) |
| MC_v4d & mesh_conv::MC_v4d::operator+= | ( | const double & | to_add | ) |
| MC_v4d mesh_conv::MC_v4d::operator- | ( | ) | const |
| MC_v4d & mesh_conv::MC_v4d::operator-= | ( | const double & | to_sub | ) |
| MC_v4d & mesh_conv::MC_v4d::operator/= | ( | const double & | to_subdiv | ) |
| double & mesh_conv::MC_v4d::operator[] | ( | const int & | k_dim | ) |
get operator (k_dim must be 0,1,2 or 3)
Definition at line 40 of file MC_v4d.cpp.
References v.
00041 { 00042 if(k_dim<0 || k_dim>3) 00043 {std::cout<<"Error in MC_v4d["<<k_dim<<"], size must be 0,1,2 or 3"<<std::endl;} 00044 return v[k_dim]; 00045 }
| const double & mesh_conv::MC_v4d::operator[] | ( | const int & | k_dim | ) | const |
get operator (k_dim must be 0,1,2 or 3)
Definition at line 34 of file MC_v4d.cpp.
References v.
00035 { 00036 if(k_dim<0 || k_dim>3) 00037 {std::cout<<"Error in const MC_v4d["<<k_dim<<"], size must be 0,1,2 or 3"<<std::endl;} 00038 return v[k_dim]; 00039 }
| const double * mesh_conv::MC_v4d::pointer | ( | ) | const |
get the pointer on the vector
Definition at line 194 of file MC_v4d.cpp.
References v.
00195 {return &v[0];}
| MC_v4d mesh_conv::MC_v4d::scale | ( | const double & | scaling | ) | const |
apply a pointwise mask to the vector
Definition at line 163 of file MC_v4d.cpp.
| MC_v4d & mesh_conv::MC_v4d::scale | ( | const double & | scaling | ) |
internal homogeneous scaling the vector
Definition at line 162 of file MC_v4d.cpp.
| MC_v4d & mesh_conv::MC_v4d::scale | ( | const double & | sx, | |
| const double & | sy, | |||
| const double & | sz, | |||
| const double & | sw | |||
| ) |
set only the 3d part without changing the 4th component
Definition at line 191 of file MC_v4d.cpp.
References v.
Referenced by mesh_conv::operator*(), and mesh_conv::MC_quaternion::operator*=().

multiply a double value to the vector
multiply a double value to the vector
add a v4d to the vector
add a double value to the vector
substract a v4d to the vector
substract a double value to the vector
divide a double value to the vector
| std::ostream& operator<< | ( | std::ostream & | stream, | |
| const MC_v4d & | v | |||
| ) | [friend] |
write the vector under the form (x,y,z,w)
read the vector from a istream under the form (x,y,z,w)
double mesh_conv::MC_v4d::v[4] [private] |
internal struct
Definition at line 214 of file MC_v4d.hpp.
Referenced by dot(), mask(), MC_v4d(), operator()(), operator*=(), operator+=(), operator-(), operator-=(), operator/=(), operator[](), pointer(), scale(), and set_v3d().
1.6.1