1#ifndef CHI_MESH_VECTOR3_H
2#define CHI_MESH_VECTOR3_H
9 struct TensorRank2Dim3;
40 explicit Vector3(
double a,
double b,
double c){
45 Vector3(std::initializer_list<double> list)
49 std::vector<double> vec = list;
50 for (
size_t i=0; ( (i<3) and ( i<vec.size() ) ); ++i)
60 explicit Vector3(
const std::vector<double>& list)
64 std::vector<double> vec = list;
65 for (
size_t i=0; ( (i<3) and ( i<vec.size() ) ); ++i)
96 std::vector<double> vec = list;
97 for (
size_t i=0; ( (i<3) and ( i<vec.size() ) ); ++i)
110 std::vector<double> vec = list;
111 for (
size_t i=0; ( (i<3) and ( i<vec.size() ) ); ++i)
126 newVector.
x = this->x + that.
x;
127 newVector.
y = this->y + that.
y;
128 newVector.
z = this->z + that.
z;
149 newVector.
x = this->x + value;
150 newVector.
y = this->y + value;
151 newVector.
z = this->z + value;
173 newVector.
x = this->x - that.
x;
174 newVector.
y = this->y - that.
y;
175 newVector.
z = this->z - that.
z;
197 newVector.
x = this->x*value;
198 newVector.
y = this->y*value;
199 newVector.
z = this->z*value;
220 newVector.
x = this->x*that.
x;
221 newVector.
y = this->y*that.
y;
222 newVector.
z = this->z*that.
z;
244 newVector.
x = this->x/value;
245 newVector.
y = this->y/value;
246 newVector.
z = this->z/value;
267 newVector.
x = this->x/that.
x;
268 newVector.
y = this->y/that.
y;
269 newVector.
z = this->z/that.
z;
289 if (i==0)
return this->
x;
290 else if (i==1)
return this->
y;
291 else if (i==2)
return this->
z;
299 if (i==0)
return this->
x;
300 else if (i==1)
return this->
y;
301 else if (i==2)
return this->
z;
320 newVector.
x = this->y*that.
z - this->z*that.
y;
321 newVector.
y = this->z*that.
x - this->x*that.
z;
322 newVector.
z = this->x*that.
y - this->y*that.
x;
332 value += this->x*that.
x;
333 value += this->y*that.
y;
334 value += this->z*that.
z;
344 value += this->x*this->
x;
345 value += this->y*this->
y;
346 value += this->z*this->
z;
359 value += this->x*this->
x;
360 value += this->y*this->
y;
361 value += this->z*this->
z;
370 double norm = this->
Norm();
381 double norm = this->
Norm();
384 newVector.
x = this->x/norm;
385 newVector.
y = this->y/norm;
386 newVector.
z = this->z/norm;
398 newVector.
x = (std::fabs(this->x)>tol)? 1.0/this->x : 0.0;
399 newVector.
y = (std::fabs(this->y)>tol)? 1.0/this->y : 0.0;
400 newVector.
z = (std::fabs(this->z)>tol)? 1.0/this->z : 0.0;
412 newVector.
x = (std::fabs(this->x)>tol)? 1.0/this->x : 1.0;
413 newVector.
y = (std::fabs(this->y)>tol)? 1.0/this->y : 1.0;
414 newVector.
z = (std::fabs(this->z)>tol)? 1.0/this->z : 1.0;
425 double dx_inv = 1.0/this->
x;
426 double dy_inv = 1.0/this->
y;
427 double dz_inv = 1.0/this->
z;
435 std::cout<<this->x <<
" ";
436 std::cout<<this->y <<
" ";
442 out <<
"[" << v.
x <<
" " << v.
y <<
" " << v.
z <<
"]";
450 std::stringstream out;
451 out <<
"[" <<
x <<
" " <<
y <<
" " <<
z <<
"]";
459 std::stringstream out;
460 out <<
"[" <<
x <<
" " <<
y <<
" " <<
z <<
"]";
chi_mesh::Vector3 operator*(double value, const chi_mesh::Vector3 &that)
Vector3(double a, double b, double c)
Vector3 operator/(const Vector3 &that) const
Vector3(std::initializer_list< double > list)
std::string PrintS() const
Vector3 & operator/=(const Vector3 &that)
Vector3 & operator=(std::initializer_list< double > list)
double NormSquare() const
Vector3 & operator*=(const double value)
Vector3 & operator+=(const Vector3 &that)
std::string PrintStr() const
Vector3(const Vector3 &that)
Vector3 Shifted(const double value) const
double & operator()(const size_t i)
double operator[](const size_t i) const
Vector3 Cross(const Vector3 &that) const
Vector3 & Shift(const double value)
Vector3 operator/(const double value) const
Vector3 & operator/=(const double value)
Vector3 Normalized() const
Vector3 operator-(const Vector3 &that) const
Vector3 Dot(const chi_mesh::TensorRank2Dim3 &that) const
Vector3(const std::vector< double > &list)
chi_mesh::TensorRank2Dim3 OTimes(const Vector3 &that) const
Vector3 & operator=(const std::vector< double > &list)
friend std::ostream & operator<<(std::ostream &out, Vector3 &v)
Vector3 InverseOneIfSmaller(const double tol) const
Vector3 operator*(const Vector3 &that) const
Vector3 & operator*=(const Vector3 &that)
Vector3(double a, double b)
Vector3 operator+(const Vector3 &that) const
double Dot(const Vector3 &that) const
Vector3 & operator-=(const Vector3 &that)
Vector3 InverseZeroIfSmaller(const double tol) const
Vector3 operator*(const double value) const
Vector3 & operator=(const Vector3 &that)