diff --git a/src/Math/Complex.h b/src/Math/Complex.h index 665523e1c..528ec3c12 100644 --- a/src/Math/Complex.h +++ b/src/Math/Complex.h @@ -102,7 +102,7 @@ template class Complex { * To be used in transformations later. @f[ * c = v_x + iv_y * @f] - * @see operator Vector2(), transformVector(), transformVectorNormalized() + * @see operator Vector2(), transformVector() */ inline constexpr explicit Complex(const Vector2& vector): _real(vector.x()), _imaginary(vector.y()) {} @@ -345,29 +345,12 @@ template class Complex { /** * @brief Rotate vector with complex number * - * See transformVectorNormalized(), which is faster for normalized - * complex numbers. @f[ - * v' = \frac c {|c|} v = \frac c {|c|} (v_x + iv_y) + * @f[ + * v' = c v = c (v_x + iv_y) * @f] * @see Complex(const Vector2&), operator Vector2(), Matrix3::transformVector() */ inline Vector2 transformVector(const Vector2& vector) const { - return Vector2(normalized()*Complex(vector)); - } - - /** - * @brief Rotate vector with normalized complex number - * - * Faster alternative to transformVector(), expects that the complex - * number is normalized. @f[ - * v' = \frac c {|c|} v = cv = c(v_x + iv_y) - * @f] - * @see Complex(const Vector2&), operator Vector2(), Matrix3::transformVector() - */ - inline Vector2 transformVectorNormalized(const Vector2& vector) const { - CORRADE_ASSERT(MathTypeTraits::equals(dot(), T(1)), - "Math::Complex::transformVectorNormalized(): complex number must be normalized", - Vector2(std::numeric_limits::quiet_NaN())); return Vector2((*this)*Complex(vector)); } diff --git a/src/Math/Quaternion.h b/src/Math/Quaternion.h index 8592e26f9..5eef4346f 100644 --- a/src/Math/Quaternion.h +++ b/src/Math/Quaternion.h @@ -423,8 +423,7 @@ template class Quaternion { * v' = qvq^{-1} = qvq^* = q [\boldsymbol v, 0] q^* * @f] * @see Quaternion(const Vector3&), vector(), Matrix4::transformVector(), - * DualQuaternion::transformPointNormalized(), - * Complex::transformVectorNormalized() + * DualQuaternion::transformPointNormalized(), Complex::transformVector() */ inline Vector3 transformVectorNormalized(const Vector3& vector) const { CORRADE_ASSERT(MathTypeTraits::equals(dot(), T(1)), diff --git a/src/Math/Test/ComplexTest.cpp b/src/Math/Test/ComplexTest.cpp index 76136dbbf..aa909989c 100644 --- a/src/Math/Test/ComplexTest.cpp +++ b/src/Math/Test/ComplexTest.cpp @@ -50,7 +50,6 @@ class ComplexTest: public Corrade::TestSuite::Tester { void rotation(); void matrix(); void transformVector(); - void transformVectorNormalized(); void debug(); }; @@ -81,7 +80,6 @@ ComplexTest::ComplexTest() { &ComplexTest::rotation, &ComplexTest::matrix, &ComplexTest::transformVector, - &ComplexTest::transformVectorNormalized, &ComplexTest::debug); } @@ -285,22 +283,6 @@ void ComplexTest::transformVector() { CORRADE_COMPARE(rotated, Vector2(-3.58733f, -0.762279f)); } -void ComplexTest::transformVectorNormalized() { - Complex a = Complex::rotation(Deg(23.0f)); - Matrix3 m = Matrix3::rotation(Deg(23.0f)); - Vector2 v(-3.6f, 0.7f); - - std::ostringstream o; - Error::setOutput(&o); - Vector2 notRotated = (a*2).transformVectorNormalized(v); - CORRADE_VERIFY(notRotated != notRotated); - CORRADE_COMPARE(o.str(), "Math::Complex::transformVectorNormalized(): complex number must be normalized\n"); - - Vector2 rotated = a.transformVectorNormalized(v); - CORRADE_COMPARE(rotated, m.transformVector(v)); - CORRADE_COMPARE(rotated, a.transformVector(v)); -} - void ComplexTest::debug() { std::ostringstream o; diff --git a/src/MeshTools/Transform.h b/src/MeshTools/Transform.h index 9ce7b07ae..2f654ab18 100644 --- a/src/MeshTools/Transform.h +++ b/src/MeshTools/Transform.h @@ -31,8 +31,8 @@ namespace Magnum { namespace MeshTools { Usable for one-time mesh transformations that would otherwise negatively affect dependent objects, such as (uneven) scaling. Accepts any forward-iterable type with compatible vector type as @p vectors. Expects that @ref Math::Quaternion "Quaternion" -or @ref Math::Complex "Complex" is normalized, no further requirements are for -transformation matrices. +is normalized, no further requirements are for other transformation +representations. Unlike in transformPointsInPlace(), the transformation does not involve translation. @@ -53,8 +53,8 @@ template void transformVectorsInPlace(const Math::Quaternion void transformVectorsInPlace(const Math::Complex& normalizedComplex, U& vectors) { - for(auto& vector: vectors) vector = normalizedComplex.transformVectorNormalized(vector); +template void transformVectorsInPlace(const Math::Complex& complex, U& vectors) { + for(auto& vector: vectors) vector = complex.transformVector(vector); } /** @overload */ @@ -86,7 +86,7 @@ Usable for one-time mesh transformations that would otherwise negatively affect dependent objects, such as (uneven) scaling. Accepts any forward-iterable type with compatible vector type as @p vectors. Expects that @ref Math::DualQuaternion "DualQuaternion" is normalized, no further -requirements are for transformation matrices. +requirements are for other transformation representations. Unlike in transformVectorsInPlace(), the transformation also involves translation.