Browse Source

Math: using new aliases for builtin types in whole Math namespace.

pull/278/head
Vladimír Vondruš 13 years ago
parent
commit
6a90b0231b
  1. 54
      doc/matrix-vector.dox
  2. 18
      src/Math/Algorithms/Svd.h
  3. 6
      src/Math/Algorithms/Test/GaussJordanTest.cpp
  4. 4
      src/Math/Algorithms/Test/GramSchmidtTest.cpp
  5. 22
      src/Math/Algorithms/Test/SvdTest.cpp
  6. 8
      src/Math/Angle.cpp
  7. 58
      src/Math/Angle.h
  8. 17
      src/Math/BoolVector.h
  9. 4
      src/Math/Complex.cpp
  10. 4
      src/Math/Complex.h
  11. 18
      src/Math/Constants.h
  12. 4
      src/Math/DualComplex.cpp
  13. 4
      src/Math/DualComplex.h
  14. 4
      src/Math/DualQuaternion.cpp
  15. 4
      src/Math/DualQuaternion.h
  16. 8
      src/Math/Functions.cpp
  17. 20
      src/Math/Functions.h
  18. 4
      src/Math/Geometry/Rectangle.h
  19. 41
      src/Math/Geometry/Test/DistanceTest.cpp
  20. 6
      src/Math/Geometry/Test/IntersectionTest.cpp
  21. 6
      src/Math/Geometry/Test/RectangleTest.cpp
  22. 43
      src/Math/MathTypeTraits.h
  23. 4
      src/Math/Matrix.h
  24. 4
      src/Math/Quaternion.cpp
  25. 4
      src/Math/Quaternion.h
  26. 72
      src/Math/RectangularMatrix.cpp
  27. 80
      src/Math/RectangularMatrix.h
  28. 2
      src/Math/Swizzle.h
  29. 32
      src/Math/Test/AngleTest.cpp
  30. 2
      src/Math/Test/BoolVectorTest.cpp
  31. 24
      src/Math/Test/ComplexTest.cpp
  32. 8
      src/Math/Test/ConstantsTest.cpp
  33. 14
      src/Math/Test/DualComplexTest.cpp
  34. 16
      src/Math/Test/DualQuaternionTest.cpp
  35. 14
      src/Math/Test/DualTest.cpp
  36. 156
      src/Math/Test/FunctionsTest.cpp
  37. 20
      src/Math/Test/MathTypeTraitsTest.cpp
  38. 8
      src/Math/Test/Matrix3Test.cpp
  39. 22
      src/Math/Test/Matrix4Test.cpp
  40. 34
      src/Math/Test/MatrixTest.cpp
  41. 44
      src/Math/Test/QuaternionTest.cpp
  42. 78
      src/Math/Test/RectangularMatrixTest.cpp
  43. 10
      src/Math/Test/SwizzleTest.cpp
  44. 14
      src/Math/Test/UnitTest.cpp
  45. 4
      src/Math/Test/Vector2Test.cpp
  46. 8
      src/Math/Test/Vector3Test.cpp
  47. 10
      src/Math/Test/Vector4Test.cpp
  48. 32
      src/Math/Test/VectorTest.cpp
  49. 48
      src/Math/Vector.cpp
  50. 52
      src/Math/Vector.h

54
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 Vector4, Color3) create zero-filled objects. Matrix (and Matrix3, Matrix4) is
by default constructed as identity matrix. Color4 has alpha value set to opaque. by default constructed as identity matrix. Color4 has alpha value set to opaque.
@code @code
RectangularMatrix<2, 3, int> a; // zero-filled RectangularMatrix<2, 3, Int> a; // zero-filled
Vector<3, int> b; // zero-filled Vector<3, Int> b; // zero-filled
Matrix<3, int> identity; // diagonal set to 1 Matrix<3, Int> identity; // diagonal set to 1
Matrix<3, int> zero(Matrix<3, int>::Zero); // zero-filled Matrix<3, Int> zero(Matrix<3, Int>::Zero); // zero-filled
Color4<float> black1; // {0.0f, 0.0f, 0.0f, 1.0f} Color4<Float> black1; // {0.0f, 0.0f, 0.0f, 1.0f}
Color4<unsigned char> black2; // {0, 0, 0, 255} Color4<unsigned char> black2; // {0, 0, 0, 255}
@endcode @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, matrix is created by passing all column vectors to the
constructor. constructor.
@code @code
Vector3<int> vec(0, 1, 2); Vector3<Int> vec(0, 1, 2);
Matrix3<int> mat({0, 1, 2}, Matrix3<Int> mat({0, 1, 2},
{3, 4, 5}, {3, 4, 5},
{6, 7, 8}); {6, 7, 8});
@endcode @endcode
@ -61,34 +61,34 @@ at compile time.
You can specify all components of vector or whole diagonal of square matrix at You can specify all components of vector or whole diagonal of square matrix at
once: once:
@code @code
Matrix3<int> diag(Matrix3<int>::Identity, 2); // diagonal set to 2, zeros elsewhere Matrix3<Int> diag(Matrix3<Int>::Identity, 2); // diagonal set to 2, zeros elsewhere
Vector3<int> fill(10); // {10, 10, 10} Vector3<Int> fill(10); // {10, 10, 10}
@endcode @endcode
It is possible to create matrices from other matrices and vectors with the It is possible to create matrices from other matrices and vectors with the
same row count; vectors from vector and scalar: same row count; vectors from vector and scalar:
@code @code
RectangularMatrix<2, 3, int> a; RectangularMatrix<2, 3, Int> a;
Vector3<int> b, c; Vector3<Int> b, c;
Matrix3<int> mat(a, b); Matrix3<Int> mat(a, b);
Vector<8, int> vec(1, b, 2, c); Vector<8, Int> vec(1, b, 2, c);
@endcode @endcode
It is also possible to create them from an C-style array. The function does 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 simple type cast without any copying, so it's possible to conveniently operate
on the array itself: on the array itself:
@code @code
int[] mat = { 2, 4, 6, Int[] mat = { 2, 4, 6,
1, 3, 5 }; 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 @endcode
Note that unlike constructors, this function has no way to check whether the 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. array is long enough to contain all elements, so use with caution.
You can also *explicitly* convert between data types: You can also *explicitly* convert between data types:
@code @code
Vector4<float> floating(1.3f, 2.7f, -15.0f, 7.0f); Vector4<Float> floating(1.3f, 2.7f, -15.0f, 7.0f);
Vector4<int> integral(floating); // {1, 2, -15, 7} Vector4<Int> integral(floating); // {1, 2, -15, 7}
@endcode @endcode
@section matrix-vector-component-access Accessing matrix and vector components @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 brackets, there is also round bracket operator for accessing matrix components
directly: directly:
@code @code
RectangularMatrix<3, 2, int> a; RectangularMatrix<3, 2, Int> a;
a[2] /= 2; // third column (column major indexing, see explanation below) a[2] /= 2; // third column (column major indexing, see explanation below)
a[0][1] = 5; // first column, second element a[0][1] = 5; // first column, second element
Vector<3, int> b; Vector<3, Int> b;
b[1] = 1; // second element b[1] = 1; // second element
@endcode @endcode
Fixed-size vector subclasses have functions for accessing named components Fixed-size vector subclasses have functions for accessing named components
and subparts: and subparts:
@code @code
Vector4<int> a; Vector4<Int> a;
int x = a.x(); Int x = a.x();
a.y() += 5; a.y() += 5;
Vector3<int> xyz = a.xyz(); Vector3<Int> xyz = a.xyz();
xyz.xy() *= 5; xyz.xy() *= 5;
@endcode @endcode
Color3 and Color4 name their components `rgba` instead of `xyzw`. Color3 and Color4 name their components `rgba` instead of `xyzw`.
For more involved operations with components there is the swizzle() function: For more involved operations with components there is the swizzle() function:
@code @code
Vector<4, int> original(-1, 2, 3, 4); Vector<4, Int> original(-1, 2, 3, 4);
Vector<4, int> bgra = swizzle<'b', 'g', 'r', 'a'>(original); // { 3, 2, -1, 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<6, Int> w10xyz = swizzle<'w', '1', '0', 'x', 'y', 'z'>(original); // { 4, 1, 0, -1, 2, 3 }
@endcode @endcode
@section matrix-vector-column-major Matrices are column-major and vectors are columns @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 - Order of template arguments in specification of RectangularMatrix is also
column-major: column-major:
@code @code
RectangularMatrix<2, 3, int> mat; // two columns, three rows RectangularMatrix<2, 3, Int> mat; // two columns, three rows
@endcode @endcode
- Order of components in matrix constructors is also column-major, further - Order of components in matrix constructors is also column-major, further
emphasized by requirement that you have to pass directly column vectors: emphasized by requirement that you have to pass directly column vectors:
@code @code
Matrix3<int> mat({0, 1, 2}, Matrix3<Int> mat({0, 1, 2},
{3, 4, 5}, {3, 4, 5},
{6, 7, 8}); // first column is {0, 1, 2} {6, 7, 8}); // first column is {0, 1, 2}
@endcode @endcode

18
src/Math/Algorithms/Svd.h

@ -41,8 +41,8 @@ template<class T> T pythagoras(T a, T b) {
} }
template<class T> T smallestDelta(); template<class T> T smallestDelta();
template<> inline constexpr float smallestDelta<float>() { return 1.0e-32; } template<> inline constexpr Float smallestDelta<Float>() { return 1.0e-32; }
template<> inline constexpr double smallestDelta<double>() { return 1.0e-64; } template<> inline constexpr Double smallestDelta<Double>() { return 1.0e-64; }
} }
#endif #endif
@ -61,22 +61,22 @@ zero matrices.
Full @f$ U @f$, @f$ \Sigma @f$ matrices and original @f$ M @f$ matrix can be Full @f$ U @f$, @f$ \Sigma @f$ matrices and original @f$ M @f$ matrix can be
reconstructed from the values as following: reconstructed from the values as following:
@code @code
RectangularMatrix<cols, rows, double> m; RectangularMatrix<cols, rows, Double> m;
RectangularMatrix<cols, rows, double> uPart; RectangularMatrix<cols, rows, Double> uPart;
Vector<cols, double> wDiagonal; Vector<cols, Double> wDiagonal;
Matrix<cols, double> v; Matrix<cols, Double> v;
std::tie(uPart, wDiagonal, v) = Math::Algorithms::svd(m); std::tie(uPart, wDiagonal, v) = Math::Algorithms::svd(m);
// Extend U // Extend U
Matrix<rows, double> u(Matrix<rows, double>::Zero); Matrix<rows, Double> u(Matrix<rows, Double>::Zero);
for(std::size_t i = 0; i != rows; ++i) for(std::size_t i = 0; i != rows; ++i)
u[i] = uPart[i]; u[i] = uPart[i];
// Diagonal W // Diagonal W
RectangularMatrix<cols, rows, double> w = RectangularMatrix<cols, rows, Double> w =
RectangularMatrix<cols, rows, double>::fromDiagonal(wDiagonal); RectangularMatrix<cols, rows, Double>::fromDiagonal(wDiagonal);
// u*w*v.transposed() == m // u*w*v.transposed() == m
@endcode @endcode

6
src/Math/Algorithms/Test/GaussJordanTest.cpp

@ -27,8 +27,8 @@ class GaussJordanTest: public Corrade::TestSuite::Tester {
void invert(); void invert();
}; };
typedef RectangularMatrix<4, 4, float> Matrix4; typedef RectangularMatrix<4, 4, Float> Matrix4;
typedef Vector<4, float> Vector4; typedef Vector<4, Float> Vector4;
GaussJordanTest::GaussJordanTest() { GaussJordanTest::GaussJordanTest() {
addTests(&GaussJordanTest::singular, addTests(&GaussJordanTest::singular,
@ -40,7 +40,7 @@ void GaussJordanTest::singular() {
Vector4(2.0f, 3.0f, -7.0f, 11.0f), Vector4(2.0f, 3.0f, -7.0f, 11.0f),
Vector4(2.0f, 4.0f, 6.0f, 8.0f), Vector4(2.0f, 4.0f, 6.0f, 8.0f),
Vector4(1.0f, 2.0f, 7.0f, 40.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)); CORRADE_VERIFY(!gaussJordanInPlaceTransposed(a, t));
} }

4
src/Math/Algorithms/Test/GramSchmidtTest.cpp

@ -27,8 +27,8 @@ class GramSchmidtTest: public Corrade::TestSuite::Tester {
void orthonormalize(); void orthonormalize();
}; };
typedef RectangularMatrix<3, 3, float> Matrix3; typedef RectangularMatrix<3, 3, Float> Matrix3;
typedef Vector<3, float> Vector3; typedef Vector<3, Float> Vector3;
GramSchmidtTest::GramSchmidtTest() { GramSchmidtTest::GramSchmidtTest() {
addTests(&GramSchmidtTest::orthogonalize, addTests(&GramSchmidtTest::orthogonalize,

22
src/Math/Algorithms/Test/SvdTest.cpp

@ -27,17 +27,17 @@ class SvdTest: public Corrade::TestSuite::Tester {
void testFloat(); void testFloat();
}; };
typedef RectangularMatrix<5, 8, double> Matrix5x8d; typedef RectangularMatrix<5, 8, Double> Matrix5x8d;
typedef Matrix<8, double> Matrix8d; typedef Matrix<8, Double> Matrix8d;
typedef Matrix<5, double> Matrix5d; typedef Matrix<5, Double> Matrix5d;
typedef Vector<8, double> Vector8d; typedef Vector<8, Double> Vector8d;
typedef Vector<5, double> Vector5d; typedef Vector<5, Double> Vector5d;
typedef RectangularMatrix<5, 8, float> Matrix5x8f; typedef RectangularMatrix<5, 8, Float> Matrix5x8f;
typedef Matrix<8, float> Matrix8f; typedef Matrix<8, Float> Matrix8f;
typedef Matrix<5, float> Matrix5f; typedef Matrix<5, Float> Matrix5f;
typedef Vector<8, float> Vector8f; typedef Vector<8, Float> Vector8f;
typedef Vector<5, float> Vector5f; typedef Vector<5, Float> Vector5f;
constexpr static Matrix5x8d a( constexpr static Matrix5x8d a(
Vector8d(22.0, 14.0, -1.0, -3.0, 9.0, 9.0, 2.0, 4.0), Vector8d(22.0, 14.0, -1.0, -3.0, 9.0, 9.0, 2.0, 4.0),

8
src/Math/Angle.cpp

@ -18,11 +18,11 @@
namespace Magnum { namespace Math { namespace Magnum { namespace Math {
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Unit<Rad, float>&); template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Unit<Rad, Float>&);
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Unit<Deg, float>&); template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Unit<Deg, Float>&);
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Unit<Rad, double>&); template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Unit<Rad, Double>&);
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Unit<Deg, double>&); template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Unit<Deg, Double>&);
#endif #endif
#endif #endif

58
src/Math/Angle.h

@ -39,17 +39,17 @@ conversion less error-prone.
You can enter the value either by using literal: You can enter the value either by using literal:
@code @code
auto degrees = 60.0_degf; // type is Deg<float> auto degrees = 60.0_degf; // type is Deg<Float>
auto radians = 1.047_rad; // type is Rad<double> auto radians = 1.047_rad; // type is Rad<Double>
@endcode @endcode
Or explicitly convert unitless value (such as output from some function) to Or explicitly convert unitless value (such as output from some function) to
either degrees or radians: either degrees or radians:
@code @code
double foo(); Double foo();
Deg<float> degrees(35.0f); Deg<Float> degrees(35.0f);
Rad<double> radians(foo()); Rad<Double> radians(foo());
//degrees = 60.0f; // error, no implicit conversion //degrees = 60.0f; // error, no implicit conversion
@endcode @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 comparison of degrees and radians is not possible without explicit conversion
to common type: to common type:
@code @code
Rad<float> angle(); Rad<Float> angle();
Deg<float> x = angle(); // convert to degrees for easier comparison Deg<Float> x = angle(); // convert to degrees for easier comparison
if(x < 30.0_degf) foo(); if(x < 30.0_degf) foo();
//if(x > 1.57_radf) bar(); // error, both need to be of the same type //if(x > 1.57_radf) bar(); // error, both need to be of the same type
@endcode @endcode
@ -75,11 +75,11 @@ if(x < 30.0_degf) foo();
It is possible to seamlessly convert between degrees and radians and explicitly It is possible to seamlessly convert between degrees and radians and explicitly
convert the value back to underlying type: convert the value back to underlying type:
@code @code
float sine(Rad<float> angle); Float sine(Rad<Float> angle);
float a = sine(60.0_degf); // the same as sine(1.047_radf) Float a = sine(60.0_degf); // the same as sine(1.047_radf)
Deg<double> b = 1.047_rad; // the same as 60.0_deg Deg<Double> b = 1.047_rad; // the same as 60.0_deg
float d = double(b); // 60.0 Float d = Double(b); // 60.0
//float e = b; // error, no implicit conversion //Float e = b; // error, no implicit conversion
@endcode @endcode
@section Rad-conversions Requirement of explicit conversion @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 reduce unit-based errors. Consider following example with implicit conversions
allowed: allowed:
@code @code
float std::sin(float angle); Float std::sin(Float angle);
float sine(Rad<float> angle); Float sine(Rad<Float> angle);
float a = 60.0f; // degrees Float a = 60.0f; // degrees
sine(a); // silent error, sine() expected radians sine(a); // silent error, sine() expected radians
auto b = 60.0_degf; // degrees 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: These silent errors are easily avoided by requiring explicit conversions:
@code @code
//sine(angleInDegrees); // compilation error //sine(angleInDegrees); // compilation error
sine(Deg<float>(angleInDegrees)); // explicitly specifying unit sine(Deg<Float>(angleInDegrees)); // explicitly specifying unit
//std::sin(angleInDegrees); // compilation error //std::sin(angleInDegrees); // compilation error
std::sin(float(Rad<float>(angleInDegrees)); // required explicit conversion hints std::sin(Float(Rad<Float>(angleInDegrees)); // required explicit conversion hints
// to user that this case needs special // to user that this case needs special
// attention (i.e., conversion to radians) // attention (i.e., conversion to radians)
@endcode @endcode
@ -142,26 +142,26 @@ template<class T> class Deg: public Unit<Deg, T> {
Example usage: Example usage:
@code @code
double cosine = Math::cos(60.0_deg); // cosine = 0.5 Double cosine = Math::cos(60.0_deg); // cosine = 0.5
double cosine = Math::cos(1.047_rad); // cosine = 0.5 Double cosine = Math::cos(1.047_rad); // cosine = 0.5
@endcode @endcode
@see Magnum::operator""_deg(), operator""_degf(), operator""_rad() @see Magnum::operator""_deg(), operator""_degf(), operator""_rad()
@note Not available on GCC < 4.7. Use Deg::Deg(T) instead. @note Not available on GCC < 4.7. Use Deg::Deg(T) instead.
*/ */
inline constexpr Deg<double> operator "" _deg(long double value) { return Deg<double>(value); } inline constexpr Deg<Double> operator "" _deg(long double value) { return Deg<Double>(value); }
/** @relates Deg /** @relates Deg
@brief Single-precision degree value literal @brief Single-precision degree value literal
Example usage: Example usage:
@code @code
float tangent = Math::tan(60.0_degf); // tangent = 1.732f Float tangent = Math::tan(60.0_degf); // tangent = 1.732f
float tangent = Math::tan(1.047_radf); // tangent = 1.732f Float tangent = Math::tan(1.047_radf); // tangent = 1.732f
@endcode @endcode
@see Magnum::operator""_degf(), operator""_deg(), operator""_radf() @see Magnum::operator""_degf(), operator""_deg(), operator""_radf()
@note Not available on GCC < 4.7. Use Deg::Deg(T) instead. @note Not available on GCC < 4.7. Use Deg::Deg(T) instead.
*/ */
inline constexpr Deg<float> operator "" _degf(long double value) { return Deg<float>(value); } inline constexpr Deg<Float> operator "" _degf(long double value) { return Deg<Float>(value); }
#endif #endif
/** /**
@ -203,7 +203,7 @@ See operator""_rad() for more information.
@see Magnum::operator""_rad(), operator""_radf(), operator""_deg() @see Magnum::operator""_rad(), operator""_radf(), operator""_deg()
@note Not available on GCC < 4.7. Use Rad::Rad(T) instead. @note Not available on GCC < 4.7. Use Rad::Rad(T) instead.
*/ */
inline constexpr Rad<double> operator "" _rad(long double value) { return Rad<double>(value); } inline constexpr Rad<Double> operator "" _rad(long double value) { return Rad<Double>(value); }
/** @relates Rad /** @relates Rad
@brief Single-precision radian value literal @brief Single-precision radian value literal
@ -212,7 +212,7 @@ See operator""_degf() for more information.
@see Magnum::operator""_radf(), operator""_rad(), operator""_degf() @see Magnum::operator""_radf(), operator""_rad(), operator""_degf()
@note Not available on GCC < 4.7. Use Rad::Rad(T) instead. @note Not available on GCC < 4.7. Use Rad::Rad(T) instead.
*/ */
inline constexpr Rad<float> operator "" _radf(long double value) { return Rad<float>(value); } inline constexpr Rad<Float> operator "" _radf(long double value) { return Rad<Float>(value); }
#endif #endif
template<class T> inline constexpr Deg<T>::Deg(Unit<Rad, T> value): Unit<Deg, T>(T(180)*T(value)/Math::Constants<T>::pi()) {} template<class T> inline constexpr Deg<T>::Deg(Unit<Rad, T> value): Unit<Deg, T>(T(180)*T(value)/Math::Constants<T>::pi()) {}
@ -238,11 +238,11 @@ template<class T> Corrade::Utility::Debug operator<<(Corrade::Utility::Debug deb
/* Explicit instantiation for commonly used types */ /* Explicit instantiation for commonly used types */
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Unit<Rad, float>&); extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Unit<Rad, Float>&);
extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Unit<Deg, float>&); extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Unit<Deg, Float>&);
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Unit<Rad, double>&); extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Unit<Rad, Double>&);
extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Unit<Deg, double>&); extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Unit<Deg, Double>&);
#endif #endif
#endif #endif

17
src/Math/BoolVector.h

@ -19,9 +19,10 @@
* @brief Class Magnum::Math::BoolVector * @brief Class Magnum::Math::BoolVector
*/ */
#include <cstdint>
#include <Utility/Debug.h> #include <Utility/Debug.h>
#include "Types.h"
namespace Magnum { namespace Math { namespace Magnum { namespace Math {
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
@ -65,9 +66,9 @@ template<std::size_t size> class BoolVector {
* @param next Values for next Bbit segments * @param next Values for next Bbit segments
*/ */
#ifdef DOXYGEN_GENERATING_OUTPUT #ifdef DOXYGEN_GENERATING_OUTPUT
template<class ...T> inline constexpr /*implicit*/ BoolVector(std::uint8_t first, T... next); template<class ...T> inline constexpr /*implicit*/ BoolVector(UnsignedByte first, T... next);
#else #else
template<class ...T, class U = typename std::enable_if<sizeof...(T)+1 == DataSize, bool>::type> inline constexpr /*implicit*/ BoolVector(std::uint8_t first, T... next): _data{first, std::uint8_t(next)...} {} template<class ...T, class U = typename std::enable_if<sizeof...(T)+1 == DataSize, bool>::type> inline constexpr /*implicit*/ BoolVector(UnsignedByte first, T... next): _data{first, UnsignedByte(next)...} {}
#endif #endif
/** @brief Construct boolean vector with one value for all fields */ /** @brief Construct boolean vector with one value for all fields */
@ -89,8 +90,8 @@ template<std::size_t size> class BoolVector {
* *
* @see operator[](), set() * @see operator[](), set()
*/ */
inline std::uint8_t* data() { return _data; } inline UnsignedByte* data() { return _data; }
inline constexpr const std::uint8_t* data() const { return _data; } /**< @overload */ inline constexpr const UnsignedByte* data() const { return _data; } /**< @overload */
/** @brief Bit at given position */ /** @brief Bit at given position */
inline constexpr bool operator[](std::size_t i) const { inline constexpr bool operator[](std::size_t i) const {
@ -225,15 +226,15 @@ template<std::size_t size> class BoolVector {
} }
private: private:
enum: std::uint8_t { enum: UnsignedByte {
FullSegmentMask = 0xFF, FullSegmentMask = 0xFF,
LastSegmentMask = (1 << size%8) - 1 LastSegmentMask = (1 << size%8) - 1
}; };
/* Implementation for Vector<size, T>::Vector(U) */ /* Implementation for Vector<size, T>::Vector(U) */
template<std::size_t ...sequence> inline constexpr explicit BoolVector(Implementation::Sequence<sequence...>, std::uint8_t value): _data{Implementation::repeat(value, sequence)...} {} template<std::size_t ...sequence> inline constexpr explicit BoolVector(Implementation::Sequence<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} */ /** @debugoperator{Magnum::Math::BoolVector} */

4
src/Math/Complex.cpp

@ -18,9 +18,9 @@
namespace Magnum { namespace Math { namespace Magnum { namespace Math {
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Complex<float>&); template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Complex<Float>&);
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Complex<double>&); template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Complex<Double>&);
#endif #endif
#endif #endif

4
src/Math/Complex.h

@ -390,9 +390,9 @@ template<class T> Corrade::Utility::Debug operator<<(Corrade::Utility::Debug deb
/* Explicit instantiation for commonly used types */ /* Explicit instantiation for commonly used types */
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Complex<float>&); extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Complex<Float>&);
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Complex<double>&); extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Complex<Double>&);
#endif #endif
#endif #endif

18
src/Math/Constants.h

@ -19,6 +19,8 @@
* @brief Class Magnum::Math::Constants * @brief Class Magnum::Math::Constants
*/ */
#include "Types.h"
namespace Magnum { namespace Math { namespace Magnum { namespace Math {
/** /**
@ -44,19 +46,19 @@ template<class T> struct Constants {
}; };
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
template<> struct Constants<double> { template<> struct Constants<Double> {
Constants() = delete; Constants() = delete;
static inline constexpr double pi() { return 3.141592653589793; } static inline constexpr Double pi() { return 3.141592653589793; }
static inline constexpr double sqrt2() { return 1.414213562373095; } static inline constexpr Double sqrt2() { return 1.414213562373095; }
static inline constexpr double sqrt3() { return 1.732050807568877; } static inline constexpr Double sqrt3() { return 1.732050807568877; }
}; };
template<> struct Constants<float> { template<> struct Constants<Float> {
Constants() = delete; Constants() = delete;
static inline constexpr float pi() { return 3.141592654f; } static inline constexpr Float pi() { return 3.141592654f; }
static inline constexpr float sqrt2() { return 1.414213562f; } static inline constexpr Float sqrt2() { return 1.414213562f; }
static inline constexpr float sqrt3() { return 1.732050808f; } static inline constexpr Float sqrt3() { return 1.732050808f; }
}; };
#endif #endif

4
src/Math/DualComplex.cpp

@ -18,9 +18,9 @@
namespace Magnum { namespace Math { namespace Magnum { namespace Math {
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const DualComplex<float>&); template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const DualComplex<Float>&);
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const DualComplex<double>&); template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const DualComplex<Double>&);
#endif #endif
#endif #endif

4
src/Math/DualComplex.h

@ -308,9 +308,9 @@ template<class T> Corrade::Utility::Debug operator<<(Corrade::Utility::Debug deb
/* Explicit instantiation for commonly used types */ /* Explicit instantiation for commonly used types */
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const DualComplex<float>&); extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const DualComplex<Float>&);
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const DualComplex<double>&); extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const DualComplex<Double>&);
#endif #endif
#endif #endif

4
src/Math/DualQuaternion.cpp

@ -18,9 +18,9 @@
namespace Magnum { namespace Math { namespace Magnum { namespace Math {
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const DualQuaternion<float>&); template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const DualQuaternion<Float>&);
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const DualQuaternion<double>&); template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const DualQuaternion<Double>&);
#endif #endif
#endif #endif

4
src/Math/DualQuaternion.h

@ -298,9 +298,9 @@ template<class T> Corrade::Utility::Debug operator<<(Corrade::Utility::Debug deb
/* Explicit instantiation for commonly used types */ /* Explicit instantiation for commonly used types */
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const DualQuaternion<float>&); extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const DualQuaternion<Float>&);
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const DualQuaternion<double>&); extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const DualQuaternion<Double>&);
#endif #endif
#endif #endif

8
src/Math/Functions.cpp

@ -17,15 +17,15 @@
namespace Magnum { namespace Math { namespace Magnum { namespace Math {
std::uint32_t log2(std::uint32_t number) { UnsignedInt log2(UnsignedInt number) {
std::uint32_t log = 0; UnsignedInt log = 0;
while(number >>= 1) while(number >>= 1)
++log; ++log;
return log; return log;
} }
std::uint32_t log(std::uint32_t base, std::uint32_t number) { UnsignedInt log(UnsignedInt base, UnsignedInt number) {
std::uint32_t log = 0; UnsignedInt log = 0;
while(number /= base) while(number /= base)
++log; ++log;
return log; return log;

20
src/Math/Functions.h

@ -31,7 +31,7 @@ namespace Magnum { namespace Math {
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
namespace Implementation { namespace Implementation {
template<std::uint32_t exponent> struct Pow { template<UnsignedInt exponent> struct Pow {
Pow() = delete; Pow() = delete;
template<class T> inline constexpr static T pow(T base) { template<class T> inline constexpr static T pow(T base) {
@ -51,7 +51,7 @@ namespace Implementation {
* *
* Returns integral power of base to the exponent. * Returns integral power of base to the exponent.
*/ */
template<std::uint32_t exponent, class T> inline constexpr T pow(T base) { template<UnsignedInt exponent, class T> inline constexpr T pow(T base) {
return Implementation::Pow<exponent>::pow(base); return Implementation::Pow<exponent>::pow(base);
} }
@ -61,7 +61,7 @@ template<std::uint32_t exponent, class T> inline constexpr T pow(T base) {
* Returns integral logarithm of given number with base `2`. * Returns integral logarithm of given number with base `2`.
* @see log() * @see log()
*/ */
std::uint32_t MAGNUM_EXPORT log2(std::uint32_t number); UnsignedInt MAGNUM_EXPORT log2(UnsignedInt number);
/** /**
* @brief Integral logarithm * @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. * Returns integral logarithm of given number with given base.
* @see log2() * @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 */ /** @brief Sine */
template<class T> inline T sin(Rad<T> angle) { return std::sin(T(angle)); } template<class T> inline T sin(Rad<T> 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$. 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 @note For best precision, resulting `FloatingPoint` type should be always
larger that `Integral` type (e.g. `double` from `std::int32_t`, `long double` larger that `Integral` type (e.g. Double from Int, LongDouble from Long and
from `std::int64_t` and similarly for vector types). similarly for vector types).
@attention To ensure the integral type is correctly detected when using @attention To ensure the integral type is correctly detected when using
literals, this function should be called with both template parameters literals, this function should be called with both template parameters
explicit, e.g.: explicit, e.g.:
@code @code
// Literal type is (signed) char, but we assumed unsigned char, a != 1.0f // Literal type is (signed) char, but we assumed unsigned char, a != 1.0f
float a = normalize<float>('\xFF'); Float a = normalize<Float>('\xFF');
// b = 1.0f // b = 1.0f
float b = normalize<float, std::uint8_t>('\xFF'); Float b = normalize<Float, UnsignedByte>('\xFF');
@endcode @endcode
@see denormalize() @see denormalize()
@ -273,8 +273,8 @@ Converts floating-point value in range @f$ [0, 1] @f$ to full range of given
integral type. integral type.
@note For best precision, `FloatingPoint` type should be always larger that @note For best precision, `FloatingPoint` type should be always larger that
resulting `Integral` type (e.g. `double` to `std::int32_t`, `long double` resulting `Integral` type (e.g. Double to Int, LongDouble to Long and
to `std::int64_t` and similarly for vector types). similarly for vector types).
@attention Return value for floating point numbers outside the normalized @attention Return value for floating point numbers outside the normalized
range is undefined. range is undefined.

4
src/Math/Geometry/Rectangle.h

@ -60,8 +60,8 @@ template<class T> class Rectangle {
* Performs only default casting on the values, no rounding or * Performs only default casting on the values, no rounding or
* anything else. Example usage: * anything else. Example usage:
* @code * @code
* Rectangle<float> floatingPoint({1.3f, 2.7f}, {-15.0f, 7.0f}); * Rectangle<Float> floatingPoint({1.3f, 2.7f}, {-15.0f, 7.0f});
* Rectangle<std::int8_t> integral(floatingPoint); // {{1, 2}, {-15, 7}} * Rectangle<Byte> integral(floatingPoint); // {{1, 2}, {-15, 7}}
* @endcode * @endcode
*/ */
template<class U> inline constexpr explicit Rectangle(const Rectangle<U>& other): _bottomLeft(other._bottomLeft), _topRight(other._topRight) {} template<class U> inline constexpr explicit Rectangle(const Rectangle<U>& other): _bottomLeft(other._bottomLeft), _topRight(other._topRight) {}

41
src/Math/Geometry/Test/DistanceTest.cpp

@ -31,8 +31,9 @@ class DistanceTest: public Corrade::TestSuite::Tester {
void lineSegmentPoint3D(); void lineSegmentPoint3D();
}; };
typedef Magnum::Math::Vector2<float> Vector2; typedef Math::Vector2<Float> Vector2;
typedef Magnum::Math::Vector3<float> Vector3; typedef Math::Vector3<Float> Vector3;
typedef Math::Constants<Float> Constants;
DistanceTest::DistanceTest() { DistanceTest::DistanceTest() {
addTests(&DistanceTest::linePoint2D, addTests(&DistanceTest::linePoint2D,
@ -49,14 +50,11 @@ void DistanceTest::linePoint2D() {
CORRADE_COMPARE((Distance::linePoint(a, b, Vector2(0.25f))), 0.0f); CORRADE_COMPARE((Distance::linePoint(a, b, Vector2(0.25f))), 0.0f);
/* The distance should be the same for all equidistant points */ /* The distance should be the same for all equidistant points */
CORRADE_COMPARE((Distance::linePoint(a, b, Vector2(1.0f, 0.0f))), CORRADE_COMPARE((Distance::linePoint(a, b, Vector2(1.0f, 0.0f))), 1.0f/Constants::sqrt2());
1.0f/Constants<float>::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)+Vector2(100.0f))),
1.0f/Constants<float>::sqrt2());
/* Be sure that *Squared() works the same, as it has slightly different implementation */ /* Be sure that *Squared() works the same, as it has slightly different implementation */
CORRADE_COMPARE((Distance::linePointSquared(a, b, Vector2(1.0f, 0.0f))), CORRADE_COMPARE((Distance::linePointSquared(a, b, Vector2(1.0f, 0.0f))), 0.5f);
0.5f);
} }
void DistanceTest::linePoint3D() { void DistanceTest::linePoint3D() {
@ -67,10 +65,8 @@ void DistanceTest::linePoint3D() {
CORRADE_COMPARE((Distance::linePoint(a, b, Vector3(0.25f))), 0.0f); CORRADE_COMPARE((Distance::linePoint(a, b, Vector3(0.25f))), 0.0f);
/* The distance should be the same for all equidistant points */ /* The distance should be the same for all equidistant points */
CORRADE_COMPARE((Distance::linePoint(a, b, Vector3(1.0f, 0.0f, 1.0f))), CORRADE_COMPARE((Distance::linePoint(a, b, Vector3(1.0f, 0.0f, 1.0f))), Constants::sqrt2()/Constants::sqrt3());
Constants<float>::sqrt2()/Constants<float>::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)+Vector3(100.0f))),
Constants<float>::sqrt2()/Constants<float>::sqrt3());
} }
void DistanceTest::lineSegmentPoint2D() { void DistanceTest::lineSegmentPoint2D() {
@ -81,19 +77,17 @@ void DistanceTest::lineSegmentPoint2D() {
CORRADE_COMPARE((Distance::lineSegmentPoint(a, b, Vector2(0.25f))), 0.0f); CORRADE_COMPARE((Distance::lineSegmentPoint(a, b, Vector2(0.25f))), 0.0f);
/* Point on the line, outside the segment, closer to A */ /* Point on the line, outside the segment, closer to A */
CORRADE_COMPARE((Distance::lineSegmentPoint(a, b, Vector2(-1.0f))), Constants<float>::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 */ /* Be sure that *Squared() works the same, as it has slightly different implementation */
CORRADE_COMPARE((Distance::lineSegmentPointSquared(a, b, Vector2(-1.0f))), 2.0f); CORRADE_COMPARE((Distance::lineSegmentPointSquared(a, b, Vector2(-1.0f))), 2.0f);
/* Point on the line, outside the segment, closer to B */ /* Point on the line, outside the segment, closer to B */
CORRADE_COMPARE((Distance::lineSegmentPoint(a, b, Vector2(1.0f+1.0f/Constants<float>::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<float>::sqrt2()))), 1.0f); CORRADE_COMPARE((Distance::lineSegmentPointSquared(a, b, Vector2(1.0f+1.0f/Constants::sqrt2()))), 1.0f);
/* Point next to the line segment */ /* Point next to the line segment */
CORRADE_COMPARE((Distance::lineSegmentPoint(a, b, Vector2(1.0f, 0.0f))), CORRADE_COMPARE((Distance::lineSegmentPoint(a, b, Vector2(1.0f, 0.0f))), 1.0f/Constants::sqrt2());
1.0f/Constants<float>::sqrt2()); CORRADE_COMPARE((Distance::lineSegmentPointSquared(a, b, Vector2(1.0f, 0.0f))), 0.5f);
CORRADE_COMPARE((Distance::lineSegmentPointSquared(a, b, Vector2(1.0f, 0.0f))),
0.5f);
/* Point outside the line segment, closer to A */ /* 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); 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); CORRADE_COMPARE((Distance::lineSegmentPoint(a, b, Vector3(0.25f))), 0.0f);
/* Point on the line, outside the segment, closer to A */ /* Point on the line, outside the segment, closer to A */
CORRADE_COMPARE((Distance::lineSegmentPoint(a, b, Vector3(-1.0f))), +Constants<float>::sqrt3()); CORRADE_COMPARE((Distance::lineSegmentPoint(a, b, Vector3(-1.0f))), Constants::sqrt3());
/* Point on the line, outside the segment, closer to B */ /* Point on the line, outside the segment, closer to B */
CORRADE_COMPARE((Distance::lineSegmentPoint(a, b, Vector3(1.0f+1.0f/Constants<float>::sqrt3()))), 1.0f); CORRADE_COMPARE((Distance::lineSegmentPoint(a, b, Vector3(1.0f+1.0f/Constants::sqrt3()))), 1.0f);
/* Point next to the line segment */ /* Point next to the line segment */
CORRADE_COMPARE((Distance::lineSegmentPoint(a, b, Vector3(1.0f, 0.0f, 1.0f))), CORRADE_COMPARE((Distance::lineSegmentPoint(a, b, Vector3(1.0f, 0.0f, 1.0f))), Constants::sqrt2()/Constants::sqrt3());
Constants<float>::sqrt2()/Constants<float>::sqrt3());
/* Point outside the line segment, closer to A */ /* 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); 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 */ /* 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<float>::sqrt2()); CORRADE_COMPARE((Distance::lineSegmentPoint(a, b, Vector3(1.0f, 0.0f, 1.0f)+Vector3(1.0f))), Constants::sqrt2());
} }
}}}} }}}}

6
src/Math/Geometry/Test/IntersectionTest.cpp

@ -27,7 +27,7 @@ class IntersectionTest: public Corrade::TestSuite::Tester {
void planeLine(); void planeLine();
}; };
typedef Magnum::Math::Vector3<float> Vector3; typedef Math::Vector3<Float> Vector3;
IntersectionTest::IntersectionTest() { IntersectionTest::IntersectionTest() {
addTests(&IntersectionTest::planeLine); addTests(&IntersectionTest::planeLine);
@ -47,11 +47,11 @@ void IntersectionTest::planeLine() {
/* Line lies on the plane */ /* Line lies on the plane */
CORRADE_COMPARE(Intersection::planeLine(planePosition, planeNormal, CORRADE_COMPARE(Intersection::planeLine(planePosition, planeNormal,
Vector3(1.0f, 0.5f, 0.5f), Vector3(0.0f, 1.0f, 0.5f)), std::numeric_limits<float>::quiet_NaN()); Vector3(1.0f, 0.5f, 0.5f), Vector3(0.0f, 1.0f, 0.5f)), std::numeric_limits<Float>::quiet_NaN());
/* Line is parallell to the plane */ /* Line is parallell to the plane */
CORRADE_COMPARE((Intersection::planeLine(planePosition, planeNormal, CORRADE_COMPARE((Intersection::planeLine(planePosition, planeNormal,
Vector3(1.0f, 0.0f, 1.0f), Vector3(0.0f, 0.0f, 1.0f))), -std::numeric_limits<float>::infinity()); Vector3(1.0f, 0.0f, 1.0f), Vector3(0.0f, 0.0f, 1.0f))), -std::numeric_limits<Float>::infinity());
} }
}}}} }}}}

6
src/Math/Geometry/Test/RectangleTest.cpp

@ -32,9 +32,9 @@ class RectangleTest: public Corrade::TestSuite::Tester {
void debug(); void debug();
}; };
typedef Geometry::Rectangle<float> Rectangle; typedef Geometry::Rectangle<Float> Rectangle;
typedef Geometry::Rectangle<std::int32_t> Rectanglei; typedef Geometry::Rectangle<Int> Rectanglei;
typedef Vector2<std::int32_t> Vector2i; typedef Vector2<Int> Vector2i;
RectangleTest::RectangleTest() { RectangleTest::RectangleTest() {
addTests(&RectangleTest::access, addTests(&RectangleTest::access,

43
src/Math/MathTypeTraits.h

@ -19,9 +19,10 @@
* @brief Class Magnum::Math::MathTypeTraits * @brief Class Magnum::Math::MathTypeTraits
*/ */
#include <cstdint>
#include <cmath> #include <cmath>
#include "Types.h"
/** @brief Precision when testing floats for equality */ /** @brief Precision when testing floats for equality */
#ifndef FLOAT_EQUALITY_PRECISION #ifndef FLOAT_EQUALITY_PRECISION
#define FLOAT_EQUALITY_PRECISION 1.0e-6 #define FLOAT_EQUALITY_PRECISION 1.0e-6
@ -113,28 +114,28 @@ namespace Implementation {
}; };
} }
template<> struct MathTypeTraits<std::uint8_t>: Implementation::MathTypeTraitsIntegral<std::uint8_t> { template<> struct MathTypeTraits<UnsignedByte>: Implementation::MathTypeTraitsIntegral<UnsignedByte> {
typedef float FloatingPointType; typedef Float FloatingPointType;
}; };
template<> struct MathTypeTraits<std::int8_t>: Implementation::MathTypeTraitsIntegral<std::int8_t> { template<> struct MathTypeTraits<Byte>: Implementation::MathTypeTraitsIntegral<Byte> {
typedef float FloatingPointType; typedef Float FloatingPointType;
}; };
template<> struct MathTypeTraits<std::uint16_t>: Implementation::MathTypeTraitsIntegral<std::uint16_t> { template<> struct MathTypeTraits<UnsignedShort>: Implementation::MathTypeTraitsIntegral<UnsignedShort> {
typedef float FloatingPointType; typedef Float FloatingPointType;
}; };
template<> struct MathTypeTraits<std::int16_t>: Implementation::MathTypeTraitsIntegral<std::int16_t> { template<> struct MathTypeTraits<Short>: Implementation::MathTypeTraitsIntegral<Short> {
typedef float FloatingPointType; typedef Float FloatingPointType;
}; };
template<> struct MathTypeTraits<std::uint32_t>: Implementation::MathTypeTraitsIntegral<std::uint32_t> { template<> struct MathTypeTraits<UnsignedInt>: Implementation::MathTypeTraitsIntegral<UnsignedInt> {
typedef double FloatingPointType; typedef Double FloatingPointType;
}; };
template<> struct MathTypeTraits<std::int32_t>: Implementation::MathTypeTraitsIntegral<std::int32_t> { template<> struct MathTypeTraits<Int>: Implementation::MathTypeTraitsIntegral<Int> {
typedef double FloatingPointType; typedef Double FloatingPointType;
}; };
template<> struct MathTypeTraits<std::uint64_t>: Implementation::MathTypeTraitsIntegral<std::uint64_t> { template<> struct MathTypeTraits<UnsignedLong>: Implementation::MathTypeTraitsIntegral<UnsignedLong> {
typedef long double FloatingPointType; typedef long double FloatingPointType;
}; };
template<> struct MathTypeTraits<std::int64_t>: Implementation::MathTypeTraitsIntegral<std::int64_t> { template<> struct MathTypeTraits<Long>: Implementation::MathTypeTraitsIntegral<Long> {
typedef long double FloatingPointType; typedef long double FloatingPointType;
}; };
@ -149,15 +150,15 @@ namespace Implementation {
}; };
} }
template<> struct MathTypeTraits<float>: Implementation::MathTypeTraitsFloatingPoint<float> { template<> struct MathTypeTraits<Float>: Implementation::MathTypeTraitsFloatingPoint<Float> {
typedef float FloatingPointType; typedef Float FloatingPointType;
inline constexpr static float epsilon() { return FLOAT_EQUALITY_PRECISION; } inline constexpr static Float epsilon() { return FLOAT_EQUALITY_PRECISION; }
}; };
template<> struct MathTypeTraits<double>: Implementation::MathTypeTraitsFloatingPoint<double> { template<> struct MathTypeTraits<Double>: Implementation::MathTypeTraitsFloatingPoint<Double> {
typedef double FloatingPointType; typedef Double FloatingPointType;
inline constexpr static double epsilon() { return DOUBLE_EQUALITY_PRECISION; } inline constexpr static Double epsilon() { return DOUBLE_EQUALITY_PRECISION; }
}; };
template<> struct MathTypeTraits<long double>: Implementation::MathTypeTraitsFloatingPoint<long double> { template<> struct MathTypeTraits<long double>: Implementation::MathTypeTraitsFloatingPoint<long double> {
typedef long double FloatingPointType; typedef long double FloatingPointType;

4
src/Math/Matrix.h

@ -81,9 +81,9 @@ template<std::size_t size, class T> class Matrix: public RectangularMatrix<size,
* Performs only default casting on the values, no rounding or * Performs only default casting on the values, no rounding or
* anything else. Example usage: * anything else. Example usage:
* @code * @code
* Matrix<2, float> floatingPoint({1.3f, 2.7f}, * Matrix<2, Float> floatingPoint({1.3f, 2.7f},
* {-15.0f, 7.0f}); * {-15.0f, 7.0f});
* Matrix<2, std::int8_t> integral(floatingPoint); * Matrix<2, Byte> integral(floatingPoint);
* // integral == {{1, 2}, {-15, 7}} * // integral == {{1, 2}, {-15, 7}}
* @endcode * @endcode
*/ */

4
src/Math/Quaternion.cpp

@ -18,9 +18,9 @@
namespace Magnum { namespace Math { namespace Magnum { namespace Math {
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Quaternion<float>&); template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Quaternion<Float>&);
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Quaternion<double>&); template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Quaternion<Double>&);
#endif #endif
#endif #endif

4
src/Math/Quaternion.h

@ -479,9 +479,9 @@ template<class T> Corrade::Utility::Debug operator<<(Corrade::Utility::Debug deb
/* Explicit instantiation for commonly used types */ /* Explicit instantiation for commonly used types */
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Quaternion<float>&); extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Quaternion<Float>&);
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Quaternion<double>&); extern template Corrade::Utility::Debug MAGNUM_EXPORT operator<<(Corrade::Utility::Debug, const Quaternion<Double>&);
#endif #endif
#endif #endif

72
src/Math/RectangularMatrix.cpp

@ -18,28 +18,28 @@
namespace Magnum { namespace Math { namespace Magnum { namespace Math {
#ifndef DOXYGEN_GENERATING_OUTPUT #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<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<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<4, 4, Float>&);
#ifndef MAGNUM_TARGET_GLES #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<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<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<4, 4, Double>&);
#endif #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<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<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<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<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<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<4, 3, Float>&);
#ifndef MAGNUM_TARGET_GLES #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<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<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<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<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<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<4, 3, Double>&);
#endif #endif
#endif #endif
@ -48,28 +48,28 @@ template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnu
namespace Corrade { namespace Utility { namespace Corrade { namespace Utility {
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<2, 2, float>>; template struct ConfigurationValue<Magnum::Math::RectangularMatrix<2, 2, Magnum::Float>>;
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<3, 3, float>>; template struct ConfigurationValue<Magnum::Math::RectangularMatrix<3, 3, Magnum::Float>>;
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<4, 4, float>>; template struct ConfigurationValue<Magnum::Math::RectangularMatrix<4, 4, Magnum::Float>>;
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<2, 2, double>>; template struct ConfigurationValue<Magnum::Math::RectangularMatrix<2, 2, Magnum::Double>>;
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<3, 3, double>>; template struct ConfigurationValue<Magnum::Math::RectangularMatrix<3, 3, Magnum::Double>>;
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<4, 4, double>>; template struct ConfigurationValue<Magnum::Math::RectangularMatrix<4, 4, Magnum::Double>>;
#endif #endif
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<2, 3, float>>; template struct ConfigurationValue<Magnum::Math::RectangularMatrix<2, 3, Magnum::Float>>;
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<3, 2, float>>; template struct ConfigurationValue<Magnum::Math::RectangularMatrix<3, 2, Magnum::Float>>;
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<2, 4, float>>; template struct ConfigurationValue<Magnum::Math::RectangularMatrix<2, 4, Magnum::Float>>;
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<4, 2, float>>; template struct ConfigurationValue<Magnum::Math::RectangularMatrix<4, 2, Magnum::Float>>;
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<3, 4, float>>; template struct ConfigurationValue<Magnum::Math::RectangularMatrix<3, 4, Magnum::Float>>;
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<4, 3, float>>; template struct ConfigurationValue<Magnum::Math::RectangularMatrix<4, 3, Magnum::Float>>;
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<2, 3, double>>; template struct ConfigurationValue<Magnum::Math::RectangularMatrix<2, 3, Magnum::Double>>;
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<3, 2, double>>; template struct ConfigurationValue<Magnum::Math::RectangularMatrix<3, 2, Magnum::Double>>;
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<2, 4, double>>; template struct ConfigurationValue<Magnum::Math::RectangularMatrix<2, 4, Magnum::Double>>;
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<4, 2, double>>; template struct ConfigurationValue<Magnum::Math::RectangularMatrix<4, 2, Magnum::Double>>;
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<3, 4, double>>; template struct ConfigurationValue<Magnum::Math::RectangularMatrix<3, 4, Magnum::Double>>;
template struct ConfigurationValue<Magnum::Math::RectangularMatrix<4, 3, double>>; template struct ConfigurationValue<Magnum::Math::RectangularMatrix<4, 3, Magnum::Double>>;
#endif #endif
#endif #endif

80
src/Math/RectangularMatrix.h

@ -104,8 +104,8 @@ template<std::size_t cols, std::size_t rows, class T> class RectangularMatrix {
* Performs only default casting on the values, no rounding or * Performs only default casting on the values, no rounding or
* anything else. Example usage: * anything else. Example usage:
* @code * @code
* RectangularMatrix<4, 1, float> floatingPoint(1.3f, 2.7f, -15.0f, 7.0f); * RectangularMatrix<4, 1, Float> floatingPoint(1.3f, 2.7f, -15.0f, 7.0f);
* RectangularMatrix<4, 1, std::int8_t> integral(floatingPoint); * RectangularMatrix<4, 1, Byte> integral(floatingPoint);
* // integral == {1, 2, -15, 7} * // integral == {1, 2, -15, 7}
* @endcode * @endcode
*/ */
@ -132,8 +132,8 @@ template<std::size_t cols, std::size_t rows, class T> class RectangularMatrix {
* *
* Particular elements can be accessed using Vector::operator[], e.g.: * Particular elements can be accessed using Vector::operator[], e.g.:
* @code * @code
* RectangularMatrix<4, 3, float> m; * RectangularMatrix<4, 3, Float> m;
* float a = m[2][1]; * Float a = m[2][1];
* @endcode * @endcode
* *
* @see data() * @see data()
@ -475,29 +475,29 @@ template<std::size_t cols, std::size_t rows, class T> Corrade::Utility::Debug op
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
/* Explicit instantiation for types used in OpenGL */ /* Explicit instantiation for types used in OpenGL */
/* Square matrices */ /* 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<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<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<4, 4, Float>&);
#ifndef MAGNUM_TARGET_GLES #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<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<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<4, 4, Double>&);
#endif #endif
/* Rectangular matrices */ /* 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<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<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<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<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<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<4, 3, Float>&);
#ifndef MAGNUM_TARGET_GLES #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<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<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<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<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<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<4, 3, Double>&);
#endif #endif
#define MAGNUM_RECTANGULARMATRIX_SUBCLASS_IMPLEMENTATION(cols, rows, ...) \ #define MAGNUM_RECTANGULARMATRIX_SUBCLASS_IMPLEMENTATION(cols, rows, ...) \
@ -591,29 +591,29 @@ template<std::size_t cols, std::size_t rows, class T> struct ConfigurationValue<
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
/* Square matrices */ /* Square matrices */
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<2, 2, float>>; extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<2, 2, Magnum::Float>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<3, 3, float>>; extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<3, 3, Magnum::Float>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<4, 4, float>>; extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<4, 4, Magnum::Float>>;
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<2, 2, double>>; extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<2, 2, Magnum::Double>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<3, 3, double>>; extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<3, 3, Magnum::Double>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<4, 4, double>>; extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<4, 4, Magnum::Double>>;
#endif #endif
/* Rectangular matrices */ /* Rectangular matrices */
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<2, 3, float>>; extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<2, 3, Magnum::Float>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<3, 2, float>>; extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<3, 2, Magnum::Float>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<2, 4, float>>; extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<2, 4, Magnum::Float>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<4, 2, float>>; extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<4, 2, Magnum::Float>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<3, 4, float>>; extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<3, 4, Magnum::Float>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<4, 3, float>>; extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<4, 3, Magnum::Float>>;
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<2, 3, double>>; extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<2, 3, Magnum::Double>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<3, 2, double>>; extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<3, 2, Magnum::Double>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<2, 4, double>>; extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<2, 4, Magnum::Double>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<4, 2, double>>; extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<4, 2, Magnum::Double>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<3, 4, double>>; extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<3, 4, Magnum::Double>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<4, 3, double>>; extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::RectangularMatrix<4, 3, Magnum::Double>>;
#endif #endif
#endif #endif

2
src/Math/Swizzle.h

@ -50,7 +50,7 @@ namespace Implementation {
Creates new vector from given components. Example: Creates new vector from given components. Example:
@code @code
Vector4<std::int32_t> original(-1, 2, 3, 4); Vector4<Int> original(-1, 2, 3, 4);
auto vec = swizzle<'w', '1', '0', 'x', 'y', 'z'>(original); auto vec = swizzle<'w', '1', '0', 'x', 'y', 'z'>(original);
// vec == { 4, 1, 0, -1, 2, 3 } // vec == { 4, 1, 0, -1, 2, 3 }

32
src/Math/Test/AngleTest.cpp

@ -32,10 +32,10 @@ class AngleTest: public Corrade::TestSuite::Tester {
void debugRad(); void debugRad();
}; };
typedef Math::Deg<float> Deg; typedef Math::Deg<Float> Deg;
typedef Math::Rad<float> Rad; typedef Math::Rad<Float> Rad;
typedef Math::Deg<double> Degd; typedef Math::Deg<Double> Degd;
typedef Math::Rad<double> Radd; typedef Math::Rad<Double> Radd;
AngleTest::AngleTest() { AngleTest::AngleTest() {
addTests(&AngleTest::construct, addTests(&AngleTest::construct,
@ -50,14 +50,14 @@ void AngleTest::construct() {
/* Default constructor */ /* Default constructor */
constexpr Degd a; constexpr Degd a;
constexpr Deg m; constexpr Deg m;
CORRADE_COMPARE(double(a), 0.0f); CORRADE_COMPARE(Double(a), 0.0f);
CORRADE_COMPARE(float(m), 0.0f); CORRADE_COMPARE(Float(m), 0.0f);
/* Value constructor */ /* Value constructor */
constexpr Deg b(25.0); constexpr Deg b(25.0);
constexpr Radd n(3.14); constexpr Radd n(3.14);
CORRADE_COMPARE(float(b), 25.0); CORRADE_COMPARE(Float(b), 25.0);
CORRADE_COMPARE(double(n), 3.14); CORRADE_COMPARE(Double(n), 3.14);
/* Copy constructor */ /* Copy constructor */
constexpr Deg c(b); constexpr Deg c(b);
@ -68,8 +68,8 @@ void AngleTest::construct() {
/* Conversion operator */ /* Conversion operator */
constexpr Degd d(b); constexpr Degd d(b);
constexpr Rad p(n); constexpr Rad p(n);
CORRADE_COMPARE(double(d), 25.0); CORRADE_COMPARE(Double(d), 25.0);
CORRADE_COMPARE(float(p), 3.14f); CORRADE_COMPARE(Float(p), 3.14f);
} }
void AngleTest::literals() { void AngleTest::literals() {
@ -77,23 +77,23 @@ void AngleTest::literals() {
constexpr auto b = 25.0_degf; constexpr auto b = 25.0_degf;
CORRADE_VERIFY((std::is_same<decltype(a), const Degd>::value)); CORRADE_VERIFY((std::is_same<decltype(a), const Degd>::value));
CORRADE_VERIFY((std::is_same<decltype(b), const Deg>::value)); CORRADE_VERIFY((std::is_same<decltype(b), const Deg>::value));
CORRADE_COMPARE(double(a), 25.0); CORRADE_COMPARE(Double(a), 25.0);
CORRADE_COMPARE(float(b), 25.0f); CORRADE_COMPARE(Float(b), 25.0f);
constexpr auto m = 3.14_rad; constexpr auto m = 3.14_rad;
constexpr auto n = 3.14_radf; constexpr auto n = 3.14_radf;
CORRADE_VERIFY((std::is_same<decltype(m), const Radd>::value)); CORRADE_VERIFY((std::is_same<decltype(m), const Radd>::value));
CORRADE_VERIFY((std::is_same<decltype(n), const Rad>::value)); CORRADE_VERIFY((std::is_same<decltype(n), const Rad>::value));
CORRADE_COMPARE(double(m), 3.14); CORRADE_COMPARE(Double(m), 3.14);
CORRADE_COMPARE(float(n), 3.14f); CORRADE_COMPARE(Float(n), 3.14f);
} }
void AngleTest::conversion() { void AngleTest::conversion() {
constexpr Deg a(Rad(1.57079633f)); constexpr Deg a(Rad(1.57079633f));
CORRADE_COMPARE(float(a), 90.0f); CORRADE_COMPARE(Float(a), 90.0f);
constexpr Rad b(Deg(90.0f)); constexpr Rad b(Deg(90.0f));
CORRADE_COMPARE(float(b), 1.57079633f); CORRADE_COMPARE(Float(b), 1.57079633f);
} }
void AngleTest::debugDeg() { void AngleTest::debugDeg() {

2
src/Math/Test/BoolVectorTest.cpp

@ -121,7 +121,7 @@ void BoolVectorTest::constExpressions() {
/* Data access, pointer chasings, i.e. *(b.data()[3]), are not possible */ /* Data access, pointer chasings, i.e. *(b.data()[3]), are not possible */
constexpr bool e = b[2]; constexpr bool e = b[2];
constexpr std::uint8_t f = *b.data(); constexpr UnsignedByte f = *b.data();
CORRADE_COMPARE(e, true); CORRADE_COMPARE(e, true);
CORRADE_COMPARE(f, 0xa5); CORRADE_COMPARE(f, 0xa5);
} }

24
src/Math/Test/ComplexTest.cpp

@ -84,12 +84,12 @@ ComplexTest::ComplexTest() {
&ComplexTest::debug); &ComplexTest::debug);
} }
typedef Math::Deg<float> Deg; typedef Math::Deg<Float> Deg;
typedef Math::Rad<float> Rad; typedef Math::Rad<Float> Rad;
typedef Math::Complex<float> Complex; typedef Math::Complex<Float> Complex;
typedef Math::Vector2<float> Vector2; typedef Math::Vector2<Float> Vector2;
typedef Math::Matrix3<float> Matrix3; typedef Math::Matrix3<Float> Matrix3;
typedef Math::Matrix<2, float> Matrix2; typedef Math::Matrix<2, Float> Matrix2;
void ComplexTest::construct() { void ComplexTest::construct() {
Complex c(0.5f, -3.7f); Complex c(0.5f, -3.7f);
@ -111,10 +111,10 @@ void ComplexTest::constructFromVector() {
} }
void ComplexTest::compare() { void ComplexTest::compare() {
CORRADE_VERIFY(Complex(3.7f, -1.0f+MathTypeTraits<float>::epsilon()/2) == Complex(3.7f, -1.0f)); CORRADE_VERIFY(Complex(3.7f, -1.0f+MathTypeTraits<Float>::epsilon()/2) == Complex(3.7f, -1.0f));
CORRADE_VERIFY(Complex(3.7f, -1.0f+MathTypeTraits<float>::epsilon()*2) != Complex(3.7f, -1.0f)); CORRADE_VERIFY(Complex(3.7f, -1.0f+MathTypeTraits<Float>::epsilon()*2) != Complex(3.7f, -1.0f));
CORRADE_VERIFY(Complex(1.0f+MathTypeTraits<float>::epsilon()/2, 3.7f) == Complex(1.0f, 3.7f)); CORRADE_VERIFY(Complex(1.0f+MathTypeTraits<Float>::epsilon()/2, 3.7f) == Complex(1.0f, 3.7f));
CORRADE_VERIFY(Complex(1.0f+MathTypeTraits<float>::epsilon()*2, 3.7f) != Complex(1.0f, 3.7f)); CORRADE_VERIFY(Complex(1.0f+MathTypeTraits<Float>::epsilon()*2, 3.7f) != Complex(1.0f, 3.7f));
} }
void ComplexTest::constExpressions() { void ComplexTest::constExpressions() {
@ -135,8 +135,8 @@ void ComplexTest::constExpressions() {
CORRADE_COMPARE(d, Complex(2.5f, -5.0f)); CORRADE_COMPARE(d, Complex(2.5f, -5.0f));
/* Data access */ /* Data access */
constexpr float e = b.real(); constexpr Float e = b.real();
constexpr float f = b.imaginary(); constexpr Float f = b.imaginary();
constexpr Vector2 g(b); constexpr Vector2 g(b);
CORRADE_COMPARE(e, 2.5f); CORRADE_COMPARE(e, 2.5f);
CORRADE_COMPARE(f, -5.0f); CORRADE_COMPARE(f, -5.0f);

8
src/Math/Test/ConstantsTest.cpp

@ -32,11 +32,11 @@ ConstantsTest::ConstantsTest() {
} }
void ConstantsTest::constants() { void ConstantsTest::constants() {
CORRADE_COMPARE(Math::pow<2>(Constants<float>::sqrt2()), 2.0f); CORRADE_COMPARE(Math::pow<2>(Constants<Float>::sqrt2()), 2.0f);
CORRADE_COMPARE(Math::pow<2>(Constants<float>::sqrt3()), 3.0f); CORRADE_COMPARE(Math::pow<2>(Constants<Float>::sqrt3()), 3.0f);
CORRADE_COMPARE(Math::pow<2>(Constants<double>::sqrt2()), 2.0); CORRADE_COMPARE(Math::pow<2>(Constants<Double>::sqrt2()), 2.0);
CORRADE_COMPARE(Math::pow<2>(Constants<double>::sqrt3()), 3.0); CORRADE_COMPARE(Math::pow<2>(Constants<Double>::sqrt3()), 3.0);
} }
}}} }}}

14
src/Math/Test/DualComplexTest.cpp

@ -52,13 +52,13 @@ class DualComplexTest: public Corrade::TestSuite::Tester {
void debug(); void debug();
}; };
typedef Math::Deg<float> Deg; typedef Math::Deg<Float> Deg;
typedef Math::Rad<float> Rad; typedef Math::Rad<Float> Rad;
typedef Math::Complex<float> Complex; typedef Math::Complex<Float> Complex;
typedef Math::Dual<float> Dual; typedef Math::Dual<Float> Dual;
typedef Math::DualComplex<float> DualComplex; typedef Math::DualComplex<Float> DualComplex;
typedef Math::Matrix3<float> Matrix3; typedef Math::Matrix3<Float> Matrix3;
typedef Math::Vector2<float> Vector2; typedef Math::Vector2<Float> Vector2;
DualComplexTest::DualComplexTest() { DualComplexTest::DualComplexTest() {
addTests(&DualComplexTest::construct, addTests(&DualComplexTest::construct,

16
src/Math/Test/DualQuaternionTest.cpp

@ -50,13 +50,13 @@ class DualQuaternionTest: public Corrade::TestSuite::Tester {
void debug(); void debug();
}; };
typedef Math::Deg<float> Deg; typedef Math::Deg<Float> Deg;
typedef Math::Rad<float> Rad; typedef Math::Rad<Float> Rad;
typedef Math::Dual<float> Dual; typedef Math::Dual<Float> Dual;
typedef Math::Matrix4<float> Matrix4; typedef Math::Matrix4<Float> Matrix4;
typedef Math::DualQuaternion<float> DualQuaternion; typedef Math::DualQuaternion<Float> DualQuaternion;
typedef Math::Quaternion<float> Quaternion; typedef Math::Quaternion<Float> Quaternion;
typedef Math::Vector3<float> Vector3; typedef Math::Vector3<Float> Vector3;
DualQuaternionTest::DualQuaternionTest() { DualQuaternionTest::DualQuaternionTest() {
addTests(&DualQuaternionTest::construct, addTests(&DualQuaternionTest::construct,
@ -184,7 +184,7 @@ void DualQuaternionTest::rotation() {
std::ostringstream o; std::ostringstream o;
Error::setOutput(&o); Error::setOutput(&o);
Vector3 axis(1.0f/Constants<float>::sqrt3()); Vector3 axis(1.0f/Constants<Float>::sqrt3());
CORRADE_COMPARE(DualQuaternion::rotation(Deg(120.0f), axis*2.0f), DualQuaternion()); CORRADE_COMPARE(DualQuaternion::rotation(Deg(120.0f), axis*2.0f), DualQuaternion());
CORRADE_COMPARE(o.str(), "Math::Quaternion::rotation(): axis must be normalized\n"); CORRADE_COMPARE(o.str(), "Math::Quaternion::rotation(): axis must be normalized\n");

14
src/Math/Test/DualTest.cpp

@ -40,7 +40,7 @@ class DualTest: public Corrade::TestSuite::Tester {
void debug(); void debug();
}; };
typedef Math::Dual<float> Dual; typedef Math::Dual<Float> Dual;
DualTest::DualTest() { DualTest::DualTest() {
addTests(&DualTest::construct, addTests(&DualTest::construct,
@ -74,10 +74,10 @@ void DualTest::constructDefault() {
} }
void DualTest::compare() { void DualTest::compare() {
CORRADE_VERIFY(Dual(1.0f, 1.0f+MathTypeTraits<float>::epsilon()/2) == Dual(1.0f, 1.0f)); CORRADE_VERIFY(Dual(1.0f, 1.0f+MathTypeTraits<Float>::epsilon()/2) == Dual(1.0f, 1.0f));
CORRADE_VERIFY(Dual(1.0f, 1.0f+MathTypeTraits<float>::epsilon()*2) != Dual(1.0f, 1.0f)); CORRADE_VERIFY(Dual(1.0f, 1.0f+MathTypeTraits<Float>::epsilon()*2) != Dual(1.0f, 1.0f));
CORRADE_VERIFY(Dual(1.0f+MathTypeTraits<float>::epsilon()/2, 1.0f) == Dual(1.0f, 1.0f)); CORRADE_VERIFY(Dual(1.0f+MathTypeTraits<Float>::epsilon()/2, 1.0f) == Dual(1.0f, 1.0f));
CORRADE_VERIFY(Dual(1.0f+MathTypeTraits<float>::epsilon()*2, 1.0f) != Dual(1.0f, 1.0f)); CORRADE_VERIFY(Dual(1.0f+MathTypeTraits<Float>::epsilon()*2, 1.0f) != Dual(1.0f, 1.0f));
/* Compare to real part only */ /* Compare to real part only */
CORRADE_VERIFY(Dual(1.0f, 0.0f) == 1.0f); CORRADE_VERIFY(Dual(1.0f, 0.0f) == 1.0f);
@ -98,8 +98,8 @@ void DualTest::constExpressions() {
CORRADE_COMPARE(c, Dual(2.0f, 3.0f)); CORRADE_COMPARE(c, Dual(2.0f, 3.0f));
/* Data access */ /* Data access */
constexpr float e = b.real(); constexpr Float e = b.real();
constexpr float f = b.dual(); constexpr Float f = b.dual();
CORRADE_COMPARE(e, 2.0f); CORRADE_COMPARE(e, 2.0f);
CORRADE_COMPARE(f, 3.0f); CORRADE_COMPARE(f, 3.0f);
} }

156
src/Math/Test/FunctionsTest.cpp

@ -45,13 +45,13 @@ class FunctionsTest: public Corrade::TestSuite::Tester {
void trigonometric(); void trigonometric();
}; };
typedef Math::Constants<float> Constants; typedef Math::Constants<Float> Constants;
typedef Math::Deg<float> Deg; typedef Math::Deg<Float> Deg;
typedef Math::Rad<float> Rad; typedef Math::Rad<Float> Rad;
typedef Math::Vector3<float> Vector3; typedef Math::Vector3<Float> Vector3;
typedef Math::Vector3<std::uint8_t> Vector3ub; typedef Math::Vector3<UnsignedByte> Vector3ub;
typedef Math::Vector3<std::int8_t> Vector3b; typedef Math::Vector3<Byte> Vector3b;
typedef Math::Vector3<std::int32_t> Vector3i; typedef Math::Vector3<Int> Vector3i;
FunctionsTest::FunctionsTest() { FunctionsTest::FunctionsTest() {
addTests(&FunctionsTest::min, 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)); CORRADE_COMPARE(Math::lerp(a, b, 0.25f), Vector3(0.0f, 1.0f, 5.0f));
/* Integer vector */ /* Integer vector */
typedef Math::Vector<3, std::int32_t> Vector3ub; typedef Math::Vector<3, Int> Vector3ub;
Vector3ub c(0, 128, 64); Vector3ub c(0, 128, 64);
Vector3ub d(16, 0, 32); Vector3ub d(16, 0, 32);
CORRADE_COMPARE(Math::lerp(c, d, 0.25f), Vector3ub(4, 96, 56)); CORRADE_COMPARE(Math::lerp(c, d, 0.25f), Vector3ub(4, 96, 56));
} }
void FunctionsTest::normalizeUnsigned() { void FunctionsTest::normalizeUnsigned() {
CORRADE_COMPARE((Math::normalize<float, std::uint8_t>(0)), 0.0f); CORRADE_COMPARE((Math::normalize<Float, UnsignedByte>(0)), 0.0f);
CORRADE_COMPARE((Math::normalize<float, std::uint8_t>(255)), 1.0f); CORRADE_COMPARE((Math::normalize<Float, UnsignedByte>(255)), 1.0f);
CORRADE_COMPARE((Math::normalize<double, std::uint32_t>(0)), 0.0); CORRADE_COMPARE((Math::normalize<Double, UnsignedInt>(0)), 0.0);
CORRADE_COMPARE((Math::normalize<double, std::uint32_t>(std::numeric_limits<std::uint32_t>::max())), 1.0); CORRADE_COMPARE((Math::normalize<Double, UnsignedInt>(std::numeric_limits<UnsignedInt>::max())), 1.0);
CORRADE_COMPARE((Math::normalize<long double, std::uint64_t>(0)), 0.0); CORRADE_COMPARE((Math::normalize<long double, UnsignedLong>(0)), 0.0);
CORRADE_COMPARE((Math::normalize<long double, std::uint64_t>(std::numeric_limits<std::uint64_t>::max())), 1.0); CORRADE_COMPARE((Math::normalize<long double, UnsignedLong>(std::numeric_limits<UnsignedLong>::max())), 1.0);
CORRADE_COMPARE((Math::normalize<float, std::uint16_t>(0)), 0.0f); CORRADE_COMPARE((Math::normalize<Float, UnsignedShort>(0)), 0.0f);
CORRADE_COMPARE((Math::normalize<float, std::uint16_t>(std::numeric_limits<std::uint16_t>::max())), 1.0f); CORRADE_COMPARE((Math::normalize<Float, UnsignedShort>(std::numeric_limits<UnsignedShort>::max())), 1.0f);
CORRADE_COMPARE((Math::normalize<float, std::uint16_t>(8192)), 0.125002f); CORRADE_COMPARE((Math::normalize<Float, UnsignedShort>(8192)), 0.125002f);
CORRADE_COMPARE((Math::normalize<float, std::uint16_t>(49152)), 0.750011f); CORRADE_COMPARE((Math::normalize<Float, UnsignedShort>(49152)), 0.750011f);
CORRADE_COMPARE(Math::normalize<Vector3>(Vector3ub(0, 127, 255)), Vector3(0.0f, 0.498039f, 1.0f)); CORRADE_COMPARE(Math::normalize<Vector3>(Vector3ub(0, 127, 255)), Vector3(0.0f, 0.498039f, 1.0f));
} }
void FunctionsTest::normalizeSigned() { void FunctionsTest::normalizeSigned() {
CORRADE_COMPARE((Math::normalize<float, std::int8_t>(127)), 1.0f); CORRADE_COMPARE((Math::normalize<Float, Byte>(127)), 1.0f);
CORRADE_COMPARE((Math::normalize<float, std::int8_t>(0)), 0.0f); CORRADE_COMPARE((Math::normalize<Float, Byte>(0)), 0.0f);
CORRADE_COMPARE((Math::normalize<float, std::int8_t>(-128)), -1.0f); CORRADE_COMPARE((Math::normalize<Float, Byte>(-128)), -1.0f);
CORRADE_COMPARE((Math::normalize<float, std::int16_t>(std::numeric_limits<std::int16_t>::min())), -1.0f); CORRADE_COMPARE((Math::normalize<Float, Short>(std::numeric_limits<Short>::min())), -1.0f);
CORRADE_COMPARE((Math::normalize<float, std::int16_t>(0)), 0.0f); CORRADE_COMPARE((Math::normalize<Float, Short>(0)), 0.0f);
CORRADE_COMPARE((Math::normalize<float, std::int16_t>(std::numeric_limits<std::int16_t>::max())), 1.0f); CORRADE_COMPARE((Math::normalize<Float, Short>(std::numeric_limits<Short>::max())), 1.0f);
CORRADE_COMPARE((Math::normalize<double, std::int32_t>(std::numeric_limits<std::int32_t>::min())), -1.0); CORRADE_COMPARE((Math::normalize<Double, Int>(std::numeric_limits<Int>::min())), -1.0);
CORRADE_COMPARE((Math::normalize<double, std::int32_t>(0)), 0.0); CORRADE_COMPARE((Math::normalize<Double, Int>(0)), 0.0);
CORRADE_COMPARE((Math::normalize<double, std::int32_t>(std::numeric_limits<std::int32_t>::max())), 1.0); CORRADE_COMPARE((Math::normalize<Double, Int>(std::numeric_limits<Int>::max())), 1.0);
CORRADE_COMPARE((Math::normalize<long double, std::int64_t>(std::numeric_limits<std::int64_t>::min())), -1.0); CORRADE_COMPARE((Math::normalize<long double, Long>(std::numeric_limits<Long>::min())), -1.0);
CORRADE_COMPARE((Math::normalize<long double, std::int64_t>(0)), 0.0); CORRADE_COMPARE((Math::normalize<long double, Long>(0)), 0.0);
CORRADE_COMPARE((Math::normalize<long double, std::int64_t>(std::numeric_limits<std::int64_t>::max())), 1.0); CORRADE_COMPARE((Math::normalize<long double, Long>(std::numeric_limits<Long>::max())), 1.0);
CORRADE_COMPARE((Math::normalize<float, std::int16_t>(16384)), 0.500015f); CORRADE_COMPARE((Math::normalize<Float, Short>(16384)), 0.500015f);
CORRADE_COMPARE((Math::normalize<float, std::int16_t>(-16384)), -0.500015f); CORRADE_COMPARE((Math::normalize<Float, Short>(-16384)), -0.500015f);
CORRADE_COMPARE(Math::normalize<Vector3>(Vector3b(0, -127, 64)), Vector3(0.0f, -1.0f, 0.503937f)); CORRADE_COMPARE(Math::normalize<Vector3>(Vector3b(0, -127, 64)), Vector3(0.0f, -1.0f, 0.503937f));
} }
void FunctionsTest::denormalizeUnsigned() { void FunctionsTest::denormalizeUnsigned() {
CORRADE_COMPARE(Math::denormalize<std::uint8_t>(0.0f), 0); CORRADE_COMPARE(Math::denormalize<UnsignedByte>(0.0f), 0);
CORRADE_COMPARE(Math::denormalize<std::uint8_t>(1.0f), 255); CORRADE_COMPARE(Math::denormalize<UnsignedByte>(1.0f), 255);
CORRADE_COMPARE(Math::denormalize<std::uint16_t>(0.0f), 0); CORRADE_COMPARE(Math::denormalize<UnsignedShort>(0.0f), 0);
CORRADE_COMPARE(Math::denormalize<std::uint16_t>(1.0f), std::numeric_limits<std::uint16_t>::max()); CORRADE_COMPARE(Math::denormalize<UnsignedShort>(1.0f), std::numeric_limits<UnsignedShort>::max());
CORRADE_COMPARE(Math::denormalize<std::uint32_t>(0.0), 0); CORRADE_COMPARE(Math::denormalize<UnsignedInt>(0.0), 0);
CORRADE_COMPARE(Math::denormalize<std::uint32_t>(1.0), std::numeric_limits<std::uint32_t>::max()); CORRADE_COMPARE(Math::denormalize<UnsignedInt>(1.0), std::numeric_limits<UnsignedInt>::max());
CORRADE_COMPARE(Math::denormalize<std::uint64_t>(0.0), 0); CORRADE_COMPARE(Math::denormalize<UnsignedLong>(0.0), 0);
CORRADE_COMPARE(Math::denormalize<std::uint64_t>(1.0), std::numeric_limits<std::uint64_t>::max()); CORRADE_COMPARE(Math::denormalize<UnsignedLong>(1.0), std::numeric_limits<UnsignedLong>::max());
CORRADE_COMPARE(Math::denormalize<std::uint16_t>(0.33f), 21626); CORRADE_COMPARE(Math::denormalize<UnsignedShort>(0.33f), 21626);
CORRADE_COMPARE(Math::denormalize<std::uint16_t>(0.66f), 43253); CORRADE_COMPARE(Math::denormalize<UnsignedShort>(0.66f), 43253);
CORRADE_COMPARE(Math::denormalize<Vector3ub>(Vector3(0.0f, 0.5f, 1.0f)), Vector3ub(0, 127, 255)); CORRADE_COMPARE(Math::denormalize<Vector3ub>(Vector3(0.0f, 0.5f, 1.0f)), Vector3ub(0, 127, 255));
} }
void FunctionsTest::denormalizeSigned() { void FunctionsTest::denormalizeSigned() {
CORRADE_COMPARE(Math::denormalize<std::int8_t>(-1.0f), -127); CORRADE_COMPARE(Math::denormalize<Byte>(-1.0f), -127);
CORRADE_COMPARE(Math::denormalize<std::int8_t>(0.0f), 0); CORRADE_COMPARE(Math::denormalize<Byte>(0.0f), 0);
CORRADE_COMPARE(Math::denormalize<std::int8_t>(1.0f), 127); CORRADE_COMPARE(Math::denormalize<Byte>(1.0f), 127);
CORRADE_COMPARE(Math::denormalize<std::int16_t>(-1.0f), std::numeric_limits<std::int16_t>::min()+1); CORRADE_COMPARE(Math::denormalize<Short>(-1.0f), std::numeric_limits<Short>::min()+1);
CORRADE_COMPARE(Math::denormalize<std::int16_t>(0.0f), 0); CORRADE_COMPARE(Math::denormalize<Short>(0.0f), 0);
CORRADE_COMPARE(Math::denormalize<std::int16_t>(1.0f), std::numeric_limits<std::int16_t>::max()); CORRADE_COMPARE(Math::denormalize<Short>(1.0f), std::numeric_limits<Short>::max());
CORRADE_COMPARE(Math::denormalize<std::int32_t>(-1.0), std::numeric_limits<std::int32_t>::min()+1); CORRADE_COMPARE(Math::denormalize<Int>(-1.0), std::numeric_limits<Int>::min()+1);
CORRADE_COMPARE(Math::denormalize<std::int32_t>(0.0), 0); CORRADE_COMPARE(Math::denormalize<Int>(0.0), 0);
CORRADE_COMPARE(Math::denormalize<std::int32_t>(1.0), std::numeric_limits<std::int32_t>::max()); CORRADE_COMPARE(Math::denormalize<Int>(1.0), std::numeric_limits<Int>::max());
CORRADE_COMPARE(Math::denormalize<std::int64_t>(-1.0l), std::numeric_limits<std::int64_t>::min()+1); CORRADE_COMPARE(Math::denormalize<Long>(-1.0l), std::numeric_limits<Long>::min()+1);
CORRADE_COMPARE(Math::denormalize<std::int64_t>(0.0l), 0); CORRADE_COMPARE(Math::denormalize<Long>(0.0l), 0);
CORRADE_COMPARE(Math::denormalize<std::int64_t>(1.0l), std::numeric_limits<std::int64_t>::max()); CORRADE_COMPARE(Math::denormalize<Long>(1.0l), std::numeric_limits<Long>::max());
CORRADE_COMPARE(Math::denormalize<std::int16_t>(-0.33f), -10813); CORRADE_COMPARE(Math::denormalize<Short>(-0.33f), -10813);
CORRADE_COMPARE(Math::denormalize<std::int16_t>(0.66f), 21626); CORRADE_COMPARE(Math::denormalize<Short>(0.66f), 21626);
CORRADE_COMPARE(Math::denormalize<Vector3b>(Vector3(0.0f, -1.0f, 0.5f)), Vector3b(0, -127, 63)); CORRADE_COMPARE(Math::denormalize<Vector3b>(Vector3(0.0f, -1.0f, 0.5f)), Vector3b(0, -127, 63));
} }
void FunctionsTest::renormalizeUnsinged() { void FunctionsTest::renormalizeUnsinged() {
CORRADE_COMPARE(Math::normalize<float>(Math::denormalize<std::uint8_t>(0.0f)), 0.0f); CORRADE_COMPARE(Math::normalize<Float>(Math::denormalize<UnsignedByte>(0.0f)), 0.0f);
CORRADE_COMPARE(Math::normalize<float>(Math::denormalize<std::uint8_t>(1.0f)), 1.0f); CORRADE_COMPARE(Math::normalize<Float>(Math::denormalize<UnsignedByte>(1.0f)), 1.0f);
CORRADE_COMPARE(Math::normalize<float>(Math::denormalize<std::uint16_t>(0.0f)), 0.0f); CORRADE_COMPARE(Math::normalize<Float>(Math::denormalize<UnsignedShort>(0.0f)), 0.0f);
CORRADE_COMPARE(Math::normalize<float>(Math::denormalize<std::uint16_t>(1.0f)), 1.0f); CORRADE_COMPARE(Math::normalize<Float>(Math::denormalize<UnsignedShort>(1.0f)), 1.0f);
CORRADE_COMPARE(Math::normalize<double>(Math::denormalize<std::uint32_t>(0.0)), 0.0); CORRADE_COMPARE(Math::normalize<Double>(Math::denormalize<UnsignedInt>(0.0)), 0.0);
CORRADE_COMPARE(Math::normalize<double>(Math::denormalize<std::uint32_t>(1.0)), 1.0); CORRADE_COMPARE(Math::normalize<Double>(Math::denormalize<UnsignedInt>(1.0)), 1.0);
CORRADE_COMPARE(Math::normalize<long double>(Math::denormalize<std::uint64_t>(0.0l)), 0.0l); CORRADE_COMPARE(Math::normalize<long double>(Math::denormalize<UnsignedLong>(0.0l)), 0.0l);
CORRADE_COMPARE(Math::normalize<long double>(Math::denormalize<std::uint64_t>(1.0l)), 1.0l); CORRADE_COMPARE(Math::normalize<long double>(Math::denormalize<UnsignedLong>(1.0l)), 1.0l);
} }
void FunctionsTest::renormalizeSinged() { void FunctionsTest::renormalizeSinged() {
CORRADE_COMPARE(Math::normalize<float>(Math::denormalize<std::int8_t>(-1.0f)), -1.0f); CORRADE_COMPARE(Math::normalize<Float>(Math::denormalize<Byte>(-1.0f)), -1.0f);
CORRADE_COMPARE(Math::normalize<float>(Math::denormalize<std::int8_t>(0.0f)), 0.0f); CORRADE_COMPARE(Math::normalize<Float>(Math::denormalize<Byte>(0.0f)), 0.0f);
CORRADE_COMPARE(Math::normalize<float>(Math::denormalize<std::int8_t>(1.0f)), 1.0f); CORRADE_COMPARE(Math::normalize<Float>(Math::denormalize<Byte>(1.0f)), 1.0f);
CORRADE_COMPARE(Math::normalize<float>(Math::denormalize<std::int16_t>(-1.0f)), -1.0f); CORRADE_COMPARE(Math::normalize<Float>(Math::denormalize<Short>(-1.0f)), -1.0f);
CORRADE_COMPARE(Math::normalize<float>(Math::denormalize<std::int16_t>(0.0f)), 0.0f); CORRADE_COMPARE(Math::normalize<Float>(Math::denormalize<Short>(0.0f)), 0.0f);
CORRADE_COMPARE(Math::normalize<float>(Math::denormalize<std::int16_t>(1.0f)), 1.0f); CORRADE_COMPARE(Math::normalize<Float>(Math::denormalize<Short>(1.0f)), 1.0f);
CORRADE_COMPARE(Math::normalize<double>(Math::denormalize<std::int32_t>(-1.0)), -1.0); CORRADE_COMPARE(Math::normalize<Double>(Math::denormalize<Int>(-1.0)), -1.0);
CORRADE_COMPARE(Math::normalize<double>(Math::denormalize<std::int32_t>(0.0)), 0.0); CORRADE_COMPARE(Math::normalize<Double>(Math::denormalize<Int>(0.0)), 0.0);
CORRADE_COMPARE(Math::normalize<double>(Math::denormalize<std::int32_t>(1.0)), 1.0); CORRADE_COMPARE(Math::normalize<Double>(Math::denormalize<Int>(1.0)), 1.0);
CORRADE_COMPARE(Math::normalize<long double>(Math::denormalize<std::int64_t>(-1.0l)), -1.0l); CORRADE_COMPARE(Math::normalize<long double>(Math::denormalize<Long>(-1.0l)), -1.0l);
CORRADE_COMPARE(Math::normalize<long double>(Math::denormalize<std::int64_t>(0.0l)), 0.0l); CORRADE_COMPARE(Math::normalize<long double>(Math::denormalize<Long>(0.0l)), 0.0l);
CORRADE_COMPARE(Math::normalize<long double>(Math::denormalize<std::int64_t>(1.0l)), 1.0l); CORRADE_COMPARE(Math::normalize<long double>(Math::denormalize<Long>(1.0l)), 1.0l);
} }
void FunctionsTest::normalizeTypeDeduction() { void FunctionsTest::normalizeTypeDeduction() {
CORRADE_COMPARE(Math::normalize<float>('\x7F'), 1.0f); CORRADE_COMPARE(Math::normalize<Float>('\x7F'), 1.0f);
CORRADE_COMPARE((Math::normalize<float, std::int8_t>('\x7F')), 1.0f); CORRADE_COMPARE((Math::normalize<Float, Byte>('\x7F')), 1.0f);
} }
void FunctionsTest::pow() { void FunctionsTest::pow() {

20
src/Math/Test/MathTypeTraitsTest.cpp

@ -38,19 +38,19 @@ MathTypeTraitsTest::MathTypeTraitsTest() {
} }
void MathTypeTraitsTest::equalsIntegral() { void MathTypeTraitsTest::equalsIntegral() {
_equalsIntegral<std::uint8_t>(); _equalsIntegral<UnsignedByte>();
_equalsIntegral<std::int8_t>(); _equalsIntegral<Byte>();
_equalsIntegral<std::uint16_t>(); _equalsIntegral<UnsignedShort>();
_equalsIntegral<std::int16_t>(); _equalsIntegral<Short>();
_equalsIntegral<std::uint32_t>(); _equalsIntegral<UnsignedInt>();
_equalsIntegral<std::int32_t>(); _equalsIntegral<Int>();
_equalsIntegral<std::uint64_t>(); _equalsIntegral<UnsignedLong>();
_equalsIntegral<std::int64_t>(); _equalsIntegral<Long>();
} }
void MathTypeTraitsTest::equalsFloatingPoint() { void MathTypeTraitsTest::equalsFloatingPoint() {
_equalsFloatingPoint<float>(); _equalsFloatingPoint<Float>();
_equalsFloatingPoint<double>(); _equalsFloatingPoint<Double>();
} }
template<class T> void MathTypeTraitsTest::_equalsIntegral() { template<class T> void MathTypeTraitsTest::_equalsIntegral() {

8
src/Math/Test/Matrix3Test.cpp

@ -43,10 +43,10 @@ class Matrix3Test: public Corrade::TestSuite::Tester {
void configuration(); void configuration();
}; };
typedef Math::Deg<float> Deg; typedef Math::Deg<Float> Deg;
typedef Math::Matrix3<float> Matrix3; typedef Math::Matrix3<Float> Matrix3;
typedef Math::Matrix<2, float> Matrix2; typedef Math::Matrix<2, Float> Matrix2;
typedef Math::Vector2<float> Vector2; typedef Math::Vector2<Float> Vector2;
Matrix3Test::Matrix3Test() { Matrix3Test::Matrix3Test() {
addTests(&Matrix3Test::constructIdentity, addTests(&Matrix3Test::constructIdentity,

22
src/Math/Test/Matrix4Test.cpp

@ -48,11 +48,11 @@ class Matrix4Test: public Corrade::TestSuite::Tester {
void configuration(); void configuration();
}; };
typedef Math::Deg<float> Deg; typedef Math::Deg<Float> Deg;
typedef Math::Rad<float> Rad; typedef Math::Rad<Float> Rad;
typedef Math::Matrix4<float> Matrix4; typedef Math::Matrix4<Float> Matrix4;
typedef Math::Matrix<3, float> Matrix3; typedef Math::Matrix<3, Float> Matrix3;
typedef Math::Vector3<float> Vector3; typedef Math::Vector3<Float> Vector3;
Matrix4Test::Matrix4Test() { Matrix4Test::Matrix4Test() {
addTests(&Matrix4Test::constructIdentity, addTests(&Matrix4Test::constructIdentity,
@ -135,8 +135,8 @@ void Matrix4Test::rotationX() {
{0.0f, 0.90096887f, 0.43388374f, 0.0f}, {0.0f, 0.90096887f, 0.43388374f, 0.0f},
{0.0f, -0.43388374f, 0.90096887f, 0.0f}, {0.0f, -0.43388374f, 0.90096887f, 0.0f},
{0.0f, 0.0f, 0.0f, 1.0f}); {0.0f, 0.0f, 0.0f, 1.0f});
CORRADE_COMPARE(Matrix4::rotation(Rad(Math::Constants<float>::pi()/7), Vector3::xAxis()), matrix); CORRADE_COMPARE(Matrix4::rotation(Rad(Math::Constants<Float>::pi()/7), Vector3::xAxis()), matrix);
CORRADE_COMPARE(Matrix4::rotationX(Rad(Math::Constants<float>::pi()/7)), matrix); CORRADE_COMPARE(Matrix4::rotationX(Rad(Math::Constants<Float>::pi()/7)), matrix);
} }
void Matrix4Test::rotationY() { void Matrix4Test::rotationY() {
@ -144,8 +144,8 @@ void Matrix4Test::rotationY() {
{ 0.0f, 1.0f, 0.0f, 0.0f}, { 0.0f, 1.0f, 0.0f, 0.0f},
{0.43388374f, 0.0f, 0.90096887f, 0.0f}, {0.43388374f, 0.0f, 0.90096887f, 0.0f},
{ 0.0f, 0.0f, 0.0f, 1.0f}); { 0.0f, 0.0f, 0.0f, 1.0f});
CORRADE_COMPARE(Matrix4::rotation(Rad(Math::Constants<float>::pi()/7), Vector3::yAxis()), matrix); CORRADE_COMPARE(Matrix4::rotation(Rad(Math::Constants<Float>::pi()/7), Vector3::yAxis()), matrix);
CORRADE_COMPARE(Matrix4::rotationY(Rad(Math::Constants<float>::pi()/7)), matrix); CORRADE_COMPARE(Matrix4::rotationY(Rad(Math::Constants<Float>::pi()/7)), matrix);
} }
void Matrix4Test::rotationZ() { void Matrix4Test::rotationZ() {
@ -153,8 +153,8 @@ void Matrix4Test::rotationZ() {
{-0.43388374f, 0.90096887f, 0.0f, 0.0f}, {-0.43388374f, 0.90096887f, 0.0f, 0.0f},
{ 0.0f, 0.0f, 1.0f, 0.0f}, { 0.0f, 0.0f, 1.0f, 0.0f},
{ 0.0f, 0.0f, 0.0f, 1.0f}); { 0.0f, 0.0f, 0.0f, 1.0f});
CORRADE_COMPARE(Matrix4::rotation(Rad(Math::Constants<float>::pi()/7), Vector3::zAxis()), matrix); CORRADE_COMPARE(Matrix4::rotation(Rad(Math::Constants<Float>::pi()/7), Vector3::zAxis()), matrix);
CORRADE_COMPARE(Matrix4::rotationZ(Rad(Math::Constants<float>::pi()/7)), matrix); CORRADE_COMPARE(Matrix4::rotationZ(Rad(Math::Constants<Float>::pi()/7)), matrix);
} }
void Matrix4Test::reflection() { void Matrix4Test::reflection() {

34
src/Math/Test/MatrixTest.cpp

@ -37,10 +37,10 @@ class MatrixTest: public Corrade::TestSuite::Tester {
void configuration(); void configuration();
}; };
typedef Matrix<4, float> Matrix4; typedef Matrix<4, Float> Matrix4;
typedef Matrix<3, float> Matrix3; typedef Matrix<3, Float> Matrix3;
typedef Vector<4, float> Vector4; typedef Vector<4, Float> Vector4;
typedef Vector<3, float> Vector3; typedef Vector<3, Float> Vector3;
MatrixTest::MatrixTest() { MatrixTest::MatrixTest() {
addTests(&MatrixTest::construct, addTests(&MatrixTest::construct,
@ -55,7 +55,7 @@ MatrixTest::MatrixTest() {
} }
void MatrixTest::construct() { void MatrixTest::construct() {
float m[] = { Float m[] = {
3.0f, 5.0f, 8.0f, 4.0f, 3.0f, 5.0f, 8.0f, 4.0f,
4.0f, 4.0f, 7.0f, 3.0f, 4.0f, 4.0f, 7.0f, 3.0f,
7.0f, -1.0f, 8.0f, 0.0f, 7.0f, -1.0f, 8.0f, 0.0f,
@ -102,12 +102,12 @@ void MatrixTest::constructZero() {
} }
void MatrixTest::trace() { void MatrixTest::trace() {
Matrix<5, std::int32_t> m( Matrix<5, Int> m(
Vector<5, std::int32_t>(1, 2, 3, 0, 0), Vector<5, Int>(1, 2, 3, 0, 0),
Vector<5, std::int32_t>(2, 3, 2, 1, -2), Vector<5, Int>(2, 3, 2, 1, -2),
Vector<5, std::int32_t>(1, 1, -20, 1, 0), Vector<5, Int>(1, 1, -20, 1, 0),
Vector<5, std::int32_t>(2, 0, 0, 10, 2), Vector<5, Int>(2, 0, 0, 10, 2),
Vector<5, std::int32_t>(3, 1, 0, 1, -2) Vector<5, Int>(3, 1, 0, 1, -2)
); );
CORRADE_COMPARE(m.trace(), -8); CORRADE_COMPARE(m.trace(), -8);
@ -127,12 +127,12 @@ void MatrixTest::ij() {
} }
void MatrixTest::determinant() { void MatrixTest::determinant() {
Matrix<5, std::int32_t> m( Matrix<5, Int> m(
Vector<5, std::int32_t>(1, 2, 2, 1, 0), Vector<5, Int>(1, 2, 2, 1, 0),
Vector<5, std::int32_t>(2, 3, 2, 1, -2), Vector<5, Int>(2, 3, 2, 1, -2),
Vector<5, std::int32_t>(1, 1, 1, 1, 0), Vector<5, Int>(1, 1, 1, 1, 0),
Vector<5, std::int32_t>(2, 0, 0, 1, 2), Vector<5, Int>(2, 0, 0, 1, 2),
Vector<5, std::int32_t>(3, 1, 0, 1, -2) Vector<5, Int>(3, 1, 0, 1, -2)
); );
CORRADE_COMPARE(m.determinant(), -2); CORRADE_COMPARE(m.determinant(), -2);

44
src/Math/Test/QuaternionTest.cpp

@ -57,13 +57,13 @@ class QuaternionTest: public Corrade::TestSuite::Tester {
void debug(); void debug();
}; };
typedef Math::Deg<float> Deg; typedef Math::Deg<Float> Deg;
typedef Math::Rad<float> Rad; typedef Math::Rad<Float> Rad;
typedef Math::Matrix<3, float> Matrix3; typedef Math::Matrix<3, Float> Matrix3;
typedef Math::Matrix4<float> Matrix4; typedef Math::Matrix4<Float> Matrix4;
typedef Math::Quaternion<float> Quaternion; typedef Math::Quaternion<Float> Quaternion;
typedef Math::Vector3<float> Vector3; typedef Math::Vector3<Float> Vector3;
typedef Math::Vector4<float> Vector4; typedef Math::Vector4<Float> Vector4;
QuaternionTest::QuaternionTest() { QuaternionTest::QuaternionTest() {
addTests(&QuaternionTest::construct, addTests(&QuaternionTest::construct,
@ -114,10 +114,10 @@ void QuaternionTest::constructFromVector() {
} }
void QuaternionTest::compare() { void QuaternionTest::compare() {
CORRADE_VERIFY(Quaternion({1.0f+MathTypeTraits<float>::epsilon()/2, 2.0f, 3.0f}, -4.0f) == Quaternion({1.0f, 2.0f, 3.0f}, -4.0f)); CORRADE_VERIFY(Quaternion({1.0f+MathTypeTraits<Float>::epsilon()/2, 2.0f, 3.0f}, -4.0f) == Quaternion({1.0f, 2.0f, 3.0f}, -4.0f));
CORRADE_VERIFY(Quaternion({1.0f+MathTypeTraits<float>::epsilon()*2, 2.0f, 3.0f}, -4.0f) != Quaternion({1.0f, 2.0f, 3.0f}, -4.0f)); CORRADE_VERIFY(Quaternion({1.0f+MathTypeTraits<Float>::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<float>::epsilon()/2) == Quaternion({4.0f, 2.0f, 3.0f}, -1.0f)); CORRADE_VERIFY(Quaternion({4.0f, 2.0f, 3.0f}, -1.0f+MathTypeTraits<Float>::epsilon()/2) == Quaternion({4.0f, 2.0f, 3.0f}, -1.0f));
CORRADE_VERIFY(Quaternion({4.0f, 2.0f, 3.0f}, -1.0f+MathTypeTraits<float>::epsilon()*2) != Quaternion({4.0f, 2.0f, 3.0f}, -1.0f)); CORRADE_VERIFY(Quaternion({4.0f, 2.0f, 3.0f}, -1.0f+MathTypeTraits<Float>::epsilon()*2) != Quaternion({4.0f, 2.0f, 3.0f}, -1.0f));
} }
void QuaternionTest::constExpressions() { void QuaternionTest::constExpressions() {
@ -139,7 +139,7 @@ void QuaternionTest::constExpressions() {
/* Data access */ /* Data access */
constexpr Vector3 e = b.vector(); 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(e, Vector3(1.0f, -3.0f, 7.0f));
CORRADE_COMPARE(f, 2.5f); CORRADE_COMPARE(f, 2.5f);
} }
@ -215,7 +215,7 @@ void QuaternionTest::invertedNormalized() {
Error::setOutput(&o); Error::setOutput(&o);
Quaternion notInverted = a.invertedNormalized(); Quaternion notInverted = a.invertedNormalized();
CORRADE_COMPARE(notInverted.vector(), Vector3()); CORRADE_COMPARE(notInverted.vector(), Vector3());
CORRADE_COMPARE(notInverted.scalar(), std::numeric_limits<float>::quiet_NaN()); CORRADE_COMPARE(notInverted.scalar(), std::numeric_limits<Float>::quiet_NaN());
CORRADE_COMPARE(o.str(), "Math::Quaternion::invertedNormalized(): quaternion must be normalized\n"); CORRADE_COMPARE(o.str(), "Math::Quaternion::invertedNormalized(): quaternion must be normalized\n");
Quaternion aNormalized = a.normalized(); Quaternion aNormalized = a.normalized();
@ -229,7 +229,7 @@ void QuaternionTest::rotation() {
std::ostringstream o; std::ostringstream o;
Error::setOutput(&o); Error::setOutput(&o);
Vector3 axis(1.0f/Constants<float>::sqrt3()); Vector3 axis(1.0f/Constants<Float>::sqrt3());
CORRADE_COMPARE(Quaternion::rotation(Deg(-74.0f), {-1.0f, 2.0f, 2.0f}), Quaternion()); 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"); CORRADE_COMPARE(o.str(), "Math::Quaternion::rotation(): axis must be normalized\n");
@ -273,8 +273,8 @@ void QuaternionTest::angle() {
} }
void QuaternionTest::matrix() { void QuaternionTest::matrix() {
Quaternion q = Quaternion::rotation(Deg(37.0f), Vector3(1.0f/Constants<float>::sqrt3())); Quaternion q = Quaternion::rotation(Deg(37.0f), Vector3(1.0f/Constants<Float>::sqrt3()));
Matrix3 m = Matrix4::rotation(Deg(37.0f), Vector3(1.0f/Constants<float>::sqrt3())).rotationScaling(); Matrix3 m = Matrix4::rotation(Deg(37.0f), Vector3(1.0f/Constants<Float>::sqrt3())).rotationScaling();
/* Verify that negated quaternion gives the same rotation */ /* Verify that negated quaternion gives the same rotation */
CORRADE_COMPARE(q.toMatrix(), m); CORRADE_COMPARE(q.toMatrix(), m);
@ -282,7 +282,7 @@ void QuaternionTest::matrix() {
} }
void QuaternionTest::lerp() { void QuaternionTest::lerp() {
Quaternion a = Quaternion::rotation(Deg(15.0f), Vector3(1.0f/Constants<float>::sqrt3())); Quaternion a = Quaternion::rotation(Deg(15.0f), Vector3(1.0f/Constants<Float>::sqrt3()));
Quaternion b = Quaternion::rotation(Deg(23.0f), Vector3::xAxis()); Quaternion b = Quaternion::rotation(Deg(23.0f), Vector3::xAxis());
std::ostringstream o; std::ostringstream o;
@ -290,13 +290,13 @@ void QuaternionTest::lerp() {
Quaternion notLerpA = Quaternion::lerp(a*3.0f, b, 0.35f); Quaternion notLerpA = Quaternion::lerp(a*3.0f, b, 0.35f);
CORRADE_COMPARE(notLerpA.vector(), Vector3()); CORRADE_COMPARE(notLerpA.vector(), Vector3());
CORRADE_COMPARE(notLerpA.scalar(), std::numeric_limits<float>::quiet_NaN()); CORRADE_COMPARE(notLerpA.scalar(), std::numeric_limits<Float>::quiet_NaN());
CORRADE_COMPARE(o.str(), "Math::Quaternion::lerp(): quaternions must be normalized\n"); CORRADE_COMPARE(o.str(), "Math::Quaternion::lerp(): quaternions must be normalized\n");
o.str({}); o.str({});
Quaternion notLerpB = Quaternion::lerp(a, b*-3.0f, 0.35f); Quaternion notLerpB = Quaternion::lerp(a, b*-3.0f, 0.35f);
CORRADE_COMPARE(notLerpB.vector(), Vector3()); CORRADE_COMPARE(notLerpB.vector(), Vector3());
CORRADE_COMPARE(notLerpB.scalar(), std::numeric_limits<float>::quiet_NaN()); CORRADE_COMPARE(notLerpB.scalar(), std::numeric_limits<Float>::quiet_NaN());
CORRADE_COMPARE(o.str(), "Math::Quaternion::lerp(): quaternions must be normalized\n"); CORRADE_COMPARE(o.str(), "Math::Quaternion::lerp(): quaternions must be normalized\n");
Quaternion lerp = Quaternion::lerp(a, b, 0.35f); Quaternion lerp = Quaternion::lerp(a, b, 0.35f);
@ -304,7 +304,7 @@ void QuaternionTest::lerp() {
} }
void QuaternionTest::slerp() { void QuaternionTest::slerp() {
Quaternion a = Quaternion::rotation(Deg(15.0f), Vector3(1.0f/Constants<float>::sqrt3())); Quaternion a = Quaternion::rotation(Deg(15.0f), Vector3(1.0f/Constants<Float>::sqrt3()));
Quaternion b = Quaternion::rotation(Deg(23.0f), Vector3::xAxis()); Quaternion b = Quaternion::rotation(Deg(23.0f), Vector3::xAxis());
std::ostringstream o; std::ostringstream o;
@ -312,13 +312,13 @@ void QuaternionTest::slerp() {
Quaternion notSlerpA = Quaternion::slerp(a*3.0f, b, 0.35f); Quaternion notSlerpA = Quaternion::slerp(a*3.0f, b, 0.35f);
CORRADE_COMPARE(notSlerpA.vector(), Vector3()); CORRADE_COMPARE(notSlerpA.vector(), Vector3());
CORRADE_COMPARE(notSlerpA.scalar(), std::numeric_limits<float>::quiet_NaN()); CORRADE_COMPARE(notSlerpA.scalar(), std::numeric_limits<Float>::quiet_NaN());
CORRADE_COMPARE(o.str(), "Math::Quaternion::slerp(): quaternions must be normalized\n"); CORRADE_COMPARE(o.str(), "Math::Quaternion::slerp(): quaternions must be normalized\n");
o.str({}); o.str({});
Quaternion notSlerpB = Quaternion::slerp(a, b*-3.0f, 0.35f); Quaternion notSlerpB = Quaternion::slerp(a, b*-3.0f, 0.35f);
CORRADE_COMPARE(notSlerpB.vector(), Vector3()); CORRADE_COMPARE(notSlerpB.vector(), Vector3());
CORRADE_COMPARE(notSlerpB.scalar(), std::numeric_limits<float>::quiet_NaN()); CORRADE_COMPARE(notSlerpB.scalar(), std::numeric_limits<Float>::quiet_NaN());
CORRADE_COMPARE(o.str(), "Math::Quaternion::slerp(): quaternions must be normalized\n"); CORRADE_COMPARE(o.str(), "Math::Quaternion::slerp(): quaternions must be normalized\n");
Quaternion slerp = Quaternion::slerp(a, b, 0.35f); Quaternion slerp = Quaternion::slerp(a, b, 0.35f);

78
src/Math/Test/RectangularMatrixTest.cpp

@ -55,14 +55,14 @@ class RectangularMatrixTest: public Corrade::TestSuite::Tester {
void configuration(); void configuration();
}; };
typedef RectangularMatrix<4, 3, float> Matrix4x3; typedef RectangularMatrix<4, 3, Float> Matrix4x3;
typedef RectangularMatrix<3, 4, float> Matrix3x4; typedef RectangularMatrix<3, 4, Float> Matrix3x4;
typedef RectangularMatrix<2, 2, float> Matrix2; typedef RectangularMatrix<2, 2, Float> Matrix2;
typedef RectangularMatrix<2, 2, std::int32_t> Matrix2i; typedef RectangularMatrix<2, 2, Int> Matrix2i;
typedef Vector<4, float> Vector4; typedef Vector<4, Float> Vector4;
typedef Vector<3, float> Vector3; typedef Vector<3, Float> Vector3;
typedef Vector<2, float> Vector2; typedef Vector<2, Float> Vector2;
typedef Vector<2, std::int32_t> Vector2i; typedef Vector<2, Int> Vector2i;
RectangularMatrixTest::RectangularMatrixTest() { RectangularMatrixTest::RectangularMatrixTest() {
addTests(&RectangularMatrixTest::constructFromData, addTests(&RectangularMatrixTest::constructFromData,
@ -96,7 +96,7 @@ RectangularMatrixTest::RectangularMatrixTest() {
} }
void RectangularMatrixTest::constructFromData() { void RectangularMatrixTest::constructFromData() {
float m[] = { Float m[] = {
3.0f, 5.0f, 8.0f, 4.0f, 3.0f, 5.0f, 8.0f, 4.0f,
4.0f, 4.0f, 7.0f, 3.0f, 4.0f, 4.0f, 7.0f, 3.0f,
7.0f, -1.0f, 8.0f, 0.0f 7.0f, -1.0f, 8.0f, 0.0f
@ -121,15 +121,15 @@ void RectangularMatrixTest::constructDefault() {
} }
void RectangularMatrixTest::constructConversion() { void RectangularMatrixTest::constructConversion() {
Matrix2 floatingPoint(Vector2( 1.3f, 2.7f), Matrix2 FloatingPoint(Vector2( 1.3f, 2.7f),
Vector2(-15.0f, 7.0f)); Vector2(-15.0f, 7.0f));
Matrix2 floatingPointRounded(Vector2(1.0f, 2.0f), Matrix2 FloatingPointRounded(Vector2(1.0f, 2.0f),
Vector2(-15.0f, 7.0f)); Vector2(-15.0f, 7.0f));
Matrix2i integral(Vector2i( 1, 2), Matrix2i integral(Vector2i( 1, 2),
Vector2i(-15, 7)); Vector2i(-15, 7));
CORRADE_COMPARE(Matrix2i(floatingPoint), integral); CORRADE_COMPARE(Matrix2i(FloatingPoint), integral);
CORRADE_COMPARE(Matrix2(integral), floatingPointRounded); CORRADE_COMPARE(Matrix2(integral), FloatingPointRounded);
} }
void RectangularMatrixTest::constructFromVectors() { void RectangularMatrixTest::constructFromVectors() {
@ -194,8 +194,8 @@ void RectangularMatrixTest::constExpressions() {
Vector4(7.0f, -1.7f, 8.0f, 0.0f))); Vector4(7.0f, -1.7f, 8.0f, 0.0f)));
/* Conversion constructor */ /* Conversion constructor */
typedef RectangularMatrix<3, 4, std::int32_t> Matrix3x4i; typedef RectangularMatrix<3, 4, Int> Matrix3x4i;
typedef Vector<4, std::int32_t> Vector4i; typedef Vector<4, Int> Vector4i;
constexpr Matrix3x4i c(b); constexpr Matrix3x4i c(b);
CORRADE_COMPARE(c, Matrix3x4i(Vector4i(3, 5, 8, 4), CORRADE_COMPARE(c, Matrix3x4i(Vector4i(3, 5, 8, 4),
Vector4i(4, 4, 7, 3), Vector4i(4, 4, 7, 3),
@ -209,8 +209,8 @@ void RectangularMatrixTest::constExpressions() {
/* Data access, pointer chasings, i.e. *(b.data()[1]), are not possible */ /* Data access, pointer chasings, i.e. *(b.data()[1]), are not possible */
constexpr Vector4 e = b[2]; constexpr Vector4 e = b[2];
constexpr float f = b[1][2]; constexpr Float f = b[1][2];
constexpr float g = *b.data(); constexpr Float g = *b.data();
CORRADE_COMPARE(e, Vector4(7.0f, -1.7f, 8.0f, 0.0f)); CORRADE_COMPARE(e, Vector4(7.0f, -1.7f, 8.0f, 0.0f));
CORRADE_COMPARE(f, 7.0f); CORRADE_COMPARE(f, 7.0f);
CORRADE_COMPARE(g, 3.0f); CORRADE_COMPARE(g, 3.0f);
@ -219,9 +219,9 @@ void RectangularMatrixTest::constExpressions() {
void RectangularMatrixTest::compare() { void RectangularMatrixTest::compare() {
Matrix2 a(Vector2(1.0f, -3.0f), Matrix2 a(Vector2(1.0f, -3.0f),
Vector2(5.0f, -10.0f)); Vector2(5.0f, -10.0f));
Matrix2 b(Vector2(1.0f + MathTypeTraits<float>::epsilon()/2, -3.0f), Matrix2 b(Vector2(1.0f + MathTypeTraits<Float>::epsilon()/2, -3.0f),
Vector2(5.0f, -10.0f)); Vector2(5.0f, -10.0f));
Matrix2 c(Vector2(1.0f, -1.0f + MathTypeTraits<float>::epsilon()*2), Matrix2 c(Vector2(1.0f, -1.0f + MathTypeTraits<Float>::epsilon()*2),
Vector2(5.0f, -10.0f)); Vector2(5.0f, -10.0f));
CORRADE_VERIFY(a == b); CORRADE_VERIFY(a == b);
CORRADE_VERIFY(a != c); CORRADE_VERIFY(a != c);
@ -270,8 +270,8 @@ void RectangularMatrixTest::multiplyDivide() {
CORRADE_COMPARE(-1.5f*matrix, multiplied); CORRADE_COMPARE(-1.5f*matrix, multiplied);
CORRADE_COMPARE(multiplied/-1.5f, matrix); CORRADE_COMPARE(multiplied/-1.5f, matrix);
Math::RectangularMatrix<1, 1, std::int8_t> matrixChar(32); Math::RectangularMatrix<1, 1, Byte> matrixChar(32);
Math::RectangularMatrix<1, 1, std::int8_t> multipliedChar(-48); Math::RectangularMatrix<1, 1, Byte> multipliedChar(-48);
CORRADE_COMPARE(matrixChar*-1.5f, multipliedChar); CORRADE_COMPARE(matrixChar*-1.5f, multipliedChar);
CORRADE_COMPARE(multipliedChar/-1.5f, matrixChar); CORRADE_COMPARE(multipliedChar/-1.5f, matrixChar);
CORRADE_COMPARE(-1.5f*matrixChar, multipliedChar); CORRADE_COMPARE(-1.5f*matrixChar, multipliedChar);
@ -286,27 +286,27 @@ void RectangularMatrixTest::multiplyDivide() {
} }
void RectangularMatrixTest::multiply() { void RectangularMatrixTest::multiply() {
RectangularMatrix<4, 6, std::int32_t> left( RectangularMatrix<4, 6, Int> left(
Vector<6, std::int32_t>(-5, 27, 10, 33, 0, -15), Vector<6, Int>(-5, 27, 10, 33, 0, -15),
Vector<6, std::int32_t>( 7, 56, 66, 1, 0, -24), Vector<6, Int>( 7, 56, 66, 1, 0, -24),
Vector<6, std::int32_t>( 4, 41, 4, 0, 1, -4), Vector<6, Int>( 4, 41, 4, 0, 1, -4),
Vector<6, std::int32_t>( 9, -100, 19, -49, 1, 9) Vector<6, Int>( 9, -100, 19, -49, 1, 9)
); );
RectangularMatrix<5, 4, std::int32_t> right( RectangularMatrix<5, 4, Int> right(
Vector<4, std::int32_t>(1, -7, 0, 158), Vector<4, Int>(1, -7, 0, 158),
Vector<4, std::int32_t>(2, 24, -3, 40), Vector<4, Int>(2, 24, -3, 40),
Vector<4, std::int32_t>(3, -15, -2, -50), Vector<4, Int>(3, -15, -2, -50),
Vector<4, std::int32_t>(4, 17, -1, -284), Vector<4, Int>(4, 17, -1, -284),
Vector<4, std::int32_t>(5, 30, 4, 18) Vector<4, Int>(5, 30, 4, 18)
); );
RectangularMatrix<5, 6, std::int32_t> expected( RectangularMatrix<5, 6, Int> expected(
Vector<6, std::int32_t>( 1368, -16165, 2550, -7716, 158, 1575), Vector<6, Int>( 1368, -16165, 2550, -7716, 158, 1575),
Vector<6, std::int32_t>( 506, -2725, 2352, -1870, 37, -234), Vector<6, Int>( 506, -2725, 2352, -1870, 37, -234),
Vector<6, std::int32_t>( -578, 4159, -1918, 2534, -52, -127), Vector<6, Int>( -578, 4159, -1918, 2534, -52, -127),
Vector<6, std::int32_t>(-2461, 29419, -4238, 14065, -285, -3020), Vector<6, Int>(-2461, 29419, -4238, 14065, -285, -3020),
Vector<6, std::int32_t>( 363, 179, 2388, -687, 22, -649) Vector<6, Int>( 363, 179, 2388, -687, 22, -649)
); );
CORRADE_COMPARE(left*right, expected); CORRADE_COMPARE(left*right, expected);
@ -399,7 +399,7 @@ void RectangularMatrixTest::debug() {
" 4, 3, 0)\n"); " 4, 3, 0)\n");
o.str({}); 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" CORRADE_COMPARE(o.str(), "a Matrix(0, 0, 0,\n"
" 0, 0, 0,\n" " 0, 0, 0,\n"
" 0, 0, 0,\n" " 0, 0, 0,\n"

10
src/Math/Test/SwizzleTest.cpp

@ -29,7 +29,7 @@ class SwizzleTest: public Corrade::TestSuite::Tester {
void constExpressions(); void constExpressions();
}; };
typedef Vector<4, std::int32_t> Vector4i; typedef Vector<4, Int> Vector4i;
SwizzleTest::SwizzleTest() { SwizzleTest::SwizzleTest() {
addTests(&SwizzleTest::components, addTests(&SwizzleTest::components,
@ -47,12 +47,12 @@ void SwizzleTest::constants() {
} }
void SwizzleTest::sizes() { void SwizzleTest::sizes() {
CORRADE_COMPARE((swizzle<'y', 'x', 'x'>(Math::Vector<2, std::int32_t>(1, 2))), CORRADE_COMPARE((swizzle<'y', 'x', 'x'>(Math::Vector<2, Int>(1, 2))),
(Math::Vector<3, std::int32_t>(2, 1, 1))); (Math::Vector<3, Int>(2, 1, 1)));
CORRADE_COMPARE(swizzle<'z'>(Vector4i(1, 2, 3, 4)), 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))), 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() { void SwizzleTest::constExpressions() {

14
src/Math/Test/UnitTest.cpp

@ -45,16 +45,16 @@ UnitTest::UnitTest() {
} }
template<class> struct Sec_; template<class> struct Sec_;
typedef Unit<Sec_, float> Sec; typedef Unit<Sec_, Float> Sec;
typedef Unit<Sec_, double> Secd; typedef Unit<Sec_, Double> Secd;
inline Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, Sec value) { inline Corrade::Utility::Debug operator<<(Corrade::Utility::Debug debug, Sec value) {
return debug << float(value); return debug << Float(value);
} }
void UnitTest::construct() { void UnitTest::construct() {
constexpr Sec a(25.0f); constexpr Sec a(25.0f);
CORRADE_COMPARE(float(a), 25.0f); CORRADE_COMPARE(Float(a), 25.0f);
} }
void UnitTest::constructDefault() { void UnitTest::constructDefault() {
@ -69,8 +69,8 @@ void UnitTest::constructConversion() {
} }
void UnitTest::compare() { void UnitTest::compare() {
CORRADE_VERIFY(Sec(25.0f + MathTypeTraits<float>::epsilon()/2) == Sec(25.0f)); CORRADE_VERIFY(Sec(25.0f + MathTypeTraits<Float>::epsilon()/2) == Sec(25.0f));
CORRADE_VERIFY(Sec(25.0f + MathTypeTraits<float>::epsilon()*2) != Sec(25.0f)); CORRADE_VERIFY(Sec(25.0f + MathTypeTraits<Float>::epsilon()*2) != Sec(25.0f));
constexpr bool c = Sec(3.0f) < Sec(3.0f); constexpr bool c = Sec(3.0f) < Sec(3.0f);
constexpr bool d = 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(e, b);
CORRADE_COMPARE(f, a); CORRADE_COMPARE(f, a);
constexpr float g = b/a; constexpr Float g = b/a;
CORRADE_COMPARE(g, -1.5f); CORRADE_COMPARE(g, -1.5f);
} }

4
src/Math/Test/Vector2Test.cpp

@ -34,7 +34,7 @@ class Vector2Test: public Corrade::TestSuite::Tester {
void configuration(); void configuration();
}; };
typedef Math::Vector2<float> Vector2; typedef Math::Vector2<Float> Vector2;
Vector2Test::Vector2Test() { Vector2Test::Vector2Test() {
addTests(&Vector2Test::construct, addTests(&Vector2Test::construct,
@ -46,7 +46,7 @@ Vector2Test::Vector2Test() {
} }
void Vector2Test::construct() { 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() { void Vector2Test::access() {

8
src/Math/Test/Vector3Test.cpp

@ -36,8 +36,8 @@ class Vector3Test: public Corrade::TestSuite::Tester {
void configuration(); void configuration();
}; };
typedef Math::Vector3<float> Vector3; typedef Math::Vector3<Float> Vector3;
typedef Math::Vector2<float> Vector2; typedef Math::Vector2<Float> Vector2;
Vector3Test::Vector3Test() { Vector3Test::Vector3Test() {
addTests(&Vector3Test::construct, addTests(&Vector3Test::construct,
@ -52,8 +52,8 @@ Vector3Test::Vector3Test() {
void Vector3Test::construct() { void Vector3Test::construct() {
CORRADE_COMPARE(Vector3(), Vector3(0.0f, 0.0f, 0.0f)); 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(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(Vector<2, Float>(1.0f, 2.0f), 3), (Vector<3, Float>(1.0f, 2.0f, 3.0f)));
} }
void Vector3Test::access() { void Vector3Test::access() {

10
src/Math/Test/Vector4Test.cpp

@ -34,9 +34,9 @@ class Vector4Test: public Corrade::TestSuite::Tester {
void configuration(); void configuration();
}; };
typedef Math::Vector4<float> Vector4; typedef Math::Vector4<Float> Vector4;
typedef Math::Vector3<float> Vector3; typedef Math::Vector3<Float> Vector3;
typedef Math::Vector2<float> Vector2; typedef Math::Vector2<Float> Vector2;
Vector4Test::Vector4Test() { Vector4Test::Vector4Test() {
addTests(&Vector4Test::construct, addTests(&Vector4Test::construct,
@ -49,8 +49,8 @@ Vector4Test::Vector4Test() {
void Vector4Test::construct() { void Vector4Test::construct() {
CORRADE_COMPARE(Vector4(), Vector4(0.0f, 0.0f, 0.0f, 0.0f)); 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(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(Vector<3, Float>(1.0f, 2.0f, 3.0f), 4), (Vector<4, Float>(1.0f, 2.0f, 3.0f, 4.0f)));
} }
void Vector4Test::access() { void Vector4Test::access() {

32
src/Math/Test/VectorTest.cpp

@ -62,10 +62,10 @@ class VectorTest: public Corrade::TestSuite::Tester {
void configuration(); void configuration();
}; };
typedef Math::Rad<float> Rad; typedef Math::Rad<Float> Rad;
typedef Vector<3, float> Vector3; typedef Vector<3, Float> Vector3;
typedef Vector<4, float> Vector4; typedef Vector<4, Float> Vector4;
typedef Vector<4, std::int32_t> Vector4i; typedef Vector<4, Int> Vector4i;
VectorTest::VectorTest() { VectorTest::VectorTest() {
addTests(&VectorTest::constructFromData, addTests(&VectorTest::constructFromData,
@ -106,7 +106,7 @@ VectorTest::VectorTest() {
} }
void VectorTest::constructFromData() { 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)); CORRADE_COMPARE(Vector4::from(data), Vector4(1.0f, 2.0f, 3.0f, 4.0f));
} }
@ -119,7 +119,7 @@ void VectorTest::constructOneValue() {
} }
void VectorTest::constructOneComponent() { void VectorTest::constructOneComponent() {
typedef Vector<1, float> Vector1; typedef Vector<1, Float> Vector1;
/* Implicit constructor must work */ /* Implicit constructor must work */
Vector1 vec = 1; Vector1 vec = 1;
@ -127,12 +127,12 @@ void VectorTest::constructOneComponent() {
} }
void VectorTest::constructConversion() { void VectorTest::constructConversion() {
Vector4 floatingPoint(1.3f, 2.7f, -15.0f, 7.0f); Vector4 FloatingPoint(1.3f, 2.7f, -15.0f, 7.0f);
Vector4 floatingPointRounded(1.0f, 2.0f, -15.0f, 7.0f); Vector4 FloatingPointRounded(1.0f, 2.0f, -15.0f, 7.0f);
Vector4i integral(1, 2, -15, 7); Vector4i integral(1, 2, -15, 7);
CORRADE_COMPARE(Vector4i(floatingPoint), integral); CORRADE_COMPARE(Vector4i(FloatingPoint), integral);
CORRADE_COMPARE(Vector4(integral), floatingPointRounded); CORRADE_COMPARE(Vector4(integral), FloatingPointRounded);
} }
void VectorTest::data() { void VectorTest::data() {
@ -167,15 +167,15 @@ void VectorTest::constExpressions() {
CORRADE_COMPARE(e, Vector4(1.0f, 3.5f, 4.0f, -2.7f)); CORRADE_COMPARE(e, Vector4(1.0f, 3.5f, 4.0f, -2.7f));
/* Data access, pointer chasings, i.e. *(b.data()[3]), are not possible */ /* Data access, pointer chasings, i.e. *(b.data()[3]), are not possible */
constexpr float f = b[3]; constexpr Float f = b[3];
constexpr float g = *b.data(); constexpr Float g = *b.data();
CORRADE_COMPARE(f, -2.7f); CORRADE_COMPARE(f, -2.7f);
CORRADE_COMPARE(g, 1.0f); CORRADE_COMPARE(g, 1.0f);
} }
void VectorTest::compare() { void VectorTest::compare() {
CORRADE_VERIFY(Vector4(1.0f, -3.5f, 5.0f, -10.0f) == Vector4(1.0f + MathTypeTraits<float>::epsilon()/2, -3.5f, 5.0f, -10.0f)); CORRADE_VERIFY(Vector4(1.0f, -3.5f, 5.0f, -10.0f) == Vector4(1.0f + MathTypeTraits<Float>::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<float>::epsilon()*2, 5.0f, -10.0f)); CORRADE_VERIFY(Vector4(1.0f, -1.0f, 5.0f, -10.0f) != Vector4(1.0f, -1.0f + MathTypeTraits<Float>::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, -3, 5, -10));
CORRADE_VERIFY(Vector4i(1, -3, 5, -10) != Vector4i(1, -2, 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(-1.5f*vector, multiplied);
CORRADE_COMPARE(multiplied/-1.5f, vector); CORRADE_COMPARE(multiplied/-1.5f, vector);
Math::Vector<1, std::int8_t> vectorChar(32); Math::Vector<1, Byte> vectorChar(32);
Math::Vector<1, std::int8_t> multipliedChar(-48); Math::Vector<1, Byte> multipliedChar(-48);
CORRADE_COMPARE(vectorChar*-1.5f, multipliedChar); CORRADE_COMPARE(vectorChar*-1.5f, multipliedChar);
CORRADE_COMPARE(multipliedChar/-1.5f, vectorChar); CORRADE_COMPARE(multipliedChar/-1.5f, vectorChar);
CORRADE_COMPARE(-1.5f*vectorChar, multipliedChar); CORRADE_COMPARE(-1.5f*vectorChar, multipliedChar);

48
src/Math/Vector.cpp

@ -18,19 +18,19 @@
namespace Magnum { namespace Math { namespace Magnum { namespace Math {
#ifndef DOXYGEN_GENERATING_OUTPUT #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<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<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<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<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<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<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<2, UnsignedInt>&);
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<3, UnsignedInt>&);
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<4, UnsignedInt>&);
#ifndef MAGNUM_TARGET_GLES #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<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<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<4, Double>&);
#endif #endif
#endif #endif
@ -39,19 +39,19 @@ template Corrade::Utility::Debug operator<<(Corrade::Utility::Debug, const Magnu
namespace Corrade { namespace Utility { namespace Corrade { namespace Utility {
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
template struct ConfigurationValue<Magnum::Math::Vector<2, float>>; template struct ConfigurationValue<Magnum::Math::Vector<2, Magnum::Float>>;
template struct ConfigurationValue<Magnum::Math::Vector<3, float>>; template struct ConfigurationValue<Magnum::Math::Vector<3, Magnum::Float>>;
template struct ConfigurationValue<Magnum::Math::Vector<4, float>>; template struct ConfigurationValue<Magnum::Math::Vector<4, Magnum::Float>>;
template struct ConfigurationValue<Magnum::Math::Vector<2, int>>; template struct ConfigurationValue<Magnum::Math::Vector<2, Magnum::Int>>;
template struct ConfigurationValue<Magnum::Math::Vector<3, int>>; template struct ConfigurationValue<Magnum::Math::Vector<3, Magnum::Int>>;
template struct ConfigurationValue<Magnum::Math::Vector<4, int>>; template struct ConfigurationValue<Magnum::Math::Vector<4, Magnum::Int>>;
template struct ConfigurationValue<Magnum::Math::Vector<2, unsigned int>>; template struct ConfigurationValue<Magnum::Math::Vector<2, Magnum::UnsignedInt>>;
template struct ConfigurationValue<Magnum::Math::Vector<3, unsigned int>>; template struct ConfigurationValue<Magnum::Math::Vector<3, Magnum::UnsignedInt>>;
template struct ConfigurationValue<Magnum::Math::Vector<4, unsigned int>>; template struct ConfigurationValue<Magnum::Math::Vector<4, Magnum::UnsignedInt>>;
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
template struct ConfigurationValue<Magnum::Math::Vector<2, double>>; template struct ConfigurationValue<Magnum::Math::Vector<2, Magnum::Double>>;
template struct ConfigurationValue<Magnum::Math::Vector<3, double>>; template struct ConfigurationValue<Magnum::Math::Vector<3, Magnum::Double>>;
template struct ConfigurationValue<Magnum::Math::Vector<4, double>>; template struct ConfigurationValue<Magnum::Math::Vector<4, Magnum::Double>>;
#endif #endif
#endif #endif

52
src/Math/Vector.h

@ -127,8 +127,8 @@ template<std::size_t size, class T> class Vector {
* Performs only default casting on the values, no rounding or * Performs only default casting on the values, no rounding or
* anything else. Example usage: * anything else. Example usage:
* @code * @code
* Vector<4, float> floatingPoint(1.3f, 2.7f, -15.0f, 7.0f); * Vector<4, Float> floatingPoint(1.3f, 2.7f, -15.0f, 7.0f);
* Vector<4, std::int8_t> integral(floatingPoint); * Vector<4, Byte> integral(floatingPoint);
* // integral == {1, 2, -15, 7} * // integral == {1, 2, -15, 7}
* @endcode * @endcode
*/ */
@ -556,19 +556,19 @@ template<std::size_t size, class T> Corrade::Utility::Debug operator<<(Corrade::
/* Explicit instantiation for types used in OpenGL */ /* Explicit instantiation for types used in OpenGL */
#ifndef DOXYGEN_GENERATING_OUTPUT #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<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<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<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<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<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<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<2, UnsignedInt>&);
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<3, UnsignedInt>&);
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<4, UnsignedInt>&);
#ifndef MAGNUM_TARGET_GLES #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<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<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<4, Double>&);
#endif #endif
#endif #endif
@ -689,19 +689,19 @@ template<std::size_t size, class T> struct ConfigurationValue<Magnum::Math::Vect
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
/* Vectors */ /* Vectors */
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Vector<2, float>>; extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Vector<2, Magnum::Float>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Vector<3, float>>; extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Vector<3, Magnum::Float>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Vector<4, float>>; extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Vector<4, Magnum::Float>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Vector<2, int>>; extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Vector<2, Magnum::Int>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Vector<3, int>>; extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Vector<3, Magnum::Int>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Vector<4, int>>; extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Vector<4, Magnum::Int>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Vector<2, unsigned int>>; extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Vector<2, Magnum::UnsignedInt>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Vector<3, unsigned int>>; extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Vector<3, Magnum::UnsignedInt>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Vector<4, unsigned int>>; extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Vector<4, Magnum::UnsignedInt>>;
#ifndef MAGNUM_TARGET_GLES #ifndef MAGNUM_TARGET_GLES
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Vector<2, double>>; extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Vector<2, Magnum::Double>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Vector<3, double>>; extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Vector<3, Magnum::Double>>;
extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Vector<4, double>>; extern template struct MAGNUM_EXPORT ConfigurationValue<Magnum::Math::Vector<4, Magnum::Double>>;
#endif #endif
#endif #endif

Loading…
Cancel
Save