Skip to content

Commit b0ba2c9

Browse files
committed
beautify
1 parent e532a62 commit b0ba2c9

13 files changed

+164
-377
lines changed

src/modm/math/geometry/vector.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ namespace modm
7171
bool operator > (const Vector &rhs) const;
7272
bool operator >= (const Vector &rhs) const;
7373

74-
const T& operator [] (std::size_t index) const;
7574
T& operator [] (std::size_t index);
75+
const T& operator [] (std::size_t index) const;
7676

7777
T* ptr();
7878
const T* ptr() const;

src/modm/math/geometry/vector1.hpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
* License, v. 2.0. If a copy of the MPL was not distributed with this
1010
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
1111
*/
12-
// ----------------------------------------------------------------------------
13-
1412
#pragma once
1513

1614
#include <cmath>
@@ -35,6 +33,12 @@ namespace modm
3533
class Vector<T, 1>
3634
{
3735
public:
36+
using WideType = GeometricTraits<T>::WideType;
37+
using FloatType = GeometricTraits<T>::FloatType;
38+
39+
T x = 0;
40+
41+
// basic constructors
3842
constexpr Vector() = default;
3943
constexpr Vector(T inX);
4044
constexpr Vector(const Matrix<T, 1, 1> &rhs);
@@ -57,8 +61,9 @@ namespace modm
5761
bool operator > (const Vector &rhs) const;
5862
bool operator >= (const Vector &rhs) const;
5963

60-
const T& operator [] (std::size_t index) const;
6164
T& operator [] (std::size_t index);
65+
const T& operator [] (std::size_t index) const;
66+
6267
T* ptr();
6368
const T* ptr() const;
6469

@@ -86,10 +91,6 @@ namespace modm
8691
bool hasNan() const;
8792
bool hasInf() const;
8893

89-
public:
90-
T x = 0;
91-
92-
public:
9394
#ifndef __DOXYGEN__
9495
IMPLEMENT_VECTOR_ACCESSOR2(x,x)
9596
IMPLEMENT_VECTOR_ACCESSOR3(x,x,x)

src/modm/math/geometry/vector1_impl.hpp

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
* License, v. 2.0. If a copy of the MPL was not distributed with this
1010
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
1111
*/
12-
// ----------------------------------------------------------------------------
13-
1412
#pragma once
1513
#include "vector1.hpp"
1614

@@ -30,19 +28,15 @@ void
3028
modm::Vector<T, 1>::set(const T& value)
3129
{ this->x = value; }
3230

33-
// ----------------------------------------------------------------------------
3431
template<typename T>
3532
void
3633
modm::Vector<T, 1>::setX(const T& value)
3734
{ this->x = value; }
3835

39-
// ----------------------------------------------------------------------------
4036
template<typename T>
4137
const T&
4238
modm::Vector<T, 1>::getX() const
43-
{
44-
return this->x;
45-
}
39+
{ return this->x; }
4640

4741
// ----------------------------------------------------------------------------
4842
template<typename T>
@@ -61,39 +55,34 @@ modm::Vector<T, 1>::operator == (const modm::Vector<T, 1> &rhs) const
6155
return (rhs.x == x);
6256
}
6357

64-
// ----------------------------------------------------------------------------
6558
template<typename T>
6659
bool
6760
modm::Vector<T, 1>::operator != (const modm::Vector<T, 1> &rhs) const
6861
{
6962
return (rhs.x != x);
7063
}
7164

72-
// ----------------------------------------------------------------------------
7365
template<typename T>
7466
bool
7567
modm::Vector<T, 1>::operator < (const modm::Vector<T, 1> &rhs) const
7668
{
7769
return (x < rhs.x);
7870
}
7971

80-
// ----------------------------------------------------------------------------
8172
template<typename T>
8273
bool
8374
modm::Vector<T, 1>::operator <= (const modm::Vector<T, 1> &rhs) const
8475
{
8576
return (x <= rhs.x);
8677
}
8778

88-
// ----------------------------------------------------------------------------
8979
template<typename T>
9080
bool
9181
modm::Vector<T, 1>::operator > (const modm::Vector<T, 1> &rhs) const
9282
{
9383
return (x > rhs.x);
9484
}
9585

96-
// ----------------------------------------------------------------------------
9786
template<typename T>
9887
bool
9988
modm::Vector<T, 1>::operator >= (const modm::Vector<T, 1> &rhs) const
@@ -139,31 +128,27 @@ modm::Vector<T, 1>::operator + (const modm::Vector<T, 1> &rhs) const
139128
return modm::Vector<T, 1>(x+rhs.x);
140129
}
141130

142-
// ----------------------------------------------------------------------------
143131
template<typename T>
144132
modm::Vector<T, 1>
145133
modm::Vector<T, 1>::operator - (const modm::Vector<T, 1> &rhs) const
146134
{
147135
return modm::Vector<T, 1>(x-rhs.x);
148136
}
149137

150-
// ----------------------------------------------------------------------------
151138
template<typename T>
152139
T
153140
modm::Vector<T, 1>::operator * (const modm::Vector<T, 1> &rhs) const
154141
{
155142
return x*rhs.x;
156143
}
157144

158-
// ----------------------------------------------------------------------------
159145
template<typename T>
160146
modm::Vector<T, 1>
161147
modm::Vector<T, 1>::operator * (const T &rhs) const
162148
{
163149
return modm::Vector<T, 1>(x*rhs);
164150
}
165151

166-
// ----------------------------------------------------------------------------
167152
template<typename T>
168153
modm::Vector<T, 1>
169154
modm::Vector<T, 1>::operator / (const T &rhs) const
@@ -180,7 +165,6 @@ modm::Vector<T, 1>::operator += (const modm::Vector<T, 1> &rhs)
180165
return *this;
181166
}
182167

183-
// ----------------------------------------------------------------------------
184168
template<typename T>
185169
modm::Vector<T, 1>&
186170
modm::Vector<T, 1>::operator -= (const modm::Vector<T, 1> &rhs)
@@ -189,7 +173,6 @@ modm::Vector<T, 1>::operator -= (const modm::Vector<T, 1> &rhs)
189173
return *this;
190174
}
191175

192-
// ----------------------------------------------------------------------------
193176
template<typename T>
194177
modm::Vector<T, 1>&
195178
modm::Vector<T, 1>::operator *= (const T &rhs)
@@ -198,7 +181,6 @@ modm::Vector<T, 1>::operator *= (const T &rhs)
198181
return *this;
199182
}
200183

201-
// ----------------------------------------------------------------------------
202184
template<typename T>
203185
modm::Vector<T, 1>&
204186
modm::Vector<T, 1>::operator /= (const T &rhs)
@@ -223,7 +205,6 @@ modm::Vector<T, 1>::getLength() const
223205
return std::abs(x);
224206
}
225207

226-
// ----------------------------------------------------------------------------
227208
template<typename T>
228209
T
229210
modm::Vector<T, 1>::getLengthSquared() const
@@ -239,7 +220,6 @@ modm::Vector<T, 1>::asMatrix()
239220
return *(modm::Matrix<T, 1, 1>*) this;
240221
}
241222

242-
// ----------------------------------------------------------------------------
243223
template<typename T>
244224
const modm::Matrix<T, 1, 1>&
245225
modm::Vector<T, 1>::asMatrix() const
@@ -255,7 +235,6 @@ modm::Vector<T, 1>::hasNan() const
255235
return std::isnan(x);
256236
}
257237

258-
// ----------------------------------------------------------------------------
259238
template<typename T>
260239
bool
261240
modm::Vector<T, 1>::hasInf() const

src/modm/math/geometry/vector2.hpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
* License, v. 2.0. If a copy of the MPL was not distributed with this
1111
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
1212
*/
13-
// ----------------------------------------------------------------------------
14-
1513
#pragma once
1614

1715
#include <cmath>
@@ -60,7 +58,9 @@ namespace modm
6058
typedef typename GeometricTraits<T>::WideType WideType;
6159
typedef typename GeometricTraits<T>::FloatType FloatType;
6260

63-
public:
61+
T x = 0, y = 0;
62+
63+
// basic constructors
6464
constexpr Vector() = default;
6565
constexpr Vector(const T& inX, const T& inY);
6666
constexpr Vector(const Vector<T, 1> &inX, const Vector<T, 1> &inY);
@@ -231,8 +231,8 @@ namespace modm
231231
bool operator > (const Vector &rhs) const;
232232
bool operator >= (const Vector &rhs) const;
233233

234-
const T& operator [] (std::size_t index) const;
235234
T& operator [] (std::size_t index);
235+
const T& operator [] (std::size_t index) const;
236236

237237
T* ptr();
238238
const T* ptr() const;
@@ -286,10 +286,6 @@ namespace modm
286286
IMPLEMENT_VECTOR_ACCESSOR4(y,y,y,x); IMPLEMENT_VECTOR_ACCESSOR4(y,y,y,y);
287287
#endif
288288

289-
public:
290-
T x = 0;
291-
T y = 0;
292-
293289
protected:
294290
template<typename U>
295291
friend IOStream&

0 commit comments

Comments
 (0)