mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-12 19:20:36 +08:00
Fix QuaternionBase::cast for quaternion map and wrapper.
This commit is contained in:
parent
7745f69013
commit
6358599ecb
@ -169,17 +169,32 @@ class QuaternionBase : public RotationBase<Derived, 3>
|
||||
/** return the result vector of \a v through the rotation*/
|
||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Vector3 _transformVector(const Vector3& v) const;
|
||||
|
||||
#ifdef EIGEN_PARSED_BY_DOXYGEN
|
||||
/** \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
|
||||
* then this function smartly returns a const reference to \c *this.
|
||||
*/
|
||||
template<typename NewScalarType>
|
||||
EIGEN_DEVICE_FUNC inline typename internal::cast_return_type<Derived,Quaternion<NewScalarType> >::type cast() const
|
||||
EIGEN_DEVICE_FUNC inline typename internal::cast_return_type<Derived,Quaternion<NewScalarType> >::type cast() const;
|
||||
|
||||
#else
|
||||
|
||||
template<typename NewScalarType>
|
||||
EIGEN_DEVICE_FUNC inline
|
||||
typename internal::enable_if<internal::is_same<Scalar,NewScalarType>::value,const Derived&>::type cast() const
|
||||
{
|
||||
return typename internal::cast_return_type<Derived,Quaternion<NewScalarType> >::type(derived());
|
||||
return derived();
|
||||
}
|
||||
|
||||
template<typename NewScalarType>
|
||||
EIGEN_DEVICE_FUNC inline
|
||||
typename internal::enable_if<!internal::is_same<Scalar,NewScalarType>::value,Quaternion<NewScalarType> >::type cast() const
|
||||
{
|
||||
return Quaternion<NewScalarType>(coeffs().template cast<NewScalarType>());
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef EIGEN_QUATERNIONBASE_PLUGIN
|
||||
# include EIGEN_QUATERNIONBASE_PLUGIN
|
||||
#endif
|
||||
|
@ -245,6 +245,14 @@ template<typename Scalar> void mapQuaternion(void){
|
||||
// is used to determine whether we can return a coeff by reference or not, which is not enough for Map<const ...>.
|
||||
//const MCQuaternionUA& cmcq3(mcq3);
|
||||
//VERIFY( &cmcq3.x() == &mcq3.x() );
|
||||
|
||||
// test cast
|
||||
{
|
||||
Quaternion<float> q1f = mq1.template cast<float>();
|
||||
VERIFY_IS_APPROX(q1f.template cast<Scalar>(),mq1);
|
||||
Quaternion<double> q1d = mq1.template cast<double>();
|
||||
VERIFY_IS_APPROX(q1d.template cast<Scalar>(),mq1);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Scalar> void quaternionAlignment(void){
|
||||
|
Loading…
x
Reference in New Issue
Block a user