Flow123d
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 }