diff --git a/Eigen/src/Geometry/AngleAxis.h b/Eigen/src/Geometry/AngleAxis.h index 3c8b7d027..f30ad0728 100644 --- a/Eigen/src/Geometry/AngleAxis.h +++ b/Eigen/src/Geometry/AngleAxis.h @@ -109,18 +109,6 @@ public: friend inline QuaternionType operator* (const QuaternionType& a, const AngleAxis& b) { return a * QuaternionType(b); } - /** Concatenates two rotations */ - inline Matrix3 operator* (const Matrix3& other) const - { return toRotationMatrix() * other; } - - /** Concatenates two rotations */ - inline friend Matrix3 operator* (const Matrix3& a, const AngleAxis& b) - { return a * b.toRotationMatrix(); } - - /** Applies rotation to vector */ - inline Vector3 operator* (const Vector3& other) const - { return toRotationMatrix() * other; } - /** \returns the inverse rotation, i.e., an angle-axis with opposite rotation angle */ AngleAxis inverse() const { return AngleAxis(-m_angle, m_axis); } diff --git a/Eigen/src/Geometry/Quaternion.h b/Eigen/src/Geometry/Quaternion.h index 71bf13297..3ffb5bf37 100644 --- a/Eigen/src/Geometry/Quaternion.h +++ b/Eigen/src/Geometry/Quaternion.h @@ -61,12 +61,14 @@ template class Quaternion : public RotationBase,3> { typedef RotationBase,3> Base; - + + + public: EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,4) using Base::operator*; - + /** the scalar type of the coefficients */ typedef _Scalar Scalar; @@ -193,8 +195,6 @@ public: Quaternion slerp(Scalar t, const Quaternion& other) const; - Vector3 operator* (const Vector3& vec) const; - /** \returns \c *this with scalar type casted to \a NewScalarType * * Note that if \a NewScalarType is equal to the current scalar type of \c *this @@ -216,7 +216,9 @@ public: bool isApprox(const Quaternion& other, typename NumTraits::Real prec = precision()) const { return m_coeffs.isApprox(other.m_coeffs, prec); } -protected: + Vector3 _transformVector(Vector3 v) const; + +protected: Coefficients m_coeffs; }; @@ -256,7 +258,7 @@ inline Quaternion& Quaternion::operator*= (const Quaternion& oth */ template inline typename Quaternion::Vector3 -Quaternion::operator* (const Vector3& v) const +Quaternion::_transformVector(Vector3 v) const { // Note that this algorithm comes from the optimization by hand // of the conversion to a Matrix followed by a Matrix/Vector product. diff --git a/Eigen/src/Geometry/RotationBase.h b/Eigen/src/Geometry/RotationBase.h index 9d5f16e3f..1ce8834a4 100644 --- a/Eigen/src/Geometry/RotationBase.h +++ b/Eigen/src/Geometry/RotationBase.h @@ -42,10 +42,31 @@ class RotationBase enum { Dim = _Dim }; /** the scalar type of the coefficients */ typedef typename ei_traits::Scalar Scalar; - + /** corresponding linear transformation matrix type */ typedef Matrix RotationMatrixType; + typedef Matrix VectorType; + protected: + template + struct generic_product_selector + { + typedef RotationMatrixType ReturnType; + inline static RotationMatrixType run(const Derived& r, const MatrixType& m) + { return r.toRotationMatrix() * m; } + }; + + template + struct generic_product_selector + { + typedef VectorType ReturnType; + inline static VectorType run(const Derived& r, const OtherVectorType& v) + { + return r._transformVector(v); + } + }; + + public: inline const Derived& derived() const { return *static_cast(this); } inline Derived& derived() { return *static_cast(this); } @@ -62,12 +83,17 @@ class RotationBase /** \returns the concatenation of the rotation \c *this with a uniform scaling \a s */ inline RotationMatrixType operator*(const UniformScaling& s) const { return toRotationMatrix() * s.factor(); } - - /** \returns the concatenation of the rotation \c *this with a linear transformation \a l */ + + /** \returns the concatenation of the rotation \c *this with a generic expression \a e + * \a e can be: + * - a DimxDim linear transformation matrix (including an axis aligned scaling) + * - a vector of size Dim + */ template - inline RotationMatrixType operator*(const MatrixBase& l) const - { return toRotationMatrix() * l.derived(); } - + inline typename generic_product_selector::ReturnType + operator*(const MatrixBase& e) const + { return generic_product_selector::run(derived(), e.derived()); } + /** \returns the concatenation of a linear transformation \a l with the rotation \a r */ template friend inline RotationMatrixType operator*(const MatrixBase& l, const Derived& r) @@ -76,6 +102,10 @@ class RotationBase /** \returns the concatenation of the rotation \c *this with an affine transformation \a t */ inline Transform operator*(const Transform& t) const { return toRotationMatrix() * t; } + + template + inline VectorType _transformVector(const OtherVectorType& v) const + { return toRotationMatrix() * v; } }; /** \geometry_module