Flow123d  jenkins-Flow123d-windows32-release-multijob-51
point.cpp
Go to the documentation of this file.
1 #include <iostream>
2 
3 #include "system/exc_common.hh"
6 
7 using namespace mathfce;
8 
10 
12  return TPoint::numberInstance++;
13 }
14 
16  x = 0;
17  y = 0;
18  z = 0;
19 
20  id = generateId();
21 }
22 
23 TPoint::TPoint(double x, double y, double z) {
24  this->x = x;
25  this->y = y;
26  this->z = z;
27 
28  id = generateId();
29 }
30 
32  x = point.X();
33  y = point.Y();
34  z = point.Z();
35 
36  id = generateId();
37 }
38 
40 }
41 
43  x = P.x;
44  y = P.y;
45  z = P.z;
46 
47  return *this;
48 }
49 
50 bool TPoint::operator ==(const TPoint& P) const {
51  if (IsEqual(x, P.x) && IsEqual(y, P.y) && IsEqual(z, P.z)) {
52  return true;
53  }
54  return false;
55 }
56 
58  x = U.X1();
59  y = U.X2();
60  z = U.X3();
61 
62  return *this;
63 }
64 
66  return TVector( x - P.x, y - P.y, z - P.z);
67 }
68 
69 TPoint TPoint::operator +(const TPoint& P) const {
70  TPoint res;
71 
72  res.x = x + P.x;
73  res.y = y + P.y;
74  res.z = z + P.z;
75 
76  return res;
77 }
78 
79 void TPoint::SetCoord(double x, double y, double z) {
80  this->x = x;
81  this->y = y;
82  this->z = z;
83 }
84 
85 void TPoint::SetCoord(const TVector& U) {
86  x = U.X1();
87  y = U.X2();
88  z = U.X3();
89 }
90 
91 double TPoint::X() const {
92  return x;
93 }
94 
95 double TPoint::Y() const {
96  return y;
97 }
98 
99 double TPoint::Z() const {
100  return z;
101 }
102 
103 double TPoint::Get(int i) const {
104  if (!(i >= 1 && i <= 3)) {
105  THROW( ExcAssertMsg() << EI_Message( "Invalid specification of the element of the vector.") );
106  }
107 
108  switch (i) {
109  case 1: return x;
110  case 2: return y;
111  case 3: return z;
112  }
113 
114  return 0.0;
115 }
116 
117 std::ostream & operator <<(std::ostream& stream, const TPoint& P) {
118  stream << "[" << P.x << " " << P.y << " " << P.z << "]";
119  return stream;
120 }
double y
Definition: point.h:16
double X2() const
Definition: vector.cpp:205
TPoint * operator+(TPoint *)
double X1() const
Definition: vector.cpp:201
TPoint * operator=(TPoint *)
double X3() const
Definition: vector.cpp:209
double X() const
Definition: point.cpp:91
Definition: point.h:10
int generateId()
Definition: point.cpp:11
double Y() const
Definition: point.cpp:95
void SetCoord(double, double, double)
Definition: point.cpp:79
TVector operator-(const TPoint &) const
Definition: point.cpp:65
std::ostream & operator<<(std::ostream &stream, const TPoint &P)
Definition: point.cpp:117
double Z() const
Definition: point.cpp:99
double x
Definition: point.h:15
bool operator==(TPoint *)
TPoint()
Definition: point.cpp:15
double Get(int) const
Definition: point.cpp:103
static int numberInstance
Definition: point.h:12
double z
Definition: point.h:17
#define THROW(whole_exception_expr)
Wrapper for throw. Saves the throwing point.
Definition: exceptions.hh:34
bool IsEqual(double, double)
Definition: mathfce.cpp:12
~TPoint()
Definition: point.cpp:39