diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6879e1b55..10d011aa7 100644 --- a/src/CMakeLists.txt +++ b/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() diff --git a/src/Math/CMakeLists.txt b/src/Math/CMakeLists.txt new file mode 100644 index 000000000..6879e1b55 --- /dev/null +++ b/src/Math/CMakeLists.txt @@ -0,0 +1,6 @@ +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + +if(BUILD_TESTS) + enable_testing() + add_subdirectory(Test) +endif() diff --git a/src/Matrix.h b/src/Math/Matrix.h similarity index 97% rename from src/Matrix.h rename to src/Math/Matrix.h index 55d00573e..6929866e8 100644 --- a/src/Matrix.h +++ b/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š @@ -16,7 +16,7 @@ */ /** @file - * @brief Class Magnum::Matrix + * @brief Class Magnum::Math::Matrix */ #include @@ -24,7 +24,7 @@ #include "Vector.h" #include "constants.h" -namespace Magnum { +namespace Magnum { namespace Math { /** * @brief Matrix @@ -150,6 +150,6 @@ template class Matrix { T _data[size*size]; }; -} +}} #endif diff --git a/src/Matrix4.h b/src/Math/Matrix4.h similarity index 96% rename from src/Matrix4.h rename to src/Math/Matrix4.h index 5e4100447..e0e15c0f9 100644 --- a/src/Matrix4.h +++ b/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š @@ -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 Matrix4: public Matrix { inline Matrix4(const Matrix& other): Matrix(other) {} }; -} +}} #endif diff --git a/src/Test/CMakeLists.txt b/src/Math/Test/CMakeLists.txt similarity index 100% rename from src/Test/CMakeLists.txt rename to src/Math/Test/CMakeLists.txt diff --git a/src/Test/Matrix4Test.cpp b/src/Math/Test/Matrix4Test.cpp similarity index 91% rename from src/Test/Matrix4Test.cpp rename to src/Math/Test/Matrix4Test.cpp index 05f03a9d8..60f09983e 100644 --- a/src/Test/Matrix4Test.cpp +++ b/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 Matrix4; +typedef Math::Matrix4 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)); } -}} +}}} diff --git a/src/Test/Matrix4Test.h b/src/Math/Test/Matrix4Test.h similarity index 84% rename from src/Test/Matrix4Test.h rename to src/Math/Test/Matrix4Test.h index f55a22ed1..2a56ece8f 100644 --- a/src/Test/Matrix4Test.h +++ b/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š @@ -17,7 +17,7 @@ #include -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 diff --git a/src/Test/MatrixTest.cpp b/src/Math/Test/MatrixTest.cpp similarity index 97% rename from src/Test/MatrixTest.cpp rename to src/Math/Test/MatrixTest.cpp index 786668bd5..c267100ee 100644 --- a/src/Test/MatrixTest.cpp +++ b/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 Matrix4; @@ -171,4 +171,4 @@ void MatrixTest::transposed() { QVERIFY(Matrix4(original).transposed() == Matrix4(transposed)); } -}} +}}} diff --git a/src/Test/MatrixTest.h b/src/Math/Test/MatrixTest.h similarity index 86% rename from src/Test/MatrixTest.h rename to src/Math/Test/MatrixTest.h index 39dfb99d4..e5433d78d 100644 --- a/src/Test/MatrixTest.h +++ b/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š @@ -17,7 +17,7 @@ #include -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 diff --git a/src/Test/Vector3Test.cpp b/src/Math/Test/Vector3Test.cpp similarity index 84% rename from src/Test/Vector3Test.cpp rename to src/Math/Test/Vector3Test.cpp index b4dead5a4..fc812cdf9 100644 --- a/src/Test/Vector3Test.cpp +++ b/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 Vector3; +typedef Math::Vector3 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)); } -}} +}}} diff --git a/src/Test/Vector3Test.h b/src/Math/Test/Vector3Test.h similarity index 83% rename from src/Test/Vector3Test.h rename to src/Math/Test/Vector3Test.h index f902119c3..2ca09cea1 100644 --- a/src/Test/Vector3Test.h +++ b/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š @@ -17,7 +17,7 @@ #include -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 diff --git a/src/Test/Vector4Test.cpp b/src/Math/Test/Vector4Test.cpp similarity index 82% rename from src/Test/Vector4Test.cpp rename to src/Math/Test/Vector4Test.cpp index 057a80a59..7e5294c4b 100644 --- a/src/Test/Vector4Test.cpp +++ b/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 Vector4; -typedef Magnum::Vector3 Vector3; +typedef Math::Vector4 Vector4; +typedef Math::Vector3 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)); } -}} +}}} diff --git a/src/Test/Vector4Test.h b/src/Math/Test/Vector4Test.h similarity index 84% rename from src/Test/Vector4Test.h rename to src/Math/Test/Vector4Test.h index 5f4c5f06d..9ced6a77a 100644 --- a/src/Test/Vector4Test.h +++ b/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š @@ -17,7 +17,7 @@ #include -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 diff --git a/src/Test/VectorTest.cpp b/src/Math/Test/VectorTest.cpp similarity index 96% rename from src/Test/VectorTest.cpp rename to src/Math/Test/VectorTest.cpp index 87821b508..28daa5e32 100644 --- a/src/Test/VectorTest.cpp +++ b/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 Vector4; @@ -119,4 +119,4 @@ void VectorTest::normalized() { QVERIFY(Vector4(vec).normalized() == Vector4(normalized)); } -}} +}}} diff --git a/src/Test/VectorTest.h b/src/Math/Test/VectorTest.h similarity index 87% rename from src/Test/VectorTest.h rename to src/Math/Test/VectorTest.h index 43c7213c2..e2d42a422 100644 --- a/src/Test/VectorTest.h +++ b/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š @@ -17,7 +17,7 @@ #include -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 diff --git a/src/Vector.h b/src/Math/Vector.h similarity index 96% rename from src/Vector.h rename to src/Math/Vector.h index 7b122e31b..a02e0ca51 100644 --- a/src/Vector.h +++ b/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š @@ -16,13 +16,13 @@ */ /** @file - * @brief Class Magnum::Vector + * @brief Class Magnum::Math::Vector */ #include #include -namespace Magnum { +namespace Magnum { namespace Math { /** @brief Vector */ template class Vector { @@ -156,6 +156,6 @@ template class Vector { T _data[size]; }; -} +}} #endif diff --git a/src/Vector3.h b/src/Math/Vector3.h similarity index 94% rename from src/Vector3.h rename to src/Math/Vector3.h index f06f607bf..9643eb286 100644 --- a/src/Vector3.h +++ b/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š @@ -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 Vector3: public Vector { @@ -69,6 +69,6 @@ template class Vector3: public Vector { inline void setB(T value) { setZ(value); } /**< @brief Set B component */ }; -} +}} #endif diff --git a/src/Vector4.h b/src/Math/Vector4.h similarity index 95% rename from src/Vector4.h rename to src/Math/Vector4.h index c000af2f6..4d2d48157 100644 --- a/src/Vector4.h +++ b/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š @@ -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 Vector4: public Vector { @@ -87,6 +87,6 @@ template class Vector4: public Vector { inline Vector3 rgb() const { return xyz(); } }; -} +}} #endif diff --git a/src/constants.h b/src/Math/constants.h similarity index 87% rename from src/constants.h rename to src/Math/constants.h index 77d38e3ea..1fd29eb6f 100644 --- a/src/constants.h +++ b/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š @@ -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