Flow123d  jenkins-Flow123d-linux-release-multijob-282
bisector.cpp
Go to the documentation of this file.
1 #include <iostream>
2 
3 #include "system/global_defs.h"
4 #include "mesh/elements.h"
5 
9 
10 using namespace mathfce;
11 
13 
16 }
17 
19  id = generateId();
20 
21  X0 = new TPoint(0, 0, 0);
22  U = new TVector(0, 0, 0);
23 }
24 
25 TBisector::TBisector(const TPoint &XX0, const TVector &UU) {
26  id = generateId();
27 
28  X0 = new TPoint(XX0);
29  U = new TVector(UU);
30 }
31 
32 TBisector::TBisector(const TPoint &P0, const TPoint &P1) {
33  id = generateId();
34 
35  X0 = new TPoint(P0);
36  U = new TVector(P0, P1);
37 }
38 
40  id = generateId();
41  ASSERT_EQUAL(ele.dim(), 1);
42 
43  X0 = new TPoint(ele.node[0]->point()(0), ele.node[0]->point()(1), ele.node[0]->point()(2));
44  U = new TVector(*X0, TPoint(ele.node[1]->point()(0), ele.node[1]->point()(1), ele.node[1]->point()(2)) );
45 }
46 
48 {
49  id = generateId();
50 
51  X0 = new TPoint(*(x.X0));
52  U = new TVector(*(x.U));
53 }
54 
56  delete X0;
57  delete U;
58 }
59 
61  *(*this).U = *b.U;
62  *(*this).X0 = *b.X0;
63 
64  return *this;
65 }
66 
67 std::ostream & operator <<(std::ostream &stream, const TBisector &b) {
68  stream << "U = (" << b.U->X1() << ", " << b.U->X2() << ", " << b.U->X3() << ")\n";
69  stream << "X0 = [" << b.X0->X() << ", " << b.X0->Y() << ", " << b.X0->Z() << "]\n";
70 
71  return stream;
72 }
73 
74 void TBisector::SetPoint(const TPoint &P) {
75  *X0 = P;
76 }
77 
78 void TBisector::SetVector(const TVector &UU) {
79  *U = UU;
80 }
81 
82 void TBisector::SetPoints(const TPoint &P0, const TPoint &P1) {
83  *X0 = P0;
84  *U = (TPoint) P1 - P0;
85 }
86 
87 const TVector &TBisector::GetVector() const {
88 
89  return *(this->U);
90 }
91 
93 {
94  return *(this->X0);
95 }
96 
97 TPoint TBisector::GetPoint(double t) const {
98  TPoint tmp;
99 
100  tmp.SetCoord(t * *U);
101  tmp = tmp + *X0;
102 
103  return tmp;
104 }
105 
106 void TBisector::GetParameter(const TPoint &P, double &t, bool &onBisector) const {
107  t = (P.X() - X0->X()) / U->X1();
108  onBisector = (fabs( (P.Y() - X0->Y()) / U->X2() - t ) < epsilon) & (fabs( (P.Z() - X0->Z()) / U->X3() - t ) < epsilon);
109 }
110 
111 bool TBisector::Belong(const TPoint &P) const {
112  if (IsZero(Distance(*this, P))) {
113  return true;
114  } else {
115  return false;
116  }
117 }
double Distance(const TBisector &, const TPoint &)
void SetVector(const TVector &)
Definition: bisector.cpp:78
const TVector & GetVector() const
Definition: bisector.cpp:87
double X2() const
Definition: vector.cpp:205
double X1() const
Definition: vector.cpp:201
static int numberInstance
Definition: bisector.h:14
Node ** node
Definition: elements.h:90
bool IsZero(double)
Definition: mathfce.cpp:5
double X3() const
Definition: vector.cpp:209
const TPoint & GetPoint() const
Definition: bisector.cpp:92
void SetPoint(const TPoint &)
Definition: bisector.cpp:74
double X() const
Definition: point.cpp:91
unsigned int dim() const
TPoint * X0
Definition: bisector.h:17
Global macros to enhance readability and debugging, general constants.
~TBisector()
Definition: bisector.cpp:55
Definition: point.h:10
int generateId()
Definition: bisector.cpp:14
double Y() const
Definition: point.cpp:95
#define ASSERT_EQUAL(a, b)
Definition: global_defs.h:136
void SetCoord(double, double, double)
Definition: point.cpp:79
double Z() const
Definition: point.cpp:99
void GetParameter(const TPoint &, double &, bool &) const
Definition: bisector.cpp:106
void SetPoints(const TPoint &, const TPoint &)
Definition: bisector.cpp:82
bool Belong(const TPoint &) const
Definition: bisector.cpp:111
STREAM & operator<<(STREAM &s, UpdateFlags u)
const double epsilon
Definition: mathfce.h:6
TBisector & operator=(const TBisector &)
Definition: bisector.cpp:60
TVector * U
Definition: bisector.h:18
arma::vec3 & point()
Definition: nodes.hh:80