-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVertex.cpp
More file actions
95 lines (78 loc) · 1.38 KB
/
Vertex.cpp
File metadata and controls
95 lines (78 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include "Vertex.hpp"
Vertex::Vertex( void ) : _x(0.0), _y(0.0), _z(0.0)
{
return ;
}
Vertex::Vertex( double x, double y, double z) : _x(x), _y(y), _z(z)
{
return ;
}
Vertex::Vertex(Vertex const & src)
{
*this = src;
return ;
}
Vertex::~Vertex( void )
{
return ;
}
double Vertex::getX() const
{
return this->_x;
}
double Vertex::getY() const
{
return this->_y;
}
double Vertex::getZ() const
{
return this->_z;
}
void Vertex::setX(double x)
{
this->_x = x;
return ;
}
void Vertex::setY(double y)
{
this->_y = y;
return ;
}
void Vertex::setZ(double z)
{
this->_z = z;
return ;
}
Vertex & Vertex::operator=(Vertex const & rhs)
{
this->_x = rhs._x;
this->_y = rhs._y;
this->_z = rhs._z;
return *this;
}
Vertex Vertex::operator+(Vertex const & rhs)
{
return Vertex(this->_x + rhs._x, this->_y + rhs._y, this->_z + rhs._z);
}
Vertex & Vertex::operator+=(Vertex const & rhs)
{
Vertex vtx = Vertex(*this + rhs);
*this = vtx;
return *this;
}
Vertex Vertex::operator*(double const rhs)
{
return Vertex(this->_x * rhs, this->_y * rhs, this->_z * rhs);
}
std::string Vertex::toString() const
{
std::stringstream sstr;
sstr << "[Vertex : {" << this->_x << ", " << this->_y << ", " << this->_z
<< "}]";
return sstr.str();
}
std::ostream & operator<<(std::ostream & o, Vertex const & rhs)
{
o << rhs.toString();
return o;
}