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
     return sqrt((_x * _x) + (_y * _y) + (_z * _z));
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
     return *this;
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
     return Vector3D(*this).add(k);
137
     return Vector3D(*this).add(k);
138
 }
138
 }
142
     return add(k);
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
     return Vector3D(*this).add(other);
147
     return Vector3D(*this).add(other);
148
 }
148
 }
152
     return add(other);
152
     return add(other);
153
 }
153
 }
154
 
154
 
155
-Vector3D Vector3D::operator-()
155
+Vector3D Vector3D::operator-() const
156
 {
156
 {
157
     return Vector3D(-_x, -_y, -_z);
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
     return Vector3D(*this).sub(k);
162
     return Vector3D(*this).sub(k);
163
 }
163
 }
167
     return sub(k);
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
     return Vector3D(*this).sub(other);
172
     return Vector3D(*this).sub(other);
173
 }
173
 }
177
     return sub(other);
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
     return Vector3D(*this).mult(k);
182
     return Vector3D(*this).mult(k);
183
 }
183
 }
187
     return mult(k);
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
     return Vector3D(*this).dotProduct(other);
192
     return Vector3D(*this).dotProduct(other);
193
 }
193
 }
198
     return *this;
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
     return Vector3D(*this).div(k);
203
     return Vector3D(*this).div(k);
204
 }
204
 }
208
     return div(k);
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
     return equal(other);
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
     return !equal(other);
218
     return !equal(other);
219
 }
219
 }
220
 
220
 
221
-bool Vector3D::operator!()
221
+bool Vector3D::operator!() const
222
 {
222
 {
223
     return isNull();
223
     return isNull();
224
 }
224
 }
225
 
225
 
226
-Vector3D::operator bool()
226
+Vector3D::operator bool() const
227
 {
227
 {
228
     return !isNull();
228
     return !isNull();
229
 }
229
 }

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

40
 
40
 
41
     double norm() const;
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
     Vector3D& operator+=(const double& k);
45
     Vector3D& operator+=(const double& k);
46
-    Vector3D operator+(const Vector3D& other);
46
+    Vector3D operator+(const Vector3D& other) const;
47
     Vector3D& operator+=(const Vector3D& other);
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
     Vector3D& operator-=(const double& k);
51
     Vector3D& operator-=(const double& k);
52
-    Vector3D operator-(const Vector3D& other);
52
+    Vector3D operator-(const Vector3D& other) const;
53
     Vector3D& operator-=(const Vector3D& other);
53
     Vector3D& operator-=(const Vector3D& other);
54
 
54
 
55
-    Vector3D operator*(const double& k);
55
+    Vector3D operator*(const double& k) const;
56
     Vector3D& operator*=(const double& k);
56
     Vector3D& operator*=(const double& k);
57
-    double operator*(const Vector3D& other);
57
+    double operator*(const Vector3D& other) const;
58
     Vector3D& operator*=(const Vector3D& other);
58
     Vector3D& operator*=(const Vector3D& other);
59
 
59
 
60
-    Vector3D operator/(const double& k);
60
+    Vector3D operator/(const double& k) const;
61
     Vector3D& operator/=(const double& k);
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
 private:
69
 private:
70
     double _x;
70
     double _x;

Loading…
Cancel
Save