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