Flow123d  release_2.2.0-26-ge868538
plain.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 plain.cpp
15  * @brief
16  */
17 
18 #include "mesh/ngh/include/plain.h"
21 
22 using namespace mathfce;
23 
25 
27  return TPlain::numberInstance++;
28 }
29 
31  id = generateId();
32 
33  U = new TVector(0, 0, 0);
34  V = new TVector(0, 0, 0);
35  N = new TVector(0, 0, 0);
36  X = new TPoint(0, 0, 0);
37 
38  Compute();
39 }
40 
41 TPlain::TPlain(const TVector &UU, const TVector &VV, const TPoint &XX) {
42  id = generateId();
43 
44  U = new TVector(UU);
45  V = new TVector(VV);
46  N = new TVector(0, 0, 0);
47  X = new TPoint(XX);
48 
49  Compute();
50 }
51 
52 TPlain::TPlain(const TPoint &P1, const TPoint &P2, const TPoint &P3) {
53  id = generateId();
54 
55  U = new TVector(P1, P2);
56  V = new TVector(P1, P3);
57  N = new TVector(0, 0, 0);
58  X = new TPoint(P1);
59 
60  Compute();
61 }
62 
64  id = generateId();
65 
66  N = new TVector();
67  U = new TVector();
68  V = new TVector();
69  X = new TPoint();
70 
71  a = p.a;
72  b = p.b;
73  c = p.c;
74  d = p.d;
75 
76  *N = *p.N;
77  *U = *p.U;
78  *V = *p.V;
79  *X = *p.X;
80 }
81 
83  *N = Cross(*U, *V);
84  a = N->X1();
85  b = N->X2();
86  c = N->X3();
87  d = -a * X->X() - b * X->Y() - c * X->Z();
88  return;
89 }
90 
92  delete U;
93  delete V;
94  delete N;
95  delete X;
96 }
97 
98 double TPlain::GetA() const {
99  return a;
100 }
101 
102 double TPlain::GetB() const {
103  return b;
104 }
105 
106 double TPlain::GetC() const {
107  return c;
108 }
109 
110 double TPlain::GetD() const {
111  return d;
112 }
113 
114 const TVector &TPlain::GetNormal() const {
115  return *N;
116 }
117 
118 const TVector &TPlain::GetU() const {
119  return *U;
120 }
121 
122 const TVector &TPlain::GetV() const {
123  return *V;
124 }
125 
126 const TPoint &TPlain::GetPoint() const {
127  return *X;
128 }
129 
130 TPoint TPlain::GetPoint(double r, double s) const {
131  TPoint tmp;
132  tmp = r * *U + s * *V + *X;
133  return tmp;
134 }
135 
136 bool TPlain::Belong(const TPoint &P) const {
137  if (IsZero(Distance(*this, P)))
138  return true;
139  return false;
140 }
141 
143  a = p.a;
144  b = p.b;
145  c = p.c;
146  d = p.d;
147  *(*this).U = *p.U;
148  *(*this).V = *p.V;
149  *(*this).N = *p.N;
150  *(*this).X = *p.X;
151  return *this;
152 }
153 
154 void TPlain::SetPoints(const TPoint &P1, const TPoint &P2, const TPoint &P3) {
155  *U = (TPoint) P2 - P1;
156  *V = (TPoint) P3 - P1;
157  *X = P1;
158  Compute();
159 }
160 
double GetA() const
Definition: plain.cpp:98
double Distance(const TBisector &, const TPoint &)
static int numberInstance
Definition: plain.h:26
double a
Definition: plain.h:33
const TPoint & GetPoint() const
Definition: plain.cpp:126
double b
Definition: plain.h:34
double d
Definition: plain.h:36
double GetC() const
Definition: plain.cpp:106
void SetPoints(const TPoint &, const TPoint &, const TPoint &)
Definition: plain.cpp:154
TPoint * X
Definition: plain.h:38
Definition: plain.h:24
bool IsZero(double)
Definition: mathfce.cpp:22
int generateId()
Definition: plain.cpp:26
TVector * V
Definition: plain.h:30
TPlain()
Definition: plain.cpp:30
const TVector & GetU() const
Definition: plain.cpp:118
Definition: point.h:27
double c
Definition: plain.h:35
double GetB() const
Definition: plain.cpp:102
TVector Cross(const TVector &, const TVector &)
Definition: vector.cpp:180
const TVector & GetV() const
Definition: plain.cpp:122
void Compute()
Definition: plain.cpp:82
bool Belong(const TPoint &) const
Definition: plain.cpp:136
TVector * U
Definition: plain.h:29
TVector * N
Definition: plain.h:31
TPlain & operator=(const TPlain &)
Definition: plain.cpp:142
const TVector & GetNormal() const
Definition: plain.cpp:114
double GetD() const
Definition: plain.cpp:110
~TPlain()
Definition: plain.cpp:91