mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
big rework of the Transform class:
* add Projective and AffineCompact modes as an optional third template argument * extend Transform::operator* to support more use cases
This commit is contained in:
@@ -99,6 +99,26 @@ template<typename MatrixType,int Direction> class Homogeneous
|
||||
ei_assert(Direction==Vertical);
|
||||
return ei_homogeneous_left_product_impl<Homogeneous,Lhs>(lhs.derived(),rhs.m_matrix);
|
||||
}
|
||||
|
||||
template<typename Scalar, int Dim, int Mode> friend
|
||||
inline const ei_homogeneous_left_product_impl<Homogeneous,
|
||||
typename Transform<Scalar,Dim,Mode>::AffinePart>
|
||||
operator* (const Transform<Scalar,Dim,Mode>& tr, const Homogeneous& rhs)
|
||||
{
|
||||
ei_assert(Direction==Vertical);
|
||||
return ei_homogeneous_left_product_impl<Homogeneous,typename Transform<Scalar,Dim,Mode>::AffinePart>
|
||||
(tr.affine(),rhs.m_matrix);
|
||||
}
|
||||
|
||||
template<typename Scalar, int Dim> friend
|
||||
inline const ei_homogeneous_left_product_impl<Homogeneous,
|
||||
typename Transform<Scalar,Dim,Projective>::MatrixType>
|
||||
operator* (const Transform<Scalar,Dim,Projective>& tr, const Homogeneous& rhs)
|
||||
{
|
||||
ei_assert(Direction==Vertical);
|
||||
return ei_homogeneous_left_product_impl<Homogeneous,typename Transform<Scalar,Dim,Projective>::MatrixType>
|
||||
(tr.matrix(),rhs.m_matrix);
|
||||
}
|
||||
|
||||
protected:
|
||||
const typename MatrixType::Nested m_matrix;
|
||||
|
||||
@@ -99,8 +99,9 @@ class RotationBase
|
||||
inline RotationMatrixType operator*(const MatrixBase<OtherDerived>& l, const Derived& r)
|
||||
{ return l.derived() * r.toRotationMatrix(); }
|
||||
|
||||
/** \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
|
||||
/** \returns the concatenation of the rotation \c *this with a transformation \a t */
|
||||
template<int Mode>
|
||||
inline Transform<Scalar,Dim,Mode> operator*(const Transform<Scalar,Dim,Mode>& t) const
|
||||
{ return toRotationMatrix() * t; }
|
||||
|
||||
template<typename OtherVectorType>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -53,7 +53,7 @@ public:
|
||||
/** corresponding linear transformation matrix type */
|
||||
typedef Matrix<Scalar,Dim,Dim> LinearMatrixType;
|
||||
/** corresponding affine transformation type */
|
||||
typedef Transform<Scalar,Dim> TransformType;
|
||||
typedef Transform<Scalar,Dim> AffineTransformType;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -89,23 +89,23 @@ public:
|
||||
{ return Translation(m_coeffs + other.m_coeffs); }
|
||||
|
||||
/** Concatenates a translation and a uniform scaling */
|
||||
inline TransformType operator* (const UniformScaling<Scalar>& other) const;
|
||||
inline AffineTransformType operator* (const UniformScaling<Scalar>& other) const;
|
||||
|
||||
/** Concatenates a translation and a linear transformation */
|
||||
template<typename OtherDerived>
|
||||
inline TransformType operator* (const MatrixBase<OtherDerived>& linear) const;
|
||||
inline AffineTransformType operator* (const MatrixBase<OtherDerived>& linear) const;
|
||||
|
||||
/** Concatenates a translation and a rotation */
|
||||
template<typename Derived>
|
||||
inline TransformType operator*(const RotationBase<Derived,Dim>& r) const
|
||||
inline AffineTransformType operator*(const RotationBase<Derived,Dim>& r) const
|
||||
{ return *this * r.toRotationMatrix(); }
|
||||
|
||||
/** \returns the concatenation of a linear transformation \a l with the translation \a t */
|
||||
// its a nightmare to define a templated friend function outside its declaration
|
||||
template<typename OtherDerived> friend
|
||||
inline TransformType operator*(const MatrixBase<OtherDerived>& linear, const Translation& t)
|
||||
inline AffineTransformType operator*(const MatrixBase<OtherDerived>& linear, const Translation& t)
|
||||
{
|
||||
TransformType res;
|
||||
AffineTransformType res;
|
||||
res.matrix().setZero();
|
||||
res.linear() = linear.derived();
|
||||
res.translation() = linear.derived() * t.m_coeffs;
|
||||
@@ -115,7 +115,13 @@ public:
|
||||
}
|
||||
|
||||
/** Concatenates a translation and an affine transformation */
|
||||
inline TransformType operator* (const TransformType& t) const;
|
||||
template<int Mode>
|
||||
inline Transform<Scalar,Dim,Mode> operator* (const Transform<Scalar,Dim,Mode>& t) const
|
||||
{
|
||||
Transform<Scalar,Dim,Mode> res = t;
|
||||
res.pretranslate(m_coeffs);
|
||||
return res;
|
||||
}
|
||||
|
||||
/** Applies translation to vector */
|
||||
inline VectorType operator* (const VectorType& other) const
|
||||
@@ -162,10 +168,10 @@ typedef Translation<double,3> Translation3d;
|
||||
//@}
|
||||
|
||||
template<typename Scalar, int Dim>
|
||||
inline typename Translation<Scalar,Dim>::TransformType
|
||||
inline typename Translation<Scalar,Dim>::AffineTransformType
|
||||
Translation<Scalar,Dim>::operator* (const UniformScaling<Scalar>& other) const
|
||||
{
|
||||
TransformType res;
|
||||
AffineTransformType res;
|
||||
res.matrix().setZero();
|
||||
res.linear().diagonal().fill(other.factor());
|
||||
res.translation() = m_coeffs;
|
||||
@@ -175,10 +181,10 @@ Translation<Scalar,Dim>::operator* (const UniformScaling<Scalar>& other) const
|
||||
|
||||
template<typename Scalar, int Dim>
|
||||
template<typename OtherDerived>
|
||||
inline typename Translation<Scalar,Dim>::TransformType
|
||||
inline typename Translation<Scalar,Dim>::AffineTransformType
|
||||
Translation<Scalar,Dim>::operator* (const MatrixBase<OtherDerived>& linear) const
|
||||
{
|
||||
TransformType res;
|
||||
AffineTransformType res;
|
||||
res.matrix().setZero();
|
||||
res.linear() = linear.derived();
|
||||
res.translation() = m_coeffs;
|
||||
@@ -187,13 +193,4 @@ Translation<Scalar,Dim>::operator* (const MatrixBase<OtherDerived>& linear) cons
|
||||
return res;
|
||||
}
|
||||
|
||||
template<typename Scalar, int Dim>
|
||||
inline typename Translation<Scalar,Dim>::TransformType
|
||||
Translation<Scalar,Dim>::operator* (const TransformType& t) const
|
||||
{
|
||||
TransformType res = t;
|
||||
res.pretranslate(m_coeffs);
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif // EIGEN_TRANSLATION_H
|
||||
|
||||
Reference in New Issue
Block a user