Skip to content

Commit 862612c

Browse files
committed
Cleanups
1 parent 05212e2 commit 862612c

17 files changed

+185
-432
lines changed

src/modm/math/geometry/quaternion.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
*/
1212
// ----------------------------------------------------------------------------
1313

14-
#ifndef MODM_QUATERNION_HPP
15-
#define MODM_QUATERNION_HPP
14+
#pragma once
1615

1716
#include <cmath>
1817
#include <stdint.h>

src/modm/math/geometry/quaternion_impl.hpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,10 @@
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-
14-
#ifndef MODM_QUATERNION_HPP
15-
# error "Don't include this file directly, use 'quaternion.hpp' instead!"
16-
#endif
1712

13+
#pragma once
1814
#include "quaternion.hpp"
1915

20-
// ----------------------------------------------------------------------------
2116
template<class T>
2217
modm::Quaternion<T>::Quaternion()
2318
:

src/modm/math/geometry/vector.hpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
*/
1313
// ----------------------------------------------------------------------------
1414

15-
#ifndef MODM_VECTOR_HPP
16-
#define MODM_VECTOR_HPP
15+
#pragma once
1716

1817
#include <cmath>
1918
#include <stdint.h>
@@ -72,8 +71,8 @@ namespace modm
7271
bool operator > (const Vector &rhs) const;
7372
bool operator >= (const Vector &rhs) const;
7473

75-
const T& operator [] (std::size_t index) const;
7674
T& operator [] (std::size_t index);
75+
const T& operator [] (std::size_t index) const;
7776

7877
T* ptr();
7978
const T* ptr() const;
@@ -147,6 +146,4 @@ namespace modm
147146
#include "vector1.hpp"
148147
#include "vector2.hpp"
149148
#include "vector3.hpp"
150-
#include "vector4.hpp"
151-
152-
#endif // MODM_VECTOR_HPP
149+
#include "vector4.hpp"

src/modm/math/geometry/vector1.hpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@
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-
14-
#ifndef MODM_VECTOR1_HPP
15-
#define MODM_VECTOR1_HPP
12+
#pragma once
1613

1714
#include <cmath>
1815
#include <cstdlib>
@@ -36,6 +33,12 @@ namespace modm
3633
class Vector<T, 1>
3734
{
3835
public:
36+
using WideType = GeometricTraits<T>::WideType;
37+
using FloatType = GeometricTraits<T>::FloatType;
38+
39+
T x = 0;
40+
41+
// basic constructors
3942
constexpr Vector() = default;
4043
constexpr Vector(T inX);
4144
constexpr Vector(const Matrix<T, 1, 1> &rhs);
@@ -58,8 +61,9 @@ namespace modm
5861
bool operator > (const Vector &rhs) const;
5962
bool operator >= (const Vector &rhs) const;
6063

61-
const T& operator [] (std::size_t index) const;
6264
T& operator [] (std::size_t index);
65+
const T& operator [] (std::size_t index) const;
66+
6367
T* ptr();
6468
const T* ptr() const;
6569

@@ -87,10 +91,6 @@ namespace modm
8791
bool hasNan() const;
8892
bool hasInf() const;
8993

90-
public:
91-
T x = 0;
92-
93-
public:
9494
#ifndef __DOXYGEN__
9595
IMPLEMENT_VECTOR_ACCESSOR2(x,x)
9696
IMPLEMENT_VECTOR_ACCESSOR3(x,x,x)
@@ -109,5 +109,3 @@ namespace modm
109109
}
110110

111111
#include "vector1_impl.hpp"
112-
113-
#endif // MODM_VECTOR1_HPP

src/modm/math/geometry/vector1_impl.hpp

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@
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-
14-
#ifndef MODM_VECTOR1_HPP
15-
#error "Don't include this file directly, use 'vector1.hpp' instead!"
16-
#endif
12+
#pragma once
13+
#include "vector1.hpp"
1714

1815
template<typename T>
1916
constexpr modm::Vector<T, 1>::Vector(T inX) :
@@ -31,19 +28,15 @@ void
3128
modm::Vector<T, 1>::set(const T& value)
3229
{ this->x = value; }
3330

34-
// ----------------------------------------------------------------------------
3531
template<typename T>
3632
void
3733
modm::Vector<T, 1>::setX(const T& value)
3834
{ this->x = value; }
3935

40-
// ----------------------------------------------------------------------------
4136
template<typename T>
4237
const T&
4338
modm::Vector<T, 1>::getX() const
44-
{
45-
return this->x;
46-
}
39+
{ return this->x; }
4740

4841
// ----------------------------------------------------------------------------
4942
template<typename T>
@@ -62,39 +55,34 @@ modm::Vector<T, 1>::operator == (const modm::Vector<T, 1> &rhs) const
6255
return (rhs.x == x);
6356
}
6457

65-
// ----------------------------------------------------------------------------
6658
template<typename T>
6759
bool
6860
modm::Vector<T, 1>::operator != (const modm::Vector<T, 1> &rhs) const
6961
{
7062
return (rhs.x != x);
7163
}
7264

73-
// ----------------------------------------------------------------------------
7465
template<typename T>
7566
bool
7667
modm::Vector<T, 1>::operator < (const modm::Vector<T, 1> &rhs) const
7768
{
7869
return (x < rhs.x);
7970
}
8071

81-
// ----------------------------------------------------------------------------
8272
template<typename T>
8373
bool
8474
modm::Vector<T, 1>::operator <= (const modm::Vector<T, 1> &rhs) const
8575
{
8676
return (x <= rhs.x);
8777
}
8878

89-
// ----------------------------------------------------------------------------
9079
template<typename T>
9180
bool
9281
modm::Vector<T, 1>::operator > (const modm::Vector<T, 1> &rhs) const
9382
{
9483
return (x > rhs.x);
9584
}
9685

97-
// ----------------------------------------------------------------------------
9886
template<typename T>
9987
bool
10088
modm::Vector<T, 1>::operator >= (const modm::Vector<T, 1> &rhs) const
@@ -140,31 +128,27 @@ modm::Vector<T, 1>::operator + (const modm::Vector<T, 1> &rhs) const
140128
return modm::Vector<T, 1>(x+rhs.x);
141129
}
142130

143-
// ----------------------------------------------------------------------------
144131
template<typename T>
145132
modm::Vector<T, 1>
146133
modm::Vector<T, 1>::operator - (const modm::Vector<T, 1> &rhs) const
147134
{
148135
return modm::Vector<T, 1>(x-rhs.x);
149136
}
150137

151-
// ----------------------------------------------------------------------------
152138
template<typename T>
153139
T
154140
modm::Vector<T, 1>::operator * (const modm::Vector<T, 1> &rhs) const
155141
{
156142
return x*rhs.x;
157143
}
158144

159-
// ----------------------------------------------------------------------------
160145
template<typename T>
161146
modm::Vector<T, 1>
162147
modm::Vector<T, 1>::operator * (const T &rhs) const
163148
{
164149
return modm::Vector<T, 1>(x*rhs);
165150
}
166151

167-
// ----------------------------------------------------------------------------
168152
template<typename T>
169153
modm::Vector<T, 1>
170154
modm::Vector<T, 1>::operator / (const T &rhs) const
@@ -181,7 +165,6 @@ modm::Vector<T, 1>::operator += (const modm::Vector<T, 1> &rhs)
181165
return *this;
182166
}
183167

184-
// ----------------------------------------------------------------------------
185168
template<typename T>
186169
modm::Vector<T, 1>&
187170
modm::Vector<T, 1>::operator -= (const modm::Vector<T, 1> &rhs)
@@ -190,7 +173,6 @@ modm::Vector<T, 1>::operator -= (const modm::Vector<T, 1> &rhs)
190173
return *this;
191174
}
192175

193-
// ----------------------------------------------------------------------------
194176
template<typename T>
195177
modm::Vector<T, 1>&
196178
modm::Vector<T, 1>::operator *= (const T &rhs)
@@ -199,7 +181,6 @@ modm::Vector<T, 1>::operator *= (const T &rhs)
199181
return *this;
200182
}
201183

202-
// ----------------------------------------------------------------------------
203184
template<typename T>
204185
modm::Vector<T, 1>&
205186
modm::Vector<T, 1>::operator /= (const T &rhs)
@@ -224,7 +205,6 @@ modm::Vector<T, 1>::getLength() const
224205
return std::abs(x);
225206
}
226207

227-
// ----------------------------------------------------------------------------
228208
template<typename T>
229209
T
230210
modm::Vector<T, 1>::getLengthSquared() const
@@ -240,7 +220,6 @@ modm::Vector<T, 1>::asMatrix()
240220
return *(modm::Matrix<T, 1, 1>*) this;
241221
}
242222

243-
// ----------------------------------------------------------------------------
244223
template<typename T>
245224
const modm::Matrix<T, 1, 1>&
246225
modm::Vector<T, 1>::asMatrix() const
@@ -256,7 +235,6 @@ modm::Vector<T, 1>::hasNan() const
256235
return std::isnan(x);
257236
}
258237

259-
// ----------------------------------------------------------------------------
260238
template<typename T>
261239
bool
262240
modm::Vector<T, 1>::hasInf() const

src/modm/math/geometry/vector2.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
#include "vector2.hpp"
1818

19-
// this explicit namespace is needed here, otherwise we get an error about
20-
// "specialization of ... in different namespace"
2119
namespace modm
2220
{
2321
template<>

src/modm/math/geometry/vector2.hpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
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-
15-
#ifndef MODM_VECTOR2_HPP
16-
#define MODM_VECTOR2_HPP
13+
#pragma once
1714

1815
#include <cmath>
1916
#include <stdint.h>
@@ -61,7 +58,9 @@ namespace modm
6158
typedef typename GeometricTraits<T>::WideType WideType;
6259
typedef typename GeometricTraits<T>::FloatType FloatType;
6360

64-
public:
61+
T x = 0, y = 0;
62+
63+
// basic constructors
6564
constexpr Vector() = default;
6665
constexpr Vector(const T& inX, const T& inY);
6766
constexpr Vector(const Vector<T, 1> &inX, const Vector<T, 1> &inY);
@@ -232,8 +231,8 @@ namespace modm
232231
bool operator > (const Vector &rhs) const;
233232
bool operator >= (const Vector &rhs) const;
234233

235-
const T& operator [] (std::size_t index) const;
236234
T& operator [] (std::size_t index);
235+
const T& operator [] (std::size_t index) const;
237236

238237
T* ptr();
239238
const T* ptr() const;
@@ -287,10 +286,6 @@ namespace modm
287286
IMPLEMENT_VECTOR_ACCESSOR4(y,y,y,x); IMPLEMENT_VECTOR_ACCESSOR4(y,y,y,y);
288287
#endif
289288

290-
public:
291-
T x = 0;
292-
T y = 0;
293-
294289
protected:
295290
template<typename U>
296291
friend IOStream&
@@ -372,6 +367,4 @@ namespace modm
372367
}
373368
}
374369

375-
#include "vector2_impl.hpp"
376-
377-
#endif // MODM_VECTOR2_HPP
370+
#include "vector2_impl.hpp"

0 commit comments

Comments
 (0)