Flow123d  release_2.2.0-41-g0958a8d
bisector.cpp
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file bisector.cpp
15  * @brief
16  */
17 
18 #include <iostream>
19 
20 #include "system/global_defs.h"
21 #include "mesh/element_impls.hh"
22 
26 
27 using namespace mathfce;
28 
30 
33 }
34 
36  id = generateId();
37 
38  X0 = new TPoint(0, 0, 0);
39  U = new TVector(0, 0, 0);
40 }
41 
42 TBisector::TBisector(const TPoint &XX0, const TVector &UU) {
43  id = generateId();
44 
45  X0 = new TPoint(XX0);
46  U = new TVector(UU);
47 }
48 
49 TBisector::TBisector(const TPoint &P0, const TPoint &P1) {
50  id = generateId();
51 
52  X0 = new TPoint(P0);
53  U = new TVector(P0, P1);
54 }
55 
57  id = generateId();
58  OLD_ASSERT_EQUAL(ele.dim(), 1);
59 
60  X0 = new TPoint(ele.node[0]->point()(0), ele.node[0]->point()(1), ele.node[0]->point()(2));
61  U = new TVector(*X0, TPoint(ele.node[1]->point()(0), ele.node[1]->point()(1), ele.node[1]->point()(2)) );
62 }
63 
65 {
66  id = generateId();
67 
68  X0 = new TPoint(*(x.X0));
69  U = new TVector(*(x.U));
70 }
71 
73  delete X0;
74  delete U;
75 }
76 
78  *(*this).U = *b.U;
79  *(*this).X0 = *b.X0;
80 
81  return *this;
82 }
83 
84 std::ostream & operator <<(std::ostream &stream, const TBisector &b) {
85  stream << "U = (" << b.U->X1() << ", " << b.U->X2() << ", " << b.U->X3() << ")\n";
86  stream << "X0 = [" << b.X0->X() << ", " << b.X0->Y() << ", " << b.X0->Z() << "]\n";
87 
88  return stream;
89 }
90 
91 void TBisector::SetPoint(const TPoint &P) {
92  *X0 = P;
93 }
94 
95 void TBisector::SetVector(const TVector &UU) {
96  *U = UU;
97 }
98 
99 void TBisector::SetPoints(const TPoint &P0, const TPoint &P1) {
100  *X0 = P0;
101  *U = (TPoint) P1 - P0;
102 }
103 
105 
106  return *(this->U);
107 }
108 
110 {
111  return *(this->X0);
112 }
113 
114 TPoint TBisector::GetPoint(double t) const {
115  TPoint tmp;
116 
117  tmp.SetCoord(t * *U);
118  tmp = tmp + *X0;
119 
120  return tmp;
121 }
122 
123 void TBisector::GetParameter(const TPoint &P, double &t, bool &onBisector) const {
124  t = (P.X() - X0->X()) / U->X1();
125  onBisector = (fabs( (P.Y() - X0->Y()) / U->X2() - t ) < epsilon) & (fabs( (P.Z() - X0->Z()) / U->X3() - t ) < epsilon);
126 }
127 
128 bool TBisector::Belong(const TPoint &P) const {
129  if (IsZero(Distance(*this, P))) {
130  return true;
131  } else {
132  return false;
133  }
134 }
double Distance(const TBisector &, const TPoint &)
void SetVector(const TVector &)
Definition: bisector.cpp:95
const TVector & GetVector() const
Definition: bisector.cpp:104
double X2() const
Definition: vector.cpp:222
double X1() const
Definition: vector.cpp:218
static int numberInstance
Definition: bisector.h:31
Node ** node
Definition: elements.h:79
bool IsZero(double)
Definition: mathfce.cpp:22
double X3() const
Definition: vector.cpp:226
const TPoint & GetPoint() const
Definition: bisector.cpp:109
void SetPoint(const TPoint &)
Definition: bisector.cpp:91
double X() const
Definition: point.cpp:108
unsigned int dim() const
TPoint * X0
Definition: bisector.h:34
Global macros to enhance readability and debugging, general constants.
~TBisector()
Definition: bisector.cpp:72
Definition: point.h:27
int generateId()
Definition: bisector.cpp:31
double Y() const
Definition: point.cpp:112
void SetCoord(double, double, double)
Definition: point.cpp:96
double Z() const
Definition: point.cpp:116
void GetParameter(const TPoint &, double &, bool &) const
Definition: bisector.cpp:123
void SetPoints(const TPoint &, const TPoint &)
Definition: bisector.cpp:99
bool Belong(const TPoint &) const
Definition: bisector.cpp:128
const double epsilon
Definition: mathfce.h:23
TBisector & operator=(const TBisector &)
Definition: bisector.cpp:77
std::ostream & operator<<(std::ostream &stream, const TBisector &b)
Definition: bisector.cpp:84
#define OLD_ASSERT_EQUAL(a, b)
Definition: global_defs.h:133
TVector * U
Definition: bisector.h:35
arma::vec3 & point()
Definition: nodes.hh:68