mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-19 19:34:29 +08:00
more MSVC fixes, and more code factorization in Geometry module
This commit is contained in:
parent
36c8a64923
commit
1752a3a677
@ -109,18 +109,6 @@ public:
|
|||||||
friend inline QuaternionType operator* (const QuaternionType& a, const AngleAxis& b)
|
friend inline QuaternionType operator* (const QuaternionType& a, const AngleAxis& b)
|
||||||
{ return a * QuaternionType(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 */
|
/** \returns the inverse rotation, i.e., an angle-axis with opposite rotation angle */
|
||||||
AngleAxis inverse() const
|
AngleAxis inverse() const
|
||||||
{ return AngleAxis(-m_angle, m_axis); }
|
{ return AngleAxis(-m_angle, m_axis); }
|
||||||
|
@ -62,6 +62,8 @@ class Quaternion : public RotationBase<Quaternion<_Scalar>,3>
|
|||||||
{
|
{
|
||||||
typedef RotationBase<Quaternion<_Scalar>,3> Base;
|
typedef RotationBase<Quaternion<_Scalar>,3> Base;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,4)
|
EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,4)
|
||||||
|
|
||||||
@ -193,8 +195,6 @@ public:
|
|||||||
|
|
||||||
Quaternion slerp(Scalar t, const Quaternion& other) const;
|
Quaternion slerp(Scalar t, const Quaternion& other) const;
|
||||||
|
|
||||||
Vector3 operator* (const Vector3& vec) const;
|
|
||||||
|
|
||||||
/** \returns \c *this with scalar type casted to \a NewScalarType
|
/** \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
|
* Note that if \a NewScalarType is equal to the current scalar type of \c *this
|
||||||
@ -216,6 +216,8 @@ public:
|
|||||||
bool isApprox(const Quaternion& other, typename NumTraits<Scalar>::Real prec = precision<Scalar>()) const
|
bool isApprox(const Quaternion& other, typename NumTraits<Scalar>::Real prec = precision<Scalar>()) const
|
||||||
{ return m_coeffs.isApprox(other.m_coeffs, prec); }
|
{ return m_coeffs.isApprox(other.m_coeffs, prec); }
|
||||||
|
|
||||||
|
Vector3 _transformVector(Vector3 v) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Coefficients m_coeffs;
|
Coefficients m_coeffs;
|
||||||
};
|
};
|
||||||
@ -256,7 +258,7 @@ inline Quaternion<Scalar>& Quaternion<Scalar>::operator*= (const Quaternion& oth
|
|||||||
*/
|
*/
|
||||||
template <typename Scalar>
|
template <typename Scalar>
|
||||||
inline typename Quaternion<Scalar>::Vector3
|
inline typename Quaternion<Scalar>::Vector3
|
||||||
Quaternion<Scalar>::operator* (const Vector3& v) const
|
Quaternion<Scalar>::_transformVector(Vector3 v) const
|
||||||
{
|
{
|
||||||
// Note that this algorithm comes from the optimization by hand
|
// Note that this algorithm comes from the optimization by hand
|
||||||
// of the conversion to a Matrix followed by a Matrix/Vector product.
|
// of the conversion to a Matrix followed by a Matrix/Vector product.
|
||||||
|
@ -45,7 +45,28 @@ class RotationBase
|
|||||||
|
|
||||||
/** corresponding linear transformation matrix type */
|
/** corresponding linear transformation matrix type */
|
||||||
typedef Matrix<Scalar,Dim,Dim> RotationMatrixType;
|
typedef Matrix<Scalar,Dim,Dim> RotationMatrixType;
|
||||||
|
typedef Matrix<Scalar,Dim,1> VectorType;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
template<typename MatrixType, bool IsVector=MatrixType::IsVectorAtCompileTime>
|
||||||
|
struct generic_product_selector
|
||||||
|
{
|
||||||
|
typedef RotationMatrixType ReturnType;
|
||||||
|
inline static RotationMatrixType run(const Derived& r, const MatrixType& m)
|
||||||
|
{ return r.toRotationMatrix() * m; }
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename OtherVectorType>
|
||||||
|
struct generic_product_selector<OtherVectorType,true>
|
||||||
|
{
|
||||||
|
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<const Derived*>(this); }
|
inline const Derived& derived() const { return *static_cast<const Derived*>(this); }
|
||||||
inline Derived& derived() { return *static_cast<Derived*>(this); }
|
inline Derived& derived() { return *static_cast<Derived*>(this); }
|
||||||
|
|
||||||
@ -63,10 +84,15 @@ class RotationBase
|
|||||||
inline RotationMatrixType operator*(const UniformScaling<Scalar>& s) const
|
inline RotationMatrixType operator*(const UniformScaling<Scalar>& s) const
|
||||||
{ return toRotationMatrix() * s.factor(); }
|
{ 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<typename OtherDerived>
|
template<typename OtherDerived>
|
||||||
inline RotationMatrixType operator*(const MatrixBase<OtherDerived>& l) const
|
inline typename generic_product_selector<OtherDerived>::ReturnType
|
||||||
{ return toRotationMatrix() * l.derived(); }
|
operator*(const MatrixBase<OtherDerived>& e) const
|
||||||
|
{ return generic_product_selector<OtherDerived>::run(derived(), e.derived()); }
|
||||||
|
|
||||||
/** \returns the concatenation of a linear transformation \a l with the rotation \a r */
|
/** \returns the concatenation of a linear transformation \a l with the rotation \a r */
|
||||||
template<typename OtherDerived> friend
|
template<typename OtherDerived> friend
|
||||||
@ -76,6 +102,10 @@ class RotationBase
|
|||||||
/** \returns the concatenation of the rotation \c *this with an affine transformation \a t */
|
/** \returns the concatenation of the rotation \c *this with an affine transformation \a t */
|
||||||
inline Transform<Scalar,Dim> operator*(const Transform<Scalar,Dim>& t) const
|
inline Transform<Scalar,Dim> operator*(const Transform<Scalar,Dim>& t) const
|
||||||
{ return toRotationMatrix() * t; }
|
{ return toRotationMatrix() * t; }
|
||||||
|
|
||||||
|
template<typename OtherVectorType>
|
||||||
|
inline VectorType _transformVector(const OtherVectorType& v) const
|
||||||
|
{ return toRotationMatrix() * v; }
|
||||||
};
|
};
|
||||||
|
|
||||||
/** \geometry_module
|
/** \geometry_module
|
||||||
|
Loading…
x
Reference in New Issue
Block a user