From 6a90b0231bc1c43fb4b28b6f0ab3dfdb89360a17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 27 Feb 2013 16:42:54 +0100 Subject: [PATCH] Math: using new aliases for builtin types in whole Math namespace. --- doc/matrix-vector.dox | 54 +++---- src/Math/Algorithms/Svd.h | 18 +-- src/Math/Algorithms/Test/GaussJordanTest.cpp | 6 +- src/Math/Algorithms/Test/GramSchmidtTest.cpp | 4 +- src/Math/Algorithms/Test/SvdTest.cpp | 22 +-- src/Math/Angle.cpp | 8 +- src/Math/Angle.h | 58 +++---- src/Math/BoolVector.h | 17 +- src/Math/Complex.cpp | 4 +- src/Math/Complex.h | 4 +- src/Math/Constants.h | 18 ++- src/Math/DualComplex.cpp | 4 +- src/Math/DualComplex.h | 4 +- src/Math/DualQuaternion.cpp | 4 +- src/Math/DualQuaternion.h | 4 +- src/Math/Functions.cpp | 8 +- src/Math/Functions.h | 20 +-- src/Math/Geometry/Rectangle.h | 4 +- src/Math/Geometry/Test/DistanceTest.cpp | 41 ++--- src/Math/Geometry/Test/IntersectionTest.cpp | 6 +- src/Math/Geometry/Test/RectangleTest.cpp | 6 +- src/Math/MathTypeTraits.h | 43 ++--- src/Math/Matrix.h | 4 +- src/Math/Quaternion.cpp | 4 +- src/Math/Quaternion.h | 4 +- src/Math/RectangularMatrix.cpp | 72 ++++----- src/Math/RectangularMatrix.h | 80 +++++----- src/Math/Swizzle.h | 2 +- src/Math/Test/AngleTest.cpp | 32 ++-- src/Math/Test/BoolVectorTest.cpp | 2 +- src/Math/Test/ComplexTest.cpp | 24 +-- src/Math/Test/ConstantsTest.cpp | 8 +- src/Math/Test/DualComplexTest.cpp | 14 +- src/Math/Test/DualQuaternionTest.cpp | 16 +- src/Math/Test/DualTest.cpp | 14 +- src/Math/Test/FunctionsTest.cpp | 156 +++++++++---------- src/Math/Test/MathTypeTraitsTest.cpp | 20 +-- src/Math/Test/Matrix3Test.cpp | 8 +- src/Math/Test/Matrix4Test.cpp | 22 +-- src/Math/Test/MatrixTest.cpp | 34 ++-- src/Math/Test/QuaternionTest.cpp | 44 +++--- src/Math/Test/RectangularMatrixTest.cpp | 78 +++++----- src/Math/Test/SwizzleTest.cpp | 10 +- src/Math/Test/UnitTest.cpp | 14 +- src/Math/Test/Vector2Test.cpp | 4 +- src/Math/Test/Vector3Test.cpp | 8 +- src/Math/Test/Vector4Test.cpp | 10 +- src/Math/Test/VectorTest.cpp | 32 ++-- src/Math/Vector.cpp | 48 +++--- src/Math/Vector.h | 52 +++---- 50 files changed, 585 insertions(+), 588 deletions(-) diff --git a/doc/matrix-vector.dox b/doc/matrix-vector.dox index a5addb366..b601cb5a8 100644 --- a/doc/matrix-vector.dox +++ b/doc/matrix-vector.dox @@ -35,13 +35,13 @@ 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. Color4 has alpha value set to opaque. @code -RectangularMatrix<2, 3, int> a; // zero-filled -Vector<3, int> b; // zero-filled +RectangularMatrix<2, 3, Int> a; // zero-filled +Vector<3, Int> b; // zero-filled -Matrix<3, int> identity; // diagonal set to 1 -Matrix<3, int> zero(Matrix<3, int>::Zero); // zero-filled +Matrix<3, Int> identity; // diagonal set to 1 +Matrix<3, Int> zero(Matrix<3, Int>::Zero); // zero-filled -Color4 black1; // {0.0f, 0.0f, 0.0f, 1.0f} +Color4 black1; // {0.0f, 0.0f, 0.0f, 1.0f} Color4 black2; // {0, 0, 0, 255} @endcode @@ -49,9 +49,9 @@ Most common and most efficient way to create vector is to pass all values to constructor, matrix is created by passing all column vectors to the constructor. @code -Vector3 vec(0, 1, 2); +Vector3 vec(0, 1, 2); -Matrix3 mat({0, 1, 2}, +Matrix3 mat({0, 1, 2}, {3, 4, 5}, {6, 7, 8}); @endcode @@ -61,34 +61,34 @@ at compile time. You can specify all components of vector or whole diagonal of square matrix at once: @code -Matrix3 diag(Matrix3::Identity, 2); // diagonal set to 2, zeros elsewhere -Vector3 fill(10); // {10, 10, 10} +Matrix3 diag(Matrix3::Identity, 2); // diagonal set to 2, zeros elsewhere +Vector3 fill(10); // {10, 10, 10} @endcode It is possible to create matrices from other matrices and vectors with the same row count; vectors from vector and scalar: @code -RectangularMatrix<2, 3, int> a; -Vector3 b, c; -Matrix3 mat(a, b); -Vector<8, int> vec(1, b, 2, c); +RectangularMatrix<2, 3, Int> a; +Vector3 b, c; +Matrix3 mat(a, b); +Vector<8, Int> vec(1, b, 2, c); @endcode It is also possible to create them from an C-style array. The function does simple type cast without any copying, so it's possible to conveniently operate on the array itself: @code -int[] mat = { 2, 4, 6, +Int[] mat = { 2, 4, 6, 1, 3, 5 }; -RectangularMatrix<2, 3, int>::from(mat) *= 2; // mat == { 4, 8, 12, 2, 6, 10 } +RectangularMatrix<2, 3, Int>::from(mat) *= 2; // mat == { 4, 8, 12, 2, 6, 10 } @endcode Note that unlike constructors, this function has no way to check whether the array is long enough to contain all elements, so use with caution. You can also *explicitly* convert between data types: @code -Vector4 floating(1.3f, 2.7f, -15.0f, 7.0f); -Vector4 integral(floating); // {1, 2, -15, 7} +Vector4 floating(1.3f, 2.7f, -15.0f, 7.0f); +Vector4 integral(floating); // {1, 2, -15, 7} @endcode @section matrix-vector-component-access Accessing matrix and vector components @@ -97,31 +97,31 @@ Column vectors of matrices and vector components can be accessed using square brackets, there is also round bracket operator for accessing matrix components directly: @code -RectangularMatrix<3, 2, int> a; +RectangularMatrix<3, 2, Int> a; a[2] /= 2; // third column (column major indexing, see explanation below) a[0][1] = 5; // first column, second element -Vector<3, int> b; +Vector<3, Int> b; b[1] = 1; // second element @endcode Fixed-size vector subclasses have functions for accessing named components and subparts: @code -Vector4 a; -int x = a.x(); +Vector4 a; +Int x = a.x(); a.y() += 5; -Vector3 xyz = a.xyz(); +Vector3 xyz = a.xyz(); xyz.xy() *= 5; @endcode Color3 and Color4 name their components `rgba` instead of `xyzw`. For more involved operations with components there is the swizzle() function: @code -Vector<4, int> original(-1, 2, 3, 4); -Vector<4, int> bgra = swizzle<'b', 'g', 'r', 'a'>(original); // { 3, 2, -1, 4 } -Vector<6, int> w10xyz = swizzle<'w', '1', '0', 'x', 'y', 'z'>(original); // { 4, 1, 0, -1, 2, 3 } +Vector<4, Int> original(-1, 2, 3, 4); +Vector<4, Int> bgra = swizzle<'b', 'g', 'r', 'a'>(original); // { 3, 2, -1, 4 } +Vector<6, Int> w10xyz = swizzle<'w', '1', '0', 'x', 'y', 'z'>(original); // { 4, 1, 0, -1, 2, 3 } @endcode @section matrix-vector-column-major Matrices are column-major and vectors are columns @@ -133,12 +133,12 @@ implications and it may differ from what is common in mathematics: - Order of template arguments in specification of RectangularMatrix is also column-major: @code -RectangularMatrix<2, 3, int> mat; // two columns, three rows +RectangularMatrix<2, 3, Int> mat; // two columns, three rows @endcode - Order of components in matrix constructors is also column-major, further emphasized by requirement that you have to pass directly column vectors: @code -Matrix3 mat({0, 1, 2}, +Matrix3 mat({0, 1, 2}, {3, 4, 5}, {6, 7, 8}); // first column is {0, 1, 2} @endcode diff --git a/src/Math/Algorithms/Svd.h b/src/Math/Algorithms/Svd.h index 7320c513c..ebdc7591e 100644 --- a/src/Math/Algorithms/Svd.h +++ b/src/Math/Algorithms/Svd.h @@ -41,8 +41,8 @@ template T pythagoras(T a, T b) { } template T smallestDelta(); -template<> inline constexpr float smallestDelta() { return 1.0e-32; } -template<> inline constexpr double smallestDelta() { return 1.0e-64; } +template<> inline constexpr Float smallestDelta() { return 1.0e-32; } +template<> inline constexpr Double smallestDelta() { return 1.0e-64; } } #endif @@ -61,22 +61,22 @@ zero matrices. Full @f$ U @f$, @f$ \Sigma @f$ matrices and original @f$ M @f$ matrix can be reconstructed from the values as following: @code -RectangularMatrix m; +RectangularMatrix m; -RectangularMatrix uPart; -Vector wDiagonal; -Matrix v; +RectangularMatrix uPart; +Vector wDiagonal; +Matrix v; std::tie(uPart, wDiagonal, v) = Math::Algorithms::svd(m); // Extend U -Matrix u(Matrix::Zero); +Matrix u(Matrix::Zero); for(std::size_t i = 0; i != rows; ++i) u[i] = uPart[i]; // Diagonal W -RectangularMatrix w = - RectangularMatrix::fromDiagonal(wDiagonal); +RectangularMatrix w = + RectangularMatrix::fromDiagonal(wDiagonal); // u*w*v.transposed() == m @endcode diff --git a/src/Math/Algorithms/Test/GaussJordanTest.cpp b/src/Math/Algorithms/Test/GaussJordanTest.cpp index 155144f84..c2ef7c925 100644 --- a/src/Math/Algorithms/Test/GaussJordanTest.cpp +++ b/src/Math/Algorithms/Test/GaussJordanTest.cpp @@ -27,8 +27,8 @@ class GaussJordanTest: public Corrade::TestSuite::Tester { void invert(); }; -typedef RectangularMatrix<4, 4, float> Matrix4; -typedef Vector<4, float> Vector4; +typedef RectangularMatrix<4, 4, Float> Matrix4; +typedef Vector<4, Float> Vector4; GaussJordanTest::GaussJordanTest() { addTests(&GaussJordanTest::singular, @@ -40,7 +40,7 @@ void GaussJordanTest::singular() { Vector4(2.0f, 3.0f, -7.0f, 11.0f), Vector4(2.0f, 4.0f, 6.0f, 8.0f), Vector4(1.0f, 2.0f, 7.0f, 40.0f)); - RectangularMatrix<4, 1, float> t; + RectangularMatrix<4, 1, Float> t; CORRADE_VERIFY(!gaussJordanInPlaceTransposed(a, t)); } diff --git a/src/Math/Algorithms/Test/GramSchmidtTest.cpp b/src/Math/Algorithms/Test/GramSchmidtTest.cpp index 67e1e7595..6af54d4e6 100644 --- a/src/Math/Algorithms/Test/GramSchmidtTest.cpp +++ b/src/Math/Algorithms/Test/GramSchmidtTest.cpp @@ -27,8 +27,8 @@ class GramSchmidtTest: public Corrade::TestSuite::Tester { void orthonormalize(); }; -typedef RectangularMatrix<3, 3, float> Matrix3; -typedef Vector<3, float> Vector3; +typedef RectangularMatrix<3, 3, Float> Matrix3; +typedef Vector<3, Float> Vector3; GramSchmidtTest::GramSchmidtTest() { addTests(&GramSchmidtTest::orthogonalize, diff --git a/src/Math/Algorithms/Test/SvdTest.cpp b/src/Math/Algorithms/Test/SvdTest.cpp index 9c0a55560..b0ccade4d 100644 --- a/src/Math/Algorithms/Test/SvdTest.cpp +++ b/src/Math/Algorithms/Test/SvdTest.cpp @@ -27,17 +27,17 @@ class SvdTest: public Corrade::TestSuite::Tester { void testFloat(); }; -typedef RectangularMatrix<5, 8, double> Matrix5x8d; -typedef Matrix<8, double> Matrix8d; -typedef Matrix<5, double> Matrix5d; -typedef Vector<8, double> Vector8d; -typedef Vector<5, double> Vector5d; - -typedef RectangularMatrix<5, 8, float> Matrix5x8f; -typedef Matrix<8, float> Matrix8f; -typedef Matrix<5, float> Matrix5f; -typedef Vector<8, float> Vector8f; -typedef Vector<5, float> Vector5f; +typedef RectangularMatrix<5, 8, Double> Matrix5x8d; +typedef Matrix<8, Double> Matrix8d; +typedef Matrix<5, Double> Matrix5d; +typedef Vector<8, Double> Vector8d; +typedef Vector<5, Double> Vector5d; + +typedef RectangularMatrix<5, 8, Float> Matrix5x8f; +typedef Matrix<8, Float> Matrix8f; +typedef Matrix<5, Float> Matrix5f; +typedef Vector<8, Float> Vector8f; +typedef Vector<5, Float> Vector5f; constexpr static Matrix5x8d a( Vector8d(22.0, 14.0, -1.0, -3.0, 9.0, 9.0, 2.0, 4.0), diff --git a/src/Math/Angle.cpp b/src/Math/Angle.cpp index bbf6ed37c..07f77b4e6 100644 --- a/src/Math/Angle.cpp +++ b/src/Math/Angle.cpp @@ -18,11 +18,11 @@ namespace Magnum { namespace Math { #ifndef DOXYGEN_GENERATING_OUTPUT -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Unit&); -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Unit&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Unit&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Unit&); #ifndef MAGNUM_TARGET_GLES -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Unit&); -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Unit&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Unit&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Unit&); #endif #endif diff --git a/src/Math/Angle.h b/src/Math/Angle.h index a692572fc..3d6e6a319 100644 --- a/src/Math/Angle.h +++ b/src/Math/Angle.h @@ -39,17 +39,17 @@ conversion less error-prone. You can enter the value either by using literal: @code -auto degrees = 60.0_degf; // type is Deg -auto radians = 1.047_rad; // type is Rad +auto degrees = 60.0_degf; // type is Deg +auto radians = 1.047_rad; // type is Rad @endcode Or explicitly convert unitless value (such as output from some function) to either degrees or radians: @code -double foo(); +Double foo(); -Deg degrees(35.0f); -Rad radians(foo()); +Deg degrees(35.0f); +Rad radians(foo()); //degrees = 60.0f; // error, no implicit conversion @endcode @@ -65,9 +65,9 @@ It is also possible to compare angles with all comparison operators, but comparison of degrees and radians is not possible without explicit conversion to common type: @code -Rad angle(); +Rad angle(); -Deg x = angle(); // convert to degrees for easier comparison +Deg x = angle(); // convert to degrees for easier comparison if(x < 30.0_degf) foo(); //if(x > 1.57_radf) bar(); // error, both need to be of the same type @endcode @@ -75,11 +75,11 @@ if(x < 30.0_degf) foo(); It is possible to seamlessly convert between degrees and radians and explicitly convert the value back to underlying type: @code -float sine(Rad angle); -float a = sine(60.0_degf); // the same as sine(1.047_radf) -Deg b = 1.047_rad; // the same as 60.0_deg -float d = double(b); // 60.0 -//float e = b; // error, no implicit conversion +Float sine(Rad angle); +Float a = sine(60.0_degf); // the same as sine(1.047_radf) +Deg b = 1.047_rad; // the same as 60.0_deg +Float d = Double(b); // 60.0 +//Float e = b; // error, no implicit conversion @endcode @section Rad-conversions Requirement of explicit conversion @@ -88,10 +88,10 @@ The requirement of explicit conversions from and to unitless types helps to reduce unit-based errors. Consider following example with implicit conversions allowed: @code -float std::sin(float angle); -float sine(Rad angle); +Float std::sin(Float angle); +Float sine(Rad angle); -float a = 60.0f; // degrees +Float a = 60.0f; // degrees sine(a); // silent error, sine() expected radians auto b = 60.0_degf; // degrees @@ -101,10 +101,10 @@ std::sin(b); // silent error, std::sin() expected radians These silent errors are easily avoided by requiring explicit conversions: @code //sine(angleInDegrees); // compilation error -sine(Deg(angleInDegrees)); // explicitly specifying unit +sine(Deg(angleInDegrees)); // explicitly specifying unit //std::sin(angleInDegrees); // compilation error -std::sin(float(Rad(angleInDegrees)); // required explicit conversion hints +std::sin(Float(Rad(angleInDegrees)); // required explicit conversion hints // to user that this case needs special // attention (i.e., conversion to radians) @endcode @@ -142,26 +142,26 @@ template class Deg: public Unit { Example usage: @code -double cosine = Math::cos(60.0_deg); // cosine = 0.5 -double cosine = Math::cos(1.047_rad); // cosine = 0.5 +Double cosine = Math::cos(60.0_deg); // cosine = 0.5 +Double cosine = Math::cos(1.047_rad); // cosine = 0.5 @endcode @see Magnum::operator""_deg(), operator""_degf(), operator""_rad() @note Not available on GCC < 4.7. Use Deg::Deg(T) instead. */ -inline constexpr Deg operator "" _deg(long double value) { return Deg(value); } +inline constexpr Deg operator "" _deg(long double value) { return Deg(value); } /** @relates Deg @brief Single-precision degree value literal Example usage: @code -float tangent = Math::tan(60.0_degf); // tangent = 1.732f -float tangent = Math::tan(1.047_radf); // tangent = 1.732f +Float tangent = Math::tan(60.0_degf); // tangent = 1.732f +Float tangent = Math::tan(1.047_radf); // tangent = 1.732f @endcode @see Magnum::operator""_degf(), operator""_deg(), operator""_radf() @note Not available on GCC < 4.7. Use Deg::Deg(T) instead. */ -inline constexpr Deg operator "" _degf(long double value) { return Deg(value); } +inline constexpr Deg operator "" _degf(long double value) { return Deg(value); } #endif /** @@ -203,7 +203,7 @@ See operator""_rad() for more information. @see Magnum::operator""_rad(), operator""_radf(), operator""_deg() @note Not available on GCC < 4.7. Use Rad::Rad(T) instead. */ -inline constexpr Rad operator "" _rad(long double value) { return Rad(value); } +inline constexpr Rad operator "" _rad(long double value) { return Rad(value); } /** @relates Rad @brief Single-precision radian value literal @@ -212,7 +212,7 @@ See operator""_degf() for more information. @see Magnum::operator""_radf(), operator""_rad(), operator""_degf() @note Not available on GCC < 4.7. Use Rad::Rad(T) instead. */ -inline constexpr Rad operator "" _radf(long double value) { return Rad(value); } +inline constexpr Rad operator "" _radf(long double value) { return Rad(value); } #endif template inline constexpr Deg::Deg(Unit value): Unit(T(180)*T(value)/Math::Constants::pi()) {} @@ -238,11 +238,11 @@ template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug deb /* Explicit instantiation for commonly used types */ #ifndef DOXYGEN_GENERATING_OUTPUT -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Unit&); -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Unit&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Unit&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Unit&); #ifndef MAGNUM_TARGET_GLES -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Unit&); -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Unit&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Unit&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Unit&); #endif #endif diff --git a/src/Math/BoolVector.h b/src/Math/BoolVector.h index a5ac589d4..14166de15 100644 --- a/src/Math/BoolVector.h +++ b/src/Math/BoolVector.h @@ -19,9 +19,10 @@ * @brief Class Magnum::Math::BoolVector */ -#include #include +#include "Types.h" + namespace Magnum { namespace Math { #ifndef DOXYGEN_GENERATING_OUTPUT @@ -65,9 +66,9 @@ template class BoolVector { * @param next Values for next Bbit segments */ #ifdef DOXYGEN_GENERATING_OUTPUT - template inline constexpr /*implicit*/ BoolVector(std::uint8_t first, T... next); + template inline constexpr /*implicit*/ BoolVector(UnsignedByte first, T... next); #else - template::type> inline constexpr /*implicit*/ BoolVector(std::uint8_t first, T... next): _data{first, std::uint8_t(next)...} {} + template::type> inline constexpr /*implicit*/ BoolVector(UnsignedByte first, T... next): _data{first, UnsignedByte(next)...} {} #endif /** @brief Construct boolean vector with one value for all fields */ @@ -89,8 +90,8 @@ template class BoolVector { * * @see operator[](), set() */ - inline std::uint8_t* data() { return _data; } - inline constexpr const std::uint8_t* data() const { return _data; } /**< @overload */ + inline UnsignedByte* data() { return _data; } + inline constexpr const UnsignedByte* data() const { return _data; } /**< @overload */ /** @brief Bit at given position */ inline constexpr bool operator[](std::size_t i) const { @@ -225,15 +226,15 @@ template class BoolVector { } private: - enum: std::uint8_t { + enum: UnsignedByte { FullSegmentMask = 0xFF, LastSegmentMask = (1 << size%8) - 1 }; /* Implementation for Vector::Vector(U) */ - template inline constexpr explicit BoolVector(Implementation::Sequence, std::uint8_t value): _data{Implementation::repeat(value, sequence)...} {} + template inline constexpr explicit BoolVector(Implementation::Sequence, UnsignedByte value): _data{Implementation::repeat(value, sequence)...} {} - std::uint8_t _data[(size-1)/8+1]; + UnsignedByte _data[(size-1)/8+1]; }; /** @debugoperator{Magnum::Math::BoolVector} */ diff --git a/src/Math/Complex.cpp b/src/Math/Complex.cpp index 0a6c5bd39..84cdf2c3e 100644 --- a/src/Math/Complex.cpp +++ b/src/Math/Complex.cpp @@ -18,9 +18,9 @@ namespace Magnum { namespace Math { #ifndef DOXYGEN_GENERATING_OUTPUT -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Complex&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Complex&); #ifndef MAGNUM_TARGET_GLES -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Complex&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Complex&); #endif #endif diff --git a/src/Math/Complex.h b/src/Math/Complex.h index 5a363b08b..cd3139a0b 100644 --- a/src/Math/Complex.h +++ b/src/Math/Complex.h @@ -390,9 +390,9 @@ template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug deb /* Explicit instantiation for commonly used types */ #ifndef DOXYGEN_GENERATING_OUTPUT -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Complex&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Complex&); #ifndef MAGNUM_TARGET_GLES -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Complex&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Complex&); #endif #endif diff --git a/src/Math/Constants.h b/src/Math/Constants.h index 7f4e3aa6b..bbc8b047c 100644 --- a/src/Math/Constants.h +++ b/src/Math/Constants.h @@ -19,6 +19,8 @@ * @brief Class Magnum::Math::Constants */ +#include "Types.h" + namespace Magnum { namespace Math { /** @@ -44,19 +46,19 @@ template struct Constants { }; #ifndef DOXYGEN_GENERATING_OUTPUT -template<> struct Constants { +template<> struct Constants { Constants() = delete; - static inline constexpr double pi() { return 3.141592653589793; } - static inline constexpr double sqrt2() { return 1.414213562373095; } - static inline constexpr double sqrt3() { return 1.732050807568877; } + static inline constexpr Double pi() { return 3.141592653589793; } + static inline constexpr Double sqrt2() { return 1.414213562373095; } + static inline constexpr Double sqrt3() { return 1.732050807568877; } }; -template<> struct Constants { +template<> struct Constants { Constants() = delete; - static inline constexpr float pi() { return 3.141592654f; } - static inline constexpr float sqrt2() { return 1.414213562f; } - static inline constexpr float sqrt3() { return 1.732050808f; } + static inline constexpr Float pi() { return 3.141592654f; } + static inline constexpr Float sqrt2() { return 1.414213562f; } + static inline constexpr Float sqrt3() { return 1.732050808f; } }; #endif diff --git a/src/Math/DualComplex.cpp b/src/Math/DualComplex.cpp index 128f2f767..e0e83ca08 100644 --- a/src/Math/DualComplex.cpp +++ b/src/Math/DualComplex.cpp @@ -18,9 +18,9 @@ namespace Magnum { namespace Math { #ifndef DOXYGEN_GENERATING_OUTPUT -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const DualComplex&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const DualComplex&); #ifndef MAGNUM_TARGET_GLES -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const DualComplex&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const DualComplex&); #endif #endif diff --git a/src/Math/DualComplex.h b/src/Math/DualComplex.h index d455d72e6..8c47152f4 100644 --- a/src/Math/DualComplex.h +++ b/src/Math/DualComplex.h @@ -308,9 +308,9 @@ template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug deb /* Explicit instantiation for commonly used types */ #ifndef DOXYGEN_GENERATING_OUTPUT -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const DualComplex&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const DualComplex&); #ifndef MAGNUM_TARGET_GLES -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const DualComplex&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const DualComplex&); #endif #endif diff --git a/src/Math/DualQuaternion.cpp b/src/Math/DualQuaternion.cpp index 7a5d2448c..fe330c6b6 100644 --- a/src/Math/DualQuaternion.cpp +++ b/src/Math/DualQuaternion.cpp @@ -18,9 +18,9 @@ namespace Magnum { namespace Math { #ifndef DOXYGEN_GENERATING_OUTPUT -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const DualQuaternion&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const DualQuaternion&); #ifndef MAGNUM_TARGET_GLES -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const DualQuaternion&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const DualQuaternion&); #endif #endif diff --git a/src/Math/DualQuaternion.h b/src/Math/DualQuaternion.h index 7bc3d70d7..0cb8bd6d0 100644 --- a/src/Math/DualQuaternion.h +++ b/src/Math/DualQuaternion.h @@ -298,9 +298,9 @@ template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug deb /* Explicit instantiation for commonly used types */ #ifndef DOXYGEN_GENERATING_OUTPUT -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const DualQuaternion&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const DualQuaternion&); #ifndef MAGNUM_TARGET_GLES -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const DualQuaternion&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const DualQuaternion&); #endif #endif diff --git a/src/Math/Functions.cpp b/src/Math/Functions.cpp index 286f5d632..afcb2ad76 100644 --- a/src/Math/Functions.cpp +++ b/src/Math/Functions.cpp @@ -17,15 +17,15 @@ namespace Magnum { namespace Math { -std::uint32_t log2(std::uint32_t number) { - std::uint32_t log = 0; +UnsignedInt log2(UnsignedInt number) { + UnsignedInt log = 0; while(number >>= 1) ++log; return log; } -std::uint32_t log(std::uint32_t base, std::uint32_t number) { - std::uint32_t log = 0; +UnsignedInt log(UnsignedInt base, UnsignedInt number) { + UnsignedInt log = 0; while(number /= base) ++log; return log; diff --git a/src/Math/Functions.h b/src/Math/Functions.h index dc2ff22e6..d123fdfad 100644 --- a/src/Math/Functions.h +++ b/src/Math/Functions.h @@ -31,7 +31,7 @@ namespace Magnum { namespace Math { #ifndef DOXYGEN_GENERATING_OUTPUT namespace Implementation { - template struct Pow { + template struct Pow { Pow() = delete; template inline constexpr static T pow(T base) { @@ -51,7 +51,7 @@ namespace Implementation { * * Returns integral power of base to the exponent. */ -template inline constexpr T pow(T base) { +template inline constexpr T pow(T base) { return Implementation::Pow::pow(base); } @@ -61,7 +61,7 @@ template inline constexpr T pow(T base) { * Returns integral logarithm of given number with base `2`. * @see log() */ -std::uint32_t MAGNUM_EXPORT log2(std::uint32_t number); +UnsignedInt MAGNUM_EXPORT log2(UnsignedInt number); /** * @brief Integral logarithm @@ -69,7 +69,7 @@ std::uint32_t MAGNUM_EXPORT log2(std::uint32_t number); * Returns integral logarithm of given number with given base. * @see log2() */ -std::uint32_t MAGNUM_EXPORT log(std::uint32_t base, std::uint32_t number); +UnsignedInt MAGNUM_EXPORT log(UnsignedInt base, UnsignedInt number); /** @brief Sine */ template inline T sin(Rad angle) { return std::sin(T(angle)); } @@ -224,18 +224,18 @@ Converts integral value from full range of given *unsigned* integral type to value in range @f$ [0, 1] @f$ or from *signed* integral to range @f$ [-1, 1] @f$. @note For best precision, resulting `FloatingPoint` type should be always - larger that `Integral` type (e.g. `double` from `std::int32_t`, `long double` - from `std::int64_t` and similarly for vector types). + larger that `Integral` type (e.g. Double from Int, LongDouble from Long and + similarly for vector types). @attention To ensure the integral type is correctly detected when using literals, this function should be called with both template parameters explicit, e.g.: @code // Literal type is (signed) char, but we assumed unsigned char, a != 1.0f -float a = normalize('\xFF'); +Float a = normalize('\xFF'); // b = 1.0f -float b = normalize('\xFF'); +Float b = normalize('\xFF'); @endcode @see denormalize() @@ -273,8 +273,8 @@ Converts floating-point value in range @f$ [0, 1] @f$ to full range of given integral type. @note For best precision, `FloatingPoint` type should be always larger that - resulting `Integral` type (e.g. `double` to `std::int32_t`, `long double` - to `std::int64_t` and similarly for vector types). + resulting `Integral` type (e.g. Double to Int, LongDouble to Long and + similarly for vector types). @attention Return value for floating point numbers outside the normalized range is undefined. diff --git a/src/Math/Geometry/Rectangle.h b/src/Math/Geometry/Rectangle.h index 1ca5275e7..c2601383f 100644 --- a/src/Math/Geometry/Rectangle.h +++ b/src/Math/Geometry/Rectangle.h @@ -60,8 +60,8 @@ template class Rectangle { * Performs only default casting on the values, no rounding or * anything else. Example usage: * @code - * Rectangle floatingPoint({1.3f, 2.7f}, {-15.0f, 7.0f}); - * Rectangle integral(floatingPoint); // {{1, 2}, {-15, 7}} + * Rectangle floatingPoint({1.3f, 2.7f}, {-15.0f, 7.0f}); + * Rectangle integral(floatingPoint); // {{1, 2}, {-15, 7}} * @endcode */ template inline constexpr explicit Rectangle(const Rectangle& other): _bottomLeft(other._bottomLeft), _topRight(other._topRight) {} diff --git a/src/Math/Geometry/Test/DistanceTest.cpp b/src/Math/Geometry/Test/DistanceTest.cpp index 069ad493d..2ddf630d2 100644 --- a/src/Math/Geometry/Test/DistanceTest.cpp +++ b/src/Math/Geometry/Test/DistanceTest.cpp @@ -31,8 +31,9 @@ class DistanceTest: public Corrade::TestSuite::Tester { void lineSegmentPoint3D(); }; -typedef Magnum::Math::Vector2 Vector2; -typedef Magnum::Math::Vector3 Vector3; +typedef Math::Vector2 Vector2; +typedef Math::Vector3 Vector3; +typedef Math::Constants Constants; DistanceTest::DistanceTest() { addTests(&DistanceTest::linePoint2D, @@ -49,14 +50,11 @@ void DistanceTest::linePoint2D() { CORRADE_COMPARE((Distance::linePoint(a, b, Vector2(0.25f))), 0.0f); /* The distance should be the same for all equidistant points */ - CORRADE_COMPARE((Distance::linePoint(a, b, Vector2(1.0f, 0.0f))), - 1.0f/Constants::sqrt2()); - CORRADE_COMPARE((Distance::linePoint(a, b, Vector2(1.0f, 0.0f)+Vector2(100.0f))), - 1.0f/Constants::sqrt2()); + CORRADE_COMPARE((Distance::linePoint(a, b, Vector2(1.0f, 0.0f))), 1.0f/Constants::sqrt2()); + CORRADE_COMPARE((Distance::linePoint(a, b, Vector2(1.0f, 0.0f)+Vector2(100.0f))), 1.0f/Constants::sqrt2()); /* Be sure that *Squared() works the same, as it has slightly different implementation */ - CORRADE_COMPARE((Distance::linePointSquared(a, b, Vector2(1.0f, 0.0f))), - 0.5f); + CORRADE_COMPARE((Distance::linePointSquared(a, b, Vector2(1.0f, 0.0f))), 0.5f); } void DistanceTest::linePoint3D() { @@ -67,10 +65,8 @@ void DistanceTest::linePoint3D() { CORRADE_COMPARE((Distance::linePoint(a, b, Vector3(0.25f))), 0.0f); /* The distance should be the same for all equidistant points */ - CORRADE_COMPARE((Distance::linePoint(a, b, Vector3(1.0f, 0.0f, 1.0f))), - Constants::sqrt2()/Constants::sqrt3()); - CORRADE_COMPARE((Distance::linePoint(a, b, Vector3(1.0f, 0.0f, 1.0f)+Vector3(100.0f))), - Constants::sqrt2()/Constants::sqrt3()); + CORRADE_COMPARE((Distance::linePoint(a, b, Vector3(1.0f, 0.0f, 1.0f))), Constants::sqrt2()/Constants::sqrt3()); + CORRADE_COMPARE((Distance::linePoint(a, b, Vector3(1.0f, 0.0f, 1.0f)+Vector3(100.0f))), Constants::sqrt2()/Constants::sqrt3()); } void DistanceTest::lineSegmentPoint2D() { @@ -81,19 +77,17 @@ void DistanceTest::lineSegmentPoint2D() { CORRADE_COMPARE((Distance::lineSegmentPoint(a, b, Vector2(0.25f))), 0.0f); /* Point on the line, outside the segment, closer to A */ - CORRADE_COMPARE((Distance::lineSegmentPoint(a, b, Vector2(-1.0f))), Constants::sqrt2()); + CORRADE_COMPARE((Distance::lineSegmentPoint(a, b, Vector2(-1.0f))), Constants::sqrt2()); /* Be sure that *Squared() works the same, as it has slightly different implementation */ CORRADE_COMPARE((Distance::lineSegmentPointSquared(a, b, Vector2(-1.0f))), 2.0f); /* Point on the line, outside the segment, closer to B */ - CORRADE_COMPARE((Distance::lineSegmentPoint(a, b, Vector2(1.0f+1.0f/Constants::sqrt2()))), 1.0f); - CORRADE_COMPARE((Distance::lineSegmentPointSquared(a, b, Vector2(1.0f+1.0f/Constants::sqrt2()))), 1.0f); + CORRADE_COMPARE((Distance::lineSegmentPoint(a, b, Vector2(1.0f+1.0f/Constants::sqrt2()))), 1.0f); + CORRADE_COMPARE((Distance::lineSegmentPointSquared(a, b, Vector2(1.0f+1.0f/Constants::sqrt2()))), 1.0f); /* Point next to the line segment */ - CORRADE_COMPARE((Distance::lineSegmentPoint(a, b, Vector2(1.0f, 0.0f))), - 1.0f/Constants::sqrt2()); - CORRADE_COMPARE((Distance::lineSegmentPointSquared(a, b, Vector2(1.0f, 0.0f))), - 0.5f); + CORRADE_COMPARE((Distance::lineSegmentPoint(a, b, Vector2(1.0f, 0.0f))), 1.0f/Constants::sqrt2()); + CORRADE_COMPARE((Distance::lineSegmentPointSquared(a, b, Vector2(1.0f, 0.0f))), 0.5f); /* Point outside the line segment, closer to A */ CORRADE_COMPARE((Distance::lineSegmentPoint(a, b, Vector2(1.0f, 0.0f)-Vector2(1.0f, 0.5f))), 0.5f); @@ -112,20 +106,19 @@ void DistanceTest::lineSegmentPoint3D() { CORRADE_COMPARE((Distance::lineSegmentPoint(a, b, Vector3(0.25f))), 0.0f); /* Point on the line, outside the segment, closer to A */ - CORRADE_COMPARE((Distance::lineSegmentPoint(a, b, Vector3(-1.0f))), +Constants::sqrt3()); + CORRADE_COMPARE((Distance::lineSegmentPoint(a, b, Vector3(-1.0f))), Constants::sqrt3()); /* Point on the line, outside the segment, closer to B */ - CORRADE_COMPARE((Distance::lineSegmentPoint(a, b, Vector3(1.0f+1.0f/Constants::sqrt3()))), 1.0f); + CORRADE_COMPARE((Distance::lineSegmentPoint(a, b, Vector3(1.0f+1.0f/Constants::sqrt3()))), 1.0f); /* Point next to the line segment */ - CORRADE_COMPARE((Distance::lineSegmentPoint(a, b, Vector3(1.0f, 0.0f, 1.0f))), - Constants::sqrt2()/Constants::sqrt3()); + CORRADE_COMPARE((Distance::lineSegmentPoint(a, b, Vector3(1.0f, 0.0f, 1.0f))), Constants::sqrt2()/Constants::sqrt3()); /* Point outside the line segment, closer to A */ CORRADE_COMPARE((Distance::lineSegmentPoint(a, b, Vector3(1.0f, 0.0f, 1.0f)-Vector3(1.0f))), 1.0f); /* Point outside the line segment, closer to B */ - CORRADE_COMPARE((Distance::lineSegmentPoint(a, b, Vector3(1.0f, 0.0f, 1.0f)+Vector3(1.0f))), +Constants::sqrt2()); + CORRADE_COMPARE((Distance::lineSegmentPoint(a, b, Vector3(1.0f, 0.0f, 1.0f)+Vector3(1.0f))), Constants::sqrt2()); } }}}} diff --git a/src/Math/Geometry/Test/IntersectionTest.cpp b/src/Math/Geometry/Test/IntersectionTest.cpp index 3e1f27d08..c9cb17fdb 100644 --- a/src/Math/Geometry/Test/IntersectionTest.cpp +++ b/src/Math/Geometry/Test/IntersectionTest.cpp @@ -27,7 +27,7 @@ class IntersectionTest: public Corrade::TestSuite::Tester { void planeLine(); }; -typedef Magnum::Math::Vector3 Vector3; +typedef Math::Vector3 Vector3; IntersectionTest::IntersectionTest() { addTests(&IntersectionTest::planeLine); @@ -47,11 +47,11 @@ void IntersectionTest::planeLine() { /* Line lies on the plane */ CORRADE_COMPARE(Intersection::planeLine(planePosition, planeNormal, - Vector3(1.0f, 0.5f, 0.5f), Vector3(0.0f, 1.0f, 0.5f)), std::numeric_limits::quiet_NaN()); + Vector3(1.0f, 0.5f, 0.5f), Vector3(0.0f, 1.0f, 0.5f)), std::numeric_limits::quiet_NaN()); /* Line is parallell to the plane */ CORRADE_COMPARE((Intersection::planeLine(planePosition, planeNormal, - Vector3(1.0f, 0.0f, 1.0f), Vector3(0.0f, 0.0f, 1.0f))), -std::numeric_limits::infinity()); + Vector3(1.0f, 0.0f, 1.0f), Vector3(0.0f, 0.0f, 1.0f))), -std::numeric_limits::infinity()); } }}}} diff --git a/src/Math/Geometry/Test/RectangleTest.cpp b/src/Math/Geometry/Test/RectangleTest.cpp index 84c8b2567..99eb5e309 100644 --- a/src/Math/Geometry/Test/RectangleTest.cpp +++ b/src/Math/Geometry/Test/RectangleTest.cpp @@ -32,9 +32,9 @@ class RectangleTest: public Corrade::TestSuite::Tester { void debug(); }; -typedef Geometry::Rectangle Rectangle; -typedef Geometry::Rectangle Rectanglei; -typedef Vector2 Vector2i; +typedef Geometry::Rectangle Rectangle; +typedef Geometry::Rectangle Rectanglei; +typedef Vector2 Vector2i; RectangleTest::RectangleTest() { addTests(&RectangleTest::access, diff --git a/src/Math/MathTypeTraits.h b/src/Math/MathTypeTraits.h index d60a1eb80..a8f72e114 100644 --- a/src/Math/MathTypeTraits.h +++ b/src/Math/MathTypeTraits.h @@ -19,9 +19,10 @@ * @brief Class Magnum::Math::MathTypeTraits */ -#include #include +#include "Types.h" + /** @brief Precision when testing floats for equality */ #ifndef FLOAT_EQUALITY_PRECISION #define FLOAT_EQUALITY_PRECISION 1.0e-6 @@ -113,28 +114,28 @@ namespace Implementation { }; } -template<> struct MathTypeTraits: Implementation::MathTypeTraitsIntegral { - typedef float FloatingPointType; +template<> struct MathTypeTraits: Implementation::MathTypeTraitsIntegral { + typedef Float FloatingPointType; }; -template<> struct MathTypeTraits: Implementation::MathTypeTraitsIntegral { - typedef float FloatingPointType; +template<> struct MathTypeTraits: Implementation::MathTypeTraitsIntegral { + typedef Float FloatingPointType; }; -template<> struct MathTypeTraits: Implementation::MathTypeTraitsIntegral { - typedef float FloatingPointType; +template<> struct MathTypeTraits: Implementation::MathTypeTraitsIntegral { + typedef Float FloatingPointType; }; -template<> struct MathTypeTraits: Implementation::MathTypeTraitsIntegral { - typedef float FloatingPointType; +template<> struct MathTypeTraits: Implementation::MathTypeTraitsIntegral { + typedef Float FloatingPointType; }; -template<> struct MathTypeTraits: Implementation::MathTypeTraitsIntegral { - typedef double FloatingPointType; +template<> struct MathTypeTraits: Implementation::MathTypeTraitsIntegral { + typedef Double FloatingPointType; }; -template<> struct MathTypeTraits: Implementation::MathTypeTraitsIntegral { - typedef double FloatingPointType; +template<> struct MathTypeTraits: Implementation::MathTypeTraitsIntegral { + typedef Double FloatingPointType; }; -template<> struct MathTypeTraits: Implementation::MathTypeTraitsIntegral { +template<> struct MathTypeTraits: Implementation::MathTypeTraitsIntegral { typedef long double FloatingPointType; }; -template<> struct MathTypeTraits: Implementation::MathTypeTraitsIntegral { +template<> struct MathTypeTraits: Implementation::MathTypeTraitsIntegral { typedef long double FloatingPointType; }; @@ -149,15 +150,15 @@ namespace Implementation { }; } -template<> struct MathTypeTraits: Implementation::MathTypeTraitsFloatingPoint { - typedef float FloatingPointType; +template<> struct MathTypeTraits: Implementation::MathTypeTraitsFloatingPoint { + typedef Float FloatingPointType; - inline constexpr static float epsilon() { return FLOAT_EQUALITY_PRECISION; } + inline constexpr static Float epsilon() { return FLOAT_EQUALITY_PRECISION; } }; -template<> struct MathTypeTraits: Implementation::MathTypeTraitsFloatingPoint { - typedef double FloatingPointType; +template<> struct MathTypeTraits: Implementation::MathTypeTraitsFloatingPoint { + typedef Double FloatingPointType; - inline constexpr static double epsilon() { return DOUBLE_EQUALITY_PRECISION; } + inline constexpr static Double epsilon() { return DOUBLE_EQUALITY_PRECISION; } }; template<> struct MathTypeTraits: Implementation::MathTypeTraitsFloatingPoint { typedef long double FloatingPointType; diff --git a/src/Math/Matrix.h b/src/Math/Matrix.h index 6334038cc..89e070f57 100644 --- a/src/Math/Matrix.h +++ b/src/Math/Matrix.h @@ -81,9 +81,9 @@ template class Matrix: public RectangularMatrix floatingPoint({1.3f, 2.7f}, + * Matrix<2, Float> floatingPoint({1.3f, 2.7f}, * {-15.0f, 7.0f}); - * Matrix<2, std::int8_t> integral(floatingPoint); + * Matrix<2, Byte> integral(floatingPoint); * // integral == {{1, 2}, {-15, 7}} * @endcode */ diff --git a/src/Math/Quaternion.cpp b/src/Math/Quaternion.cpp index c736cbfbf..9939dc854 100644 --- a/src/Math/Quaternion.cpp +++ b/src/Math/Quaternion.cpp @@ -18,9 +18,9 @@ namespace Magnum { namespace Math { #ifndef DOXYGEN_GENERATING_OUTPUT -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Quaternion&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Quaternion&); #ifndef MAGNUM_TARGET_GLES -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Quaternion&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Quaternion&); #endif #endif diff --git a/src/Math/Quaternion.h b/src/Math/Quaternion.h index f50904fdc..97024a248 100644 --- a/src/Math/Quaternion.h +++ b/src/Math/Quaternion.h @@ -479,9 +479,9 @@ template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug deb /* Explicit instantiation for commonly used types */ #ifndef DOXYGEN_GENERATING_OUTPUT -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Quaternion&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Quaternion&); #ifndef MAGNUM_TARGET_GLES -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Quaternion&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Quaternion&); #endif #endif diff --git a/src/Math/RectangularMatrix.cpp b/src/Math/RectangularMatrix.cpp index 1716c3a14..76d8e9cdf 100644 --- a/src/Math/RectangularMatrix.cpp +++ b/src/Math/RectangularMatrix.cpp @@ -18,28 +18,28 @@ namespace Magnum { namespace Math { #ifndef DOXYGEN_GENERATING_OUTPUT -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<2, 2, float>&); -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<3, 3, float>&); -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<4, 4, float>&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<2, 2, Float>&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<3, 3, Float>&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<4, 4, Float>&); #ifndef MAGNUM_TARGET_GLES -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<2, 2, double>&); -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<3, 3, double>&); -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<4, 4, double>&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<2, 2, Double>&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<3, 3, Double>&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<4, 4, Double>&); #endif -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<2, 3, float>&); -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<3, 2, float>&); -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<2, 4, float>&); -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<4, 2, float>&); -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<3, 4, float>&); -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<4, 3, float>&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<2, 3, Float>&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<3, 2, Float>&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<2, 4, Float>&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<4, 2, Float>&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<3, 4, Float>&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<4, 3, Float>&); #ifndef MAGNUM_TARGET_GLES -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<2, 3, double>&); -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<3, 2, double>&); -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<2, 4, double>&); -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<4, 2, double>&); -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<3, 4, double>&); -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<4, 3, double>&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<2, 3, Double>&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<3, 2, Double>&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<2, 4, Double>&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<4, 2, Double>&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<3, 4, Double>&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::RectangularMatrix<4, 3, Double>&); #endif #endif @@ -48,28 +48,28 @@ template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnu namespace Corrade { namespace Utility { #ifndef DOXYGEN_GENERATING_OUTPUT -template struct ConfigurationValue>; -template struct ConfigurationValue>; -template struct ConfigurationValue>; +template struct ConfigurationValue>; +template struct ConfigurationValue>; +template struct ConfigurationValue>; #ifndef MAGNUM_TARGET_GLES -template struct ConfigurationValue>; -template struct ConfigurationValue>; -template struct ConfigurationValue>; +template struct ConfigurationValue>; +template struct ConfigurationValue>; +template struct ConfigurationValue>; #endif -template struct ConfigurationValue>; -template struct ConfigurationValue>; -template struct ConfigurationValue>; -template struct ConfigurationValue>; -template struct ConfigurationValue>; -template struct ConfigurationValue>; +template struct ConfigurationValue>; +template struct ConfigurationValue>; +template struct ConfigurationValue>; +template struct ConfigurationValue>; +template struct ConfigurationValue>; +template struct ConfigurationValue>; #ifndef MAGNUM_TARGET_GLES -template struct ConfigurationValue>; -template struct ConfigurationValue>; -template struct ConfigurationValue>; -template struct ConfigurationValue>; -template struct ConfigurationValue>; -template struct ConfigurationValue>; +template struct ConfigurationValue>; +template struct ConfigurationValue>; +template struct ConfigurationValue>; +template struct ConfigurationValue>; +template struct ConfigurationValue>; +template struct ConfigurationValue>; #endif #endif diff --git a/src/Math/RectangularMatrix.h b/src/Math/RectangularMatrix.h index 29189eab9..0702ff57d 100644 --- a/src/Math/RectangularMatrix.h +++ b/src/Math/RectangularMatrix.h @@ -104,8 +104,8 @@ template class RectangularMatrix { * Performs only default casting on the values, no rounding or * anything else. Example usage: * @code - * RectangularMatrix<4, 1, float> floatingPoint(1.3f, 2.7f, -15.0f, 7.0f); - * RectangularMatrix<4, 1, std::int8_t> integral(floatingPoint); + * RectangularMatrix<4, 1, Float> floatingPoint(1.3f, 2.7f, -15.0f, 7.0f); + * RectangularMatrix<4, 1, Byte> integral(floatingPoint); * // integral == {1, 2, -15, 7} * @endcode */ @@ -132,8 +132,8 @@ template class RectangularMatrix { * * Particular elements can be accessed using Vector::operator[], e.g.: * @code - * RectangularMatrix<4, 3, float> m; - * float a = m[2][1]; + * RectangularMatrix<4, 3, Float> m; + * Float a = m[2][1]; * @endcode * * @see data() @@ -475,29 +475,29 @@ template Corrade::Utility::Debug op #ifndef DOXYGEN_GENERATING_OUTPUT /* Explicit instantiation for types used in OpenGL */ /* Square matrices */ -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<2, 2, float>&); -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<3, 3, float>&); -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<4, 4, float>&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<2, 2, Float>&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<3, 3, Float>&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<4, 4, Float>&); #ifndef MAGNUM_TARGET_GLES -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<2, 2, double>&); -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<3, 3, double>&); -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<4, 4, double>&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<2, 2, Double>&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<3, 3, Double>&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<4, 4, Double>&); #endif /* Rectangular matrices */ -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<2, 3, float>&); -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<3, 2, float>&); -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<2, 4, float>&); -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<4, 2, float>&); -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<3, 4, float>&); -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<4, 3, float>&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<2, 3, Float>&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<3, 2, Float>&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<2, 4, Float>&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<4, 2, Float>&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<3, 4, Float>&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<4, 3, Float>&); #ifndef MAGNUM_TARGET_GLES -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<2, 3, double>&); -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<3, 2, double>&); -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<2, 4, double>&); -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<4, 2, double>&); -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<3, 4, double>&); -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<4, 3, double>&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<2, 3, Double>&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<3, 2, Double>&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<2, 4, Double>&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<4, 2, Double>&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<3, 4, Double>&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const RectangularMatrix<4, 3, Double>&); #endif #define MAGNUM_RECTANGULARMATRIX_SUBCLASS_IMPLEMENTATION(cols, rows, ...) \ @@ -591,29 +591,29 @@ template struct ConfigurationValue< #ifndef DOXYGEN_GENERATING_OUTPUT /* Square matrices */ -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; #ifndef MAGNUM_TARGET_GLES -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; #endif /* Rectangular matrices */ -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; #ifndef MAGNUM_TARGET_GLES -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; #endif #endif diff --git a/src/Math/Swizzle.h b/src/Math/Swizzle.h index 482236d29..b0010fab0 100644 --- a/src/Math/Swizzle.h +++ b/src/Math/Swizzle.h @@ -50,7 +50,7 @@ namespace Implementation { Creates new vector from given components. Example: @code -Vector4 original(-1, 2, 3, 4); +Vector4 original(-1, 2, 3, 4); auto vec = swizzle<'w', '1', '0', 'x', 'y', 'z'>(original); // vec == { 4, 1, 0, -1, 2, 3 } diff --git a/src/Math/Test/AngleTest.cpp b/src/Math/Test/AngleTest.cpp index fbd71685c..7ac2f7e6b 100644 --- a/src/Math/Test/AngleTest.cpp +++ b/src/Math/Test/AngleTest.cpp @@ -32,10 +32,10 @@ class AngleTest: public Corrade::TestSuite::Tester { void debugRad(); }; -typedef Math::Deg Deg; -typedef Math::Rad Rad; -typedef Math::Deg Degd; -typedef Math::Rad Radd; +typedef Math::Deg Deg; +typedef Math::Rad Rad; +typedef Math::Deg Degd; +typedef Math::Rad Radd; AngleTest::AngleTest() { addTests(&AngleTest::construct, @@ -50,14 +50,14 @@ void AngleTest::construct() { /* Default constructor */ constexpr Degd a; constexpr Deg m; - CORRADE_COMPARE(double(a), 0.0f); - CORRADE_COMPARE(float(m), 0.0f); + CORRADE_COMPARE(Double(a), 0.0f); + CORRADE_COMPARE(Float(m), 0.0f); /* Value constructor */ constexpr Deg b(25.0); constexpr Radd n(3.14); - CORRADE_COMPARE(float(b), 25.0); - CORRADE_COMPARE(double(n), 3.14); + CORRADE_COMPARE(Float(b), 25.0); + CORRADE_COMPARE(Double(n), 3.14); /* Copy constructor */ constexpr Deg c(b); @@ -68,8 +68,8 @@ void AngleTest::construct() { /* Conversion operator */ constexpr Degd d(b); constexpr Rad p(n); - CORRADE_COMPARE(double(d), 25.0); - CORRADE_COMPARE(float(p), 3.14f); + CORRADE_COMPARE(Double(d), 25.0); + CORRADE_COMPARE(Float(p), 3.14f); } void AngleTest::literals() { @@ -77,23 +77,23 @@ void AngleTest::literals() { constexpr auto b = 25.0_degf; CORRADE_VERIFY((std::is_same::value)); CORRADE_VERIFY((std::is_same::value)); - CORRADE_COMPARE(double(a), 25.0); - CORRADE_COMPARE(float(b), 25.0f); + CORRADE_COMPARE(Double(a), 25.0); + CORRADE_COMPARE(Float(b), 25.0f); constexpr auto m = 3.14_rad; constexpr auto n = 3.14_radf; CORRADE_VERIFY((std::is_same::value)); CORRADE_VERIFY((std::is_same::value)); - CORRADE_COMPARE(double(m), 3.14); - CORRADE_COMPARE(float(n), 3.14f); + CORRADE_COMPARE(Double(m), 3.14); + CORRADE_COMPARE(Float(n), 3.14f); } void AngleTest::conversion() { constexpr Deg a(Rad(1.57079633f)); - CORRADE_COMPARE(float(a), 90.0f); + CORRADE_COMPARE(Float(a), 90.0f); constexpr Rad b(Deg(90.0f)); - CORRADE_COMPARE(float(b), 1.57079633f); + CORRADE_COMPARE(Float(b), 1.57079633f); } void AngleTest::debugDeg() { diff --git a/src/Math/Test/BoolVectorTest.cpp b/src/Math/Test/BoolVectorTest.cpp index 5729c9415..c0328348f 100644 --- a/src/Math/Test/BoolVectorTest.cpp +++ b/src/Math/Test/BoolVectorTest.cpp @@ -121,7 +121,7 @@ void BoolVectorTest::constExpressions() { /* Data access, pointer chasings, i.e. *(b.data()[3]), are not possible */ constexpr bool e = b[2]; - constexpr std::uint8_t f = *b.data(); + constexpr UnsignedByte f = *b.data(); CORRADE_COMPARE(e, true); CORRADE_COMPARE(f, 0xa5); } diff --git a/src/Math/Test/ComplexTest.cpp b/src/Math/Test/ComplexTest.cpp index 8b49bacbb..ec407d53b 100644 --- a/src/Math/Test/ComplexTest.cpp +++ b/src/Math/Test/ComplexTest.cpp @@ -84,12 +84,12 @@ ComplexTest::ComplexTest() { &ComplexTest::debug); } -typedef Math::Deg Deg; -typedef Math::Rad Rad; -typedef Math::Complex Complex; -typedef Math::Vector2 Vector2; -typedef Math::Matrix3 Matrix3; -typedef Math::Matrix<2, float> Matrix2; +typedef Math::Deg Deg; +typedef Math::Rad Rad; +typedef Math::Complex Complex; +typedef Math::Vector2 Vector2; +typedef Math::Matrix3 Matrix3; +typedef Math::Matrix<2, Float> Matrix2; void ComplexTest::construct() { Complex c(0.5f, -3.7f); @@ -111,10 +111,10 @@ void ComplexTest::constructFromVector() { } void ComplexTest::compare() { - CORRADE_VERIFY(Complex(3.7f, -1.0f+MathTypeTraits::epsilon()/2) == Complex(3.7f, -1.0f)); - CORRADE_VERIFY(Complex(3.7f, -1.0f+MathTypeTraits::epsilon()*2) != Complex(3.7f, -1.0f)); - CORRADE_VERIFY(Complex(1.0f+MathTypeTraits::epsilon()/2, 3.7f) == Complex(1.0f, 3.7f)); - CORRADE_VERIFY(Complex(1.0f+MathTypeTraits::epsilon()*2, 3.7f) != Complex(1.0f, 3.7f)); + CORRADE_VERIFY(Complex(3.7f, -1.0f+MathTypeTraits::epsilon()/2) == Complex(3.7f, -1.0f)); + CORRADE_VERIFY(Complex(3.7f, -1.0f+MathTypeTraits::epsilon()*2) != Complex(3.7f, -1.0f)); + CORRADE_VERIFY(Complex(1.0f+MathTypeTraits::epsilon()/2, 3.7f) == Complex(1.0f, 3.7f)); + CORRADE_VERIFY(Complex(1.0f+MathTypeTraits::epsilon()*2, 3.7f) != Complex(1.0f, 3.7f)); } void ComplexTest::constExpressions() { @@ -135,8 +135,8 @@ void ComplexTest::constExpressions() { CORRADE_COMPARE(d, Complex(2.5f, -5.0f)); /* Data access */ - constexpr float e = b.real(); - constexpr float f = b.imaginary(); + constexpr Float e = b.real(); + constexpr Float f = b.imaginary(); constexpr Vector2 g(b); CORRADE_COMPARE(e, 2.5f); CORRADE_COMPARE(f, -5.0f); diff --git a/src/Math/Test/ConstantsTest.cpp b/src/Math/Test/ConstantsTest.cpp index 1354beacf..7192b2db7 100644 --- a/src/Math/Test/ConstantsTest.cpp +++ b/src/Math/Test/ConstantsTest.cpp @@ -32,11 +32,11 @@ ConstantsTest::ConstantsTest() { } void ConstantsTest::constants() { - CORRADE_COMPARE(Math::pow<2>(Constants::sqrt2()), 2.0f); - CORRADE_COMPARE(Math::pow<2>(Constants::sqrt3()), 3.0f); + CORRADE_COMPARE(Math::pow<2>(Constants::sqrt2()), 2.0f); + CORRADE_COMPARE(Math::pow<2>(Constants::sqrt3()), 3.0f); - CORRADE_COMPARE(Math::pow<2>(Constants::sqrt2()), 2.0); - CORRADE_COMPARE(Math::pow<2>(Constants::sqrt3()), 3.0); + CORRADE_COMPARE(Math::pow<2>(Constants::sqrt2()), 2.0); + CORRADE_COMPARE(Math::pow<2>(Constants::sqrt3()), 3.0); } }}} diff --git a/src/Math/Test/DualComplexTest.cpp b/src/Math/Test/DualComplexTest.cpp index 758088379..ee292a6ba 100644 --- a/src/Math/Test/DualComplexTest.cpp +++ b/src/Math/Test/DualComplexTest.cpp @@ -52,13 +52,13 @@ class DualComplexTest: public Corrade::TestSuite::Tester { void debug(); }; -typedef Math::Deg Deg; -typedef Math::Rad Rad; -typedef Math::Complex Complex; -typedef Math::Dual Dual; -typedef Math::DualComplex DualComplex; -typedef Math::Matrix3 Matrix3; -typedef Math::Vector2 Vector2; +typedef Math::Deg Deg; +typedef Math::Rad Rad; +typedef Math::Complex Complex; +typedef Math::Dual Dual; +typedef Math::DualComplex DualComplex; +typedef Math::Matrix3 Matrix3; +typedef Math::Vector2 Vector2; DualComplexTest::DualComplexTest() { addTests(&DualComplexTest::construct, diff --git a/src/Math/Test/DualQuaternionTest.cpp b/src/Math/Test/DualQuaternionTest.cpp index 72d8acb06..7bcbcbccd 100644 --- a/src/Math/Test/DualQuaternionTest.cpp +++ b/src/Math/Test/DualQuaternionTest.cpp @@ -50,13 +50,13 @@ class DualQuaternionTest: public Corrade::TestSuite::Tester { void debug(); }; -typedef Math::Deg Deg; -typedef Math::Rad Rad; -typedef Math::Dual Dual; -typedef Math::Matrix4 Matrix4; -typedef Math::DualQuaternion DualQuaternion; -typedef Math::Quaternion Quaternion; -typedef Math::Vector3 Vector3; +typedef Math::Deg Deg; +typedef Math::Rad Rad; +typedef Math::Dual Dual; +typedef Math::Matrix4 Matrix4; +typedef Math::DualQuaternion DualQuaternion; +typedef Math::Quaternion Quaternion; +typedef Math::Vector3 Vector3; DualQuaternionTest::DualQuaternionTest() { addTests(&DualQuaternionTest::construct, @@ -184,7 +184,7 @@ void DualQuaternionTest::rotation() { std::ostringstream o; Error::setOutput(&o); - Vector3 axis(1.0f/Constants::sqrt3()); + Vector3 axis(1.0f/Constants::sqrt3()); CORRADE_COMPARE(DualQuaternion::rotation(Deg(120.0f), axis*2.0f), DualQuaternion()); CORRADE_COMPARE(o.str(), "Math::Quaternion::rotation(): axis must be normalized\n"); diff --git a/src/Math/Test/DualTest.cpp b/src/Math/Test/DualTest.cpp index 5b2987075..e1be57922 100644 --- a/src/Math/Test/DualTest.cpp +++ b/src/Math/Test/DualTest.cpp @@ -40,7 +40,7 @@ class DualTest: public Corrade::TestSuite::Tester { void debug(); }; -typedef Math::Dual Dual; +typedef Math::Dual Dual; DualTest::DualTest() { addTests(&DualTest::construct, @@ -74,10 +74,10 @@ void DualTest::constructDefault() { } void DualTest::compare() { - CORRADE_VERIFY(Dual(1.0f, 1.0f+MathTypeTraits::epsilon()/2) == Dual(1.0f, 1.0f)); - CORRADE_VERIFY(Dual(1.0f, 1.0f+MathTypeTraits::epsilon()*2) != Dual(1.0f, 1.0f)); - CORRADE_VERIFY(Dual(1.0f+MathTypeTraits::epsilon()/2, 1.0f) == Dual(1.0f, 1.0f)); - CORRADE_VERIFY(Dual(1.0f+MathTypeTraits::epsilon()*2, 1.0f) != Dual(1.0f, 1.0f)); + CORRADE_VERIFY(Dual(1.0f, 1.0f+MathTypeTraits::epsilon()/2) == Dual(1.0f, 1.0f)); + CORRADE_VERIFY(Dual(1.0f, 1.0f+MathTypeTraits::epsilon()*2) != Dual(1.0f, 1.0f)); + CORRADE_VERIFY(Dual(1.0f+MathTypeTraits::epsilon()/2, 1.0f) == Dual(1.0f, 1.0f)); + CORRADE_VERIFY(Dual(1.0f+MathTypeTraits::epsilon()*2, 1.0f) != Dual(1.0f, 1.0f)); /* Compare to real part only */ CORRADE_VERIFY(Dual(1.0f, 0.0f) == 1.0f); @@ -98,8 +98,8 @@ void DualTest::constExpressions() { CORRADE_COMPARE(c, Dual(2.0f, 3.0f)); /* Data access */ - constexpr float e = b.real(); - constexpr float f = b.dual(); + constexpr Float e = b.real(); + constexpr Float f = b.dual(); CORRADE_COMPARE(e, 2.0f); CORRADE_COMPARE(f, 3.0f); } diff --git a/src/Math/Test/FunctionsTest.cpp b/src/Math/Test/FunctionsTest.cpp index e0858e566..cfe7b64d4 100644 --- a/src/Math/Test/FunctionsTest.cpp +++ b/src/Math/Test/FunctionsTest.cpp @@ -45,13 +45,13 @@ class FunctionsTest: public Corrade::TestSuite::Tester { void trigonometric(); }; -typedef Math::Constants Constants; -typedef Math::Deg Deg; -typedef Math::Rad Rad; -typedef Math::Vector3 Vector3; -typedef Math::Vector3 Vector3ub; -typedef Math::Vector3 Vector3b; -typedef Math::Vector3 Vector3i; +typedef Math::Constants Constants; +typedef Math::Deg Deg; +typedef Math::Rad Rad; +typedef Math::Vector3 Vector3; +typedef Math::Vector3 Vector3ub; +typedef Math::Vector3 Vector3b; +typedef Math::Vector3 Vector3i; FunctionsTest::FunctionsTest() { addTests(&FunctionsTest::min, @@ -115,131 +115,131 @@ void FunctionsTest::lerp() { CORRADE_COMPARE(Math::lerp(a, b, 0.25f), Vector3(0.0f, 1.0f, 5.0f)); /* Integer vector */ - typedef Math::Vector<3, std::int32_t> Vector3ub; + typedef Math::Vector<3, Int> Vector3ub; Vector3ub c(0, 128, 64); Vector3ub d(16, 0, 32); CORRADE_COMPARE(Math::lerp(c, d, 0.25f), Vector3ub(4, 96, 56)); } void FunctionsTest::normalizeUnsigned() { - CORRADE_COMPARE((Math::normalize(0)), 0.0f); - CORRADE_COMPARE((Math::normalize(255)), 1.0f); + CORRADE_COMPARE((Math::normalize(0)), 0.0f); + CORRADE_COMPARE((Math::normalize(255)), 1.0f); - CORRADE_COMPARE((Math::normalize(0)), 0.0); - CORRADE_COMPARE((Math::normalize(std::numeric_limits::max())), 1.0); + CORRADE_COMPARE((Math::normalize(0)), 0.0); + CORRADE_COMPARE((Math::normalize(std::numeric_limits::max())), 1.0); - CORRADE_COMPARE((Math::normalize(0)), 0.0); - CORRADE_COMPARE((Math::normalize(std::numeric_limits::max())), 1.0); + CORRADE_COMPARE((Math::normalize(0)), 0.0); + CORRADE_COMPARE((Math::normalize(std::numeric_limits::max())), 1.0); - CORRADE_COMPARE((Math::normalize(0)), 0.0f); - CORRADE_COMPARE((Math::normalize(std::numeric_limits::max())), 1.0f); + CORRADE_COMPARE((Math::normalize(0)), 0.0f); + CORRADE_COMPARE((Math::normalize(std::numeric_limits::max())), 1.0f); - CORRADE_COMPARE((Math::normalize(8192)), 0.125002f); - CORRADE_COMPARE((Math::normalize(49152)), 0.750011f); + CORRADE_COMPARE((Math::normalize(8192)), 0.125002f); + CORRADE_COMPARE((Math::normalize(49152)), 0.750011f); CORRADE_COMPARE(Math::normalize(Vector3ub(0, 127, 255)), Vector3(0.0f, 0.498039f, 1.0f)); } void FunctionsTest::normalizeSigned() { - CORRADE_COMPARE((Math::normalize(127)), 1.0f); - CORRADE_COMPARE((Math::normalize(0)), 0.0f); - CORRADE_COMPARE((Math::normalize(-128)), -1.0f); + CORRADE_COMPARE((Math::normalize(127)), 1.0f); + CORRADE_COMPARE((Math::normalize(0)), 0.0f); + CORRADE_COMPARE((Math::normalize(-128)), -1.0f); - CORRADE_COMPARE((Math::normalize(std::numeric_limits::min())), -1.0f); - CORRADE_COMPARE((Math::normalize(0)), 0.0f); - CORRADE_COMPARE((Math::normalize(std::numeric_limits::max())), 1.0f); + CORRADE_COMPARE((Math::normalize(std::numeric_limits::min())), -1.0f); + CORRADE_COMPARE((Math::normalize(0)), 0.0f); + CORRADE_COMPARE((Math::normalize(std::numeric_limits::max())), 1.0f); - CORRADE_COMPARE((Math::normalize(std::numeric_limits::min())), -1.0); - CORRADE_COMPARE((Math::normalize(0)), 0.0); - CORRADE_COMPARE((Math::normalize(std::numeric_limits::max())), 1.0); + CORRADE_COMPARE((Math::normalize(std::numeric_limits::min())), -1.0); + CORRADE_COMPARE((Math::normalize(0)), 0.0); + CORRADE_COMPARE((Math::normalize(std::numeric_limits::max())), 1.0); - CORRADE_COMPARE((Math::normalize(std::numeric_limits::min())), -1.0); - CORRADE_COMPARE((Math::normalize(0)), 0.0); - CORRADE_COMPARE((Math::normalize(std::numeric_limits::max())), 1.0); + CORRADE_COMPARE((Math::normalize(std::numeric_limits::min())), -1.0); + CORRADE_COMPARE((Math::normalize(0)), 0.0); + CORRADE_COMPARE((Math::normalize(std::numeric_limits::max())), 1.0); - CORRADE_COMPARE((Math::normalize(16384)), 0.500015f); - CORRADE_COMPARE((Math::normalize(-16384)), -0.500015f); + CORRADE_COMPARE((Math::normalize(16384)), 0.500015f); + CORRADE_COMPARE((Math::normalize(-16384)), -0.500015f); CORRADE_COMPARE(Math::normalize(Vector3b(0, -127, 64)), Vector3(0.0f, -1.0f, 0.503937f)); } void FunctionsTest::denormalizeUnsigned() { - CORRADE_COMPARE(Math::denormalize(0.0f), 0); - CORRADE_COMPARE(Math::denormalize(1.0f), 255); + CORRADE_COMPARE(Math::denormalize(0.0f), 0); + CORRADE_COMPARE(Math::denormalize(1.0f), 255); - CORRADE_COMPARE(Math::denormalize(0.0f), 0); - CORRADE_COMPARE(Math::denormalize(1.0f), std::numeric_limits::max()); + CORRADE_COMPARE(Math::denormalize(0.0f), 0); + CORRADE_COMPARE(Math::denormalize(1.0f), std::numeric_limits::max()); - CORRADE_COMPARE(Math::denormalize(0.0), 0); - CORRADE_COMPARE(Math::denormalize(1.0), std::numeric_limits::max()); + CORRADE_COMPARE(Math::denormalize(0.0), 0); + CORRADE_COMPARE(Math::denormalize(1.0), std::numeric_limits::max()); - CORRADE_COMPARE(Math::denormalize(0.0), 0); - CORRADE_COMPARE(Math::denormalize(1.0), std::numeric_limits::max()); + CORRADE_COMPARE(Math::denormalize(0.0), 0); + CORRADE_COMPARE(Math::denormalize(1.0), std::numeric_limits::max()); - CORRADE_COMPARE(Math::denormalize(0.33f), 21626); - CORRADE_COMPARE(Math::denormalize(0.66f), 43253); + CORRADE_COMPARE(Math::denormalize(0.33f), 21626); + CORRADE_COMPARE(Math::denormalize(0.66f), 43253); CORRADE_COMPARE(Math::denormalize(Vector3(0.0f, 0.5f, 1.0f)), Vector3ub(0, 127, 255)); } void FunctionsTest::denormalizeSigned() { - CORRADE_COMPARE(Math::denormalize(-1.0f), -127); - CORRADE_COMPARE(Math::denormalize(0.0f), 0); - CORRADE_COMPARE(Math::denormalize(1.0f), 127); + CORRADE_COMPARE(Math::denormalize(-1.0f), -127); + CORRADE_COMPARE(Math::denormalize(0.0f), 0); + CORRADE_COMPARE(Math::denormalize(1.0f), 127); - CORRADE_COMPARE(Math::denormalize(-1.0f), std::numeric_limits::min()+1); - CORRADE_COMPARE(Math::denormalize(0.0f), 0); - CORRADE_COMPARE(Math::denormalize(1.0f), std::numeric_limits::max()); + CORRADE_COMPARE(Math::denormalize(-1.0f), std::numeric_limits::min()+1); + CORRADE_COMPARE(Math::denormalize(0.0f), 0); + CORRADE_COMPARE(Math::denormalize(1.0f), std::numeric_limits::max()); - CORRADE_COMPARE(Math::denormalize(-1.0), std::numeric_limits::min()+1); - CORRADE_COMPARE(Math::denormalize(0.0), 0); - CORRADE_COMPARE(Math::denormalize(1.0), std::numeric_limits::max()); + CORRADE_COMPARE(Math::denormalize(-1.0), std::numeric_limits::min()+1); + CORRADE_COMPARE(Math::denormalize(0.0), 0); + CORRADE_COMPARE(Math::denormalize(1.0), std::numeric_limits::max()); - CORRADE_COMPARE(Math::denormalize(-1.0l), std::numeric_limits::min()+1); - CORRADE_COMPARE(Math::denormalize(0.0l), 0); - CORRADE_COMPARE(Math::denormalize(1.0l), std::numeric_limits::max()); + CORRADE_COMPARE(Math::denormalize(-1.0l), std::numeric_limits::min()+1); + CORRADE_COMPARE(Math::denormalize(0.0l), 0); + CORRADE_COMPARE(Math::denormalize(1.0l), std::numeric_limits::max()); - CORRADE_COMPARE(Math::denormalize(-0.33f), -10813); - CORRADE_COMPARE(Math::denormalize(0.66f), 21626); + CORRADE_COMPARE(Math::denormalize(-0.33f), -10813); + CORRADE_COMPARE(Math::denormalize(0.66f), 21626); CORRADE_COMPARE(Math::denormalize(Vector3(0.0f, -1.0f, 0.5f)), Vector3b(0, -127, 63)); } void FunctionsTest::renormalizeUnsinged() { - CORRADE_COMPARE(Math::normalize(Math::denormalize(0.0f)), 0.0f); - CORRADE_COMPARE(Math::normalize(Math::denormalize(1.0f)), 1.0f); + CORRADE_COMPARE(Math::normalize(Math::denormalize(0.0f)), 0.0f); + CORRADE_COMPARE(Math::normalize(Math::denormalize(1.0f)), 1.0f); - CORRADE_COMPARE(Math::normalize(Math::denormalize(0.0f)), 0.0f); - CORRADE_COMPARE(Math::normalize(Math::denormalize(1.0f)), 1.0f); + CORRADE_COMPARE(Math::normalize(Math::denormalize(0.0f)), 0.0f); + CORRADE_COMPARE(Math::normalize(Math::denormalize(1.0f)), 1.0f); - CORRADE_COMPARE(Math::normalize(Math::denormalize(0.0)), 0.0); - CORRADE_COMPARE(Math::normalize(Math::denormalize(1.0)), 1.0); + CORRADE_COMPARE(Math::normalize(Math::denormalize(0.0)), 0.0); + CORRADE_COMPARE(Math::normalize(Math::denormalize(1.0)), 1.0); - CORRADE_COMPARE(Math::normalize(Math::denormalize(0.0l)), 0.0l); - CORRADE_COMPARE(Math::normalize(Math::denormalize(1.0l)), 1.0l); + CORRADE_COMPARE(Math::normalize(Math::denormalize(0.0l)), 0.0l); + CORRADE_COMPARE(Math::normalize(Math::denormalize(1.0l)), 1.0l); } void FunctionsTest::renormalizeSinged() { - CORRADE_COMPARE(Math::normalize(Math::denormalize(-1.0f)), -1.0f); - CORRADE_COMPARE(Math::normalize(Math::denormalize(0.0f)), 0.0f); - CORRADE_COMPARE(Math::normalize(Math::denormalize(1.0f)), 1.0f); + CORRADE_COMPARE(Math::normalize(Math::denormalize(-1.0f)), -1.0f); + CORRADE_COMPARE(Math::normalize(Math::denormalize(0.0f)), 0.0f); + CORRADE_COMPARE(Math::normalize(Math::denormalize(1.0f)), 1.0f); - CORRADE_COMPARE(Math::normalize(Math::denormalize(-1.0f)), -1.0f); - CORRADE_COMPARE(Math::normalize(Math::denormalize(0.0f)), 0.0f); - CORRADE_COMPARE(Math::normalize(Math::denormalize(1.0f)), 1.0f); + CORRADE_COMPARE(Math::normalize(Math::denormalize(-1.0f)), -1.0f); + CORRADE_COMPARE(Math::normalize(Math::denormalize(0.0f)), 0.0f); + CORRADE_COMPARE(Math::normalize(Math::denormalize(1.0f)), 1.0f); - CORRADE_COMPARE(Math::normalize(Math::denormalize(-1.0)), -1.0); - CORRADE_COMPARE(Math::normalize(Math::denormalize(0.0)), 0.0); - CORRADE_COMPARE(Math::normalize(Math::denormalize(1.0)), 1.0); + CORRADE_COMPARE(Math::normalize(Math::denormalize(-1.0)), -1.0); + CORRADE_COMPARE(Math::normalize(Math::denormalize(0.0)), 0.0); + CORRADE_COMPARE(Math::normalize(Math::denormalize(1.0)), 1.0); - CORRADE_COMPARE(Math::normalize(Math::denormalize(-1.0l)), -1.0l); - CORRADE_COMPARE(Math::normalize(Math::denormalize(0.0l)), 0.0l); - CORRADE_COMPARE(Math::normalize(Math::denormalize(1.0l)), 1.0l); + CORRADE_COMPARE(Math::normalize(Math::denormalize(-1.0l)), -1.0l); + CORRADE_COMPARE(Math::normalize(Math::denormalize(0.0l)), 0.0l); + CORRADE_COMPARE(Math::normalize(Math::denormalize(1.0l)), 1.0l); } void FunctionsTest::normalizeTypeDeduction() { - CORRADE_COMPARE(Math::normalize('\x7F'), 1.0f); - CORRADE_COMPARE((Math::normalize('\x7F')), 1.0f); + CORRADE_COMPARE(Math::normalize('\x7F'), 1.0f); + CORRADE_COMPARE((Math::normalize('\x7F')), 1.0f); } void FunctionsTest::pow() { diff --git a/src/Math/Test/MathTypeTraitsTest.cpp b/src/Math/Test/MathTypeTraitsTest.cpp index 74e50d286..1f276b3a5 100644 --- a/src/Math/Test/MathTypeTraitsTest.cpp +++ b/src/Math/Test/MathTypeTraitsTest.cpp @@ -38,19 +38,19 @@ MathTypeTraitsTest::MathTypeTraitsTest() { } void MathTypeTraitsTest::equalsIntegral() { - _equalsIntegral(); - _equalsIntegral(); - _equalsIntegral(); - _equalsIntegral(); - _equalsIntegral(); - _equalsIntegral(); - _equalsIntegral(); - _equalsIntegral(); + _equalsIntegral(); + _equalsIntegral(); + _equalsIntegral(); + _equalsIntegral(); + _equalsIntegral(); + _equalsIntegral(); + _equalsIntegral(); + _equalsIntegral(); } void MathTypeTraitsTest::equalsFloatingPoint() { - _equalsFloatingPoint(); - _equalsFloatingPoint(); + _equalsFloatingPoint(); + _equalsFloatingPoint(); } template void MathTypeTraitsTest::_equalsIntegral() { diff --git a/src/Math/Test/Matrix3Test.cpp b/src/Math/Test/Matrix3Test.cpp index 5cf07abb9..6df37ed9f 100644 --- a/src/Math/Test/Matrix3Test.cpp +++ b/src/Math/Test/Matrix3Test.cpp @@ -43,10 +43,10 @@ class Matrix3Test: public Corrade::TestSuite::Tester { void configuration(); }; -typedef Math::Deg Deg; -typedef Math::Matrix3 Matrix3; -typedef Math::Matrix<2, float> Matrix2; -typedef Math::Vector2 Vector2; +typedef Math::Deg Deg; +typedef Math::Matrix3 Matrix3; +typedef Math::Matrix<2, Float> Matrix2; +typedef Math::Vector2 Vector2; Matrix3Test::Matrix3Test() { addTests(&Matrix3Test::constructIdentity, diff --git a/src/Math/Test/Matrix4Test.cpp b/src/Math/Test/Matrix4Test.cpp index da5f96e57..9258c9ff8 100644 --- a/src/Math/Test/Matrix4Test.cpp +++ b/src/Math/Test/Matrix4Test.cpp @@ -48,11 +48,11 @@ class Matrix4Test: public Corrade::TestSuite::Tester { void configuration(); }; -typedef Math::Deg Deg; -typedef Math::Rad Rad; -typedef Math::Matrix4 Matrix4; -typedef Math::Matrix<3, float> Matrix3; -typedef Math::Vector3 Vector3; +typedef Math::Deg Deg; +typedef Math::Rad Rad; +typedef Math::Matrix4 Matrix4; +typedef Math::Matrix<3, Float> Matrix3; +typedef Math::Vector3 Vector3; Matrix4Test::Matrix4Test() { addTests(&Matrix4Test::constructIdentity, @@ -135,8 +135,8 @@ void Matrix4Test::rotationX() { {0.0f, 0.90096887f, 0.43388374f, 0.0f}, {0.0f, -0.43388374f, 0.90096887f, 0.0f}, {0.0f, 0.0f, 0.0f, 1.0f}); - CORRADE_COMPARE(Matrix4::rotation(Rad(Math::Constants::pi()/7), Vector3::xAxis()), matrix); - CORRADE_COMPARE(Matrix4::rotationX(Rad(Math::Constants::pi()/7)), matrix); + CORRADE_COMPARE(Matrix4::rotation(Rad(Math::Constants::pi()/7), Vector3::xAxis()), matrix); + CORRADE_COMPARE(Matrix4::rotationX(Rad(Math::Constants::pi()/7)), matrix); } void Matrix4Test::rotationY() { @@ -144,8 +144,8 @@ void Matrix4Test::rotationY() { { 0.0f, 1.0f, 0.0f, 0.0f}, {0.43388374f, 0.0f, 0.90096887f, 0.0f}, { 0.0f, 0.0f, 0.0f, 1.0f}); - CORRADE_COMPARE(Matrix4::rotation(Rad(Math::Constants::pi()/7), Vector3::yAxis()), matrix); - CORRADE_COMPARE(Matrix4::rotationY(Rad(Math::Constants::pi()/7)), matrix); + CORRADE_COMPARE(Matrix4::rotation(Rad(Math::Constants::pi()/7), Vector3::yAxis()), matrix); + CORRADE_COMPARE(Matrix4::rotationY(Rad(Math::Constants::pi()/7)), matrix); } void Matrix4Test::rotationZ() { @@ -153,8 +153,8 @@ void Matrix4Test::rotationZ() { {-0.43388374f, 0.90096887f, 0.0f, 0.0f}, { 0.0f, 0.0f, 1.0f, 0.0f}, { 0.0f, 0.0f, 0.0f, 1.0f}); - CORRADE_COMPARE(Matrix4::rotation(Rad(Math::Constants::pi()/7), Vector3::zAxis()), matrix); - CORRADE_COMPARE(Matrix4::rotationZ(Rad(Math::Constants::pi()/7)), matrix); + CORRADE_COMPARE(Matrix4::rotation(Rad(Math::Constants::pi()/7), Vector3::zAxis()), matrix); + CORRADE_COMPARE(Matrix4::rotationZ(Rad(Math::Constants::pi()/7)), matrix); } void Matrix4Test::reflection() { diff --git a/src/Math/Test/MatrixTest.cpp b/src/Math/Test/MatrixTest.cpp index 1cd499397..a862326be 100644 --- a/src/Math/Test/MatrixTest.cpp +++ b/src/Math/Test/MatrixTest.cpp @@ -37,10 +37,10 @@ class MatrixTest: public Corrade::TestSuite::Tester { void configuration(); }; -typedef Matrix<4, float> Matrix4; -typedef Matrix<3, float> Matrix3; -typedef Vector<4, float> Vector4; -typedef Vector<3, float> Vector3; +typedef Matrix<4, Float> Matrix4; +typedef Matrix<3, Float> Matrix3; +typedef Vector<4, Float> Vector4; +typedef Vector<3, Float> Vector3; MatrixTest::MatrixTest() { addTests(&MatrixTest::construct, @@ -55,7 +55,7 @@ MatrixTest::MatrixTest() { } void MatrixTest::construct() { - float m[] = { + Float m[] = { 3.0f, 5.0f, 8.0f, 4.0f, 4.0f, 4.0f, 7.0f, 3.0f, 7.0f, -1.0f, 8.0f, 0.0f, @@ -102,12 +102,12 @@ void MatrixTest::constructZero() { } void MatrixTest::trace() { - Matrix<5, std::int32_t> m( - Vector<5, std::int32_t>(1, 2, 3, 0, 0), - Vector<5, std::int32_t>(2, 3, 2, 1, -2), - Vector<5, std::int32_t>(1, 1, -20, 1, 0), - Vector<5, std::int32_t>(2, 0, 0, 10, 2), - Vector<5, std::int32_t>(3, 1, 0, 1, -2) + Matrix<5, Int> m( + Vector<5, Int>(1, 2, 3, 0, 0), + Vector<5, Int>(2, 3, 2, 1, -2), + Vector<5, Int>(1, 1, -20, 1, 0), + Vector<5, Int>(2, 0, 0, 10, 2), + Vector<5, Int>(3, 1, 0, 1, -2) ); CORRADE_COMPARE(m.trace(), -8); @@ -127,12 +127,12 @@ void MatrixTest::ij() { } void MatrixTest::determinant() { - Matrix<5, std::int32_t> m( - Vector<5, std::int32_t>(1, 2, 2, 1, 0), - Vector<5, std::int32_t>(2, 3, 2, 1, -2), - Vector<5, std::int32_t>(1, 1, 1, 1, 0), - Vector<5, std::int32_t>(2, 0, 0, 1, 2), - Vector<5, std::int32_t>(3, 1, 0, 1, -2) + Matrix<5, Int> m( + Vector<5, Int>(1, 2, 2, 1, 0), + Vector<5, Int>(2, 3, 2, 1, -2), + Vector<5, Int>(1, 1, 1, 1, 0), + Vector<5, Int>(2, 0, 0, 1, 2), + Vector<5, Int>(3, 1, 0, 1, -2) ); CORRADE_COMPARE(m.determinant(), -2); diff --git a/src/Math/Test/QuaternionTest.cpp b/src/Math/Test/QuaternionTest.cpp index de71e044a..2d4be8a32 100644 --- a/src/Math/Test/QuaternionTest.cpp +++ b/src/Math/Test/QuaternionTest.cpp @@ -57,13 +57,13 @@ class QuaternionTest: public Corrade::TestSuite::Tester { void debug(); }; -typedef Math::Deg Deg; -typedef Math::Rad Rad; -typedef Math::Matrix<3, float> Matrix3; -typedef Math::Matrix4 Matrix4; -typedef Math::Quaternion Quaternion; -typedef Math::Vector3 Vector3; -typedef Math::Vector4 Vector4; +typedef Math::Deg Deg; +typedef Math::Rad Rad; +typedef Math::Matrix<3, Float> Matrix3; +typedef Math::Matrix4 Matrix4; +typedef Math::Quaternion Quaternion; +typedef Math::Vector3 Vector3; +typedef Math::Vector4 Vector4; QuaternionTest::QuaternionTest() { addTests(&QuaternionTest::construct, @@ -114,10 +114,10 @@ void QuaternionTest::constructFromVector() { } void QuaternionTest::compare() { - CORRADE_VERIFY(Quaternion({1.0f+MathTypeTraits::epsilon()/2, 2.0f, 3.0f}, -4.0f) == Quaternion({1.0f, 2.0f, 3.0f}, -4.0f)); - CORRADE_VERIFY(Quaternion({1.0f+MathTypeTraits::epsilon()*2, 2.0f, 3.0f}, -4.0f) != Quaternion({1.0f, 2.0f, 3.0f}, -4.0f)); - CORRADE_VERIFY(Quaternion({4.0f, 2.0f, 3.0f}, -1.0f+MathTypeTraits::epsilon()/2) == Quaternion({4.0f, 2.0f, 3.0f}, -1.0f)); - CORRADE_VERIFY(Quaternion({4.0f, 2.0f, 3.0f}, -1.0f+MathTypeTraits::epsilon()*2) != Quaternion({4.0f, 2.0f, 3.0f}, -1.0f)); + CORRADE_VERIFY(Quaternion({1.0f+MathTypeTraits::epsilon()/2, 2.0f, 3.0f}, -4.0f) == Quaternion({1.0f, 2.0f, 3.0f}, -4.0f)); + CORRADE_VERIFY(Quaternion({1.0f+MathTypeTraits::epsilon()*2, 2.0f, 3.0f}, -4.0f) != Quaternion({1.0f, 2.0f, 3.0f}, -4.0f)); + CORRADE_VERIFY(Quaternion({4.0f, 2.0f, 3.0f}, -1.0f+MathTypeTraits::epsilon()/2) == Quaternion({4.0f, 2.0f, 3.0f}, -1.0f)); + CORRADE_VERIFY(Quaternion({4.0f, 2.0f, 3.0f}, -1.0f+MathTypeTraits::epsilon()*2) != Quaternion({4.0f, 2.0f, 3.0f}, -1.0f)); } void QuaternionTest::constExpressions() { @@ -139,7 +139,7 @@ void QuaternionTest::constExpressions() { /* Data access */ constexpr Vector3 e = b.vector(); - constexpr float f = b.scalar(); + constexpr Float f = b.scalar(); CORRADE_COMPARE(e, Vector3(1.0f, -3.0f, 7.0f)); CORRADE_COMPARE(f, 2.5f); } @@ -215,7 +215,7 @@ void QuaternionTest::invertedNormalized() { Error::setOutput(&o); Quaternion notInverted = a.invertedNormalized(); CORRADE_COMPARE(notInverted.vector(), Vector3()); - CORRADE_COMPARE(notInverted.scalar(), std::numeric_limits::quiet_NaN()); + CORRADE_COMPARE(notInverted.scalar(), std::numeric_limits::quiet_NaN()); CORRADE_COMPARE(o.str(), "Math::Quaternion::invertedNormalized(): quaternion must be normalized\n"); Quaternion aNormalized = a.normalized(); @@ -229,7 +229,7 @@ void QuaternionTest::rotation() { std::ostringstream o; Error::setOutput(&o); - Vector3 axis(1.0f/Constants::sqrt3()); + Vector3 axis(1.0f/Constants::sqrt3()); CORRADE_COMPARE(Quaternion::rotation(Deg(-74.0f), {-1.0f, 2.0f, 2.0f}), Quaternion()); CORRADE_COMPARE(o.str(), "Math::Quaternion::rotation(): axis must be normalized\n"); @@ -273,8 +273,8 @@ void QuaternionTest::angle() { } void QuaternionTest::matrix() { - Quaternion q = Quaternion::rotation(Deg(37.0f), Vector3(1.0f/Constants::sqrt3())); - Matrix3 m = Matrix4::rotation(Deg(37.0f), Vector3(1.0f/Constants::sqrt3())).rotationScaling(); + Quaternion q = Quaternion::rotation(Deg(37.0f), Vector3(1.0f/Constants::sqrt3())); + Matrix3 m = Matrix4::rotation(Deg(37.0f), Vector3(1.0f/Constants::sqrt3())).rotationScaling(); /* Verify that negated quaternion gives the same rotation */ CORRADE_COMPARE(q.toMatrix(), m); @@ -282,7 +282,7 @@ void QuaternionTest::matrix() { } void QuaternionTest::lerp() { - Quaternion a = Quaternion::rotation(Deg(15.0f), Vector3(1.0f/Constants::sqrt3())); + Quaternion a = Quaternion::rotation(Deg(15.0f), Vector3(1.0f/Constants::sqrt3())); Quaternion b = Quaternion::rotation(Deg(23.0f), Vector3::xAxis()); std::ostringstream o; @@ -290,13 +290,13 @@ void QuaternionTest::lerp() { Quaternion notLerpA = Quaternion::lerp(a*3.0f, b, 0.35f); CORRADE_COMPARE(notLerpA.vector(), Vector3()); - CORRADE_COMPARE(notLerpA.scalar(), std::numeric_limits::quiet_NaN()); + CORRADE_COMPARE(notLerpA.scalar(), std::numeric_limits::quiet_NaN()); CORRADE_COMPARE(o.str(), "Math::Quaternion::lerp(): quaternions must be normalized\n"); o.str({}); Quaternion notLerpB = Quaternion::lerp(a, b*-3.0f, 0.35f); CORRADE_COMPARE(notLerpB.vector(), Vector3()); - CORRADE_COMPARE(notLerpB.scalar(), std::numeric_limits::quiet_NaN()); + CORRADE_COMPARE(notLerpB.scalar(), std::numeric_limits::quiet_NaN()); CORRADE_COMPARE(o.str(), "Math::Quaternion::lerp(): quaternions must be normalized\n"); Quaternion lerp = Quaternion::lerp(a, b, 0.35f); @@ -304,7 +304,7 @@ void QuaternionTest::lerp() { } void QuaternionTest::slerp() { - Quaternion a = Quaternion::rotation(Deg(15.0f), Vector3(1.0f/Constants::sqrt3())); + Quaternion a = Quaternion::rotation(Deg(15.0f), Vector3(1.0f/Constants::sqrt3())); Quaternion b = Quaternion::rotation(Deg(23.0f), Vector3::xAxis()); std::ostringstream o; @@ -312,13 +312,13 @@ void QuaternionTest::slerp() { Quaternion notSlerpA = Quaternion::slerp(a*3.0f, b, 0.35f); CORRADE_COMPARE(notSlerpA.vector(), Vector3()); - CORRADE_COMPARE(notSlerpA.scalar(), std::numeric_limits::quiet_NaN()); + CORRADE_COMPARE(notSlerpA.scalar(), std::numeric_limits::quiet_NaN()); CORRADE_COMPARE(o.str(), "Math::Quaternion::slerp(): quaternions must be normalized\n"); o.str({}); Quaternion notSlerpB = Quaternion::slerp(a, b*-3.0f, 0.35f); CORRADE_COMPARE(notSlerpB.vector(), Vector3()); - CORRADE_COMPARE(notSlerpB.scalar(), std::numeric_limits::quiet_NaN()); + CORRADE_COMPARE(notSlerpB.scalar(), std::numeric_limits::quiet_NaN()); CORRADE_COMPARE(o.str(), "Math::Quaternion::slerp(): quaternions must be normalized\n"); Quaternion slerp = Quaternion::slerp(a, b, 0.35f); diff --git a/src/Math/Test/RectangularMatrixTest.cpp b/src/Math/Test/RectangularMatrixTest.cpp index 5f3e8867f..2e1cf095d 100644 --- a/src/Math/Test/RectangularMatrixTest.cpp +++ b/src/Math/Test/RectangularMatrixTest.cpp @@ -55,14 +55,14 @@ class RectangularMatrixTest: public Corrade::TestSuite::Tester { void configuration(); }; -typedef RectangularMatrix<4, 3, float> Matrix4x3; -typedef RectangularMatrix<3, 4, float> Matrix3x4; -typedef RectangularMatrix<2, 2, float> Matrix2; -typedef RectangularMatrix<2, 2, std::int32_t> Matrix2i; -typedef Vector<4, float> Vector4; -typedef Vector<3, float> Vector3; -typedef Vector<2, float> Vector2; -typedef Vector<2, std::int32_t> Vector2i; +typedef RectangularMatrix<4, 3, Float> Matrix4x3; +typedef RectangularMatrix<3, 4, Float> Matrix3x4; +typedef RectangularMatrix<2, 2, Float> Matrix2; +typedef RectangularMatrix<2, 2, Int> Matrix2i; +typedef Vector<4, Float> Vector4; +typedef Vector<3, Float> Vector3; +typedef Vector<2, Float> Vector2; +typedef Vector<2, Int> Vector2i; RectangularMatrixTest::RectangularMatrixTest() { addTests(&RectangularMatrixTest::constructFromData, @@ -96,7 +96,7 @@ RectangularMatrixTest::RectangularMatrixTest() { } void RectangularMatrixTest::constructFromData() { - float m[] = { + Float m[] = { 3.0f, 5.0f, 8.0f, 4.0f, 4.0f, 4.0f, 7.0f, 3.0f, 7.0f, -1.0f, 8.0f, 0.0f @@ -121,15 +121,15 @@ void RectangularMatrixTest::constructDefault() { } void RectangularMatrixTest::constructConversion() { - Matrix2 floatingPoint(Vector2( 1.3f, 2.7f), + Matrix2 FloatingPoint(Vector2( 1.3f, 2.7f), Vector2(-15.0f, 7.0f)); - Matrix2 floatingPointRounded(Vector2(1.0f, 2.0f), + Matrix2 FloatingPointRounded(Vector2(1.0f, 2.0f), Vector2(-15.0f, 7.0f)); Matrix2i integral(Vector2i( 1, 2), Vector2i(-15, 7)); - CORRADE_COMPARE(Matrix2i(floatingPoint), integral); - CORRADE_COMPARE(Matrix2(integral), floatingPointRounded); + CORRADE_COMPARE(Matrix2i(FloatingPoint), integral); + CORRADE_COMPARE(Matrix2(integral), FloatingPointRounded); } void RectangularMatrixTest::constructFromVectors() { @@ -194,8 +194,8 @@ void RectangularMatrixTest::constExpressions() { Vector4(7.0f, -1.7f, 8.0f, 0.0f))); /* Conversion constructor */ - typedef RectangularMatrix<3, 4, std::int32_t> Matrix3x4i; - typedef Vector<4, std::int32_t> Vector4i; + typedef RectangularMatrix<3, 4, Int> Matrix3x4i; + typedef Vector<4, Int> Vector4i; constexpr Matrix3x4i c(b); CORRADE_COMPARE(c, Matrix3x4i(Vector4i(3, 5, 8, 4), Vector4i(4, 4, 7, 3), @@ -209,8 +209,8 @@ void RectangularMatrixTest::constExpressions() { /* Data access, pointer chasings, i.e. *(b.data()[1]), are not possible */ constexpr Vector4 e = b[2]; - constexpr float f = b[1][2]; - constexpr float g = *b.data(); + constexpr Float f = b[1][2]; + constexpr Float g = *b.data(); CORRADE_COMPARE(e, Vector4(7.0f, -1.7f, 8.0f, 0.0f)); CORRADE_COMPARE(f, 7.0f); CORRADE_COMPARE(g, 3.0f); @@ -219,9 +219,9 @@ void RectangularMatrixTest::constExpressions() { void RectangularMatrixTest::compare() { Matrix2 a(Vector2(1.0f, -3.0f), Vector2(5.0f, -10.0f)); - Matrix2 b(Vector2(1.0f + MathTypeTraits::epsilon()/2, -3.0f), + Matrix2 b(Vector2(1.0f + MathTypeTraits::epsilon()/2, -3.0f), Vector2(5.0f, -10.0f)); - Matrix2 c(Vector2(1.0f, -1.0f + MathTypeTraits::epsilon()*2), + Matrix2 c(Vector2(1.0f, -1.0f + MathTypeTraits::epsilon()*2), Vector2(5.0f, -10.0f)); CORRADE_VERIFY(a == b); CORRADE_VERIFY(a != c); @@ -270,8 +270,8 @@ void RectangularMatrixTest::multiplyDivide() { CORRADE_COMPARE(-1.5f*matrix, multiplied); CORRADE_COMPARE(multiplied/-1.5f, matrix); - Math::RectangularMatrix<1, 1, std::int8_t> matrixChar(32); - Math::RectangularMatrix<1, 1, std::int8_t> multipliedChar(-48); + Math::RectangularMatrix<1, 1, Byte> matrixChar(32); + Math::RectangularMatrix<1, 1, Byte> multipliedChar(-48); CORRADE_COMPARE(matrixChar*-1.5f, multipliedChar); CORRADE_COMPARE(multipliedChar/-1.5f, matrixChar); CORRADE_COMPARE(-1.5f*matrixChar, multipliedChar); @@ -286,27 +286,27 @@ void RectangularMatrixTest::multiplyDivide() { } void RectangularMatrixTest::multiply() { - RectangularMatrix<4, 6, std::int32_t> left( - Vector<6, std::int32_t>(-5, 27, 10, 33, 0, -15), - Vector<6, std::int32_t>( 7, 56, 66, 1, 0, -24), - Vector<6, std::int32_t>( 4, 41, 4, 0, 1, -4), - Vector<6, std::int32_t>( 9, -100, 19, -49, 1, 9) + RectangularMatrix<4, 6, Int> left( + Vector<6, Int>(-5, 27, 10, 33, 0, -15), + Vector<6, Int>( 7, 56, 66, 1, 0, -24), + Vector<6, Int>( 4, 41, 4, 0, 1, -4), + Vector<6, Int>( 9, -100, 19, -49, 1, 9) ); - RectangularMatrix<5, 4, std::int32_t> right( - Vector<4, std::int32_t>(1, -7, 0, 158), - Vector<4, std::int32_t>(2, 24, -3, 40), - Vector<4, std::int32_t>(3, -15, -2, -50), - Vector<4, std::int32_t>(4, 17, -1, -284), - Vector<4, std::int32_t>(5, 30, 4, 18) + RectangularMatrix<5, 4, Int> right( + Vector<4, Int>(1, -7, 0, 158), + Vector<4, Int>(2, 24, -3, 40), + Vector<4, Int>(3, -15, -2, -50), + Vector<4, Int>(4, 17, -1, -284), + Vector<4, Int>(5, 30, 4, 18) ); - RectangularMatrix<5, 6, std::int32_t> expected( - Vector<6, std::int32_t>( 1368, -16165, 2550, -7716, 158, 1575), - Vector<6, std::int32_t>( 506, -2725, 2352, -1870, 37, -234), - Vector<6, std::int32_t>( -578, 4159, -1918, 2534, -52, -127), - Vector<6, std::int32_t>(-2461, 29419, -4238, 14065, -285, -3020), - Vector<6, std::int32_t>( 363, 179, 2388, -687, 22, -649) + RectangularMatrix<5, 6, Int> expected( + Vector<6, Int>( 1368, -16165, 2550, -7716, 158, 1575), + Vector<6, Int>( 506, -2725, 2352, -1870, 37, -234), + Vector<6, Int>( -578, 4159, -1918, 2534, -52, -127), + Vector<6, Int>(-2461, 29419, -4238, 14065, -285, -3020), + Vector<6, Int>( 363, 179, 2388, -687, 22, -649) ); CORRADE_COMPARE(left*right, expected); @@ -399,7 +399,7 @@ void RectangularMatrixTest::debug() { " 4, 3, 0)\n"); o.str({}); - Debug(&o) << "a" << Matrix3x4() << "b" << RectangularMatrix<4, 3, std::int8_t>(); + Debug(&o) << "a" << Matrix3x4() << "b" << RectangularMatrix<4, 3, Byte>(); CORRADE_COMPARE(o.str(), "a Matrix(0, 0, 0,\n" " 0, 0, 0,\n" " 0, 0, 0,\n" diff --git a/src/Math/Test/SwizzleTest.cpp b/src/Math/Test/SwizzleTest.cpp index 795d4297a..fd51bdc38 100644 --- a/src/Math/Test/SwizzleTest.cpp +++ b/src/Math/Test/SwizzleTest.cpp @@ -29,7 +29,7 @@ class SwizzleTest: public Corrade::TestSuite::Tester { void constExpressions(); }; -typedef Vector<4, std::int32_t> Vector4i; +typedef Vector<4, Int> Vector4i; SwizzleTest::SwizzleTest() { addTests(&SwizzleTest::components, @@ -47,12 +47,12 @@ void SwizzleTest::constants() { } void SwizzleTest::sizes() { - CORRADE_COMPARE((swizzle<'y', 'x', 'x'>(Math::Vector<2, std::int32_t>(1, 2))), - (Math::Vector<3, std::int32_t>(2, 1, 1))); + CORRADE_COMPARE((swizzle<'y', 'x', 'x'>(Math::Vector<2, Int>(1, 2))), + (Math::Vector<3, Int>(2, 1, 1))); CORRADE_COMPARE(swizzle<'z'>(Vector4i(1, 2, 3, 4)), - (Math::Vector<1, std::int32_t>(3))); + (Math::Vector<1, Int>(3))); CORRADE_COMPARE((swizzle<'z', 'x', 'w', 'y', 'z', 'y', 'x'>(Vector4i(1, 2, 3, 4))), - (Math::Vector<7, std::int32_t>(3, 1, 4, 2, 3, 2, 1))); + (Math::Vector<7, Int>(3, 1, 4, 2, 3, 2, 1))); } void SwizzleTest::constExpressions() { diff --git a/src/Math/Test/UnitTest.cpp b/src/Math/Test/UnitTest.cpp index a0a57978b..347474d53 100644 --- a/src/Math/Test/UnitTest.cpp +++ b/src/Math/Test/UnitTest.cpp @@ -45,16 +45,16 @@ UnitTest::UnitTest() { } template struct Sec_; -typedef Unit Sec; -typedef Unit Secd; +typedef Unit Sec; +typedef Unit Secd; inline Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, Sec value) { - return debug << float(value); + return debug << Float(value); } void UnitTest::construct() { constexpr Sec a(25.0f); - CORRADE_COMPARE(float(a), 25.0f); + CORRADE_COMPARE(Float(a), 25.0f); } void UnitTest::constructDefault() { @@ -69,8 +69,8 @@ void UnitTest::constructConversion() { } void UnitTest::compare() { - CORRADE_VERIFY(Sec(25.0f + MathTypeTraits::epsilon()/2) == Sec(25.0f)); - CORRADE_VERIFY(Sec(25.0f + MathTypeTraits::epsilon()*2) != Sec(25.0f)); + CORRADE_VERIFY(Sec(25.0f + MathTypeTraits::epsilon()/2) == Sec(25.0f)); + CORRADE_VERIFY(Sec(25.0f + MathTypeTraits::epsilon()*2) != Sec(25.0f)); constexpr bool c = Sec(3.0f) < Sec(3.0f); constexpr bool d = Sec(3.0f) <= Sec(3.0f); @@ -129,7 +129,7 @@ void UnitTest::multiplyDivide() { CORRADE_COMPARE(e, b); CORRADE_COMPARE(f, a); - constexpr float g = b/a; + constexpr Float g = b/a; CORRADE_COMPARE(g, -1.5f); } diff --git a/src/Math/Test/Vector2Test.cpp b/src/Math/Test/Vector2Test.cpp index 4314ee219..31d017b6f 100644 --- a/src/Math/Test/Vector2Test.cpp +++ b/src/Math/Test/Vector2Test.cpp @@ -34,7 +34,7 @@ class Vector2Test: public Corrade::TestSuite::Tester { void configuration(); }; -typedef Math::Vector2 Vector2; +typedef Math::Vector2 Vector2; Vector2Test::Vector2Test() { addTests(&Vector2Test::construct, @@ -46,7 +46,7 @@ Vector2Test::Vector2Test() { } void Vector2Test::construct() { - CORRADE_COMPARE(Vector2(1, 2), (Vector<2, float>(1.0f, 2.0f))); + CORRADE_COMPARE(Vector2(1, 2), (Vector<2, Float>(1.0f, 2.0f))); } void Vector2Test::access() { diff --git a/src/Math/Test/Vector3Test.cpp b/src/Math/Test/Vector3Test.cpp index 36204c764..4c25b28c6 100644 --- a/src/Math/Test/Vector3Test.cpp +++ b/src/Math/Test/Vector3Test.cpp @@ -36,8 +36,8 @@ class Vector3Test: public Corrade::TestSuite::Tester { void configuration(); }; -typedef Math::Vector3 Vector3; -typedef Math::Vector2 Vector2; +typedef Math::Vector3 Vector3; +typedef Math::Vector2 Vector2; Vector3Test::Vector3Test() { addTests(&Vector3Test::construct, @@ -52,8 +52,8 @@ Vector3Test::Vector3Test() { void Vector3Test::construct() { CORRADE_COMPARE(Vector3(), Vector3(0.0f, 0.0f, 0.0f)); - CORRADE_COMPARE(Vector3(1, 2, 3), (Vector<3, float>(1.0f, 2.0f, 3.0f))); - CORRADE_COMPARE(Vector3(Vector<2, float>(1.0f, 2.0f), 3), (Vector<3, float>(1.0f, 2.0f, 3.0f))); + CORRADE_COMPARE(Vector3(1, 2, 3), (Vector<3, Float>(1.0f, 2.0f, 3.0f))); + CORRADE_COMPARE(Vector3(Vector<2, Float>(1.0f, 2.0f), 3), (Vector<3, Float>(1.0f, 2.0f, 3.0f))); } void Vector3Test::access() { diff --git a/src/Math/Test/Vector4Test.cpp b/src/Math/Test/Vector4Test.cpp index a5d5953ae..a52063e65 100644 --- a/src/Math/Test/Vector4Test.cpp +++ b/src/Math/Test/Vector4Test.cpp @@ -34,9 +34,9 @@ class Vector4Test: public Corrade::TestSuite::Tester { void configuration(); }; -typedef Math::Vector4 Vector4; -typedef Math::Vector3 Vector3; -typedef Math::Vector2 Vector2; +typedef Math::Vector4 Vector4; +typedef Math::Vector3 Vector3; +typedef Math::Vector2 Vector2; Vector4Test::Vector4Test() { addTests(&Vector4Test::construct, @@ -49,8 +49,8 @@ Vector4Test::Vector4Test() { void Vector4Test::construct() { CORRADE_COMPARE(Vector4(), Vector4(0.0f, 0.0f, 0.0f, 0.0f)); - CORRADE_COMPARE(Vector4(1, 2, 3, 4), (Vector<4, float>(1.0f, 2.0f, 3.0f, 4.0f))); - CORRADE_COMPARE(Vector4(Vector<3, float>(1.0f, 2.0f, 3.0f), 4), (Vector<4, float>(1.0f, 2.0f, 3.0f, 4.0f))); + CORRADE_COMPARE(Vector4(1, 2, 3, 4), (Vector<4, Float>(1.0f, 2.0f, 3.0f, 4.0f))); + CORRADE_COMPARE(Vector4(Vector<3, Float>(1.0f, 2.0f, 3.0f), 4), (Vector<4, Float>(1.0f, 2.0f, 3.0f, 4.0f))); } void Vector4Test::access() { diff --git a/src/Math/Test/VectorTest.cpp b/src/Math/Test/VectorTest.cpp index d334430a3..24a1003ca 100644 --- a/src/Math/Test/VectorTest.cpp +++ b/src/Math/Test/VectorTest.cpp @@ -62,10 +62,10 @@ class VectorTest: public Corrade::TestSuite::Tester { void configuration(); }; -typedef Math::Rad Rad; -typedef Vector<3, float> Vector3; -typedef Vector<4, float> Vector4; -typedef Vector<4, std::int32_t> Vector4i; +typedef Math::Rad Rad; +typedef Vector<3, Float> Vector3; +typedef Vector<4, Float> Vector4; +typedef Vector<4, Int> Vector4i; VectorTest::VectorTest() { addTests(&VectorTest::constructFromData, @@ -106,7 +106,7 @@ VectorTest::VectorTest() { } void VectorTest::constructFromData() { - float data[] = { 1.0f, 2.0f, 3.0f, 4.0f }; + Float data[] = { 1.0f, 2.0f, 3.0f, 4.0f }; CORRADE_COMPARE(Vector4::from(data), Vector4(1.0f, 2.0f, 3.0f, 4.0f)); } @@ -119,7 +119,7 @@ void VectorTest::constructOneValue() { } void VectorTest::constructOneComponent() { - typedef Vector<1, float> Vector1; + typedef Vector<1, Float> Vector1; /* Implicit constructor must work */ Vector1 vec = 1; @@ -127,12 +127,12 @@ void VectorTest::constructOneComponent() { } void VectorTest::constructConversion() { - Vector4 floatingPoint(1.3f, 2.7f, -15.0f, 7.0f); - Vector4 floatingPointRounded(1.0f, 2.0f, -15.0f, 7.0f); + Vector4 FloatingPoint(1.3f, 2.7f, -15.0f, 7.0f); + Vector4 FloatingPointRounded(1.0f, 2.0f, -15.0f, 7.0f); Vector4i integral(1, 2, -15, 7); - CORRADE_COMPARE(Vector4i(floatingPoint), integral); - CORRADE_COMPARE(Vector4(integral), floatingPointRounded); + CORRADE_COMPARE(Vector4i(FloatingPoint), integral); + CORRADE_COMPARE(Vector4(integral), FloatingPointRounded); } void VectorTest::data() { @@ -167,15 +167,15 @@ void VectorTest::constExpressions() { CORRADE_COMPARE(e, Vector4(1.0f, 3.5f, 4.0f, -2.7f)); /* Data access, pointer chasings, i.e. *(b.data()[3]), are not possible */ - constexpr float f = b[3]; - constexpr float g = *b.data(); + constexpr Float f = b[3]; + constexpr Float g = *b.data(); CORRADE_COMPARE(f, -2.7f); CORRADE_COMPARE(g, 1.0f); } void VectorTest::compare() { - CORRADE_VERIFY(Vector4(1.0f, -3.5f, 5.0f, -10.0f) == Vector4(1.0f + MathTypeTraits::epsilon()/2, -3.5f, 5.0f, -10.0f)); - CORRADE_VERIFY(Vector4(1.0f, -1.0f, 5.0f, -10.0f) != Vector4(1.0f, -1.0f + MathTypeTraits::epsilon()*2, 5.0f, -10.0f)); + CORRADE_VERIFY(Vector4(1.0f, -3.5f, 5.0f, -10.0f) == Vector4(1.0f + MathTypeTraits::epsilon()/2, -3.5f, 5.0f, -10.0f)); + CORRADE_VERIFY(Vector4(1.0f, -1.0f, 5.0f, -10.0f) != Vector4(1.0f, -1.0f + MathTypeTraits::epsilon()*2, 5.0f, -10.0f)); CORRADE_VERIFY(Vector4i(1, -3, 5, -10) == Vector4i(1, -3, 5, -10)); CORRADE_VERIFY(Vector4i(1, -3, 5, -10) != Vector4i(1, -2, 5, -10)); @@ -210,8 +210,8 @@ void VectorTest::multiplyDivide() { CORRADE_COMPARE(-1.5f*vector, multiplied); CORRADE_COMPARE(multiplied/-1.5f, vector); - Math::Vector<1, std::int8_t> vectorChar(32); - Math::Vector<1, std::int8_t> multipliedChar(-48); + Math::Vector<1, Byte> vectorChar(32); + Math::Vector<1, Byte> multipliedChar(-48); CORRADE_COMPARE(vectorChar*-1.5f, multipliedChar); CORRADE_COMPARE(multipliedChar/-1.5f, vectorChar); CORRADE_COMPARE(-1.5f*vectorChar, multipliedChar); diff --git a/src/Math/Vector.cpp b/src/Math/Vector.cpp index 3e54dedd8..c01650c88 100644 --- a/src/Math/Vector.cpp +++ b/src/Math/Vector.cpp @@ -18,19 +18,19 @@ namespace Magnum { namespace Math { #ifndef DOXYGEN_GENERATING_OUTPUT -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<2, float>&); -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<3, float>&); -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<4, float>&); -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<2, int>&); -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<3, int>&); -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<4, int>&); -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<2, unsigned int>&); -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<3, unsigned int>&); -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<4, unsigned int>&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<2, Float>&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<3, Float>&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<4, Float>&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<2, Int>&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<3, Int>&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<4, Int>&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<2, UnsignedInt>&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<3, UnsignedInt>&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<4, UnsignedInt>&); #ifndef MAGNUM_TARGET_GLES -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<2, double>&); -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<3, double>&); -template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<4, double>&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<2, Double>&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<3, Double>&); +template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnum::Math::Vector<4, Double>&); #endif #endif @@ -39,19 +39,19 @@ template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnu namespace Corrade { namespace Utility { #ifndef DOXYGEN_GENERATING_OUTPUT -template struct ConfigurationValue>; -template struct ConfigurationValue>; -template struct ConfigurationValue>; -template struct ConfigurationValue>; -template struct ConfigurationValue>; -template struct ConfigurationValue>; -template struct ConfigurationValue>; -template struct ConfigurationValue>; -template struct ConfigurationValue>; +template struct ConfigurationValue>; +template struct ConfigurationValue>; +template struct ConfigurationValue>; +template struct ConfigurationValue>; +template struct ConfigurationValue>; +template struct ConfigurationValue>; +template struct ConfigurationValue>; +template struct ConfigurationValue>; +template struct ConfigurationValue>; #ifndef MAGNUM_TARGET_GLES -template struct ConfigurationValue>; -template struct ConfigurationValue>; -template struct ConfigurationValue>; +template struct ConfigurationValue>; +template struct ConfigurationValue>; +template struct ConfigurationValue>; #endif #endif diff --git a/src/Math/Vector.h b/src/Math/Vector.h index 8630cca78..833554cb8 100644 --- a/src/Math/Vector.h +++ b/src/Math/Vector.h @@ -127,8 +127,8 @@ template class Vector { * Performs only default casting on the values, no rounding or * anything else. Example usage: * @code - * Vector<4, float> floatingPoint(1.3f, 2.7f, -15.0f, 7.0f); - * Vector<4, std::int8_t> integral(floatingPoint); + * Vector<4, Float> floatingPoint(1.3f, 2.7f, -15.0f, 7.0f); + * Vector<4, Byte> integral(floatingPoint); * // integral == {1, 2, -15, 7} * @endcode */ @@ -556,19 +556,19 @@ template Corrade::Utility::Debug operator<<(Corrade:: /* Explicit instantiation for types used in OpenGL */ #ifndef DOXYGEN_GENERATING_OUTPUT -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Vector<2, float>&); -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Vector<3, float>&); -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Vector<4, float>&); -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Vector<2, int>&); -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Vector<3, int>&); -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Vector<4, int>&); -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Vector<2, unsigned int>&); -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Vector<3, unsigned int>&); -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Vector<4, unsigned int>&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Vector<2, Float>&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Vector<3, Float>&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Vector<4, Float>&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Vector<2, Int>&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Vector<3, Int>&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Vector<4, Int>&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Vector<2, UnsignedInt>&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Vector<3, UnsignedInt>&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Vector<4, UnsignedInt>&); #ifndef MAGNUM_TARGET_GLES -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Vector<2, double>&); -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Vector<3, double>&); -extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Vector<4, double>&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Vector<2, Double>&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Vector<3, Double>&); +extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Vector<4, Double>&); #endif #endif @@ -689,19 +689,19 @@ template struct ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; #ifndef MAGNUM_TARGET_GLES -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; -extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; +extern template struct MAGNUM_EXPORT ConfigurationValue>; #endif #endif