Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GeoPrimitives.C
Go to the documentation of this file.
1 #include "GeoPrimitives.H"
7 
8 
9 namespace GeoPrim {
10  void
11  Transpose(CVector matrix[])
12  {
13  CVector tpose[3];
14 
15  tpose[0].init(matrix[0].x(),matrix[1].x(),matrix[2].x());
16  tpose[1].init(matrix[0].y(),matrix[1].y(),matrix[2].y());
17  tpose[2].init(matrix[0].z(),matrix[1].z(),matrix[2].z());
18  matrix[0].init(tpose[0]);
19  matrix[1].init(tpose[1]);
20  matrix[2].init(tpose[2]);
21  }
22 
23  void
24  Transpose_2x3(CVector matrix[],double tpose[][2])
25  {
26  tpose[0][0] = matrix[0].x();
27  tpose[1][0] = matrix[0].y();
28  tpose[2][0] = matrix[0].z();
29  tpose[0][1] = matrix[1].x();
30  tpose[1][1] = matrix[1].y();
31  tpose[2][1] = matrix[1].z();
32  }
33 
34  double
35  Distance(const CPoint &p,const CLine &l)
36  {
37  double u = (((p.x() - l.p.x())*l.v.x() + (p.y() - l.p.y())*l.v.y() +
38  (p.z() - l.p.z())*l.v.z())/l.v.mag2());
39  CPoint p2(l.p.x()+(u*l.v.x()),l.p.y()+(u*l.v.y()),l.p.z()+(u*l.v.z()));
40  CVector v(p,p2);
41  return(v.mag());
42  }
43 
44  double
45  Distance(const C3Point &p,const CLine &l)
46  {
47  double u = (((p.x() - l.p.x())*l.v.x() + (p.y() - l.p.y())*l.v.y() +
48  (p.z() - l.p.z())*l.v.z())/l.v.mag2());
49  C3Point p2(l.p.x()+(u*l.v.x()),l.p.y()+(u*l.v.y()),l.p.z()+(u*l.v.z()));
50  C3Vector v(p,p2);
51  return(v.Mag());
52  }
53 
54  std::ostream &
55  operator<<(std::ostream &oS,const GeoPrim::CBox &b)
56  {
57  oS << b.P1() << " " << b.P2();
58  return(oS);
59  }
60 
61  std::ostream &
62  operator<<(std::ostream &oS,const GeoPrim::CPoint &p)
63  {
64  oS << p.x() << " " << p.y() << " " << p.z();
65  return(oS);
66  }
67 
68  std::istream &
69  operator>>(std::istream &iS,GeoPrim::CPoint &p)
70  {
71  iS >> p[0] >> p[1] >> p[2];
72  return(iS);
73  }
74 
75 // std::ostream &
76 // operator<<(std::ostream &oS,const GeoPrim::C3Point &p)
77 // {
78 // oS << p.x() << " " << p.y() << " " << p.z();
79 // return(oS);
80 // }
81 
82 // std::istream &
83 // operator>>(std::istream &iS,GeoPrim::C3Point &p)
84 // {
85 // iS >> p[0] >> p[1] >> p[2];
86 // return(iS);
87 // }
88 
89  std::ostream &
90  operator<<(std::ostream &oS,const GeoPrim::CVector &v)
91  {
92  oS << v.x() << " " << v.y() << " " << v.z();
93  return(oS);
94  }
95 
96  std::istream &
97  operator>>(std::istream &iS,GeoPrim::CVector &v)
98  {
99  iS >> v[0] >> v[1] >> v[2];
100  return(iS);
101  }
102 
103  std::ostream &
104  operator<<(std::ostream &oS,const GeoPrim::C3Vector &v)
105  {
106  oS << v.x() << " " << v.y() << " " << v.z();
107  return(oS);
108  }
109 
110  std::istream &
111  operator>>(std::istream &iS,GeoPrim::C3Vector &v)
112  {
113  iS >> v[0] >> v[1] >> v[2];
114  return(iS);
115  }
116 
117  GeoPrim::CPoint operator*(double scalar,const GeoPrim::CPoint &p)
118  {
119  GeoPrim::CPoint rv(p);
120  rv.x() *= scalar;
121  rv.y() *= scalar;
122  rv.z() *= scalar;
123  return(rv);
124  }
125 
127  {
128  GeoPrim::C3Vector rv(v);
129  return(rv *= scalar);
130  }
131 
133  {
134  GeoPrim::CVector rv(v);
135  return(rv *= scalar);
136  }
137 
138 }
/brief Cartesian 3 Vector
Geometric Primitives interface.
const CPoint & P2() const
void int int REAL REAL * y
Definition: read.cpp:74
std::istream & operator>>(std::istream &iS, GeoPrim::CPoint &p)
Definition: GeoPrimitives.C:69
*********************************************************************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 mag() const
double mag2() const
void int int int REAL REAL REAL * z
Definition: write.cpp:76
CVector & init(const CPoint &p)
void int int REAL * x
Definition: read.cpp:74
std::ostream & operator<<(std::ostream &oS, const GeoPrim::CBox &b)
Definition: GeoPrimitives.C:55
void Transpose(CVector matrix[])
Definition: GeoPrimitives.C:11
GeoPrim::CPoint operator*(double scalar, const GeoPrim::CPoint &p)
double Mag() const
double Distance(const CPoint &p, const CLine &l)
Definition: GeoPrimitives.C:35
void Transpose_2x3(CVector matrix[], double tpose[][2])
Definition: GeoPrimitives.C:24
const CPoint & P1() const