-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTriangle.cpp
More file actions
72 lines (57 loc) · 1.03 KB
/
Triangle.cpp
File metadata and controls
72 lines (57 loc) · 1.03 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
#include "Triangle.hpp"
Triangle::Triangle( void )
{
this->_initNormalVector();
return ;
}
Triangle::Triangle( Vertex const & a, Vertex const & b, Vertex const & c ) : _a(a), _b(b), _c(c)
{
this->_initNormalVector();
return ;
}
Triangle::Triangle(Triangle const & src)
{
*this = src;
return ;
}
Triangle::~Triangle( void )
{
return ;
}
Triangle & Triangle::operator=(Triangle const & rhs)
{
this->_a = rhs._a;
this->_b = rhs._b;
this->_c = rhs._c;
return *this;
}
Vertex Triangle::getA() const
{
return this->_a;
}
Vertex Triangle::getB() const
{
return this->_b;
}
Vertex Triangle::getC() const
{
return this->_c;
}
void Triangle::_initNormalVector()
{
Vector ab(this->_a, this->_b);
Vector ac(this->_a, this->_c);
this->_normal = ab ^ ac;
}
std::string Triangle::toString() const
{
std::stringstream sstr;
sstr << "[Triangle : {" << this->_a << ", " << this->_b << ", " << this->_c
<< "}]";
return sstr.str();
}
std::ostream & operator<<(std::ostream & o, Triangle const & rhs)
{
o << rhs.toString();
return o;
}