Browse Source

made const operators

develop
Robin Thoni 7 years ago
parent
commit
ed812a68b0
2 changed files with 26 additions and 26 deletions
  1. 13
    13
      UGameEngine/utils/vector3d.cpp
  2. 13
    13
      UGameEngine/utils/vector3d.h

+ 13
- 13
UGameEngine/utils/vector3d.cpp View File

@@ -127,12 +127,12 @@ double Vector3D::norm() const
127 127
     return sqrt((_x * _x) + (_y * _y) + (_z * _z));
128 128
 }
129 129
 
130
-Vector3D Vector3D::operator+()
130
+Vector3D Vector3D::operator+() const
131 131
 {
132 132
     return *this;
133 133
 }
134 134
 
135
-Vector3D Vector3D::operator+(const double &k)
135
+Vector3D Vector3D::operator+(const double &k) const
136 136
 {
137 137
     return Vector3D(*this).add(k);
138 138
 }
@@ -142,7 +142,7 @@ Vector3D &Vector3D::operator+=(const double &k)
142 142
     return add(k);
143 143
 }
144 144
 
145
-Vector3D Vector3D::operator+(const Vector3D &other)
145
+Vector3D Vector3D::operator+(const Vector3D &other) const
146 146
 {
147 147
     return Vector3D(*this).add(other);
148 148
 }
@@ -152,12 +152,12 @@ Vector3D &Vector3D::operator+=(const Vector3D &other)
152 152
     return add(other);
153 153
 }
154 154
 
155
-Vector3D Vector3D::operator-()
155
+Vector3D Vector3D::operator-() const
156 156
 {
157 157
     return Vector3D(-_x, -_y, -_z);
158 158
 }
159 159
 
160
-Vector3D Vector3D::operator-(const double &k)
160
+Vector3D Vector3D::operator-(const double &k) const
161 161
 {
162 162
     return Vector3D(*this).sub(k);
163 163
 }
@@ -167,7 +167,7 @@ Vector3D &Vector3D::operator-=(const double &k)
167 167
     return sub(k);
168 168
 }
169 169
 
170
-Vector3D Vector3D::operator-(const Vector3D &other)
170
+Vector3D Vector3D::operator-(const Vector3D &other) const
171 171
 {
172 172
     return Vector3D(*this).sub(other);
173 173
 }
@@ -177,7 +177,7 @@ Vector3D &Vector3D::operator-=(const Vector3D &other)
177 177
     return sub(other);
178 178
 }
179 179
 
180
-Vector3D Vector3D::operator*(const double &k)
180
+Vector3D Vector3D::operator*(const double &k) const
181 181
 {
182 182
     return Vector3D(*this).mult(k);
183 183
 }
@@ -187,7 +187,7 @@ Vector3D &Vector3D::operator*=(const double &k)
187 187
     return mult(k);
188 188
 }
189 189
 
190
-double Vector3D::operator*(const Vector3D &other)
190
+double Vector3D::operator*(const Vector3D &other) const
191 191
 {
192 192
     return Vector3D(*this).dotProduct(other);
193 193
 }
@@ -198,7 +198,7 @@ Vector3D &Vector3D::operator*=(const Vector3D &other)
198 198
     return *this;
199 199
 }
200 200
 
201
-Vector3D Vector3D::operator/(const double &k)
201
+Vector3D Vector3D::operator/(const double &k) const
202 202
 {
203 203
     return Vector3D(*this).div(k);
204 204
 }
@@ -208,22 +208,22 @@ Vector3D &Vector3D::operator/=(const double &k)
208 208
     return div(k);
209 209
 }
210 210
 
211
-bool Vector3D::operator==(const Vector3D &other)
211
+bool Vector3D::operator==(const Vector3D &other) const
212 212
 {
213 213
     return equal(other);
214 214
 }
215 215
 
216
-bool Vector3D::operator!=(const Vector3D &other)
216
+bool Vector3D::operator!=(const Vector3D &other) const
217 217
 {
218 218
     return !equal(other);
219 219
 }
220 220
 
221
-bool Vector3D::operator!()
221
+bool Vector3D::operator!() const
222 222
 {
223 223
     return isNull();
224 224
 }
225 225
 
226
-Vector3D::operator bool()
226
+Vector3D::operator bool() const
227 227
 {
228 228
     return !isNull();
229 229
 }

+ 13
- 13
UGameEngine/utils/vector3d.h View File

@@ -40,31 +40,31 @@ public:
40 40
 
41 41
     double norm() const;
42 42
 
43
-    Vector3D operator+();
44
-    Vector3D operator+(const double& k);
43
+    Vector3D operator+() const;
44
+    Vector3D operator+(const double& k) const;
45 45
     Vector3D& operator+=(const double& k);
46
-    Vector3D operator+(const Vector3D& other);
46
+    Vector3D operator+(const Vector3D& other) const;
47 47
     Vector3D& operator+=(const Vector3D& other);
48 48
 
49
-    Vector3D operator-();
50
-    Vector3D operator-(const double& k);
49
+    Vector3D operator-() const;
50
+    Vector3D operator-(const double& k) const;
51 51
     Vector3D& operator-=(const double& k);
52
-    Vector3D operator-(const Vector3D& other);
52
+    Vector3D operator-(const Vector3D& other) const;
53 53
     Vector3D& operator-=(const Vector3D& other);
54 54
 
55
-    Vector3D operator*(const double& k);
55
+    Vector3D operator*(const double& k) const;
56 56
     Vector3D& operator*=(const double& k);
57
-    double operator*(const Vector3D& other);
57
+    double operator*(const Vector3D& other) const;
58 58
     Vector3D& operator*=(const Vector3D& other);
59 59
 
60
-    Vector3D operator/(const double& k);
60
+    Vector3D operator/(const double& k) const;
61 61
     Vector3D& operator/=(const double& k);
62 62
 
63
-    bool operator==(const Vector3D& other);
64
-    bool operator!=(const Vector3D& other);
63
+    bool operator==(const Vector3D& other) const;
64
+    bool operator!=(const Vector3D& other) const;
65 65
 
66
-    bool operator!();
67
-    operator bool();
66
+    bool operator!() const;
67
+    operator bool() const;
68 68
 
69 69
 private:
70 70
     double _x;

Loading…
Cancel
Save