Skyscraper 2.0
triangle.h
Go to the documentation of this file.
1/*
2 Scalable Building Simulator - Triangle Type
3 The Skyscraper Project - Version 2.0
4 Copyright (C)2004-2024 Ryan Thoryk
5 https://www.skyscrapersim.net
6 https://sourceforge.net/projects/skyscraper/
7 Contact - ryan@skyscrapersim.net
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22*/
23
24//triangles have a, b and c components (each a vertex index)
25
26#ifndef _SBS_TRIANGLE_H
27#define _SBS_TRIANGLE_H
28
29namespace SBS {
30
32{
33 unsigned int a, b, c;
34
35 inline Triangle(unsigned int a, unsigned int b, unsigned int c)
36 {
37 this->a = a;
38 this->b = b;
39 this->c = c;
40 }
41
42 inline Triangle()
43 {
44 this->a = 0;
45 this->b = 0;
46 this->c = 0;
47 }
48
49 inline bool operator == (const Triangle &other) const
50 {
51 return (a == other.a && b == other.b && c == other.c);
52 }
53
54 inline bool operator != (const Triangle &other) const
55 {
56 return !(*this == other);
57 }
58
59 inline Triangle& operator += (const Triangle &other)
60 {
61 a += other.a;
62 b += other.b;
63 c += other.b;
64 return *this;
65 }
66
67 inline Triangle& operator += (const unsigned int value)
68 {
69 a += value;
70 b += value;
71 c += value;
72 return *this;
73 }
74
75 inline Triangle& operator -= (const Triangle &other)
76 {
77 a -= other.a;
78 b -= other.b;
79 c -= other.b;
80 return *this;
81 }
82
83 inline Triangle& operator -= (const unsigned int value)
84 {
85 a -= value;
86 b -= value;
87 c -= value;
88 return *this;
89 }
90
91 inline Triangle& operator = (const Triangle &other)
92 {
93 a = other.a;
94 b = other.b;
95 c = other.c;
96 return *this;
97 }
98
99 inline Triangle operator + (const Triangle &other) const
100 {
101 return Triangle(a + other.a, b + other.b, c + other.c);
102 }
103
104 inline Triangle operator + (const unsigned int value) const
105 {
106 return Triangle(a + value, b + value, c + value);
107 }
108
109 inline Triangle operator - (const Triangle &other) const
110 {
111 return Triangle(a - other.a, b - other.b, c - other.c);
112 }
113
114 inline Triangle operator - (const unsigned int value) const
115 {
116 return Triangle(a - value, b - value, c - value);
117 }
118};
119
120}
121
122#endif
Triangle operator+(const Triangle &other) const
Definition triangle.h:99
unsigned int c
Definition triangle.h:33
Triangle(unsigned int a, unsigned int b, unsigned int c)
Definition triangle.h:35
unsigned int a
Definition triangle.h:33
bool operator==(const Triangle &other) const
Definition triangle.h:49
Triangle & operator=(const Triangle &other)
Definition triangle.h:91
unsigned int b
Definition triangle.h:33
Triangle & operator-=(const Triangle &other)
Definition triangle.h:75
bool operator!=(const Triangle &other) const
Definition triangle.h:54
Triangle operator-(const Triangle &other) const
Definition triangle.h:109
Triangle & operator+=(const Triangle &other)
Definition triangle.h:59