From 58d156bc4795a1486f717ac4369f4ca3563d4467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 22 Feb 2013 01:22:05 +0100 Subject: [PATCH] Math: removed Point2D/Point3D altogether. --- doc/matrix-vector.dox | 11 +--- src/Magnum.h | 6 -- src/Math/CMakeLists.txt | 2 - src/Math/Math.h | 3 - src/Math/Matrix3.h | 10 +--- src/Math/Matrix4.h | 10 +--- src/Math/Point2D.h | 105 ---------------------------------- src/Math/Point3D.h | 105 ---------------------------------- src/Math/Test/CMakeLists.txt | 2 - src/Math/Test/Matrix3Test.cpp | 1 - src/Math/Test/Matrix4Test.cpp | 1 - src/Math/Test/Point2DTest.cpp | 66 --------------------- src/Math/Test/Point3DTest.cpp | 66 --------------------- src/Math/Vector3.h | 3 +- src/Math/Vector4.h | 3 +- 15 files changed, 9 insertions(+), 385 deletions(-) delete mode 100644 src/Math/Point2D.h delete mode 100644 src/Math/Point3D.h delete mode 100644 src/Math/Test/Point2DTest.cpp delete mode 100644 src/Math/Test/Point3DTest.cpp diff --git a/doc/matrix-vector.dox b/doc/matrix-vector.dox index 115e13991..c1ded9d3f 100644 --- a/doc/matrix-vector.dox +++ b/doc/matrix-vector.dox @@ -26,16 +26,14 @@ return the most specialized type known to make subsequent operations more convenient - columns of %RectangularMatrix are returned as %Vector, but when accessing columns of e.g. %Matrix3, they are returned as %Vector3. -There are also even more specialized subclasses - Point2D, Point3D for -creating points with homogeneous coordinates and Color3, Color4 for color -handling and conversion. +There are also even more specialized subclasses, e.g. Color3 and Color4 for +color handling and conversion. @section matrix-vector-construction Constructing matrices and vectors Default constructors of RectangularMatrix and Vector (and Vector2, Vector3, Vector4, Color3) create zero-filled objects. Matrix (and Matrix3, Matrix4) is -by default constructed as identity matrix. Point2D and Point3D have -homogeneous component set to one, Color4 has alpha value set to opaque. +by default constructed as identity matrix. Color4 has alpha value set to opaque. @code RectangularMatrix<2, 3, int> a; // zero-filled Vector<3, int> b; // zero-filled @@ -43,9 +41,6 @@ Vector<3, int> b; // zero-filled Matrix<3, int> identity; // diagonal set to 1 Matrix<3, int> zero(Matrix<3, int>::Zero); // zero-filled -Point2D c; // {0, 0, 1} -Point3D d; // {0, 0, 0, 1} - Color4 black1; // {0.0f, 0.0f, 0.0f, 1.0f} Color4 black2; // {0, 0, 0, 255} @endcode diff --git a/src/Magnum.h b/src/Magnum.h index afe726912..f5dd8a4ed 100644 --- a/src/Magnum.h +++ b/src/Magnum.h @@ -103,12 +103,6 @@ typedef Math::Vector3 Vector3d; typedef Math::Vector4 Vector4d; #endif -/** @brief Two-dimensional floating-point homogeneous coordinates */ -typedef Math::Point2D Point2D; - -/** @brief Three-dimensional floating-point homogeneous coordinates */ -typedef Math::Point3D Point3D; - /** @brief 3x3 float matrix */ typedef Math::Matrix3 Matrix3; diff --git a/src/Math/CMakeLists.txt b/src/Math/CMakeLists.txt index e6d909a0c..287d96427 100644 --- a/src/Math/CMakeLists.txt +++ b/src/Math/CMakeLists.txt @@ -11,8 +11,6 @@ set(MagnumMath_HEADERS Matrix.h Matrix3.h Matrix4.h - Point2D.h - Point3D.h Quaternion.h RectangularMatrix.h Swizzle.h diff --git a/src/Math/Math.h b/src/Math/Math.h index 31feb02b3..8124b0a3b 100644 --- a/src/Math/Math.h +++ b/src/Math/Math.h @@ -34,9 +34,6 @@ template class Matrix; template class Matrix3; template class Matrix4; -template class Point2D; -template class Point3D; - template class Quaternion; template class RectangularMatrix; diff --git a/src/Math/Matrix3.h b/src/Math/Matrix3.h index 59398a3ad..d1a455d64 100644 --- a/src/Math/Matrix3.h +++ b/src/Math/Matrix3.h @@ -19,8 +19,8 @@ * @brief Class Magnum::Math::Matrix3 */ -#include "Matrix.h" -#include "Point2D.h" +#include "Math/Matrix.h" +#include "Math/Vector3.h" namespace Magnum { namespace Math { @@ -226,12 +226,6 @@ template class Matrix3: public Matrix<3, T> { return ((*this)*Vector3(vector, T(1))).xy(); } - #ifndef DOXYGEN_GENERATING_OUTPUT - inline Point2D operator*(const Point2D& other) const { - return Matrix<3, T>::operator*(other); - } - #endif - MAGNUM_RECTANGULARMATRIX_SUBCLASS_IMPLEMENTATION(3, 3, Matrix3) MAGNUM_MATRIX_SUBCLASS_IMPLEMENTATION(Matrix3, Vector3, 3) }; diff --git a/src/Math/Matrix4.h b/src/Math/Matrix4.h index 9e278dfc3..1684f816d 100644 --- a/src/Math/Matrix4.h +++ b/src/Math/Matrix4.h @@ -19,8 +19,8 @@ * @brief Class Magnum::Math::Matrix4 */ -#include "Matrix.h" -#include "Point3D.h" +#include "Math/Matrix.h" +#include "Math/Vector4.h" #ifdef _WIN32 /* I so HATE windows.h */ #undef near @@ -375,12 +375,6 @@ template class Matrix4: public Matrix<4, T> { return ((*this)*Vector4(vector, T(1))).xyz(); } - #ifndef DOXYGEN_GENERATING_OUTPUT - inline Point3D operator*(const Point3D& other) const { - return Matrix<4, T>::operator*(other); - } - #endif - MAGNUM_RECTANGULARMATRIX_SUBCLASS_IMPLEMENTATION(4, 4, Matrix4) MAGNUM_MATRIX_SUBCLASS_IMPLEMENTATION(Matrix4, Vector4, 4) }; diff --git a/src/Math/Point2D.h b/src/Math/Point2D.h deleted file mode 100644 index 967a91692..000000000 --- a/src/Math/Point2D.h +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef Magnum_Math_Point2D_h -#define Magnum_Math_Point2D_h -/* - Copyright © 2010, 2011, 2012 Vladimír Vondruš - - This file is part of Magnum. - - Magnum is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 3 - only, as published by the Free Software Foundation. - - Magnum is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License version 3 for more details. -*/ - -/** @file - * @brief Class Magnum::Math::Point2D - */ - -#include "Vector3.h" - -namespace Magnum { namespace Math { - -/** -@brief Two-dimensional homogeneous coordinates -@tparam T Data type - -Same as Vector3, except that constructors have default value for Z component -set to one. See also @ref matrix-vector for brief introduction. -@see Magnum::Point2D, Point3D -@configurationvalueref{Magnum::Math::Point2D} -*/ -template class Point2D: public Vector3 { - public: - /** - * @brief Default constructor - * - * @f[ - * \boldsymbol p = (0, 0, 1)^T - * @f] - */ - inline constexpr /*implicit*/ Point2D(): Vector3(T(0), T(0), T(1)) {} - - /** - * @brief Constructor - * - * @f[ - * \boldsymbol p = (x, y, z)^T - * @f] - */ - inline constexpr /*implicit*/ Point2D(T x, T y, T z = T(1)): Vector3(x, y, z) {} - - /** - * @brief Constructor - * - * @f[ - * \boldsymbol p = (v_x, v_y, z)^T - * @f] - */ - inline constexpr /*implicit*/ Point2D(const Vector2& xy, T z): Vector3(xy, z) {} - - /** - * @brief Construct 2D point from 2D vector - * - * @f[ - * \boldsymbol p = (v_x, v_y, 1)^T - * @f] - */ - inline constexpr explicit Point2D(const Vector2& xy): Vector3(xy, T(1)) {} - - /** @copydoc Vector::Vector(const Vector&) */ - template inline constexpr explicit Point2D(const Vector<3, U>& other): Vector3(other) {} - - /** @brief Copy constructor */ - inline constexpr Point2D(const Vector<3, T>& other): Vector3(other) {} - - /** - * @brief Vector part of the point - * - * Equivalent to calling xy(). Useful for seamless 2D/3D integration. - * @see Point3D::vector() - */ - inline Vector2& vector() { return Vector3::xy(); } - inline constexpr Vector2 vector() const { return Vector3::xy(); } /**< @overload */ - - MAGNUM_VECTOR_SUBCLASS_IMPLEMENTATION(Point2D, 3) -}; - -MAGNUM_VECTOR_SUBCLASS_OPERATOR_IMPLEMENTATION(Point2D, 3) - -/** @debugoperator{Magnum::Math::Point2D} */ -template inline Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Point2D& value) { - return debug << static_cast&>(value); -} - -}} - -namespace Corrade { namespace Utility { - /** @configurationvalue{Magnum::Math::Point2D} */ - template struct ConfigurationValue>: public ConfigurationValue> {}; -}} - -#endif diff --git a/src/Math/Point3D.h b/src/Math/Point3D.h deleted file mode 100644 index fbe97faa3..000000000 --- a/src/Math/Point3D.h +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef Magnum_Math_Point3D_h -#define Magnum_Math_Point3D_h -/* - Copyright © 2010, 2011, 2012 Vladimír Vondruš - - This file is part of Magnum. - - Magnum is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 3 - only, as published by the Free Software Foundation. - - Magnum is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License version 3 for more details. -*/ - -/** @file - * @brief Class Magnum::Math::Point3D - */ - -#include "Vector4.h" - -namespace Magnum { namespace Math { - -/** -@brief Three-dimensional homogeneous coordinates -@tparam T Data type - -Same as Vector4, except that constructors have default value for W component -set to one. See also @ref matrix-vector for brief introduction. -@see Magnum::Point3D, Point2D -@configurationvalueref{Magnum::Math::Point3D} -*/ -template class Point3D: public Vector4 { - public: - /** - * @brief Default constructor - * - * @f[ - * \boldsymbol p = (0, 0, 0, 1)^T - * @f] - */ - inline constexpr /*implicit*/ Point3D(): Vector4(T(0), T(0), T(0), T(1)) {} - - /** - * @brief Constructor - * - * @f[ - * \boldsymbol p = (x, y, z, w)^T - * @f] - */ - inline constexpr /*implicit*/ Point3D(T x, T y, T z, T w = T(1)): Vector4(x, y, z, w) {} - - /** - * @brief Constructor - * - * @f[ - * \boldsymbol p = (v_x, v_y, v_z, w)^T - * @f] - */ - inline constexpr /*implicit*/ Point3D(const Vector3& xyz, T w): Vector4(xyz, w) {} - - /** - * @brief Construct 3D point from 3D vector - * - * @f[ - * \boldsymbol p = (v_x, v_y, v_z, 1)^T - * @f] - */ - inline constexpr explicit Point3D(const Vector3& xyz): Vector4(xyz, T(1)) {} - - /** @copydoc Vector::Vector(const Vector&) */ - template inline constexpr explicit Point3D(const Vector<4, U>& other): Vector4(other) {} - - /** @brief Copy constructor */ - inline constexpr Point3D(const Vector<4, T>& other): Vector4(other) {} - - /** - * @brief Vector part of the point - * - * Equivalent to calling xyz(). Useful for seamless 2D/3D integration. - * @see Point2D::vector() - */ - inline Vector3& vector() { return Vector4::xyz(); } - inline constexpr Vector3 vector() const { return Vector4::xyz(); } /**< @overload */ - - MAGNUM_VECTOR_SUBCLASS_IMPLEMENTATION(Point3D, 4) -}; - -MAGNUM_VECTOR_SUBCLASS_OPERATOR_IMPLEMENTATION(Point3D, 4) - -/** @debugoperator{Magnum::Math::Point3D} */ -template inline Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, const Point3D& value) { - return debug << static_cast&>(value); -} - -}} - -namespace Corrade { namespace Utility { - /** @configurationvalue{Magnum::Math::Point3D} */ - template struct ConfigurationValue>: public ConfigurationValue> {}; -}} - -#endif diff --git a/src/Math/Test/CMakeLists.txt b/src/Math/Test/CMakeLists.txt index c76ea26fb..d5e0f63f0 100644 --- a/src/Math/Test/CMakeLists.txt +++ b/src/Math/Test/CMakeLists.txt @@ -7,8 +7,6 @@ corrade_add_test(MathVectorTest VectorTest.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(MathVector2Test Vector2Test.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(MathVector3Test Vector3Test.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(MathVector4Test Vector4Test.cpp LIBRARIES MagnumMathTestLib) -corrade_add_test(MathPoint2DTest Point2DTest.cpp LIBRARIES MagnumMathTestLib) -corrade_add_test(MathPoint3DTest Point3DTest.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(MathRectangularMatrixTest RectangularMatrixTest.cpp LIBRARIES MagnumMathTestLib) corrade_add_test(MathMatrixTest MatrixTest.cpp LIBRARIES MagnumMathTestLib) diff --git a/src/Math/Test/Matrix3Test.cpp b/src/Math/Test/Matrix3Test.cpp index 47e5a8194..3ac4de620 100644 --- a/src/Math/Test/Matrix3Test.cpp +++ b/src/Math/Test/Matrix3Test.cpp @@ -47,7 +47,6 @@ typedef Math::Deg Deg; typedef Math::Matrix3 Matrix3; typedef Math::Matrix<2, float> Matrix2; typedef Math::Vector2 Vector2; -typedef Math::Point2D Point2D; Matrix3Test::Matrix3Test() { addTests(&Matrix3Test::constructIdentity, diff --git a/src/Math/Test/Matrix4Test.cpp b/src/Math/Test/Matrix4Test.cpp index afd0a9247..434ff84d7 100644 --- a/src/Math/Test/Matrix4Test.cpp +++ b/src/Math/Test/Matrix4Test.cpp @@ -53,7 +53,6 @@ typedef Math::Rad Rad; typedef Math::Matrix4 Matrix4; typedef Math::Matrix<3, float> Matrix3; typedef Math::Vector3 Vector3; -typedef Math::Point3D Point3D; Matrix4Test::Matrix4Test() { addTests(&Matrix4Test::constructIdentity, diff --git a/src/Math/Test/Point2DTest.cpp b/src/Math/Test/Point2DTest.cpp deleted file mode 100644 index e3e29e9c3..000000000 --- a/src/Math/Test/Point2DTest.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - Copyright © 2010, 2011, 2012 Vladimír Vondruš - - This file is part of Magnum. - - Magnum is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 3 - only, as published by the Free Software Foundation. - - Magnum is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License version 3 for more details. -*/ - -#include -#include -#include - -#include "Math/Point2D.h" - -namespace Magnum { namespace Math { namespace Test { - -class Point2DTest: public Corrade::TestSuite::Tester { - public: - Point2DTest(); - - void construct(); - void debug(); - void configuration(); -}; - -typedef Math::Point2D Point2D; - -Point2DTest::Point2DTest() { - addTests(&Point2DTest::construct, - &Point2DTest::debug, - &Point2DTest::configuration); -} - -void Point2DTest::construct() { - CORRADE_COMPARE(Point2D(), (Vector<3, float>(0.0f, 0.0f, 1.0f))); - CORRADE_COMPARE(Point2D(1, 2), (Vector<3, float>(1.0f, 2.0f, 1.0f))); - CORRADE_COMPARE(Point2D(Vector<2, float>(1.0f, 2.0f), 3), (Vector<3, float>(1.0f, 2.0f, 3.0f))); -} - -void Point2DTest::debug() { - std::ostringstream o; - Debug(&o) << Point2D(0.5f, 15.0f, 1.0f); - CORRADE_COMPARE(o.str(), "Vector(0.5, 15, 1)\n"); -} - -void Point2DTest::configuration() { - Corrade::Utility::Configuration c; - - Point2D vec(3.0f, 3.125f, 9.55f); - std::string value("3 3.125 9.55"); - - c.setValue("point", vec); - CORRADE_COMPARE(c.value("point"), value); - CORRADE_COMPARE(c.value("point"), vec); -} - -}}} - -CORRADE_TEST_MAIN(Magnum::Math::Test::Point2DTest) diff --git a/src/Math/Test/Point3DTest.cpp b/src/Math/Test/Point3DTest.cpp deleted file mode 100644 index 9ac4f30c0..000000000 --- a/src/Math/Test/Point3DTest.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - Copyright © 2010, 2011, 2012 Vladimír Vondruš - - This file is part of Magnum. - - Magnum is free software: you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License version 3 - only, as published by the Free Software Foundation. - - Magnum is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Lesser General Public License version 3 for more details. -*/ - -#include -#include -#include - -#include "Math/Point3D.h" - -namespace Magnum { namespace Math { namespace Test { - -class Point3DTest: public Corrade::TestSuite::Tester { - public: - Point3DTest(); - - void construct(); - void debug(); - void configuration(); -}; - -typedef Math::Point3D Point3D; - -Point3DTest::Point3DTest() { - addTests(&Point3DTest::construct, - &Point3DTest::debug, - &Point3DTest::configuration); -} - -void Point3DTest::construct() { - CORRADE_COMPARE(Point3D(), Point3D(0.0f, 0.0f, 0.0f, 1.0f)); - CORRADE_COMPARE(Point3D(1, 2, 3, 4), (Vector<4, float>(1.0f, 2.0f, 3.0f, 4.0f))); - CORRADE_COMPARE(Point3D(Vector<3, float>(1.0f, 2.0f, 3.0f), 4), (Vector<4, float>(1.0f, 2.0f, 3.0f, 4.0f))); -} - -void Point3DTest::debug() { - std::ostringstream o; - Debug(&o) << Point3D(0.5f, 15.0f, 1.0f, 1.0f); - CORRADE_COMPARE(o.str(), "Vector(0.5, 15, 1, 1)\n"); -} - -void Point3DTest::configuration() { - Corrade::Utility::Configuration c; - - Point3D vec(3.0f, 3.125f, 9.0f, 9.55f); - std::string value("3 3.125 9 9.55"); - - c.setValue("point", vec); - CORRADE_COMPARE(c.value("point"), value); - CORRADE_COMPARE(c.value("point"), vec); -} - -}}} - -CORRADE_TEST_MAIN(Magnum::Math::Test::Point3DTest) diff --git a/src/Math/Vector3.h b/src/Math/Vector3.h index cb2c2486b..f0ed34d9c 100644 --- a/src/Math/Vector3.h +++ b/src/Math/Vector3.h @@ -28,8 +28,7 @@ namespace Magnum { namespace Math { @brief Three-component vector @tparam T Data type -See @ref matrix-vector for brief introduction. See also Point2D for -homogeneous two-dimensional coordinates. +See @ref matrix-vector for brief introduction. @see Magnum::Vector3, Magnum::Vector3i, Magnum::Vector3ui, Magnum::Vector3d @configurationvalueref{Magnum::Math::Vector3} */ diff --git a/src/Math/Vector4.h b/src/Math/Vector4.h index 9c45d24b0..846634544 100644 --- a/src/Math/Vector4.h +++ b/src/Math/Vector4.h @@ -27,8 +27,7 @@ namespace Magnum { namespace Math { @brief Four-component vector @tparam T Data type -See @ref matrix-vector for brief introduction. See also Point3D for -homogeneous three-dimensional coordinates. +See @ref matrix-vector for brief introduction. @see Magnum::Vector4, Magnum::Vector4i, Magnum::Vector4ui, Magnum::Vector4d @configurationvalueref{Magnum::Math::Vector4} */