Browse Source

New namespace Magnum::Math.

vectorfields
Vladimír Vondruš 16 years ago
parent
commit
c41d6ad582
  1. 3
      src/CMakeLists.txt
  2. 6
      src/Math/CMakeLists.txt
  3. 10
      src/Math/Matrix.h
  4. 10
      src/Math/Matrix4.h
  5. 0
      src/Math/Test/CMakeLists.txt
  6. 8
      src/Math/Test/Matrix4Test.cpp
  7. 8
      src/Math/Test/Matrix4Test.h
  8. 6
      src/Math/Test/MatrixTest.cpp
  9. 8
      src/Math/Test/MatrixTest.h
  10. 8
      src/Math/Test/Vector3Test.cpp
  11. 8
      src/Math/Test/Vector3Test.h
  12. 10
      src/Math/Test/Vector4Test.cpp
  13. 8
      src/Math/Test/Vector4Test.h
  14. 6
      src/Math/Test/VectorTest.cpp
  15. 8
      src/Math/Test/VectorTest.h
  16. 10
      src/Math/Vector.h
  17. 10
      src/Math/Vector3.h
  18. 10
      src/Math/Vector4.h
  19. 8
      src/Math/constants.h

3
src/CMakeLists.txt

@ -1,6 +1,7 @@
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
add_subdirectory(Math)
if(BUILD_TESTS)
enable_testing()
add_subdirectory(Test)
endif()

6
src/Math/CMakeLists.txt

@ -0,0 +1,6 @@
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
if(BUILD_TESTS)
enable_testing()
add_subdirectory(Test)
endif()

10
src/Matrix.h → src/Math/Matrix.h

@ -1,5 +1,5 @@
#ifndef Magnum_Matrix_h
#define Magnum_Matrix_h
#ifndef Magnum_Math_Matrix_h
#define Magnum_Math_Matrix_h
/*
Copyright © 2010 Vladimír Vondruš <mosra@centrum.cz>
@ -16,7 +16,7 @@
*/
/** @file
* @brief Class Magnum::Matrix
* @brief Class Magnum::Math::Matrix
*/
#include <cstring>
@ -24,7 +24,7 @@
#include "Vector.h"
#include "constants.h"
namespace Magnum {
namespace Magnum { namespace Math {
/**
* @brief Matrix
@ -150,6 +150,6 @@ template<class T, size_t size> class Matrix {
T _data[size*size];
};
}
}}
#endif

10
src/Matrix4.h → src/Math/Matrix4.h

@ -1,5 +1,5 @@
#ifndef Magnum_Matrix4_h
#define Magnum_Matrix4_h
#ifndef Magnum_Math_Matrix4_h
#define Magnum_Math_Matrix4_h
/*
Copyright © 2010 Vladimír Vondruš <mosra@centrum.cz>
@ -16,14 +16,14 @@
*/
/** @file
* @brief Class Magnum::Matrix4
* @brief Class Magnum::Math::Matrix4
*/
#include "Matrix.h"
#include "Vector3.h"
namespace Magnum {
namespace Magnum { namespace Math {
/**
* @brief Matrix 4x4
@ -138,6 +138,6 @@ template<class T> class Matrix4: public Matrix<T, 4> {
inline Matrix4(const Matrix<T, 4>& other): Matrix<T, 4>(other) {}
};
}
}}
#endif

0
src/Test/CMakeLists.txt → src/Math/Test/CMakeLists.txt

8
src/Test/Matrix4Test.cpp → src/Math/Test/Matrix4Test.cpp

@ -20,11 +20,11 @@
#include "Matrix4.h"
#include "constants.h"
QTEST_APPLESS_MAIN(Magnum::Test::Matrix4Test)
QTEST_APPLESS_MAIN(Magnum::Math::Test::Matrix4Test)
namespace Magnum { namespace Test {
namespace Magnum { namespace Math { namespace Test {
typedef Magnum::Matrix4<float> Matrix4;
typedef Math::Matrix4<float> Matrix4;
void Matrix4Test::translation() {
float matrix[] = {
@ -59,4 +59,4 @@ void Matrix4Test::rotation() {
QVERIFY(Matrix4::rotation(-74*PI/180.0f, -1.0f, 2.0f, 2.0f) == Matrix4(matrix));
}
}}
}}}

8
src/Test/Matrix4Test.h → src/Math/Test/Matrix4Test.h

@ -1,5 +1,5 @@
#ifndef Magnum_Test_Matrix4Test_h
#define Magnum_Test_Matrix4Test_h
#ifndef Magnum_Math_Test_Matrix4Test_h
#define Magnum_Math_Test_Matrix4Test_h
/*
Copyright © 2010 Vladimír Vondruš <mosra@centrum.cz>
@ -17,7 +17,7 @@
#include <QtCore/QObject>
namespace Magnum { namespace Test {
namespace Magnum { namespace Math { namespace Test {
class Matrix4Test: public QObject {
Q_OBJECT
@ -28,6 +28,6 @@ class Matrix4Test: public QObject {
void rotation();
};
}}
}}}
#endif

6
src/Test/MatrixTest.cpp → src/Math/Test/MatrixTest.cpp

@ -19,9 +19,9 @@
#include "Matrix.h"
QTEST_APPLESS_MAIN(Magnum::Test::MatrixTest)
QTEST_APPLESS_MAIN(Magnum::Math::Test::MatrixTest)
namespace Magnum { namespace Test {
namespace Magnum { namespace Math { namespace Test {
typedef Matrix<float, 4> Matrix4;
@ -171,4 +171,4 @@ void MatrixTest::transposed() {
QVERIFY(Matrix4(original).transposed() == Matrix4(transposed));
}
}}
}}}

8
src/Test/MatrixTest.h → src/Math/Test/MatrixTest.h

@ -1,5 +1,5 @@
#ifndef Magnum_Test_MatrixTest_h
#define Magnum_Test_MatrixTest_h
#ifndef Magnum_Math_Test_MatrixTest_h
#define Magnum_Math_Test_MatrixTest_h
/*
Copyright © 2010 Vladimír Vondruš <mosra@centrum.cz>
@ -17,7 +17,7 @@
#include <QtCore/QObject>
namespace Magnum { namespace Test {
namespace Magnum { namespace Math { namespace Test {
class MatrixTest: public QObject {
Q_OBJECT
@ -33,6 +33,6 @@ class MatrixTest: public QObject {
void transposed();
};
}}
}}}
#endif

8
src/Test/Vector3Test.cpp → src/Math/Test/Vector3Test.cpp

@ -19,11 +19,11 @@
#include "Vector3.h"
QTEST_APPLESS_MAIN(Magnum::Test::Vector3Test)
QTEST_APPLESS_MAIN(Magnum::Math::Test::Vector3Test)
namespace Magnum { namespace Test {
namespace Magnum { namespace Math { namespace Test {
typedef Magnum::Vector3<float> Vector3;
typedef Math::Vector3<float> Vector3;
void Vector3Test::cross() {
Vector3 a(1, -1, 1);
@ -32,4 +32,4 @@ void Vector3Test::cross() {
QVERIFY(Vector3::cross(a, b) == Vector3(-10, -3, 7));
}
}}
}}}

8
src/Test/Vector3Test.h → src/Math/Test/Vector3Test.h

@ -1,5 +1,5 @@
#ifndef Magnum_Test_Vector3Test_h
#define Magnum_Test_Vector3Test_h
#ifndef Magnum_Math_Test_Vector3Test_h
#define Magnum_Math_Test_Vector3Test_h
/*
Copyright © 2010 Vladimír Vondruš <mosra@centrum.cz>
@ -17,7 +17,7 @@
#include <QtCore/QObject>
namespace Magnum { namespace Test {
namespace Magnum { namespace Math { namespace Test {
class Vector3Test: public QObject {
Q_OBJECT
@ -26,6 +26,6 @@ class Vector3Test: public QObject {
void cross();
};
}}
}}}
#endif

10
src/Test/Vector4Test.cpp → src/Math/Test/Vector4Test.cpp

@ -19,12 +19,12 @@
#include "Vector4.h"
QTEST_APPLESS_MAIN(Magnum::Test::Vector4Test)
QTEST_APPLESS_MAIN(Magnum::Math::Test::Vector4Test)
namespace Magnum { namespace Test {
namespace Magnum { namespace Math { namespace Test {
typedef Magnum::Vector4<float> Vector4;
typedef Magnum::Vector3<float> Vector3;
typedef Math::Vector4<float> Vector4;
typedef Math::Vector3<float> Vector3;
void Vector4Test::construct() {
QVERIFY(Vector4() == Vector4(0.0f, 0.0f, 0.0f, 1.0f));
@ -34,4 +34,4 @@ void Vector4Test::threeComponent() {
QVERIFY(Vector4(1.0f, 2.0f, 3.0f, 4.0f).xyz() == Vector3(1.0f, 2.0f, 3.0f));
}
}}
}}}

8
src/Test/Vector4Test.h → src/Math/Test/Vector4Test.h

@ -1,5 +1,5 @@
#ifndef Magnum_Test_Vector4Test_h
#define Magnum_Test_Vector4Test_h
#ifndef Magnum_Math_Test_Vector4Test_h
#define Magnum_Math_Test_Vector4Test_h
/*
Copyright © 2010 Vladimír Vondruš <mosra@centrum.cz>
@ -17,7 +17,7 @@
#include <QtCore/QObject>
namespace Magnum { namespace Test {
namespace Magnum { namespace Math { namespace Test {
class Vector4Test: public QObject {
Q_OBJECT
@ -27,6 +27,6 @@ class Vector4Test: public QObject {
void threeComponent();
};
}}
}}}
#endif

6
src/Test/VectorTest.cpp → src/Math/Test/VectorTest.cpp

@ -21,11 +21,11 @@
#include "Vector.h"
#include "constants.h"
QTEST_APPLESS_MAIN(Magnum::Test::VectorTest)
QTEST_APPLESS_MAIN(Magnum::Math::Test::VectorTest)
using namespace std;
namespace Magnum { namespace Test {
namespace Magnum { namespace Math { namespace Test {
typedef Vector<float, 4> Vector4;
@ -119,4 +119,4 @@ void VectorTest::normalized() {
QVERIFY(Vector4(vec).normalized() == Vector4(normalized));
}
}}
}}}

8
src/Test/VectorTest.h → src/Math/Test/VectorTest.h

@ -1,5 +1,5 @@
#ifndef Magnum_Test_VectorTest_h
#define Magnum_Test_VectorTest_h
#ifndef Magnum_Math_Test_VectorTest_h
#define Magnum_Math_Test_VectorTest_h
/*
Copyright © 2010 Vladimír Vondruš <mosra@centrum.cz>
@ -17,7 +17,7 @@
#include <QtCore/QObject>
namespace Magnum { namespace Test {
namespace Magnum { namespace Math { namespace Test {
class VectorTest: public QObject {
Q_OBJECT
@ -34,6 +34,6 @@ class VectorTest: public QObject {
void normalized();
};
}}
}}}
#endif

10
src/Vector.h → src/Math/Vector.h

@ -1,5 +1,5 @@
#ifndef Magnum_Vector_h
#define Magnum_Vector_h
#ifndef Magnum_Math_Vector_h
#define Magnum_Math_Vector_h
/*
Copyright © 2010 Vladimír Vondruš <mosra@centrum.cz>
@ -16,13 +16,13 @@
*/
/** @file
* @brief Class Magnum::Vector
* @brief Class Magnum::Math::Vector
*/
#include <cstring>
#include <cmath>
namespace Magnum {
namespace Magnum { namespace Math {
/** @brief Vector */
template<class T, size_t size> class Vector {
@ -156,6 +156,6 @@ template<class T, size_t size> class Vector {
T _data[size];
};
}
}}
#endif

10
src/Vector3.h → src/Math/Vector3.h

@ -1,5 +1,5 @@
#ifndef Magnum_Vector3_h
#define Magnum_Vector3_h
#ifndef Magnum_Math_Vector3_h
#define Magnum_Math_Vector3_h
/*
Copyright © 2010 Vladimír Vondruš <mosra@centrum.cz>
@ -16,12 +16,12 @@
*/
/** @file
* @brief Class Magnum::Vector3
* @brief Class Magnum::Math::Vector3
*/
#include "Vector.h"
namespace Magnum {
namespace Magnum { namespace Math {
/** @brief Vector (three-component) */
template<class T> class Vector3: public Vector<T, 3> {
@ -69,6 +69,6 @@ template<class T> class Vector3: public Vector<T, 3> {
inline void setB(T value) { setZ(value); } /**< @brief Set B component */
};
}
}}
#endif

10
src/Vector4.h → src/Math/Vector4.h

@ -1,5 +1,5 @@
#ifndef Magnum_Vector4_h
#define Magnum_Vector4_h
#ifndef Magnum_Math_Vector4_h
#define Magnum_Math_Vector4_h
/*
Copyright © 2010 Vladimír Vondruš <mosra@centrum.cz>
@ -16,14 +16,14 @@
*/
/** @file
* @brief Class Magnum::Vector4
* @brief Class Magnum::Math::Vector4
*/
#include "Vector.h"
#include "Vector3.h"
namespace Magnum {
namespace Magnum { namespace Math {
/** @brief Vector (four-component) */
template<class T> class Vector4: public Vector<T, 4> {
@ -87,6 +87,6 @@ template<class T> class Vector4: public Vector<T, 4> {
inline Vector3<T> rgb() const { return xyz(); }
};
}
}}
#endif

8
src/constants.h → src/Math/constants.h

@ -1,5 +1,5 @@
#ifndef Magnum_constants_h
#define Magnum_constants_h
#ifndef Magnum_Math_constants_h
#define Magnum_Math_constants_h
/*
Copyright © 2010 Vladimír Vondruš <mosra@centrum.cz>
@ -19,7 +19,7 @@
* @brief Constants
*/
namespace Magnum {
namespace Magnum { namespace Math {
/** @brief Pi */
#define PI 3.1415926535
@ -27,6 +27,6 @@ namespace Magnum {
/** @brief Maximal tolerance when comparing doubles */
#define EPSILON 1.0e-8
}
}}
#endif
Loading…
Cancel
Save