Flow123d  release_2.2.0-914-gf1a3a4f
abscissa.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 abscissa.cpp
15  * @brief
16  */
17 
18 #include <cmath>
19 
22 #include "stdio.h"
23 
24 namespace ngh {
25 
27 
29  return TAbscissa::numberInstance++;
30 }
31 
33  id = generateId();
34 }
35 
36 TAbscissa::TAbscissa(const TPoint& PP0, const TPoint& PP1)
37 : TBisector(PP0, PP1)
38 {
39  id = generateId();
40 
41  ComputeLength();
42 }
43 
44 
46 : TBisector(ele)
47 {
48  id = generateId();
49 
50  ComputeLength();
51 }
52 
53 
54 
56 
57  *U = *(a.U);
58  *X0 = *(a.X0);
59 
60  length = a.length;
61 
62  return *this;
63 }
64 
66 }
67 
68 void TAbscissa::SetPoints(const TPoint& PP0, const TPoint& PP1) {
69  TBisector::SetPoints(PP0, PP1);
70  ComputeLength();
71 }
72 
74 
75  length = U->Length();
76 }
77 
79  return length;
80 }
81 
83  arma::vec3 minCoor;
84  arma::vec3 maxCoor;
85 
86  for (int i=0; i<3; ++i) {
87  minCoor(i) = GetMin(i+1);
88  maxCoor(i) = GetMax(i+1);
89  }
90 
91  boundingBox=BoundingBox(minCoor, maxCoor);
92 
93  return boundingBox;
94 }
95 
96 double TAbscissa::GetMin(int x) const {
97  if (U == NULL ) printf("U is null!");
98  if (U->Get(x) < 0 ) {
99  return U->Get(x)+X0->Get(x);
100  } else {
101  return X0->Get(x);
102  }
103 }
104 
105 double TAbscissa::GetMax(int x) const {
106  if (U->Get(x) > 0 ) {
107  return U->Get(x)+X0->Get(x);
108  } else {
109  return X0->Get(x);
110  }
111 }
112 
113 bool TAbscissa::IsInner(const TPoint& P) const {
114  TVector Up(*X0, P);
115 
116  double x_proportion = Up.X1() / U->X1();
117  if ( x_proportion < 0 || x_proportion > 1 ) {
118  return false;
119  }
120 
121  if ( (fabs( Up.X2() / U->X2() - x_proportion ) < epsilon) && (fabs( Up.X3() / U->X3() - x_proportion ) < epsilon) ) {
122  return true;
123  } else {
124  return false;
125  }
126 }
127 
128 } // namespace ngh
Bounding box in 3d ambient space.
Definition: bounding_box.hh:45
double GetMax(int) const
Definition: abscissa.cpp:105
bool IsInner(const TPoint &) const
Definition: abscissa.cpp:113
TVector * U
Definition: bisector.h:37
TAbscissa & operator=(const TAbscissa &)
Definition: abscissa.cpp:55
Definition: abscissa.h:25
double Get(int) const
Definition: point.cpp:123
double Length()
Definition: abscissa.cpp:78
void Get(double &, double &, double &) const
Definition: vector.cpp:163
void SetPoints(const TPoint &, const TPoint &)
Definition: abscissa.cpp:68
double X2() const
Definition: vector.cpp:224
double Length() const
Definition: vector.cpp:159
BoundingBox & get_bounding_box()
Definition: abscissa.cpp:82
double X3() const
Definition: vector.cpp:228
BoundingBox boundingBox
Definition: abscissa.h:33
void ComputeLength()
Definition: abscissa.cpp:73
const double epsilon
Definition: mathfce.h:23
TPoint * X0
Definition: bisector.h:36
int generateId()
Definition: abscissa.cpp:28
double length
Definition: abscissa.h:35
static int numberInstance
Definition: abscissa.h:30
double GetMin(int) const
Definition: abscissa.cpp:96
void SetPoints(const TPoint &, const TPoint &)
Definition: bisector.cpp:100
double X1() const
Definition: vector.cpp:220
void printf(BasicWriter< Char > &w, BasicCStringRef< Char > format, ArgList args)
Definition: printf.h:444