mirror of
https://gitlab.com/libeigen/eigen.git
synced 2024-12-15 07:10:37 +08:00
Make Transform::rotation() an alias to Transform::linear() in the case of an Isometry
This commit is contained in:
parent
2c2c114995
commit
2b70b2f570
@ -605,7 +605,9 @@ public:
|
||||
template<typename Derived>
|
||||
EIGEN_DEVICE_FUNC inline Transform operator*(const RotationBase<Derived,Dim>& r) const;
|
||||
|
||||
EIGEN_DEVICE_FUNC const LinearMatrixType rotation() const;
|
||||
typedef typename internal::conditional<int(Mode)==Isometry,ConstLinearPart,const LinearMatrixType>::type RotationReturnType;
|
||||
EIGEN_DEVICE_FUNC RotationReturnType rotation() const;
|
||||
|
||||
template<typename RotationMatrixType, typename ScalingMatrixType>
|
||||
EIGEN_DEVICE_FUNC
|
||||
void computeRotationScaling(RotationMatrixType *rotation, ScalingMatrixType *scaling) const;
|
||||
@ -1049,20 +1051,43 @@ EIGEN_DEVICE_FUNC inline Transform<Scalar,Dim,Mode,Options> Transform<Scalar,Dim
|
||||
*** Special functions ***
|
||||
************************/
|
||||
|
||||
namespace internal {
|
||||
template<int Mode> struct transform_rotation_impl {
|
||||
template<typename TransformType>
|
||||
EIGEN_DEVICE_FUNC static inline
|
||||
const typename TransformType::LinearMatrixType run(const TransformType& t)
|
||||
{
|
||||
typedef typename TransformType::LinearMatrixType LinearMatrixType;
|
||||
LinearMatrixType result;
|
||||
t.computeRotationScaling(&result, (LinearMatrixType*)0);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
template<> struct transform_rotation_impl<Isometry> {
|
||||
template<typename TransformType>
|
||||
EIGEN_DEVICE_FUNC static inline
|
||||
typename TransformType::ConstLinearPart run(const TransformType& t)
|
||||
{
|
||||
return t.linear();
|
||||
}
|
||||
};
|
||||
}
|
||||
/** \returns the rotation part of the transformation
|
||||
*
|
||||
* If Mode==Isometry, then this method is an alias for linear(),
|
||||
* otherwise it calls computeRotationScaling() to extract the rotation
|
||||
* through a SVD decomposition.
|
||||
*
|
||||
* \svd_module
|
||||
*
|
||||
* \sa computeRotationScaling(), computeScalingRotation(), class SVD
|
||||
*/
|
||||
template<typename Scalar, int Dim, int Mode, int Options>
|
||||
EIGEN_DEVICE_FUNC const typename Transform<Scalar,Dim,Mode,Options>::LinearMatrixType
|
||||
EIGEN_DEVICE_FUNC
|
||||
typename Transform<Scalar,Dim,Mode,Options>::RotationReturnType
|
||||
Transform<Scalar,Dim,Mode,Options>::rotation() const
|
||||
{
|
||||
LinearMatrixType result;
|
||||
computeRotationScaling(&result, (LinearMatrixType*)0);
|
||||
return result;
|
||||
return internal::transform_rotation_impl<Mode>::run(*this);
|
||||
}
|
||||
|
||||
|
||||
|
@ -666,6 +666,10 @@ template<typename Scalar, int Mode, int Options> void transformations_no_scale()
|
||||
VERIFY((m3 * m3.inverse()).isIdentity(test_precision<Scalar>()));
|
||||
// Verify implicit last row is initialized.
|
||||
VERIFY_IS_APPROX(Vector4(m3.row(3)), Vector4(0.0, 0.0, 0.0, 1.0));
|
||||
|
||||
VERIFY_IS_APPROX(t3.rotation(), t3.linear());
|
||||
if(Mode==Isometry)
|
||||
VERIFY(t3.rotation().data()==t3.linear().data());
|
||||
}
|
||||
|
||||
EIGEN_DECLARE_TEST(geo_transformations)
|
||||
|
Loading…
Reference in New Issue
Block a user