Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MVec Class Reference

#include <MVec.hpp>

Public Member Functions

 MVec ()
 
 MVec (const MVec &v)
 
 MVec (double x, double y, double z)
 
 ~MVec ()
 
MVec operator- (const MVec &ovec) const
 
MVec operator+ (const MVec &ovec) const
 
MVec operator/ (double val) const
 
MVec operator* (double val) const
 
const MVecoperator= (const MVec ovec)
 
boolean operator== (const MVec ovec) const
 
MVec operator* (const MVec &ovec) const
 
double operator% (const MVec &ovec) const
 
double length () const
 
double length_squared () const
 
double distance_between (MVec &end) const
 
void normalize ()
 
double x () const
 
double y () const
 
double z () const
 
void x (double nx)
 
void y (double ny)
 
void z (double nz)
 
double operator[] (int i) const
 
void move_to_line (const MVec &from, const MVec &to)
 

Private Attributes

double d_x
 
double d_y
 
double d_z
 

Friends

istream & operator>> (istream &stream, MVec &v)
 
ostream & operator<< (ostream &stream, const MVec &v)
 

Detailed Description

Definition at line 8 of file MVec.hpp.

Constructor & Destructor Documentation

MVec ( )

Definition at line 5 of file MVec.cpp.

5 {}
MVec ( const MVec v)

Definition at line 6 of file MVec.cpp.

6  :
7  d_x(v.d_x),
8  d_y(v.d_y),
9  d_z(v.d_z) {}
double d_z
Definition: MVec.hpp:59
double d_x
Definition: MVec.hpp:57
double d_y
Definition: MVec.hpp:58
MVec ( double  x,
double  y,
double  z 
)

Definition at line 11 of file MVec.cpp.

11  :
12  d_x(x),
13  d_y(y),
14  d_z(z) {}
double x() const
Definition: MVec.hpp:104
double z() const
Definition: MVec.hpp:106
double d_z
Definition: MVec.hpp:59
double d_x
Definition: MVec.hpp:57
double y() const
Definition: MVec.hpp:105
double d_y
Definition: MVec.hpp:58
~MVec ( )

Definition at line 16 of file MVec.cpp.

16 {}

Member Function Documentation

double distance_between ( MVec end) const
inline

Definition at line 90 of file MVec.hpp.

References d_x, d_y, d_z, Mesquite::pow(), sqrt(), x(), y(), and z().

Referenced by TetElement::getMinEdgeLength().

90  {
91  return sqrt( pow((d_x - end.x()),2) +
92  pow((d_y - end.y()),2) +
93  pow((d_z - end.z()),2) ) ;
94 }
double x() const
Definition: MVec.hpp:104
double sqrt(double d)
Definition: double.h:73
double z() const
Definition: MVec.hpp:106
double d_z
Definition: MVec.hpp:59
double d_x
Definition: MVec.hpp:57
double y() const
Definition: MVec.hpp:105
double pow(double value, const Exponent &exp)
double d_y
Definition: MVec.hpp:58

Here is the call graph for this function:

Here is the caller graph for this function:

double length ( ) const
inline

Definition at line 82 of file MVec.hpp.

References d_x, d_y, d_z, and sqrt().

Referenced by normalize().

82  {
83  return sqrt( d_x * d_x + d_y * d_y + d_z * d_z);
84 }
double sqrt(double d)
Definition: double.h:73
double d_z
Definition: MVec.hpp:59
double d_x
Definition: MVec.hpp:57
double d_y
Definition: MVec.hpp:58

Here is the call graph for this function:

Here is the caller graph for this function:

double length_squared ( ) const
inline

Definition at line 86 of file MVec.hpp.

References d_x, d_y, and d_z.

Referenced by move_to_line(), and operator==().

86  {
87  return d_x * d_x + d_y * d_y + d_z * d_z;
88 }
double d_z
Definition: MVec.hpp:59
double d_x
Definition: MVec.hpp:57
double d_y
Definition: MVec.hpp:58

Here is the caller graph for this function:

void move_to_line ( const MVec from,
const MVec to 
)

Definition at line 90 of file MVec.cpp.

References length_squared(), and sqrt().

90  {
91 
92  MVec base = to - from;
93  MVec vec = *this - from;
94  double b2 = base.length_squared();
95  double dot = base%vec;
96  if (dot <= 0.0) {
97  *this = from;
98  return;
99  }
100  double percent2 = ((dot*dot)/b2)/b2;
101  if (percent2 >= 1.0){
102  *this = to;
103  return;
104  }
105  double delta = sqrt (percent2);
106  *this = from * ( 1.0 - delta ) + to * delta;
107 }
Definition: MVec.hpp:8
double sqrt(double d)
Definition: double.h:73
double length_squared() const
Definition: MVec.hpp:86

Here is the call graph for this function:

void normalize ( )
inline

Definition at line 96 of file MVec.hpp.

References d_x, d_y, d_z, and length().

96  {
97  double len = length();
98 
99  d_x /= len;
100  d_y /= len;
101  d_z /= len;
102 }
double length() const
Definition: MVec.hpp:82
double d_z
Definition: MVec.hpp:59
double d_x
Definition: MVec.hpp:57
double d_y
Definition: MVec.hpp:58

Here is the call graph for this function:

double operator% ( const MVec ovec) const
inline

Definition at line 76 of file MVec.hpp.

References d_x, d_y, and d_z.

76  {
77 
78  return d_x * ovec.d_x + d_y * ovec.d_y + d_z * ovec.d_z;
79 }
double d_z
Definition: MVec.hpp:59
double d_x
Definition: MVec.hpp:57
double d_y
Definition: MVec.hpp:58
MVec operator* ( double  val) const

Definition at line 57 of file MVec.cpp.

References d_x, d_y, d_z, and v.

57  {
58 
59  MVec v;
60  v.d_x = d_x*val;
61  v.d_y = d_y*val;
62  v.d_z = d_z*val;
63  return v;
64 }
Definition: MVec.hpp:8
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
double d_z
Definition: MVec.hpp:59
double d_x
Definition: MVec.hpp:57
double d_y
Definition: MVec.hpp:58
MVec operator* ( const MVec ovec) const

Definition at line 67 of file MVec.cpp.

References d_x, d_y, d_z, and v.

67  {
68 
69  MVec v;
70  v.d_x = d_y * ovec.d_z - d_z * ovec.d_y;
71  v.d_y = d_z * ovec.d_x - d_x * ovec.d_z;
72  v.d_z = d_x * ovec.d_y - d_y * ovec.d_x;
73  return v;
74 }
Definition: MVec.hpp:8
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
double d_z
Definition: MVec.hpp:59
double d_x
Definition: MVec.hpp:57
double d_y
Definition: MVec.hpp:58
MVec operator+ ( const MVec ovec) const

Definition at line 39 of file MVec.cpp.

References d_x, d_y, d_z, and v.

39  {
40 
41  MVec v;
42  v.d_x = d_x + ovec.d_x;
43  v.d_y = d_y + ovec.d_y;
44  v.d_z = d_z + ovec.d_z;
45  return v;
46 }
Definition: MVec.hpp:8
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
double d_z
Definition: MVec.hpp:59
double d_x
Definition: MVec.hpp:57
double d_y
Definition: MVec.hpp:58
MVec operator- ( const MVec ovec) const

Definition at line 30 of file MVec.cpp.

References d_x, d_y, d_z, and v.

30  {
31 
32  MVec v;
33  v.d_x = d_x - ovec.d_x;
34  v.d_y = d_y - ovec.d_y;
35  v.d_z = d_z - ovec.d_z;
36  return v;
37 }
Definition: MVec.hpp:8
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
double d_z
Definition: MVec.hpp:59
double d_x
Definition: MVec.hpp:57
double d_y
Definition: MVec.hpp:58
MVec operator/ ( double  val) const

Definition at line 48 of file MVec.cpp.

References d_x, d_y, d_z, and v.

48  {
49 
50  MVec v;
51  v.d_x = d_x/val;
52  v.d_y = d_y/val;
53  v.d_z = d_z/val;
54  return v;
55 }
Definition: MVec.hpp:8
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
double d_z
Definition: MVec.hpp:59
double d_x
Definition: MVec.hpp:57
double d_y
Definition: MVec.hpp:58
const MVec & operator= ( const MVec  ovec)
inline

Definition at line 67 of file MVec.hpp.

References d_x, d_y, and d_z.

67  {
68 
69  d_x = ovec.d_x;
70  d_y = ovec.d_y;
71  d_z = ovec.d_z;
72  return *this;
73 }
double d_z
Definition: MVec.hpp:59
double d_x
Definition: MVec.hpp:57
double d_y
Definition: MVec.hpp:58
boolean operator== ( const MVec  ovec) const

Definition at line 76 of file MVec.cpp.

References c_epsilon, c_epsilon2, d_x, d_y, d_z, FALSE, length_squared(), and TRUE.

76  {
77 
78  if( ovec.d_x > d_x + c_epsilon
79  || ovec.d_x < d_x - c_epsilon
80  || ovec.d_y > d_y + c_epsilon
81  || ovec.d_y < d_y - c_epsilon
82  || ovec.d_z > d_z + c_epsilon
83  || ovec.d_z < d_z - c_epsilon ) {
84  return FALSE;
85  }
86  return ( (*this - ovec).length_squared() < c_epsilon2 ? TRUE : FALSE );
87 }
#define FALSE
Definition: vinci.h:133
double length_squared() const
Definition: MVec.hpp:86
#define TRUE
Definition: vinci.h:134
const double c_epsilon
Definition: MVec.hpp:63
double d_z
Definition: MVec.hpp:59
double d_x
Definition: MVec.hpp:57
const double c_epsilon2
Definition: MVec.hpp:64
double d_y
Definition: MVec.hpp:58

Here is the call graph for this function:

double operator[] ( int  i) const
inline

Definition at line 112 of file MVec.hpp.

References d_x, d_y, and d_z.

112  {
113  return ( i == 0 ? d_x : ( i == 1 ? d_y : d_z ) );
114 }
blockLoc i
Definition: read.cpp:79
double d_z
Definition: MVec.hpp:59
double d_x
Definition: MVec.hpp:57
double d_y
Definition: MVec.hpp:58
double x ( ) const
inline

Definition at line 104 of file MVec.hpp.

References d_x.

Referenced by distance_between().

104 { return d_x; }
double d_x
Definition: MVec.hpp:57

Here is the caller graph for this function:

void x ( double  nx)
inline

Definition at line 108 of file MVec.hpp.

References d_x.

108 { d_x = nx; }
double d_x
Definition: MVec.hpp:57
double y ( ) const
inline

Definition at line 105 of file MVec.hpp.

References d_y.

Referenced by distance_between().

105 { return d_y; }
double d_y
Definition: MVec.hpp:58

Here is the caller graph for this function:

void y ( double  ny)
inline

Definition at line 109 of file MVec.hpp.

References d_y.

109 { d_y = ny; }
double d_y
Definition: MVec.hpp:58
double z ( ) const
inline

Definition at line 106 of file MVec.hpp.

References d_z.

Referenced by distance_between().

106 { return d_z; }
double d_z
Definition: MVec.hpp:59

Here is the caller graph for this function:

void z ( double  nz)
inline

Definition at line 110 of file MVec.hpp.

References d_z.

110 { d_z = nz; }
double d_z
Definition: MVec.hpp:59

Friends And Related Function Documentation

ostream& operator<< ( ostream &  stream,
const MVec v 
)
friend

Definition at line 25 of file MVec.cpp.

25  {
26  stream << ' ' << v.d_x << ' ' << v.d_y << ' ' << v.d_z;
27  return stream;
28 }
double d_z
Definition: MVec.hpp:59
double d_x
Definition: MVec.hpp:57
double d_y
Definition: MVec.hpp:58
istream& operator>> ( istream &  stream,
MVec v 
)
friend

Definition at line 19 of file MVec.cpp.

19  {
20  stream >> v.d_x >> v.d_y >> v.d_z;
21  return stream;
22 }
double d_z
Definition: MVec.hpp:59
double d_x
Definition: MVec.hpp:57
double d_y
Definition: MVec.hpp:58

Member Data Documentation


The documentation for this class was generated from the following files: