Browse Source

Math: change all assertions to debug-only.

The perf cost is just too great for these to be enabled always. The only
place where the assertions are kept always is in the batch APIs -- there
it's assumed the function is called on large enough data to offset this
overhead, plus since it's often dealing with large blocks of data the
memory safety is more important than various FP drifts which were the
usual case why other assertions were firing.
pull/617/head
Vladimír Vondruš 3 years ago
parent
commit
be9a3c247d
  1. 3
      doc/changelog.dox
  2. 2
      src/Magnum/Math/Algorithms/GaussJordan.h
  3. 4
      src/Magnum/Math/Algorithms/Svd.h
  4. 2
      src/Magnum/Math/Color.h
  5. 12
      src/Magnum/Math/Complex.h
  6. 6
      src/Magnum/Math/CubicHermite.h
  7. 2
      src/Magnum/Math/Distance.h
  8. 2
      src/Magnum/Math/DualComplex.h
  9. 10
      src/Magnum/Math/DualQuaternion.h
  10. 4
      src/Magnum/Math/Frustum.h
  11. 9
      src/Magnum/Math/Functions.cpp
  12. 4
      src/Magnum/Math/Functions.h
  13. 2
      src/Magnum/Math/Intersection.h
  14. 2
      src/Magnum/Math/Matrix.h
  15. 10
      src/Magnum/Math/Matrix3.h
  16. 12
      src/Magnum/Math/Matrix4.h
  17. 24
      src/Magnum/Math/Quaternion.h
  18. 10
      src/Magnum/Math/Test/ComplexTest.cpp
  19. 16
      src/Magnum/Math/Test/CubicHermiteTest.cpp
  20. 2
      src/Magnum/Math/Test/DistanceTest.cpp
  21. 4
      src/Magnum/Math/Test/DualComplexTest.cpp
  22. 10
      src/Magnum/Math/Test/DualQuaternionTest.cpp
  23. 2
      src/Magnum/Math/Test/FrustumTest.cpp
  24. 8
      src/Magnum/Math/Test/FunctionsTest.cpp
  25. 2
      src/Magnum/Math/Test/IntersectionTest.cpp
  26. 10
      src/Magnum/Math/Test/Matrix3Test.cpp
  27. 12
      src/Magnum/Math/Test/Matrix4Test.cpp
  28. 2
      src/Magnum/Math/Test/MatrixTest.cpp
  29. 22
      src/Magnum/Math/Test/QuaternionTest.cpp
  30. 4
      src/Magnum/Math/Test/VectorTest.cpp
  31. 6
      src/Magnum/Math/Vector.h
  32. 2
      src/Magnum/Shaders/Implementation/lineMiterLimit.h
  33. 2
      src/Magnum/Trade/LightData.cpp
  34. 1
      src/Magnum/Trade/ObjectData2D.cpp
  35. 1
      src/Magnum/Trade/ObjectData3D.cpp

3
doc/changelog.dox

@ -539,6 +539,9 @@ See also:
@subsubsection changelog-latest-changes-math Math library @subsubsection changelog-latest-changes-math Math library
- Assertions in all @ref Math APIs except for batch functions in
@ref Magnum/Math/PackingBatch.h and @ref Magnum/Math/FunctionsBatch.h
were changed to debug-only for better performance in release builds
- Added @ref Math::BitVector::set(std::size_t) and - Added @ref Math::BitVector::set(std::size_t) and
@ref Math::BitVector::reset(std::size_t) for branchless bit setting @ref Math::BitVector::reset(std::size_t) for branchless bit setting
- Added @ref Math::castInto() overloads for casting between @ref UnsignedByte - Added @ref Math::castInto() overloads for casting between @ref UnsignedByte

2
src/Magnum/Math/Algorithms/GaussJordan.h

@ -122,7 +122,7 @@ returning the inverted matrix. Expects that the matrix is invertible.
*/ */
template<std::size_t size, class T> Matrix<size, T> gaussJordanInverted(Matrix<size, T> matrix) { template<std::size_t size, class T> Matrix<size, T> gaussJordanInverted(Matrix<size, T> matrix) {
Matrix<size, T> inverted{Math::IdentityInit}; Matrix<size, T> inverted{Math::IdentityInit};
CORRADE_INTERNAL_ASSERT_OUTPUT(gaussJordanInPlaceTransposed(matrix, inverted)); CORRADE_INTERNAL_DEBUG_ASSERT_OUTPUT(gaussJordanInPlaceTransposed(matrix, inverted));
return inverted; return inverted;
} }

4
src/Magnum/Math/Algorithms/Svd.h

@ -223,7 +223,7 @@ template<std::size_t cols, std::size_t rows, class T> std::tuple<RectangularMatr
T c = T(0); T c = T(0);
T s = T(1); T s = T(1);
for(std::size_t i = l; i != k+1; ++i) { for(std::size_t i = l; i != k+1; ++i) {
CORRADE_INTERNAL_ASSERT(i <= k+1); CORRADE_INTERNAL_DEBUG_ASSERT(i <= k+1);
const T f = s*e[i]; const T f = s*e[i];
e[i] = c*e[i]; e[i] = c*e[i];
@ -276,7 +276,7 @@ template<std::size_t cols, std::size_t rows, class T> std::tuple<RectangularMatr
T c = T(1); T c = T(1);
T s = T(1); T s = T(1);
for(std::size_t i = l+1; i != k+1; ++i) { for(std::size_t i = l+1; i != k+1; ++i) {
CORRADE_INTERNAL_ASSERT(i <= k+1); CORRADE_INTERNAL_DEBUG_ASSERT(i <= k+1);
const T g1 = c*e[i]; const T g1 = c*e[i];
const T h1 = s*e[i]; const T h1 = s*e[i];

2
src/Magnum/Math/Color.h

@ -66,7 +66,7 @@ template<class T> typename std::enable_if<IsFloatingPoint<T>::value, Color3<T>>:
case 3: return {p, q, hsv.value}; case 3: return {p, q, hsv.value};
case 4: return {t, p, hsv.value}; case 4: return {t, p, hsv.value};
case 5: return {hsv.value, p, q}; case 5: return {hsv.value, p, q};
default: CORRADE_INTERNAL_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */ default: CORRADE_INTERNAL_DEBUG_ASSERT_UNREACHABLE(); /* LCOV_EXCL_LINE */
} }
} }
template<class T> inline typename std::enable_if<IsIntegral<T>::value, Color3<T>>::type fromHsv(const ColorHsv<typename TypeTraits<T>::FloatingPointType>& hsv) { template<class T> inline typename std::enable_if<IsIntegral<T>::value, Color3<T>>::type fromHsv(const ColorHsv<typename TypeTraits<T>::FloatingPointType>& hsv) {

12
src/Magnum/Math/Complex.h

@ -29,10 +29,10 @@
* @brief Class @ref Magnum::Math::Complex, function @ref Magnum::Math::dot(), @ref Magnum::Math::angle() * @brief Class @ref Magnum::Math::Complex, function @ref Magnum::Math::dot(), @ref Magnum::Math::angle()
*/ */
#include <Corrade/Utility/Assert.h>
#ifndef CORRADE_NO_DEBUG #ifndef CORRADE_NO_DEBUG
#include <Corrade/Utility/Debug.h> #include <Corrade/Utility/Debug.h>
#endif #endif
#include <Corrade/Utility/DebugAssert.h>
#include "Magnum/Math/Matrix.h" #include "Magnum/Math/Matrix.h"
#include "Magnum/Math/Vector2.h" #include "Magnum/Math/Vector2.h"
@ -76,7 +76,7 @@ passed to @f$ \arccos @f$.
@ref angle(const Vector<size, FloatingPoint>&, const Vector<size, FloatingPoint>&) @ref angle(const Vector<size, FloatingPoint>&, const Vector<size, FloatingPoint>&)
*/ */
template<class T> inline Rad<T> angle(const Complex<T>& normalizedA, const Complex<T>& normalizedB) { template<class T> inline Rad<T> angle(const Complex<T>& normalizedA, const Complex<T>& normalizedB) {
CORRADE_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(), CORRADE_DEBUG_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(),
"Math::angle(): complex numbers" << normalizedA << "and" << normalizedB << "are not normalized", {}); "Math::angle(): complex numbers" << normalizedA << "and" << normalizedB << "are not normalized", {});
return Rad<T>(std::acos(clamp(dot(normalizedA, normalizedB), T(-1), T(1)))); return Rad<T>(std::acos(clamp(dot(normalizedA, normalizedB), T(-1), T(1))));
} }
@ -522,7 +522,7 @@ template<class T> class Complex {
* @see @ref isNormalized(), @ref inverted() * @see @ref isNormalized(), @ref inverted()
*/ */
Complex<T> invertedNormalized() const { Complex<T> invertedNormalized() const {
CORRADE_ASSERT(isNormalized(), CORRADE_DEBUG_ASSERT(isNormalized(),
"Math::Complex::invertedNormalized():" << *this << "is not normalized", {}); "Math::Complex::invertedNormalized():" << *this << "is not normalized", {});
return conjugated(); return conjugated();
} }
@ -608,7 +608,7 @@ Expects that both complex numbers are normalized. @f[
@ref lerp(const CubicHermiteQuaternion<T>&, const CubicHermiteQuaternion<T>&, T) @ref lerp(const CubicHermiteQuaternion<T>&, const CubicHermiteQuaternion<T>&, T)
*/ */
template<class T> inline Complex<T> lerp(const Complex<T>& normalizedA, const Complex<T>& normalizedB, T t) { template<class T> inline Complex<T> lerp(const Complex<T>& normalizedA, const Complex<T>& normalizedB, T t) {
CORRADE_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(), CORRADE_DEBUG_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(),
"Math::lerp(): complex numbers" << normalizedA << "and" << normalizedB << "are not normalized", {}); "Math::lerp(): complex numbers" << normalizedA << "and" << normalizedB << "are not normalized", {});
return ((T(1) - t)*normalizedA + t*normalizedB).normalized(); return ((T(1) - t)*normalizedA + t*normalizedB).normalized();
} }
@ -630,7 +630,7 @@ the same, returns the first argument. @f[
@ref slerp(const Quaternion<T>&, const Quaternion<T>&, T) @ref slerp(const Quaternion<T>&, const Quaternion<T>&, T)
*/ */
template<class T> inline Complex<T> slerp(const Complex<T>& normalizedA, const Complex<T>& normalizedB, T t) { template<class T> inline Complex<T> slerp(const Complex<T>& normalizedA, const Complex<T>& normalizedB, T t) {
CORRADE_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(), CORRADE_DEBUG_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(),
"Math::slerp(): complex numbers" << normalizedA << "and" << normalizedB << "are not normalized", {}); "Math::slerp(): complex numbers" << normalizedA << "and" << normalizedB << "are not normalized", {});
const T cosAngle = dot(normalizedA, normalizedB); const T cosAngle = dot(normalizedA, normalizedB);
@ -652,7 +652,7 @@ template<class T> inline Complex<T> Complex<T>::fromMatrix(const Matrix2x2<T>& m
fuzzy comparison should be 1 ± 2ε. This is similar to fuzzy comparison should be 1 ± 2ε. This is similar to
Vector::isNormalized(), which compares the dot product (length squared) Vector::isNormalized(), which compares the dot product (length squared)
to 1 ± 2ε. */ to 1 ± 2ε. */
CORRADE_ASSERT(std::abs(matrix.determinant() - T(1)) < T(2)*TypeTraits<T>::epsilon(), CORRADE_DEBUG_ASSERT(std::abs(matrix.determinant() - T(1)) < T(2)*TypeTraits<T>::epsilon(),
"Math::Complex::fromMatrix(): the matrix is not a rotation:" << Corrade::Utility::Debug::newline << matrix, {}); "Math::Complex::fromMatrix(): the matrix is not a rotation:" << Corrade::Utility::Debug::newline << matrix, {});
return Implementation::complexFromMatrix(matrix); return Implementation::complexFromMatrix(matrix);
} }

6
src/Magnum/Math/CubicHermite.h

@ -94,7 +94,7 @@ template<class T> class CubicHermite {
typename std::enable_if<std::is_base_of<Vector<dimensions, U>, T>::value, CubicHermite<T>>::type typename std::enable_if<std::is_base_of<Vector<dimensions, U>, T>::value, CubicHermite<T>>::type
#endif #endif
fromBezier(const CubicBezier<dimensions, U>& a, const CubicBezier<dimensions, U>& b) { fromBezier(const CubicBezier<dimensions, U>& a, const CubicBezier<dimensions, U>& b) {
return CORRADE_CONSTEXPR_ASSERT(a[3] == b[0], return CORRADE_CONSTEXPR_DEBUG_ASSERT(a[3] == b[0],
"Math::CubicHermite::fromBezier(): segments are not adjacent"), "Math::CubicHermite::fromBezier(): segments are not adjacent"),
CubicHermite<T>{3*(a[3] - a[2]), a[3], 3*(b[1] - a[3])}; CubicHermite<T>{3*(a[3] - a[2]), a[3], 3*(b[1] - a[3])};
} }
@ -512,7 +512,7 @@ Expects that @ref CubicHermite::point() is a normalized complex number in both
@ref slerp(const CubicHermiteComplex<T>&, const CubicHermiteComplex<T>&, T) @ref slerp(const CubicHermiteComplex<T>&, const CubicHermiteComplex<T>&, T)
*/ */
template<class T> Complex<T> splerp(const CubicHermiteComplex<T>& a, const CubicHermiteComplex<T>& b, T t) { template<class T> Complex<T> splerp(const CubicHermiteComplex<T>& a, const CubicHermiteComplex<T>& b, T t) {
CORRADE_ASSERT(a.point().isNormalized() && b.point().isNormalized(), CORRADE_DEBUG_ASSERT(a.point().isNormalized() && b.point().isNormalized(),
"Math::splerp(): complex spline points" << a.point() << "and" << b.point() << "are not normalized", {}); "Math::splerp(): complex spline points" << a.point() << "and" << b.point() << "are not normalized", {});
return ((T(2)*t*t*t - T(3)*t*t + T(1))*a.point() + return ((T(2)*t*t*t - T(3)*t*t + T(1))*a.point() +
(t*t*t - T(2)*t*t + t)*a.outTangent() + (t*t*t - T(2)*t*t + t)*a.outTangent() +
@ -542,7 +542,7 @@ and @p b.
@ref slerp(const CubicHermiteQuaternion<T>&, const CubicHermiteQuaternion<T>&, T) @ref slerp(const CubicHermiteQuaternion<T>&, const CubicHermiteQuaternion<T>&, T)
*/ */
template<class T> Quaternion<T> splerp(const CubicHermiteQuaternion<T>& a, const CubicHermiteQuaternion<T>& b, T t) { template<class T> Quaternion<T> splerp(const CubicHermiteQuaternion<T>& a, const CubicHermiteQuaternion<T>& b, T t) {
CORRADE_ASSERT(a.point().isNormalized() && b.point().isNormalized(), CORRADE_DEBUG_ASSERT(a.point().isNormalized() && b.point().isNormalized(),
"Math::splerp(): quaternion spline points" << a.point() << "and" << b.point() << "are not normalized", {}); "Math::splerp(): quaternion spline points" << a.point() << "and" << b.point() << "are not normalized", {});
return ((T(2)*t*t*t - T(3)*t*t + T(1))*a.point() + return ((T(2)*t*t*t - T(3)*t*t + T(1))*a.point() +
(t*t*t - T(2)*t*t + t)*a.outTangent() + (t*t*t - T(2)*t*t + t)*a.outTangent() +

2
src/Magnum/Math/Distance.h

@ -275,7 +275,7 @@ top.
@see @ref planeEquation() @see @ref planeEquation()
*/ */
template<class T> inline T pointPlaneNormalized(const Vector3<T>& point, const Vector4<T>& plane) { template<class T> inline T pointPlaneNormalized(const Vector3<T>& point, const Vector4<T>& plane) {
CORRADE_ASSERT(plane.xyz().isNormalized(), CORRADE_DEBUG_ASSERT(plane.xyz().isNormalized(),
"Math::Distance::pointPlaneNormalized(): plane normal" << plane.xyz() << "is not normalized", {}); "Math::Distance::pointPlaneNormalized(): plane normal" << plane.xyz() << "is not normalized", {});
return pointPlaneScaled<T>(point, plane); return pointPlaneScaled<T>(point, plane);
} }

2
src/Magnum/Math/DualComplex.h

@ -102,7 +102,7 @@ template<class T> class DualComplex: public Dual<Complex<T>> {
* @ref Matrix3::isRigidTransformation() * @ref Matrix3::isRigidTransformation()
*/ */
static DualComplex<T> fromMatrix(const Matrix3<T>& matrix) { static DualComplex<T> fromMatrix(const Matrix3<T>& matrix) {
CORRADE_ASSERT(matrix.isRigidTransformation(), CORRADE_DEBUG_ASSERT(matrix.isRigidTransformation(),
"Math::DualComplex::fromMatrix(): the matrix doesn't represent rigid transformation:" << Corrade::Utility::Debug::newline << matrix, {}); "Math::DualComplex::fromMatrix(): the matrix doesn't represent rigid transformation:" << Corrade::Utility::Debug::newline << matrix, {});
return {Implementation::complexFromMatrix(matrix.rotationScaling()), Complex<T>(matrix.translation())}; return {Implementation::complexFromMatrix(matrix.rotationScaling()), Complex<T>(matrix.translation())};
} }

10
src/Magnum/Math/DualQuaternion.h

@ -79,7 +79,7 @@ Note that this function does not check for shortest path interpolation, see
@ref slerp(const Quaternion<T>&, const Quaternion<T>&, T) @ref slerp(const Quaternion<T>&, const Quaternion<T>&, T)
*/ */
template<class T> inline DualQuaternion<T> sclerp(const DualQuaternion<T>& normalizedA, const DualQuaternion<T>& normalizedB, const T t) { template<class T> inline DualQuaternion<T> sclerp(const DualQuaternion<T>& normalizedA, const DualQuaternion<T>& normalizedB, const T t) {
CORRADE_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(), CORRADE_DEBUG_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(),
"Math::sclerp(): dual quaternions" << normalizedA << "and" << normalizedB << "are not normalized", {}); "Math::sclerp(): dual quaternions" << normalizedA << "and" << normalizedB << "are not normalized", {});
const T cosHalfAngle = dot(normalizedA.real(), normalizedB.real()); const T cosHalfAngle = dot(normalizedA.real(), normalizedB.real());
@ -145,7 +145,7 @@ otherwise, the interpolation is performed as: @f[
@ref slerpShortestPath() @ref slerpShortestPath()
*/ */
template<class T> inline DualQuaternion<T> sclerpShortestPath(const DualQuaternion<T>& normalizedA, const DualQuaternion<T>& normalizedB, const T t) { template<class T> inline DualQuaternion<T> sclerpShortestPath(const DualQuaternion<T>& normalizedA, const DualQuaternion<T>& normalizedB, const T t) {
CORRADE_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(), CORRADE_DEBUG_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(),
"Math::sclerp(): dual quaternions" << normalizedA << "and" << normalizedB << "are not normalized", {}); "Math::sclerp(): dual quaternions" << normalizedA << "and" << normalizedB << "are not normalized", {});
const T cosHalfAngle = dot(normalizedA.real(), normalizedB.real()); const T cosHalfAngle = dot(normalizedA.real(), normalizedB.real());
@ -240,7 +240,7 @@ template<class T> class DualQuaternion: public Dual<Quaternion<T>> {
* @ref Matrix4::isRigidTransformation() * @ref Matrix4::isRigidTransformation()
*/ */
static DualQuaternion<T> fromMatrix(const Matrix4<T>& matrix) { static DualQuaternion<T> fromMatrix(const Matrix4<T>& matrix) {
CORRADE_ASSERT(matrix.isRigidTransformation(), CORRADE_DEBUG_ASSERT(matrix.isRigidTransformation(),
"Math::DualQuaternion::fromMatrix(): the matrix doesn't represent a rigid transformation:" << Corrade::Utility::Debug::newline << matrix, {}); "Math::DualQuaternion::fromMatrix(): the matrix doesn't represent a rigid transformation:" << Corrade::Utility::Debug::newline << matrix, {});
Quaternion<T> q = Implementation::quaternionFromMatrix(matrix.rotationScaling()); Quaternion<T> q = Implementation::quaternionFromMatrix(matrix.rotationScaling());
@ -501,7 +501,7 @@ template<class T> class DualQuaternion: public Dual<Quaternion<T>> {
* @see @ref isNormalized(), @ref inverted() * @see @ref isNormalized(), @ref inverted()
*/ */
DualQuaternion<T> invertedNormalized() const { DualQuaternion<T> invertedNormalized() const {
CORRADE_ASSERT(isNormalized(), CORRADE_DEBUG_ASSERT(isNormalized(),
"Math::DualQuaternion::invertedNormalized():" << *this << "is not normalized", {}); "Math::DualQuaternion::invertedNormalized():" << *this << "is not normalized", {});
return quaternionConjugated(); return quaternionConjugated();
} }
@ -556,7 +556,7 @@ template<class T> class DualQuaternion: public Dual<Quaternion<T>> {
* @ref DualComplex::transformPoint() * @ref DualComplex::transformPoint()
*/ */
Vector3<T> transformPointNormalized(const Vector3<T>& vector) const { Vector3<T> transformPointNormalized(const Vector3<T>& vector) const {
CORRADE_ASSERT(isNormalized(), CORRADE_DEBUG_ASSERT(isNormalized(),
"Math::DualQuaternion::transformPointNormalized():" << *this << "is not normalized", {}); "Math::DualQuaternion::transformPointNormalized():" << *this << "is not normalized", {});
return ((*this)*DualQuaternion<T>(vector)*conjugated()).dual().vector(); return ((*this)*DualQuaternion<T>(vector)*conjugated()).dual().vector();
} }

4
src/Magnum/Math/Frustum.h

@ -175,7 +175,7 @@ template<class T> class Frustum {
* Expects that @p i is less than @cpp 6 @ce. * Expects that @p i is less than @cpp 6 @ce.
*/ */
Vector4<T>& operator[](std::size_t i) { Vector4<T>& operator[](std::size_t i) {
CORRADE_ASSERT(i < 6, "Math::Frustum::operator[](): index" << i << "out of range", CORRADE_DEBUG_ASSERT(i < 6, "Math::Frustum::operator[](): index" << i << "out of range",
_data[i]); _data[i]);
return _data[i]; return _data[i];
} }
@ -183,7 +183,7 @@ template<class T> class Frustum {
/** @overload */ /** @overload */
/* returns const& so [][] operations are also constexpr */ /* returns const& so [][] operations are also constexpr */
constexpr const Vector4<T>& operator[](std::size_t i) const { constexpr const Vector4<T>& operator[](std::size_t i) const {
return CORRADE_CONSTEXPR_ASSERT(i < 6, "Math::Frustum::operator[](): index" << i << "out of range"), _data[i]; return CORRADE_CONSTEXPR_DEBUG_ASSERT(i < 6, "Math::Frustum::operator[](): index" << i << "out of range"), _data[i];
} }
/** /**

9
src/Magnum/Math/Functions.cpp

@ -24,10 +24,10 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <Corrade/Utility/Assert.h>
#include "Functions.h" #include "Functions.h"
#include <Corrade/Utility/DebugAssert.h>
namespace Magnum { namespace Math { namespace Magnum { namespace Math {
#if !defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) #if !defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG)
@ -69,7 +69,7 @@ UnsignedInt log2(UnsignedInt number) {
} }
UnsignedLong binomialCoefficient(const UnsignedInt n, UnsignedInt k) { UnsignedLong binomialCoefficient(const UnsignedInt n, UnsignedInt k) {
CORRADE_ASSERT(n >= k, CORRADE_DEBUG_ASSERT(n >= k,
"Math::binomialCoefficient(): k can't be greater than n in (" << Corrade::Utility::Debug::nospace << n << "choose" << k << Corrade::Utility::Debug::nospace << ")", {}); "Math::binomialCoefficient(): k can't be greater than n in (" << Corrade::Utility::Debug::nospace << n << "choose" << k << Corrade::Utility::Debug::nospace << ")", {});
/* k and n - k gives the same value, optimize the calculation to do fewer /* k and n - k gives the same value, optimize the calculation to do fewer
@ -80,7 +80,8 @@ UnsignedLong binomialCoefficient(const UnsignedInt n, UnsignedInt k) {
UnsignedLong result = n; UnsignedLong result = n;
for(UnsignedInt i = 2; i <= k; ++i) { for(UnsignedInt i = 2; i <= k; ++i) {
CORRADE_ASSERT(result < ~UnsignedLong{} / (n-i+1), "Math::binomialCoefficient(): overflow for (" << Corrade::Utility::Debug::nospace << n << "choose" << k << Corrade::Utility::Debug::nospace << ")", {}); CORRADE_DEBUG_ASSERT(result < ~UnsignedLong{} / (n-i+1),
"Math::binomialCoefficient(): overflow for (" << Corrade::Utility::Debug::nospace << n << "choose" << k << Corrade::Utility::Debug::nospace << ")", {});
result *= n - i + 1; result *= n - i + 1;
result /= i; result /= i;

4
src/Magnum/Math/Functions.h

@ -763,7 +763,7 @@ calculated as: @f[
@ref Matrix4::reflection() @ref Matrix4::reflection()
*/ */
template<std::size_t size, class T> inline Vector<size, T> reflect(const Vector<size, T>& vector, const Vector<size, T>& normal) { template<std::size_t size, class T> inline Vector<size, T> reflect(const Vector<size, T>& vector, const Vector<size, T>& normal) {
CORRADE_ASSERT(normal.isNormalized(), CORRADE_DEBUG_ASSERT(normal.isNormalized(),
"Math::reflect(): normal" << normal << "is not normalized", {}); "Math::reflect(): normal" << normal << "is not normalized", {});
return vector - T(2.0)*dot(vector, normal)*normal; return vector - T(2.0)*dot(vector, normal)*normal;
} }
@ -792,7 +792,7 @@ Wikipedia has a [List of refractive indices](https://en.wikipedia.org/wiki/List_
@ref Vector::isNormalized() @ref Vector::isNormalized()
*/ */
template<std::size_t size, class T> inline Vector<size, T> refract(const Vector<size, T>& vector, const Vector<size, T>& normal, T eta) { template<std::size_t size, class T> inline Vector<size, T> refract(const Vector<size, T>& vector, const Vector<size, T>& normal, T eta) {
CORRADE_ASSERT(vector.isNormalized() && normal.isNormalized(), CORRADE_DEBUG_ASSERT(vector.isNormalized() && normal.isNormalized(),
"Math::refract(): vectors" << vector << "and" << normal << "are not normalized", {}); "Math::refract(): vectors" << vector << "and" << normal << "are not normalized", {});
const T dot = Math::dot(vector, normal); const T dot = Math::dot(vector, normal);
const T k = T(1.0) - eta*eta*(T(1.0) - dot*dot); const T k = T(1.0) - eta*eta*(T(1.0) - dot*dot);

2
src/Magnum/Math/Intersection.h

@ -572,7 +572,7 @@ template<class T> bool sphereConeView(const Vector3<T>& sphereCenter, const T sp
} }
template<class T> bool sphereConeView(const Vector3<T>& sphereCenter, const T sphereRadius, const Matrix4<T>& coneView, const T sinAngle, const T tanAngle) { template<class T> bool sphereConeView(const Vector3<T>& sphereCenter, const T sphereRadius, const Matrix4<T>& coneView, const T sinAngle, const T tanAngle) {
CORRADE_ASSERT(coneView.isRigidTransformation(), CORRADE_DEBUG_ASSERT(coneView.isRigidTransformation(),
"Math::Intersection::sphereConeView(): coneView does not represent a rigid transformation:" << Corrade::Utility::Debug::newline << coneView, false); "Math::Intersection::sphereConeView(): coneView does not represent a rigid transformation:" << Corrade::Utility::Debug::newline << coneView, false);
/* Transform the sphere so that we can test against Z axis aligned origin /* Transform the sphere so that we can test against Z axis aligned origin

2
src/Magnum/Math/Matrix.h

@ -274,7 +274,7 @@ template<std::size_t size, class T> class Matrix: public RectangularMatrix<size,
* @ref Matrix4::invertedRigid() * @ref Matrix4::invertedRigid()
*/ */
Matrix<size, T> invertedOrthogonal() const { Matrix<size, T> invertedOrthogonal() const {
CORRADE_ASSERT(isOrthogonal(), CORRADE_DEBUG_ASSERT(isOrthogonal(),
"Math::Matrix::invertedOrthogonal(): the matrix is not orthogonal:" << Corrade::Utility::Debug::Debug::newline << *this, {}); "Math::Matrix::invertedOrthogonal(): the matrix is not orthogonal:" << Corrade::Utility::Debug::Debug::newline << *this, {});
return RectangularMatrix<size, size, T>::transposed(); return RectangularMatrix<size, size, T>::transposed();
} }

10
src/Magnum/Math/Matrix3.h

@ -161,7 +161,7 @@ template<class T> class Matrix3: public Matrix3x3<T> {
* @ref reflect() * @ref reflect()
*/ */
static Matrix3<T> reflection(const Vector2<T>& normal) { static Matrix3<T> reflection(const Vector2<T>& normal) {
CORRADE_ASSERT(normal.isNormalized(), CORRADE_DEBUG_ASSERT(normal.isNormalized(),
"Math::Matrix3::reflection(): normal" << normal << "is not normalized", {}); "Math::Matrix3::reflection(): normal" << normal << "is not normalized", {});
return from(Matrix2x2<T>() - T(2)*normal*RectangularMatrix<1, 2, T>(normal).transposed(), {}); return from(Matrix2x2<T>() - T(2)*normal*RectangularMatrix<1, 2, T>(normal).transposed(), {});
} }
@ -764,7 +764,7 @@ template<class T> Matrix3<T> Matrix3<T>::projection(const Vector2<T>& bottomLeft
template<class T> Matrix2x2<T> Matrix3<T>::rotation() const { template<class T> Matrix2x2<T> Matrix3<T>::rotation() const {
Matrix2x2<T> rotation{(*this)[0].xy().normalized(), Matrix2x2<T> rotation{(*this)[0].xy().normalized(),
(*this)[1].xy().normalized()}; (*this)[1].xy().normalized()};
CORRADE_ASSERT(rotation.isOrthogonal(), CORRADE_DEBUG_ASSERT(rotation.isOrthogonal(),
"Math::Matrix3::rotation(): the normalized rotation part is not orthogonal:" << Corrade::Utility::Debug::newline << rotation, {}); "Math::Matrix3::rotation(): the normalized rotation part is not orthogonal:" << Corrade::Utility::Debug::newline << rotation, {});
return rotation; return rotation;
} }
@ -772,20 +772,20 @@ template<class T> Matrix2x2<T> Matrix3<T>::rotation() const {
template<class T> Matrix2x2<T> Matrix3<T>::rotationNormalized() const { template<class T> Matrix2x2<T> Matrix3<T>::rotationNormalized() const {
Matrix2x2<T> rotation{(*this)[0].xy(), Matrix2x2<T> rotation{(*this)[0].xy(),
(*this)[1].xy()}; (*this)[1].xy()};
CORRADE_ASSERT(rotation.isOrthogonal(), CORRADE_DEBUG_ASSERT(rotation.isOrthogonal(),
"Math::Matrix3::rotationNormalized(): the rotation part is not orthogonal:" << Corrade::Utility::Debug::newline << rotation, {}); "Math::Matrix3::rotationNormalized(): the rotation part is not orthogonal:" << Corrade::Utility::Debug::newline << rotation, {});
return rotation; return rotation;
} }
template<class T> T Matrix3<T>::uniformScalingSquared() const { template<class T> T Matrix3<T>::uniformScalingSquared() const {
const T scalingSquared = (*this)[0].xy().dot(); const T scalingSquared = (*this)[0].xy().dot();
CORRADE_ASSERT(TypeTraits<T>::equals((*this)[1].xy().dot(), scalingSquared), CORRADE_DEBUG_ASSERT(TypeTraits<T>::equals((*this)[1].xy().dot(), scalingSquared),
"Math::Matrix3::uniformScaling(): the matrix doesn't have uniform scaling:" << Corrade::Utility::Debug::newline << rotationScaling(), {}); "Math::Matrix3::uniformScaling(): the matrix doesn't have uniform scaling:" << Corrade::Utility::Debug::newline << rotationScaling(), {});
return scalingSquared; return scalingSquared;
} }
template<class T> inline Matrix3<T> Matrix3<T>::invertedRigid() const { template<class T> inline Matrix3<T> Matrix3<T>::invertedRigid() const {
CORRADE_ASSERT(isRigidTransformation(), CORRADE_DEBUG_ASSERT(isRigidTransformation(),
"Math::Matrix3::invertedRigid(): the matrix doesn't represent a rigid transformation:" << Corrade::Utility::Debug::newline << *this, {}); "Math::Matrix3::invertedRigid(): the matrix doesn't represent a rigid transformation:" << Corrade::Utility::Debug::newline << *this, {});
Matrix2x2<T> inverseRotation = rotationScaling().transposed(); Matrix2x2<T> inverseRotation = rotationScaling().transposed();

12
src/Magnum/Math/Matrix4.h

@ -1087,7 +1087,7 @@ MAGNUM_MATRIXn_OPERATOR_IMPLEMENTATION(4, Matrix4)
#endif #endif
template<class T> Matrix4<T> Matrix4<T>::rotation(const Rad<T> angle, const Vector3<T>& normalizedAxis) { template<class T> Matrix4<T> Matrix4<T>::rotation(const Rad<T> angle, const Vector3<T>& normalizedAxis) {
CORRADE_ASSERT(normalizedAxis.isNormalized(), CORRADE_DEBUG_ASSERT(normalizedAxis.isNormalized(),
"Math::Matrix4::rotation(): axis" << normalizedAxis << "is not normalized", {}); "Math::Matrix4::rotation(): axis" << normalizedAxis << "is not normalized", {});
const T sine = std::sin(T(angle)); const T sine = std::sin(T(angle));
@ -1149,7 +1149,7 @@ template<class T> Matrix4<T> Matrix4<T>::rotationZ(const Rad<T> angle) {
} }
template<class T> Matrix4<T> Matrix4<T>::reflection(const Vector3<T>& normal) { template<class T> Matrix4<T> Matrix4<T>::reflection(const Vector3<T>& normal) {
CORRADE_ASSERT(normal.isNormalized(), CORRADE_DEBUG_ASSERT(normal.isNormalized(),
"Math::Matrix4::reflection(): normal" << normal << "is not normalized", {}); "Math::Matrix4::reflection(): normal" << normal << "is not normalized", {});
return from(Matrix3x3<T>() - T(2)*normal*RectangularMatrix<1, 3, T>(normal).transposed(), {}); return from(Matrix3x3<T>() - T(2)*normal*RectangularMatrix<1, 3, T>(normal).transposed(), {});
} }
@ -1226,7 +1226,7 @@ template<class T> Matrix3x3<T> Matrix4<T>::rotation() const {
Matrix3x3<T> rotation{(*this)[0].xyz().normalized(), Matrix3x3<T> rotation{(*this)[0].xyz().normalized(),
(*this)[1].xyz().normalized(), (*this)[1].xyz().normalized(),
(*this)[2].xyz().normalized()}; (*this)[2].xyz().normalized()};
CORRADE_ASSERT(rotation.isOrthogonal(), CORRADE_DEBUG_ASSERT(rotation.isOrthogonal(),
"Math::Matrix4::rotation(): the normalized rotation part is not orthogonal:" << Corrade::Utility::Debug::newline << rotation, {}); "Math::Matrix4::rotation(): the normalized rotation part is not orthogonal:" << Corrade::Utility::Debug::newline << rotation, {});
return rotation; return rotation;
} }
@ -1235,21 +1235,21 @@ template<class T> Matrix3x3<T> Matrix4<T>::rotationNormalized() const {
Matrix3x3<T> rotation{(*this)[0].xyz(), Matrix3x3<T> rotation{(*this)[0].xyz(),
(*this)[1].xyz(), (*this)[1].xyz(),
(*this)[2].xyz()}; (*this)[2].xyz()};
CORRADE_ASSERT(rotation.isOrthogonal(), CORRADE_DEBUG_ASSERT(rotation.isOrthogonal(),
"Math::Matrix4::rotationNormalized(): the rotation part is not orthogonal:" << Corrade::Utility::Debug::newline << rotation, {}); "Math::Matrix4::rotationNormalized(): the rotation part is not orthogonal:" << Corrade::Utility::Debug::newline << rotation, {});
return rotation; return rotation;
} }
template<class T> T Matrix4<T>::uniformScalingSquared() const { template<class T> T Matrix4<T>::uniformScalingSquared() const {
const T scalingSquared = (*this)[0].xyz().dot(); const T scalingSquared = (*this)[0].xyz().dot();
CORRADE_ASSERT(TypeTraits<T>::equals((*this)[1].xyz().dot(), scalingSquared) && CORRADE_DEBUG_ASSERT(TypeTraits<T>::equals((*this)[1].xyz().dot(), scalingSquared) &&
TypeTraits<T>::equals((*this)[2].xyz().dot(), scalingSquared), TypeTraits<T>::equals((*this)[2].xyz().dot(), scalingSquared),
"Math::Matrix4::uniformScaling(): the matrix doesn't have uniform scaling:" << Corrade::Utility::Debug::newline << rotationScaling(), {}); "Math::Matrix4::uniformScaling(): the matrix doesn't have uniform scaling:" << Corrade::Utility::Debug::newline << rotationScaling(), {});
return scalingSquared; return scalingSquared;
} }
template<class T> Matrix4<T> Matrix4<T>::invertedRigid() const { template<class T> Matrix4<T> Matrix4<T>::invertedRigid() const {
CORRADE_ASSERT(isRigidTransformation(), CORRADE_DEBUG_ASSERT(isRigidTransformation(),
"Math::Matrix4::invertedRigid(): the matrix doesn't represent a rigid transformation:" << Corrade::Utility::Debug::newline << *this, {}); "Math::Matrix4::invertedRigid(): the matrix doesn't represent a rigid transformation:" << Corrade::Utility::Debug::newline << *this, {});
Matrix3x3<T> inverseRotation = rotationScaling().transposed(); Matrix3x3<T> inverseRotation = rotationScaling().transposed();

24
src/Magnum/Math/Quaternion.h

@ -30,10 +30,10 @@
* @brief Class @ref Magnum::Math::Quaternion, function @ref Magnum::Math::dot(), @ref Magnum::Math::angle(), @ref Magnum::Math::lerp(), @ref Magnum::Math::slerp() * @brief Class @ref Magnum::Math::Quaternion, function @ref Magnum::Math::dot(), @ref Magnum::Math::angle(), @ref Magnum::Math::lerp(), @ref Magnum::Math::slerp()
*/ */
#include <Corrade/Utility/Assert.h>
#ifndef CORRADE_NO_DEBUG #ifndef CORRADE_NO_DEBUG
#include <Corrade/Utility/Debug.h> #include <Corrade/Utility/Debug.h>
#endif #endif
#include <Corrade/Utility/DebugAssert.h>
#include <Corrade/Utility/StlMath.h> #include <Corrade/Utility/StlMath.h>
#include "Magnum/Math/Matrix.h" #include "Magnum/Math/Matrix.h"
@ -73,7 +73,7 @@ passed to @f$ \arccos @f$.
@ref angle(const Vector<size, FloatingPoint>&, const Vector<size, FloatingPoint>&) @ref angle(const Vector<size, FloatingPoint>&, const Vector<size, FloatingPoint>&)
*/ */
template<class T> inline Rad<T> angle(const Quaternion<T>& normalizedA, const Quaternion<T>& normalizedB) { template<class T> inline Rad<T> angle(const Quaternion<T>& normalizedA, const Quaternion<T>& normalizedB) {
CORRADE_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(), CORRADE_DEBUG_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(),
"Math::angle(): quaternions" << normalizedA << "and" << normalizedB << "are not normalized", {}); "Math::angle(): quaternions" << normalizedA << "and" << normalizedB << "are not normalized", {});
return Rad<T>{std::acos(clamp(dot(normalizedA, normalizedB), T(-1), T(1)))}; return Rad<T>{std::acos(clamp(dot(normalizedA, normalizedB), T(-1), T(1)))};
} }
@ -100,7 +100,7 @@ alternative.
@ref lerp(const CubicHermiteQuaternion<T>&, const CubicHermiteQuaternion<T>&, T) @ref lerp(const CubicHermiteQuaternion<T>&, const CubicHermiteQuaternion<T>&, T)
*/ */
template<class T> inline Quaternion<T> lerp(const Quaternion<T>& normalizedA, const Quaternion<T>& normalizedB, T t) { template<class T> inline Quaternion<T> lerp(const Quaternion<T>& normalizedA, const Quaternion<T>& normalizedB, T t) {
CORRADE_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(), CORRADE_DEBUG_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(),
"Math::lerp(): quaternions" << normalizedA << "and" << normalizedB << "are not normalized", {}); "Math::lerp(): quaternions" << normalizedA << "and" << normalizedB << "are not normalized", {});
return ((T(1) - t)*normalizedA + t*normalizedB).normalized(); return ((T(1) - t)*normalizedA + t*normalizedB).normalized();
} }
@ -169,7 +169,7 @@ alternative.
@ref slerp(const CubicHermiteQuaternion<T>&, const CubicHermiteQuaternion<T>&, T) @ref slerp(const CubicHermiteQuaternion<T>&, const CubicHermiteQuaternion<T>&, T)
*/ */
template<class T> inline Quaternion<T> slerp(const Quaternion<T>& normalizedA, const Quaternion<T>& normalizedB, T t) { template<class T> inline Quaternion<T> slerp(const Quaternion<T>& normalizedA, const Quaternion<T>& normalizedB, T t) {
CORRADE_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(), CORRADE_DEBUG_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(),
"Math::slerp(): quaternions" << normalizedA << "and" << normalizedB << "are not normalized", {}); "Math::slerp(): quaternions" << normalizedA << "and" << normalizedB << "are not normalized", {});
const T cosHalfAngle = dot(normalizedA, normalizedB); const T cosHalfAngle = dot(normalizedA, normalizedB);
@ -240,7 +240,7 @@ Otherwise, the interpolation is performed as: @f[
@ref sclerpShortestPath() @ref sclerpShortestPath()
*/ */
template<class T> inline Quaternion<T> slerpShortestPath(const Quaternion<T>& normalizedA, const Quaternion<T>& normalizedB, T t) { template<class T> inline Quaternion<T> slerpShortestPath(const Quaternion<T>& normalizedA, const Quaternion<T>& normalizedB, T t) {
CORRADE_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(), CORRADE_DEBUG_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(),
"Math::slerpShortestPath(): quaternions" << normalizedA << "and" << normalizedB << "are not normalized", {}); "Math::slerpShortestPath(): quaternions" << normalizedA << "and" << normalizedB << "are not normalized", {});
const T cosHalfAngle = dot(normalizedA, normalizedB); const T cosHalfAngle = dot(normalizedA, normalizedB);
@ -781,7 +781,7 @@ template<class T> Quaternion<T> quaternionFromMatrix(const Matrix3x3<T>& m) {
} }
template<class T> inline Quaternion<T> Quaternion<T>::rotation(const Rad<T> angle, const Vector3<T>& normalizedAxis) { template<class T> inline Quaternion<T> Quaternion<T>::rotation(const Rad<T> angle, const Vector3<T>& normalizedAxis) {
CORRADE_ASSERT(normalizedAxis.isNormalized(), CORRADE_DEBUG_ASSERT(normalizedAxis.isNormalized(),
"Math::Quaternion::rotation(): axis" << normalizedAxis << "is not normalized", {}); "Math::Quaternion::rotation(): axis" << normalizedAxis << "is not normalized", {});
return {normalizedAxis*std::sin(T(angle)/2), std::cos(T(angle)/2)}; return {normalizedAxis*std::sin(T(angle)/2), std::cos(T(angle)/2)};
} }
@ -796,19 +796,19 @@ template<class T> inline Quaternion<T> Quaternion<T>::fromMatrix(const Matrix3x3
unrepresentable, the fuzzy comparison should be 1 ± 3ε. This is similar unrepresentable, the fuzzy comparison should be 1 ± 3ε. This is similar
to Vector::isNormalized(), which compares the dot product (length to Vector::isNormalized(), which compares the dot product (length
squared) to 1 ± 2ε. */ squared) to 1 ± 2ε. */
CORRADE_ASSERT(std::abs(matrix.determinant() - T(1)) < T(3)*TypeTraits<T>::epsilon(), CORRADE_DEBUG_ASSERT(std::abs(matrix.determinant() - T(1)) < T(3)*TypeTraits<T>::epsilon(),
"Math::Quaternion::fromMatrix(): the matrix is not a rotation:" << Corrade::Utility::Debug::newline << matrix, {}); "Math::Quaternion::fromMatrix(): the matrix is not a rotation:" << Corrade::Utility::Debug::newline << matrix, {});
return Implementation::quaternionFromMatrix(matrix); return Implementation::quaternionFromMatrix(matrix);
} }
template<class T> inline Rad<T> Quaternion<T>::angle() const { template<class T> inline Rad<T> Quaternion<T>::angle() const {
CORRADE_ASSERT(isNormalized(), CORRADE_DEBUG_ASSERT(isNormalized(),
"Math::Quaternion::angle():" << *this << "is not normalized", {}); "Math::Quaternion::angle():" << *this << "is not normalized", {});
return Rad<T>(T(2)*std::acos(_scalar)); return Rad<T>(T(2)*std::acos(_scalar));
} }
template<class T> inline Vector3<T> Quaternion<T>::axis() const { template<class T> inline Vector3<T> Quaternion<T>::axis() const {
CORRADE_ASSERT(isNormalized(), CORRADE_DEBUG_ASSERT(isNormalized(),
"Math::Quaternion::axis():" << *this << "is not normalized", {}); "Math::Quaternion::axis():" << *this << "is not normalized", {});
return _vector/std::sqrt(1-pow2(_scalar)); return _vector/std::sqrt(1-pow2(_scalar));
} }
@ -830,7 +830,7 @@ template<class T> Matrix3x3<T> Quaternion<T>::toMatrix() const {
/* Algorithm from: /* Algorithm from:
https://github.com/mrdoob/three.js/blob/6892dd0aba1411d35c5e2b44dc6ff280b24d6aa2/src/math/Euler.js#L197 */ https://github.com/mrdoob/three.js/blob/6892dd0aba1411d35c5e2b44dc6ff280b24d6aa2/src/math/Euler.js#L197 */
template<class T> Vector3<Rad<T>> Quaternion<T>::toEuler() const { template<class T> Vector3<Rad<T>> Quaternion<T>::toEuler() const {
CORRADE_ASSERT(isNormalized(), CORRADE_DEBUG_ASSERT(isNormalized(),
"Math::Quaternion::toEuler():" << *this << "is not normalized", {}); "Math::Quaternion::toEuler():" << *this << "is not normalized", {});
Vector3<Rad<T>> euler{Magnum::NoInit}; Vector3<Rad<T>> euler{Magnum::NoInit};
@ -864,13 +864,13 @@ template<class T> inline Quaternion<T> Quaternion<T>::operator*(const Quaternion
} }
template<class T> inline Quaternion<T> Quaternion<T>::invertedNormalized() const { template<class T> inline Quaternion<T> Quaternion<T>::invertedNormalized() const {
CORRADE_ASSERT(isNormalized(), CORRADE_DEBUG_ASSERT(isNormalized(),
"Math::Quaternion::invertedNormalized():" << *this << "is not normalized", {}); "Math::Quaternion::invertedNormalized():" << *this << "is not normalized", {});
return conjugated(); return conjugated();
} }
template<class T> inline Vector3<T> Quaternion<T>::transformVectorNormalized(const Vector3<T>& vector) const { template<class T> inline Vector3<T> Quaternion<T>::transformVectorNormalized(const Vector3<T>& vector) const {
CORRADE_ASSERT(isNormalized(), CORRADE_DEBUG_ASSERT(isNormalized(),
"Math::Quaternion::transformVectorNormalized():" << *this << "is not normalized", {}); "Math::Quaternion::transformVectorNormalized():" << *this << "is not normalized", {});
const Vector3<T> t = T(2)*Math::cross(_vector, vector); const Vector3<T> t = T(2)*Math::cross(_vector, vector);
return vector + _scalar*t + Math::cross(_vector, t); return vector + _scalar*t + Math::cross(_vector, t);

10
src/Magnum/Math/Test/ComplexTest.cpp

@ -437,7 +437,7 @@ void ComplexTest::invertedNormalized() {
} }
void ComplexTest::invertedNormalizedNotNormalized() { void ComplexTest::invertedNormalizedNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -476,7 +476,7 @@ void ComplexTest::angleNormalizedButOver1() {
} }
void ComplexTest::angleNotNormalized() { void ComplexTest::angleNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -516,7 +516,7 @@ void ComplexTest::matrix() {
} }
void ComplexTest::matrixNotRotation() { void ComplexTest::matrixNotRotation() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -551,7 +551,7 @@ void ComplexTest::lerp() {
} }
void ComplexTest::lerpNotNormalized() { void ComplexTest::lerpNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -579,7 +579,7 @@ void ComplexTest::slerp() {
} }
void ComplexTest::slerpNotNormalized() { void ComplexTest::slerpNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};

16
src/Magnum/Math/Test/CubicHermiteTest.cpp

@ -890,7 +890,7 @@ void CubicHermiteTest::lerpComplex() {
} }
void CubicHermiteTest::lerpComplexNotNormalized() { void CubicHermiteTest::lerpComplexNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -933,7 +933,7 @@ void CubicHermiteTest::lerpQuaternion() {
} }
void CubicHermiteTest::lerpQuaternionNotNormalized() { void CubicHermiteTest::lerpQuaternionNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -975,7 +975,7 @@ void CubicHermiteTest::lerpQuaternionShortestPath() {
} }
void CubicHermiteTest::lerpQuaternionShortestPathNotNormalized() { void CubicHermiteTest::lerpQuaternionShortestPathNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -1013,7 +1013,7 @@ void CubicHermiteTest::slerpComplex() {
} }
void CubicHermiteTest::slerpComplexNotNormalized() { void CubicHermiteTest::slerpComplexNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -1056,7 +1056,7 @@ void CubicHermiteTest::slerpQuaternion() {
} }
void CubicHermiteTest::slerpQuaternionNotNormalized() { void CubicHermiteTest::slerpQuaternionNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -1099,7 +1099,7 @@ void CubicHermiteTest::slerpQuaternionShortestPath() {
} }
void CubicHermiteTest::slerpQuaternionShortestPathNotNormalized() { void CubicHermiteTest::slerpQuaternionShortestPathNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -1173,7 +1173,7 @@ void CubicHermiteTest::splerpComplex() {
} }
void CubicHermiteTest::splerpComplexNotNormalized() { void CubicHermiteTest::splerpComplexNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -1212,7 +1212,7 @@ void CubicHermiteTest::splerpQuaternion() {
} }
void CubicHermiteTest::splerpQuaternionNotNormalized() { void CubicHermiteTest::splerpQuaternionNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};

2
src/Magnum/Math/Test/DistanceTest.cpp

@ -234,7 +234,7 @@ void DistanceTest::pointPlaneNormalized() {
} }
void DistanceTest::pointPlaneNormalizedNotNormalized() { void DistanceTest::pointPlaneNormalizedNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};

4
src/Magnum/Math/Test/DualComplexTest.cpp

@ -402,7 +402,7 @@ void DualComplexTest::invertedNormalized() {
} }
void DualComplexTest::invertedNormalizedNotNormalized() { void DualComplexTest::invertedNormalizedNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -464,7 +464,7 @@ void DualComplexTest::matrix() {
} }
void DualComplexTest::matrixNotOrthogonal() { void DualComplexTest::matrixNotOrthogonal() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream o; std::ostringstream o;
Error redirectError{&o}; Error redirectError{&o};

10
src/Magnum/Math/Test/DualQuaternionTest.cpp

@ -439,7 +439,7 @@ void DualQuaternionTest::invertedNormalized() {
} }
void DualQuaternionTest::invertedNormalizedNotNormalized() { void DualQuaternionTest::invertedNormalizedNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -467,7 +467,7 @@ void DualQuaternionTest::rotation() {
} }
void DualQuaternionTest::rotationNotNormalized() { void DualQuaternionTest::rotationNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -521,7 +521,7 @@ void DualQuaternionTest::matrix() {
} }
void DualQuaternionTest::matrixNotOrthogonal() { void DualQuaternionTest::matrixNotOrthogonal() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -558,7 +558,7 @@ void DualQuaternionTest::transformVectorNormalized() {
} }
void DualQuaternionTest::transformVectorNormalizedNotNormalized() { void DualQuaternionTest::transformVectorNormalizedNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -602,7 +602,7 @@ void DualQuaternionTest::transformPointNormalized() {
} }
void DualQuaternionTest::transformPointNormalizedNotNormalized() { void DualQuaternionTest::transformPointNormalizedNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};

2
src/Magnum/Math/Test/FrustumTest.cpp

@ -354,7 +354,7 @@ void FrustumTest::data() {
} }
void FrustumTest::dataOutOfRange() { void FrustumTest::dataOutOfRange() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
Frustum a; Frustum a;
constexpr Frustum ca; constexpr Frustum ca;

8
src/Magnum/Math/Test/FunctionsTest.cpp

@ -323,7 +323,7 @@ void FunctionsTest::binomialCoefficient() {
} }
void FunctionsTest::binomialCoefficientInvalidInput() { void FunctionsTest::binomialCoefficientInvalidInput() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -332,7 +332,7 @@ void FunctionsTest::binomialCoefficientInvalidInput() {
} }
void FunctionsTest::binomialCoefficientOverflow() { void FunctionsTest::binomialCoefficientOverflow() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -516,7 +516,7 @@ void FunctionsTest::reflect() {
} }
void FunctionsTest::reflectNotNormalized() { void FunctionsTest::reflectNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -543,7 +543,7 @@ void FunctionsTest::refract() {
} }
void FunctionsTest::refractNotNormalized() { void FunctionsTest::refractNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};

2
src/Magnum/Math/Test/IntersectionTest.cpp

@ -460,7 +460,7 @@ void IntersectionTest::sphereConeView() {
} }
void IntersectionTest::sphereConeViewNotRigid() { void IntersectionTest::sphereConeViewNotRigid() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};

10
src/Magnum/Math/Test/Matrix3Test.cpp

@ -377,7 +377,7 @@ void Matrix3Test::reflection() {
} }
void Matrix3Test::reflectionNotNormalized() { void Matrix3Test::reflectionNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -505,7 +505,7 @@ void Matrix3Test::rotationPart() {
} }
void Matrix3Test::rotationPartNotOrthogonal() { void Matrix3Test::rotationPartNotOrthogonal() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -557,7 +557,7 @@ void Matrix3Test::rotationNormalizedPart() {
} }
void Matrix3Test::rotationNormalizedPartNotOrthogonal() { void Matrix3Test::rotationNormalizedPartNotOrthogonal() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -619,7 +619,7 @@ void Matrix3Test::uniformScalingPart() {
} }
void Matrix3Test::uniformScalingPartNotUniform() { void Matrix3Test::uniformScalingPartNotUniform() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -665,7 +665,7 @@ void Matrix3Test::invertedRigid() {
} }
void Matrix3Test::invertedRigidNotRigid() { void Matrix3Test::invertedRigidNotRigid() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};

12
src/Magnum/Math/Test/Matrix4Test.cpp

@ -426,7 +426,7 @@ void Matrix4Test::rotation() {
} }
void Matrix4Test::rotationNotNormalized() { void Matrix4Test::rotationNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -476,7 +476,7 @@ void Matrix4Test::reflection() {
} }
void Matrix4Test::reflectionNotNormalized() { void Matrix4Test::reflectionNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -738,7 +738,7 @@ void Matrix4Test::rotationPart() {
} }
void Matrix4Test::rotationPartNotOrthogonal() { void Matrix4Test::rotationPartNotOrthogonal() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -798,7 +798,7 @@ void Matrix4Test::rotationNormalizedPart() {
} }
void Matrix4Test::rotationNormalizedPartNotOrthogonal() { void Matrix4Test::rotationNormalizedPartNotOrthogonal() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -861,7 +861,7 @@ void Matrix4Test::uniformScalingPart() {
} }
void Matrix4Test::uniformScalingPartNotUniform() { void Matrix4Test::uniformScalingPartNotUniform() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Matrix4::scaling(Vector3::yScale(3.0f)).uniformScaling(); Error redirectError{&out}; Matrix4::scaling(Vector3::yScale(3.0f)).uniformScaling();
@ -1032,7 +1032,7 @@ void Matrix4Test::invertedRigid() {
} }
void Matrix4Test::invertedRigidNotRigid() { void Matrix4Test::invertedRigidNotRigid() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};

2
src/Magnum/Math/Test/MatrixTest.cpp

@ -412,7 +412,7 @@ void MatrixTest::invertedOrthogonal() {
} }
void MatrixTest::invertedOrthogonalNotOrthogonal() { void MatrixTest::invertedOrthogonalNotOrthogonal() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream o; std::ostringstream o;
Error redirectError{&o}; Error redirectError{&o};

22
src/Magnum/Math/Test/QuaternionTest.cpp

@ -375,7 +375,7 @@ void QuaternionTest::axisAngle() {
} }
void QuaternionTest::axisAngleNotNormalized() { void QuaternionTest::axisAngleNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -478,7 +478,7 @@ void QuaternionTest::invertedNormalized() {
} }
void QuaternionTest::invertedNormalizedNotNormalized() { void QuaternionTest::invertedNormalizedNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -508,7 +508,7 @@ void QuaternionTest::rotation() {
} }
void QuaternionTest::rotationNotNormalized() { void QuaternionTest::rotationNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -550,7 +550,7 @@ void QuaternionTest::angleNormalizedButOver1() {
} }
void QuaternionTest::angleNotNormalized() { void QuaternionTest::angleNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -613,7 +613,7 @@ void QuaternionTest::matrix() {
} }
void QuaternionTest::matrixNotRotation() { void QuaternionTest::matrixNotRotation() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -657,7 +657,7 @@ void QuaternionTest::euler() {
} }
void QuaternionTest::eulerNotNormalized() { void QuaternionTest::eulerNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -694,7 +694,7 @@ void QuaternionTest::lerp2D() {
} }
void QuaternionTest::lerpNotNormalized() { void QuaternionTest::lerpNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -726,7 +726,7 @@ void QuaternionTest::lerpShortestPath() {
} }
void QuaternionTest::lerpShortestPathNotNormalized() { void QuaternionTest::lerpShortestPathNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -811,7 +811,7 @@ void QuaternionTest::slerpNormalizedButOver1() {
} }
void QuaternionTest::slerpNotNormalized() { void QuaternionTest::slerpNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -872,7 +872,7 @@ template<class T> void QuaternionTest::slerpShortestPathLinearFallbackIsNormaliz
} }
void QuaternionTest::slerpShortestPathNotNormalized() { void QuaternionTest::slerpShortestPathNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};
@ -906,7 +906,7 @@ void QuaternionTest::transformVectorNormalized() {
} }
void QuaternionTest::transformVectorNormalizedNotNormalized() { void QuaternionTest::transformVectorNormalizedNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};

4
src/Magnum/Math/Test/VectorTest.cpp

@ -578,7 +578,7 @@ void VectorTest::projectedOntoNormalized() {
} }
void VectorTest::projectedOntoNormalizedNotNormalized() { void VectorTest::projectedOntoNormalizedNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
Vector3 vector(1.0f, 2.0f, 3.0f); Vector3 vector(1.0f, 2.0f, 3.0f);
Vector3 line(1.0f, -1.0f, 0.5f); Vector3 line(1.0f, -1.0f, 0.5f);
@ -623,7 +623,7 @@ void VectorTest::angleNormalizedButOver1() {
} }
void VectorTest::angleNotNormalized() { void VectorTest::angleNotNormalized() {
CORRADE_SKIP_IF_NO_ASSERT(); CORRADE_SKIP_IF_NO_DEBUG_ASSERT();
std::ostringstream out; std::ostringstream out;
Error redirectError{&out}; Error redirectError{&out};

6
src/Magnum/Math/Vector.h

@ -30,10 +30,10 @@
*/ */
#include <utility> #include <utility>
#include <Corrade/Utility/Assert.h>
#ifndef CORRADE_NO_DEBUG #ifndef CORRADE_NO_DEBUG
#include <Corrade/Utility/Debug.h> #include <Corrade/Utility/Debug.h>
#endif #endif
#include <Corrade/Utility/DebugAssert.h>
#include <Corrade/Utility/StlMath.h> #include <Corrade/Utility/StlMath.h>
#include "Magnum/visibility.h" #include "Magnum/visibility.h"
@ -130,7 +130,7 @@ Rad<FloatingPoint>
typename std::enable_if<std::is_floating_point<FloatingPoint>::value, Rad<FloatingPoint>>::type typename std::enable_if<std::is_floating_point<FloatingPoint>::value, Rad<FloatingPoint>>::type
#endif #endif
angle(const Vector<size, FloatingPoint>& normalizedA, const Vector<size, FloatingPoint>& normalizedB) { angle(const Vector<size, FloatingPoint>& normalizedA, const Vector<size, FloatingPoint>& normalizedB) {
CORRADE_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(), CORRADE_DEBUG_ASSERT(normalizedA.isNormalized() && normalizedB.isNormalized(),
"Math::angle(): vectors" << normalizedA << "and" << normalizedB << "are not normalized", {}); "Math::angle(): vectors" << normalizedA << "and" << normalizedB << "are not normalized", {});
return Rad<FloatingPoint>(std::acos(clamp(dot(normalizedA, normalizedB), FloatingPoint(-1), FloatingPoint(1)))); return Rad<FloatingPoint>(std::acos(clamp(dot(normalizedA, normalizedB), FloatingPoint(-1), FloatingPoint(1))));
} }
@ -1510,7 +1510,7 @@ inline Vector<size, T>
template<class U> inline typename std::enable_if<std::is_floating_point<U>::value, Vector<size, T>>::type template<class U> inline typename std::enable_if<std::is_floating_point<U>::value, Vector<size, T>>::type
#endif #endif
Vector<size, T>::projectedOntoNormalized(const Vector<size, T>& line) const { Vector<size, T>::projectedOntoNormalized(const Vector<size, T>& line) const {
CORRADE_ASSERT(line.isNormalized(), CORRADE_DEBUG_ASSERT(line.isNormalized(),
"Math::Vector::projectedOntoNormalized(): line" << line << "is not normalized", {}); "Math::Vector::projectedOntoNormalized(): line" << line << "is not normalized", {});
return line*Math::dot(*this, line); return line*Math::dot(*this, line);
} }

2
src/Magnum/Shaders/Implementation/lineMiterLimit.h

@ -25,6 +25,8 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include <Corrade/Utility/Assert.h>
#include "Magnum/Math/Functions.h" #include "Magnum/Math/Functions.h"
namespace Magnum { namespace Shaders { namespace Implementation { namespace Magnum { namespace Shaders { namespace Implementation {

2
src/Magnum/Trade/LightData.cpp

@ -25,6 +25,8 @@
#include "LightData.h" #include "LightData.h"
#include <Corrade/Utility/Assert.h>
namespace Magnum { namespace Trade { namespace Magnum { namespace Trade {
using namespace Math::Literals; using namespace Math::Literals;

1
src/Magnum/Trade/ObjectData2D.cpp

@ -28,6 +28,7 @@
#include "ObjectData2D.h" #include "ObjectData2D.h"
#include <Corrade/Containers/EnumSet.hpp> #include <Corrade/Containers/EnumSet.hpp>
#include <Corrade/Utility/Assert.h>
namespace Magnum { namespace Trade { namespace Magnum { namespace Trade {

1
src/Magnum/Trade/ObjectData3D.cpp

@ -28,6 +28,7 @@
#include "ObjectData3D.h" #include "ObjectData3D.h"
#include <Corrade/Containers/EnumSet.hpp> #include <Corrade/Containers/EnumSet.hpp>
#include <Corrade/Utility/Assert.h>
namespace Magnum { namespace Trade { namespace Magnum { namespace Trade {

Loading…
Cancel
Save