mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
bug #86 : use internal:: namespace instead of ei_ prefix
This commit is contained in:
@@ -84,7 +84,7 @@ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim)
|
||||
template<typename Derived>
|
||||
inline explicit AlignedBox(const MatrixBase<Derived>& a_p)
|
||||
{
|
||||
const typename ei_nested<Derived,2>::type p(a_p.derived());
|
||||
const typename internal::nested<Derived,2>::type p(a_p.derived());
|
||||
m_min = p;
|
||||
m_max = p;
|
||||
}
|
||||
@@ -120,8 +120,8 @@ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim)
|
||||
inline VectorType& max() { return m_max; }
|
||||
|
||||
/** \returns the center of the box */
|
||||
inline const CwiseUnaryOp<ei_scalar_quotient1_op<Scalar>,
|
||||
CwiseBinaryOp<ei_scalar_sum_op<Scalar>, VectorType, VectorType> >
|
||||
inline const CwiseUnaryOp<internal::scalar_quotient1_op<Scalar>,
|
||||
CwiseBinaryOp<internal::scalar_sum_op<Scalar>, VectorType, VectorType> >
|
||||
center() const
|
||||
{ return (m_min+m_max)/2; }
|
||||
|
||||
@@ -129,7 +129,7 @@ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim)
|
||||
* Note that this function does not get the same
|
||||
* result for integral or floating scalar types: see
|
||||
*/
|
||||
inline const CwiseBinaryOp< ei_scalar_difference_op<Scalar>, VectorType, VectorType> sizes() const
|
||||
inline const CwiseBinaryOp< internal::scalar_difference_op<Scalar>, VectorType, VectorType> sizes() const
|
||||
{ return m_max - m_min; }
|
||||
|
||||
/** \returns the volume of the bounding box */
|
||||
@@ -140,7 +140,7 @@ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim)
|
||||
* if the length of the diagonal is needed: diagonal().norm()
|
||||
* will provide it.
|
||||
*/
|
||||
inline CwiseBinaryOp< ei_scalar_difference_op<Scalar>, VectorType, VectorType> diagonal() const
|
||||
inline CwiseBinaryOp< internal::scalar_difference_op<Scalar>, VectorType, VectorType> diagonal() const
|
||||
{ return sizes(); }
|
||||
|
||||
/** \returns the vertex of the bounding box at the corner defined by
|
||||
@@ -178,10 +178,10 @@ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim)
|
||||
if(!ScalarTraits::IsInteger)
|
||||
{
|
||||
r[d] = m_min[d] + (m_max[d]-m_min[d])
|
||||
* ei_random<Scalar>(Scalar(0), Scalar(1));
|
||||
* internal::random<Scalar>(Scalar(0), Scalar(1));
|
||||
}
|
||||
else
|
||||
r[d] = ei_random(m_min[d], m_max[d]);
|
||||
r[d] = internal::random(m_min[d], m_max[d]);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
@@ -190,7 +190,7 @@ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim)
|
||||
template<typename Derived>
|
||||
inline bool contains(const MatrixBase<Derived>& a_p) const
|
||||
{
|
||||
const typename ei_nested<Derived,2>::type p(a_p.derived());
|
||||
const typename internal::nested<Derived,2>::type p(a_p.derived());
|
||||
return (m_min.array()<=p.array()).all() && (p.array()<=m_max.array()).all();
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim)
|
||||
template<typename Derived>
|
||||
inline AlignedBox& extend(const MatrixBase<Derived>& a_p)
|
||||
{
|
||||
const typename ei_nested<Derived,2>::type p(a_p.derived());
|
||||
const typename internal::nested<Derived,2>::type p(a_p.derived());
|
||||
m_min = m_min.cwiseMin(p);
|
||||
m_max = m_max.cwiseMax(p);
|
||||
return *this;
|
||||
@@ -236,7 +236,7 @@ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim)
|
||||
template<typename Derived>
|
||||
inline AlignedBox& translate(const MatrixBase<Derived>& a_t)
|
||||
{
|
||||
const typename ei_nested<Derived,2>::type t(a_t.derived());
|
||||
const typename internal::nested<Derived,2>::type t(a_t.derived());
|
||||
m_min += t;
|
||||
m_max += t;
|
||||
return *this;
|
||||
@@ -261,14 +261,14 @@ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim)
|
||||
*/
|
||||
template<typename Derived>
|
||||
inline NonInteger exteriorDistance(const MatrixBase<Derived>& p) const
|
||||
{ return ei_sqrt(NonInteger(squaredExteriorDistance(p))); }
|
||||
{ return internal::sqrt(NonInteger(squaredExteriorDistance(p))); }
|
||||
|
||||
/** \returns the distance between the boxes \a b and \c *this,
|
||||
* and zero if the boxes intersect.
|
||||
* \sa squaredExteriorDistance()
|
||||
*/
|
||||
inline NonInteger exteriorDistance(const AlignedBox& b) const
|
||||
{ return ei_sqrt(NonInteger(squaredExteriorDistance(b))); }
|
||||
{ return internal::sqrt(NonInteger(squaredExteriorDistance(b))); }
|
||||
|
||||
/** \returns \c *this with scalar type casted to \a NewScalarType
|
||||
*
|
||||
@@ -276,10 +276,10 @@ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim)
|
||||
* then this function smartly returns a const reference to \c *this.
|
||||
*/
|
||||
template<typename NewScalarType>
|
||||
inline typename ei_cast_return_type<AlignedBox,
|
||||
inline typename internal::cast_return_type<AlignedBox,
|
||||
AlignedBox<NewScalarType,AmbientDimAtCompileTime> >::type cast() const
|
||||
{
|
||||
return typename ei_cast_return_type<AlignedBox,
|
||||
return typename internal::cast_return_type<AlignedBox,
|
||||
AlignedBox<NewScalarType,AmbientDimAtCompileTime> >::type(*this);
|
||||
}
|
||||
|
||||
@@ -309,7 +309,7 @@ template<typename Scalar,int AmbientDim>
|
||||
template<typename Derived>
|
||||
inline Scalar AlignedBox<Scalar,AmbientDim>::squaredExteriorDistance(const MatrixBase<Derived>& a_p) const
|
||||
{
|
||||
const typename ei_nested<Derived,2*AmbientDim>::type p(a_p.derived());
|
||||
const typename internal::nested<Derived,2*AmbientDim>::type p(a_p.derived());
|
||||
Scalar dist2 = 0.;
|
||||
Scalar aux;
|
||||
for (Index k=0; k<dim(); ++k)
|
||||
|
||||
@@ -51,10 +51,12 @@
|
||||
* \sa class Quaternion, class Transform, MatrixBase::UnitX()
|
||||
*/
|
||||
|
||||
template<typename _Scalar> struct ei_traits<AngleAxis<_Scalar> >
|
||||
namespace internal {
|
||||
template<typename _Scalar> struct traits<AngleAxis<_Scalar> >
|
||||
{
|
||||
typedef _Scalar Scalar;
|
||||
};
|
||||
}
|
||||
|
||||
template<typename _Scalar>
|
||||
class AngleAxis : public RotationBase<AngleAxis<_Scalar>,3>
|
||||
@@ -131,8 +133,8 @@ public:
|
||||
* then this function smartly returns a const reference to \c *this.
|
||||
*/
|
||||
template<typename NewScalarType>
|
||||
inline typename ei_cast_return_type<AngleAxis,AngleAxis<NewScalarType> >::type cast() const
|
||||
{ return typename ei_cast_return_type<AngleAxis,AngleAxis<NewScalarType> >::type(*this); }
|
||||
inline typename internal::cast_return_type<AngleAxis,AngleAxis<NewScalarType> >::type cast() const
|
||||
{ return typename internal::cast_return_type<AngleAxis,AngleAxis<NewScalarType> >::type(*this); }
|
||||
|
||||
/** Copy constructor with scalar type conversion */
|
||||
template<typename OtherScalarType>
|
||||
@@ -149,7 +151,7 @@ public:
|
||||
*
|
||||
* \sa MatrixBase::isApprox() */
|
||||
bool isApprox(const AngleAxis& other, typename NumTraits<Scalar>::Real prec = NumTraits<Scalar>::dummy_precision()) const
|
||||
{ return m_axis.isApprox(other.m_axis, prec) && ei_isApprox(m_angle,other.m_angle, prec); }
|
||||
{ return m_axis.isApprox(other.m_axis, prec) && internal::isApprox(m_angle,other.m_angle, prec); }
|
||||
};
|
||||
|
||||
/** \ingroup Geometry_Module
|
||||
@@ -175,7 +177,7 @@ AngleAxis<Scalar>& AngleAxis<Scalar>::operator=(const QuaternionBase<QuatDerived
|
||||
else
|
||||
{
|
||||
m_angle = 2*std::acos(q.w());
|
||||
m_axis = q.vec() / ei_sqrt(n2);
|
||||
m_axis = q.vec() / internal::sqrt(n2);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@@ -208,8 +210,8 @@ typename AngleAxis<Scalar>::Matrix3
|
||||
AngleAxis<Scalar>::toRotationMatrix(void) const
|
||||
{
|
||||
Matrix3 res;
|
||||
Vector3 sin_axis = ei_sin(m_angle) * m_axis;
|
||||
Scalar c = ei_cos(m_angle);
|
||||
Vector3 sin_axis = internal::sin(m_angle) * m_axis;
|
||||
Scalar c = internal::cos(m_angle);
|
||||
Vector3 cos1_axis = (Scalar(1)-c) * m_axis;
|
||||
|
||||
Scalar tmp;
|
||||
|
||||
@@ -60,31 +60,31 @@ MatrixBase<Derived>::eulerAngles(Index a0, Index a1, Index a2) const
|
||||
if (a0==a2)
|
||||
{
|
||||
Scalar s = Vector2(coeff(j,i) , coeff(k,i)).norm();
|
||||
res[1] = ei_atan2(s, coeff(i,i));
|
||||
res[1] = internal::atan2(s, coeff(i,i));
|
||||
if (s > epsilon)
|
||||
{
|
||||
res[0] = ei_atan2(coeff(j,i), coeff(k,i));
|
||||
res[2] = ei_atan2(coeff(i,j),-coeff(i,k));
|
||||
res[0] = internal::atan2(coeff(j,i), coeff(k,i));
|
||||
res[2] = internal::atan2(coeff(i,j),-coeff(i,k));
|
||||
}
|
||||
else
|
||||
{
|
||||
res[0] = Scalar(0);
|
||||
res[2] = (coeff(i,i)>0?1:-1)*ei_atan2(-coeff(k,j), coeff(j,j));
|
||||
res[2] = (coeff(i,i)>0?1:-1)*internal::atan2(-coeff(k,j), coeff(j,j));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Scalar c = Vector2(coeff(i,i) , coeff(i,j)).norm();
|
||||
res[1] = ei_atan2(-coeff(i,k), c);
|
||||
res[1] = internal::atan2(-coeff(i,k), c);
|
||||
if (c > epsilon)
|
||||
{
|
||||
res[0] = ei_atan2(coeff(j,k), coeff(k,k));
|
||||
res[2] = ei_atan2(coeff(i,j), coeff(i,i));
|
||||
res[0] = internal::atan2(coeff(j,k), coeff(k,k));
|
||||
res[2] = internal::atan2(coeff(i,j), coeff(i,i));
|
||||
}
|
||||
else
|
||||
{
|
||||
res[0] = Scalar(0);
|
||||
res[2] = (coeff(i,k)>0?1:-1)*ei_atan2(-coeff(k,j), coeff(j,j));
|
||||
res[2] = (coeff(i,k)>0?1:-1)*internal::atan2(-coeff(k,j), coeff(j,j));
|
||||
}
|
||||
}
|
||||
if (!odd)
|
||||
|
||||
@@ -39,13 +39,16 @@
|
||||
*
|
||||
* \sa MatrixBase::homogeneous()
|
||||
*/
|
||||
|
||||
namespace internal {
|
||||
|
||||
template<typename MatrixType,int Direction>
|
||||
struct ei_traits<Homogeneous<MatrixType,Direction> >
|
||||
: ei_traits<MatrixType>
|
||||
struct traits<Homogeneous<MatrixType,Direction> >
|
||||
: traits<MatrixType>
|
||||
{
|
||||
typedef typename ei_traits<MatrixType>::StorageKind StorageKind;
|
||||
typedef typename ei_nested<MatrixType>::type MatrixTypeNested;
|
||||
typedef typename ei_unref<MatrixTypeNested>::type _MatrixTypeNested;
|
||||
typedef typename traits<MatrixType>::StorageKind StorageKind;
|
||||
typedef typename nested<MatrixType>::type MatrixTypeNested;
|
||||
typedef typename unref<MatrixTypeNested>::type _MatrixTypeNested;
|
||||
enum {
|
||||
RowsPlusOne = (MatrixType::RowsAtCompileTime != Dynamic) ?
|
||||
int(MatrixType::RowsAtCompileTime) + 1 : Dynamic,
|
||||
@@ -63,8 +66,10 @@ struct ei_traits<Homogeneous<MatrixType,Direction> >
|
||||
};
|
||||
};
|
||||
|
||||
template<typename MatrixType,typename Lhs> struct ei_homogeneous_left_product_impl;
|
||||
template<typename MatrixType,typename Rhs> struct ei_homogeneous_right_product_impl;
|
||||
template<typename MatrixType,typename Lhs> struct homogeneous_left_product_impl;
|
||||
template<typename MatrixType,typename Rhs> struct homogeneous_right_product_impl;
|
||||
|
||||
} // end namespace internal
|
||||
|
||||
template<typename MatrixType,int _Direction> class Homogeneous
|
||||
: public MatrixBase<Homogeneous<MatrixType,_Direction> >
|
||||
@@ -92,38 +97,38 @@ template<typename MatrixType,int _Direction> class Homogeneous
|
||||
}
|
||||
|
||||
template<typename Rhs>
|
||||
inline const ei_homogeneous_right_product_impl<Homogeneous,Rhs>
|
||||
inline const internal::homogeneous_right_product_impl<Homogeneous,Rhs>
|
||||
operator* (const MatrixBase<Rhs>& rhs) const
|
||||
{
|
||||
ei_assert(int(Direction)==Horizontal);
|
||||
return ei_homogeneous_right_product_impl<Homogeneous,Rhs>(m_matrix,rhs.derived());
|
||||
eigen_assert(int(Direction)==Horizontal);
|
||||
return internal::homogeneous_right_product_impl<Homogeneous,Rhs>(m_matrix,rhs.derived());
|
||||
}
|
||||
|
||||
template<typename Lhs> friend
|
||||
inline const ei_homogeneous_left_product_impl<Homogeneous,Lhs>
|
||||
inline const internal::homogeneous_left_product_impl<Homogeneous,Lhs>
|
||||
operator* (const MatrixBase<Lhs>& lhs, const Homogeneous& rhs)
|
||||
{
|
||||
ei_assert(int(Direction)==Vertical);
|
||||
return ei_homogeneous_left_product_impl<Homogeneous,Lhs>(lhs.derived(),rhs.m_matrix);
|
||||
eigen_assert(int(Direction)==Vertical);
|
||||
return internal::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,
|
||||
inline const internal::homogeneous_left_product_impl<Homogeneous,
|
||||
typename Transform<Scalar,Dim,Mode>::AffinePartNested>
|
||||
operator* (const Transform<Scalar,Dim,Mode>& tr, const Homogeneous& rhs)
|
||||
{
|
||||
ei_assert(int(Direction)==Vertical);
|
||||
return ei_homogeneous_left_product_impl<Homogeneous,typename Transform<Scalar,Dim,Mode>::AffinePartNested >
|
||||
eigen_assert(int(Direction)==Vertical);
|
||||
return internal::homogeneous_left_product_impl<Homogeneous,typename Transform<Scalar,Dim,Mode>::AffinePartNested >
|
||||
(tr.affine(),rhs.m_matrix);
|
||||
}
|
||||
|
||||
template<typename Scalar, int Dim> friend
|
||||
inline const ei_homogeneous_left_product_impl<Homogeneous,
|
||||
inline const internal::homogeneous_left_product_impl<Homogeneous,
|
||||
typename Transform<Scalar,Dim,Projective>::MatrixType>
|
||||
operator* (const Transform<Scalar,Dim,Projective>& tr, const Homogeneous& rhs)
|
||||
{
|
||||
ei_assert(int(Direction)==Vertical);
|
||||
return ei_homogeneous_left_product_impl<Homogeneous,typename Transform<Scalar,Dim,Projective>::MatrixType>
|
||||
eigen_assert(int(Direction)==Vertical);
|
||||
return internal::homogeneous_left_product_impl<Homogeneous,typename Transform<Scalar,Dim,Projective>::MatrixType>
|
||||
(tr.matrix(),rhs.m_matrix);
|
||||
}
|
||||
|
||||
@@ -210,11 +215,13 @@ VectorwiseOp<ExpressionType,Direction>::hnormalized() const
|
||||
Direction==Horizontal ? _expression().cols()-1 : 1));
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
|
||||
template<typename MatrixType,typename Lhs>
|
||||
struct ei_traits<ei_homogeneous_left_product_impl<Homogeneous<MatrixType,Vertical>,Lhs> >
|
||||
struct traits<homogeneous_left_product_impl<Homogeneous<MatrixType,Vertical>,Lhs> >
|
||||
{
|
||||
typedef typename ei_make_proper_matrix_type<
|
||||
typename ei_traits<MatrixType>::Scalar,
|
||||
typedef typename make_proper_matrix_type<
|
||||
typename traits<MatrixType>::Scalar,
|
||||
Lhs::RowsAtCompileTime,
|
||||
MatrixType::ColsAtCompileTime,
|
||||
MatrixType::PlainObject::Options,
|
||||
@@ -223,12 +230,12 @@ struct ei_traits<ei_homogeneous_left_product_impl<Homogeneous<MatrixType,Vertica
|
||||
};
|
||||
|
||||
template<typename MatrixType,typename Lhs>
|
||||
struct ei_homogeneous_left_product_impl<Homogeneous<MatrixType,Vertical>,Lhs>
|
||||
: public ReturnByValue<ei_homogeneous_left_product_impl<Homogeneous<MatrixType,Vertical>,Lhs> >
|
||||
struct homogeneous_left_product_impl<Homogeneous<MatrixType,Vertical>,Lhs>
|
||||
: public ReturnByValue<homogeneous_left_product_impl<Homogeneous<MatrixType,Vertical>,Lhs> >
|
||||
{
|
||||
typedef typename ei_cleantype<typename Lhs::Nested>::type LhsNested;
|
||||
typedef typename cleantype<typename Lhs::Nested>::type LhsNested;
|
||||
typedef typename MatrixType::Index Index;
|
||||
ei_homogeneous_left_product_impl(const Lhs& lhs, const MatrixType& rhs)
|
||||
homogeneous_left_product_impl(const Lhs& lhs, const MatrixType& rhs)
|
||||
: m_lhs(lhs), m_rhs(rhs)
|
||||
{}
|
||||
|
||||
@@ -251,9 +258,9 @@ struct ei_homogeneous_left_product_impl<Homogeneous<MatrixType,Vertical>,Lhs>
|
||||
};
|
||||
|
||||
template<typename MatrixType,typename Rhs>
|
||||
struct ei_traits<ei_homogeneous_right_product_impl<Homogeneous<MatrixType,Horizontal>,Rhs> >
|
||||
struct traits<homogeneous_right_product_impl<Homogeneous<MatrixType,Horizontal>,Rhs> >
|
||||
{
|
||||
typedef typename ei_make_proper_matrix_type<typename ei_traits<MatrixType>::Scalar,
|
||||
typedef typename make_proper_matrix_type<typename traits<MatrixType>::Scalar,
|
||||
MatrixType::RowsAtCompileTime,
|
||||
Rhs::ColsAtCompileTime,
|
||||
MatrixType::PlainObject::Options,
|
||||
@@ -262,12 +269,12 @@ struct ei_traits<ei_homogeneous_right_product_impl<Homogeneous<MatrixType,Horizo
|
||||
};
|
||||
|
||||
template<typename MatrixType,typename Rhs>
|
||||
struct ei_homogeneous_right_product_impl<Homogeneous<MatrixType,Horizontal>,Rhs>
|
||||
: public ReturnByValue<ei_homogeneous_right_product_impl<Homogeneous<MatrixType,Horizontal>,Rhs> >
|
||||
struct homogeneous_right_product_impl<Homogeneous<MatrixType,Horizontal>,Rhs>
|
||||
: public ReturnByValue<homogeneous_right_product_impl<Homogeneous<MatrixType,Horizontal>,Rhs> >
|
||||
{
|
||||
typedef typename ei_cleantype<typename Rhs::Nested>::type RhsNested;
|
||||
typedef typename cleantype<typename Rhs::Nested>::type RhsNested;
|
||||
typedef typename MatrixType::Index Index;
|
||||
ei_homogeneous_right_product_impl(const MatrixType& lhs, const Rhs& rhs)
|
||||
homogeneous_right_product_impl(const MatrixType& lhs, const Rhs& rhs)
|
||||
: m_lhs(lhs), m_rhs(rhs)
|
||||
{}
|
||||
|
||||
@@ -289,4 +296,6 @@ struct ei_homogeneous_right_product_impl<Homogeneous<MatrixType,Horizontal>,Rhs>
|
||||
const typename Rhs::Nested m_rhs;
|
||||
};
|
||||
|
||||
} // end namespace internal
|
||||
|
||||
#endif // EIGEN_HOMOGENEOUS_H
|
||||
|
||||
@@ -139,7 +139,7 @@ public:
|
||||
/** \returns the absolute distance between the plane \c *this and a point \a p.
|
||||
* \sa signedDistance()
|
||||
*/
|
||||
inline Scalar absDistance(const VectorType& p) const { return ei_abs(signedDistance(p)); }
|
||||
inline Scalar absDistance(const VectorType& p) const { return internal::abs(signedDistance(p)); }
|
||||
|
||||
/** \returns the projection of a point \a p onto the plane \c *this.
|
||||
*/
|
||||
@@ -186,9 +186,9 @@ public:
|
||||
Scalar det = coeffs().coeff(0) * other.coeffs().coeff(1) - coeffs().coeff(1) * other.coeffs().coeff(0);
|
||||
// since the line equations ax+by=c are normalized with a^2+b^2=1, the following tests
|
||||
// whether the two lines are approximately parallel.
|
||||
if(ei_isMuchSmallerThan(det, Scalar(1)))
|
||||
if(internal::isMuchSmallerThan(det, Scalar(1)))
|
||||
{ // special case where the two lines are approximately parallel. Pick any point on the first line.
|
||||
if(ei_abs(coeffs().coeff(1))>ei_abs(coeffs().coeff(0)))
|
||||
if(internal::abs(coeffs().coeff(1))>internal::abs(coeffs().coeff(0)))
|
||||
return VectorType(coeffs().coeff(1), -coeffs().coeff(2)/coeffs().coeff(1)-coeffs().coeff(0));
|
||||
else
|
||||
return VectorType(-coeffs().coeff(2)/coeffs().coeff(0)-coeffs().coeff(1), coeffs().coeff(0));
|
||||
@@ -216,7 +216,7 @@ public:
|
||||
normal() = mat * normal();
|
||||
else
|
||||
{
|
||||
ei_assert("invalid traits value in Hyperplane::transform()");
|
||||
eigen_assert("invalid traits value in Hyperplane::transform()");
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@@ -242,10 +242,10 @@ public:
|
||||
* then this function smartly returns a const reference to \c *this.
|
||||
*/
|
||||
template<typename NewScalarType>
|
||||
inline typename ei_cast_return_type<Hyperplane,
|
||||
inline typename internal::cast_return_type<Hyperplane,
|
||||
Hyperplane<NewScalarType,AmbientDimAtCompileTime> >::type cast() const
|
||||
{
|
||||
return typename ei_cast_return_type<Hyperplane,
|
||||
return typename internal::cast_return_type<Hyperplane,
|
||||
Hyperplane<NewScalarType,AmbientDimAtCompileTime> >::type(*this);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,23 +43,25 @@ MatrixBase<Derived>::cross(const MatrixBase<OtherDerived>& other) const
|
||||
|
||||
// Note that there is no need for an expression here since the compiler
|
||||
// optimize such a small temporary very well (even within a complex expression)
|
||||
const typename ei_nested<Derived,2>::type lhs(derived());
|
||||
const typename ei_nested<OtherDerived,2>::type rhs(other.derived());
|
||||
return typename ei_plain_matrix_type<Derived>::type(
|
||||
const typename internal::nested<Derived,2>::type lhs(derived());
|
||||
const typename internal::nested<OtherDerived,2>::type rhs(other.derived());
|
||||
return typename internal::plain_matrix_type<Derived>::type(
|
||||
lhs.coeff(1) * rhs.coeff(2) - lhs.coeff(2) * rhs.coeff(1),
|
||||
lhs.coeff(2) * rhs.coeff(0) - lhs.coeff(0) * rhs.coeff(2),
|
||||
lhs.coeff(0) * rhs.coeff(1) - lhs.coeff(1) * rhs.coeff(0)
|
||||
);
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
|
||||
template< int Arch,typename VectorLhs,typename VectorRhs,
|
||||
typename Scalar = typename VectorLhs::Scalar,
|
||||
bool Vectorizable = (VectorLhs::Flags&VectorRhs::Flags)&PacketAccessBit>
|
||||
struct ei_cross3_impl {
|
||||
inline static typename ei_plain_matrix_type<VectorLhs>::type
|
||||
struct cross3_impl {
|
||||
inline static typename internal::plain_matrix_type<VectorLhs>::type
|
||||
run(const VectorLhs& lhs, const VectorRhs& rhs)
|
||||
{
|
||||
return typename ei_plain_matrix_type<VectorLhs>::type(
|
||||
return typename internal::plain_matrix_type<VectorLhs>::type(
|
||||
lhs.coeff(1) * rhs.coeff(2) - lhs.coeff(2) * rhs.coeff(1),
|
||||
lhs.coeff(2) * rhs.coeff(0) - lhs.coeff(0) * rhs.coeff(2),
|
||||
lhs.coeff(0) * rhs.coeff(1) - lhs.coeff(1) * rhs.coeff(0),
|
||||
@@ -68,6 +70,8 @@ struct ei_cross3_impl {
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/** \geometry_module
|
||||
*
|
||||
* \returns the cross product of \c *this and \a other using only the x, y, and z coefficients
|
||||
@@ -85,14 +89,14 @@ MatrixBase<Derived>::cross3(const MatrixBase<OtherDerived>& other) const
|
||||
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Derived,4)
|
||||
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,4)
|
||||
|
||||
typedef typename ei_nested<Derived,2>::type DerivedNested;
|
||||
typedef typename ei_nested<OtherDerived,2>::type OtherDerivedNested;
|
||||
typedef typename internal::nested<Derived,2>::type DerivedNested;
|
||||
typedef typename internal::nested<OtherDerived,2>::type OtherDerivedNested;
|
||||
const DerivedNested lhs(derived());
|
||||
const OtherDerivedNested rhs(other.derived());
|
||||
|
||||
return ei_cross3_impl<Architecture::Target,
|
||||
typename ei_cleantype<DerivedNested>::type,
|
||||
typename ei_cleantype<OtherDerivedNested>::type>::run(lhs,rhs);
|
||||
return internal::cross3_impl<Architecture::Target,
|
||||
typename internal::cleantype<DerivedNested>::type,
|
||||
typename internal::cleantype<OtherDerivedNested>::type>::run(lhs,rhs);
|
||||
}
|
||||
|
||||
/** \returns a matrix expression of the cross product of each column or row
|
||||
@@ -110,20 +114,20 @@ const typename VectorwiseOp<ExpressionType,Direction>::CrossReturnType
|
||||
VectorwiseOp<ExpressionType,Direction>::cross(const MatrixBase<OtherDerived>& other) const
|
||||
{
|
||||
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(OtherDerived,3)
|
||||
EIGEN_STATIC_ASSERT((ei_is_same_type<Scalar, typename OtherDerived::Scalar>::ret),
|
||||
EIGEN_STATIC_ASSERT((internal::is_same_type<Scalar, typename OtherDerived::Scalar>::ret),
|
||||
YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
|
||||
|
||||
CrossReturnType res(_expression().rows(),_expression().cols());
|
||||
if(Direction==Vertical)
|
||||
{
|
||||
ei_assert(CrossReturnType::RowsAtCompileTime==3 && "the matrix must have exactly 3 rows");
|
||||
eigen_assert(CrossReturnType::RowsAtCompileTime==3 && "the matrix must have exactly 3 rows");
|
||||
res.row(0) = _expression().row(1) * other.coeff(2) - _expression().row(2) * other.coeff(1);
|
||||
res.row(1) = _expression().row(2) * other.coeff(0) - _expression().row(0) * other.coeff(2);
|
||||
res.row(2) = _expression().row(0) * other.coeff(1) - _expression().row(1) * other.coeff(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
ei_assert(CrossReturnType::ColsAtCompileTime==3 && "the matrix must have exactly 3 columns");
|
||||
eigen_assert(CrossReturnType::ColsAtCompileTime==3 && "the matrix must have exactly 3 columns");
|
||||
res.col(0) = _expression().col(1) * other.coeff(2) - _expression().col(2) * other.coeff(1);
|
||||
res.col(1) = _expression().col(2) * other.coeff(0) - _expression().col(0) * other.coeff(2);
|
||||
res.col(2) = _expression().col(0) * other.coeff(1) - _expression().col(1) * other.coeff(0);
|
||||
@@ -131,11 +135,13 @@ VectorwiseOp<ExpressionType,Direction>::cross(const MatrixBase<OtherDerived>& ot
|
||||
return res;
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
|
||||
template<typename Derived, int Size = Derived::SizeAtCompileTime>
|
||||
struct ei_unitOrthogonal_selector
|
||||
struct unitOrthogonal_selector
|
||||
{
|
||||
typedef typename ei_plain_matrix_type<Derived>::type VectorType;
|
||||
typedef typename ei_traits<Derived>::Scalar Scalar;
|
||||
typedef typename plain_matrix_type<Derived>::type VectorType;
|
||||
typedef typename traits<Derived>::Scalar Scalar;
|
||||
typedef typename NumTraits<Scalar>::Real RealScalar;
|
||||
typedef typename Derived::Index Index;
|
||||
typedef Matrix<Scalar,2,1> Vector2;
|
||||
@@ -148,18 +154,18 @@ struct ei_unitOrthogonal_selector
|
||||
if (maxi==0)
|
||||
sndi = 1;
|
||||
RealScalar invnm = RealScalar(1)/(Vector2() << src.coeff(sndi),src.coeff(maxi)).finished().norm();
|
||||
perp.coeffRef(maxi) = -ei_conj(src.coeff(sndi)) * invnm;
|
||||
perp.coeffRef(sndi) = ei_conj(src.coeff(maxi)) * invnm;
|
||||
perp.coeffRef(maxi) = -conj(src.coeff(sndi)) * invnm;
|
||||
perp.coeffRef(sndi) = conj(src.coeff(maxi)) * invnm;
|
||||
|
||||
return perp;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Derived>
|
||||
struct ei_unitOrthogonal_selector<Derived,3>
|
||||
struct unitOrthogonal_selector<Derived,3>
|
||||
{
|
||||
typedef typename ei_plain_matrix_type<Derived>::type VectorType;
|
||||
typedef typename ei_traits<Derived>::Scalar Scalar;
|
||||
typedef typename plain_matrix_type<Derived>::type VectorType;
|
||||
typedef typename traits<Derived>::Scalar Scalar;
|
||||
typedef typename NumTraits<Scalar>::Real RealScalar;
|
||||
inline static VectorType run(const Derived& src)
|
||||
{
|
||||
@@ -171,12 +177,12 @@ struct ei_unitOrthogonal_selector<Derived,3>
|
||||
/* unless the x and y coords are both close to zero, we can
|
||||
* simply take ( -y, x, 0 ) and normalize it.
|
||||
*/
|
||||
if((!ei_isMuchSmallerThan(src.x(), src.z()))
|
||||
|| (!ei_isMuchSmallerThan(src.y(), src.z())))
|
||||
if((!isMuchSmallerThan(src.x(), src.z()))
|
||||
|| (!isMuchSmallerThan(src.y(), src.z())))
|
||||
{
|
||||
RealScalar invnm = RealScalar(1)/src.template head<2>().norm();
|
||||
perp.coeffRef(0) = -ei_conj(src.y())*invnm;
|
||||
perp.coeffRef(1) = ei_conj(src.x())*invnm;
|
||||
perp.coeffRef(0) = -conj(src.y())*invnm;
|
||||
perp.coeffRef(1) = conj(src.x())*invnm;
|
||||
perp.coeffRef(2) = 0;
|
||||
}
|
||||
/* if both x and y are close to zero, then the vector is close
|
||||
@@ -187,8 +193,8 @@ struct ei_unitOrthogonal_selector<Derived,3>
|
||||
{
|
||||
RealScalar invnm = RealScalar(1)/src.template tail<2>().norm();
|
||||
perp.coeffRef(0) = 0;
|
||||
perp.coeffRef(1) = -ei_conj(src.z())*invnm;
|
||||
perp.coeffRef(2) = ei_conj(src.y())*invnm;
|
||||
perp.coeffRef(1) = -conj(src.z())*invnm;
|
||||
perp.coeffRef(2) = conj(src.y())*invnm;
|
||||
}
|
||||
|
||||
return perp;
|
||||
@@ -196,13 +202,15 @@ struct ei_unitOrthogonal_selector<Derived,3>
|
||||
};
|
||||
|
||||
template<typename Derived>
|
||||
struct ei_unitOrthogonal_selector<Derived,2>
|
||||
struct unitOrthogonal_selector<Derived,2>
|
||||
{
|
||||
typedef typename ei_plain_matrix_type<Derived>::type VectorType;
|
||||
typedef typename plain_matrix_type<Derived>::type VectorType;
|
||||
inline static VectorType run(const Derived& src)
|
||||
{ return VectorType(-ei_conj(src.y()), ei_conj(src.x())).normalized(); }
|
||||
{ return VectorType(-conj(src.y()), conj(src.x())).normalized(); }
|
||||
};
|
||||
|
||||
} // end namespace internal
|
||||
|
||||
/** \returns a unit vector which is orthogonal to \c *this
|
||||
*
|
||||
* The size of \c *this must be at least 2. If the size is exactly 2,
|
||||
@@ -215,7 +223,7 @@ typename MatrixBase<Derived>::PlainObject
|
||||
MatrixBase<Derived>::unitOrthogonal() const
|
||||
{
|
||||
EIGEN_STATIC_ASSERT_VECTOR_ONLY(Derived)
|
||||
return ei_unitOrthogonal_selector<Derived>::run(derived());
|
||||
return internal::unitOrthogonal_selector<Derived>::run(derived());
|
||||
}
|
||||
|
||||
#endif // EIGEN_ORTHOMETHODS_H
|
||||
|
||||
@@ -91,7 +91,7 @@ public:
|
||||
/** \returns the distance of a point \a p to its projection onto the line \c *this.
|
||||
* \sa squaredDistance()
|
||||
*/
|
||||
RealScalar distance(const VectorType& p) const { return ei_sqrt(squaredDistance(p)); }
|
||||
RealScalar distance(const VectorType& p) const { return internal::sqrt(squaredDistance(p)); }
|
||||
|
||||
/** \returns the projection of a point \a p onto the line \c *this. */
|
||||
VectorType projection(const VectorType& p) const
|
||||
@@ -105,10 +105,10 @@ public:
|
||||
* then this function smartly returns a const reference to \c *this.
|
||||
*/
|
||||
template<typename NewScalarType>
|
||||
inline typename ei_cast_return_type<ParametrizedLine,
|
||||
inline typename internal::cast_return_type<ParametrizedLine,
|
||||
ParametrizedLine<NewScalarType,AmbientDimAtCompileTime> >::type cast() const
|
||||
{
|
||||
return typename ei_cast_return_type<ParametrizedLine,
|
||||
return typename internal::cast_return_type<ParametrizedLine,
|
||||
ParametrizedLine<NewScalarType,AmbientDimAtCompileTime> >::type(*this);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,10 +31,12 @@
|
||||
* The implementation is at the end of the file
|
||||
***************************************************************************/
|
||||
|
||||
namespace internal {
|
||||
template<typename Other,
|
||||
int OtherRows=Other::RowsAtCompileTime,
|
||||
int OtherCols=Other::ColsAtCompileTime>
|
||||
struct ei_quaternionbase_assign_impl;
|
||||
struct quaternionbase_assign_impl;
|
||||
}
|
||||
|
||||
template<class Derived>
|
||||
class QuaternionBase : public RotationBase<Derived, 3>
|
||||
@@ -44,9 +46,9 @@ public:
|
||||
using Base::operator*;
|
||||
using Base::derived;
|
||||
|
||||
typedef typename ei_traits<Derived>::Scalar Scalar;
|
||||
typedef typename internal::traits<Derived>::Scalar Scalar;
|
||||
typedef typename NumTraits<Scalar>::Real RealScalar;
|
||||
typedef typename ei_traits<Derived>::Coefficients Coefficients;
|
||||
typedef typename internal::traits<Derived>::Coefficients Coefficients;
|
||||
|
||||
// typedef typename Matrix<Scalar,4,1> Coefficients;
|
||||
/** the type of a 3D vector */
|
||||
@@ -83,10 +85,10 @@ public:
|
||||
inline VectorBlock<Coefficients,3> vec() { return coeffs().template head<3>(); }
|
||||
|
||||
/** \returns a read-only vector expression of the coefficients (x,y,z,w) */
|
||||
inline const typename ei_traits<Derived>::Coefficients& coeffs() const { return derived().coeffs(); }
|
||||
inline const typename internal::traits<Derived>::Coefficients& coeffs() const { return derived().coeffs(); }
|
||||
|
||||
/** \returns a vector expression of the coefficients (x,y,z,w) */
|
||||
inline typename ei_traits<Derived>::Coefficients& coeffs() { return derived().coeffs(); }
|
||||
inline typename internal::traits<Derived>::Coefficients& coeffs() { return derived().coeffs(); }
|
||||
|
||||
EIGEN_STRONG_INLINE QuaternionBase<Derived>& operator=(const QuaternionBase<Derived>& other);
|
||||
template<class OtherDerived> EIGEN_STRONG_INLINE Derived& operator=(const QuaternionBase<OtherDerived>& other);
|
||||
@@ -175,9 +177,9 @@ public:
|
||||
* then this function smartly returns a const reference to \c *this.
|
||||
*/
|
||||
template<typename NewScalarType>
|
||||
inline typename ei_cast_return_type<Derived,Quaternion<NewScalarType> >::type cast() const
|
||||
inline typename internal::cast_return_type<Derived,Quaternion<NewScalarType> >::type cast() const
|
||||
{
|
||||
return typename ei_cast_return_type<Derived,Quaternion<NewScalarType> >::type(
|
||||
return typename internal::cast_return_type<Derived,Quaternion<NewScalarType> >::type(
|
||||
coeffs().template cast<NewScalarType>());
|
||||
}
|
||||
|
||||
@@ -212,8 +214,9 @@ public:
|
||||
* \sa class AngleAxis, class Transform
|
||||
*/
|
||||
|
||||
namespace internal {
|
||||
template<typename _Scalar>
|
||||
struct ei_traits<Quaternion<_Scalar> >
|
||||
struct traits<Quaternion<_Scalar> >
|
||||
{
|
||||
typedef Quaternion<_Scalar> PlainObject;
|
||||
typedef _Scalar Scalar;
|
||||
@@ -222,6 +225,7 @@ struct ei_traits<Quaternion<_Scalar> >
|
||||
PacketAccess = Aligned
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
template<typename _Scalar>
|
||||
class Quaternion : public QuaternionBase<Quaternion<_Scalar> >{
|
||||
@@ -232,7 +236,7 @@ public:
|
||||
EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Quaternion<Scalar>)
|
||||
using Base::operator*=;
|
||||
|
||||
typedef typename ei_traits<Quaternion<Scalar> >::Coefficients Coefficients;
|
||||
typedef typename internal::traits<Quaternion<Scalar> >::Coefficients Coefficients;
|
||||
typedef typename Base::AngleAxisType AngleAxisType;
|
||||
|
||||
/** Default constructor leaving the quaternion uninitialized. */
|
||||
@@ -281,9 +285,10 @@ typedef Quaternion<double> Quaterniond;
|
||||
* Specialization of Map<Quaternion<Scalar>>
|
||||
***************************************************************************/
|
||||
|
||||
namespace internal {
|
||||
template<typename _Scalar, int _PacketAccess>
|
||||
struct ei_traits<Map<Quaternion<_Scalar>, _PacketAccess> >:
|
||||
ei_traits<Quaternion<_Scalar> >
|
||||
struct traits<Map<Quaternion<_Scalar>, _PacketAccess> >:
|
||||
traits<Quaternion<_Scalar> >
|
||||
{
|
||||
typedef _Scalar Scalar;
|
||||
typedef Map<Matrix<_Scalar,4,1>, _PacketAccess> Coefficients;
|
||||
@@ -291,6 +296,7 @@ ei_traits<Quaternion<_Scalar> >
|
||||
PacketAccess = _PacketAccess
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
/** \brief Expression of a quaternion from a memory buffer
|
||||
*
|
||||
@@ -310,7 +316,7 @@ class Map<Quaternion<_Scalar>, PacketAccess >
|
||||
|
||||
public:
|
||||
typedef _Scalar Scalar;
|
||||
typedef typename ei_traits<Map>::Coefficients Coefficients;
|
||||
typedef typename internal::traits<Map>::Coefficients Coefficients;
|
||||
EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Map)
|
||||
using Base::operator*=;
|
||||
|
||||
@@ -348,7 +354,8 @@ typedef Map<Quaternion<double>, Aligned> QuaternionMapAlignedd;
|
||||
|
||||
// Generic Quaternion * Quaternion product
|
||||
// This product can be specialized for a given architecture via the Arch template argument.
|
||||
template<int Arch, class Derived1, class Derived2, typename Scalar, int PacketAccess> struct ei_quat_product
|
||||
namespace internal {
|
||||
template<int Arch, class Derived1, class Derived2, typename Scalar, int PacketAccess> struct quat_product
|
||||
{
|
||||
EIGEN_STRONG_INLINE static Quaternion<Scalar> run(const QuaternionBase<Derived1>& a, const QuaternionBase<Derived2>& b){
|
||||
return Quaternion<Scalar>
|
||||
@@ -360,18 +367,19 @@ template<int Arch, class Derived1, class Derived2, typename Scalar, int PacketAc
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/** \returns the concatenation of two rotations as a quaternion-quaternion product */
|
||||
template <class Derived>
|
||||
template <class OtherDerived>
|
||||
EIGEN_STRONG_INLINE Quaternion<typename ei_traits<Derived>::Scalar>
|
||||
EIGEN_STRONG_INLINE Quaternion<typename internal::traits<Derived>::Scalar>
|
||||
QuaternionBase<Derived>::operator* (const QuaternionBase<OtherDerived>& other) const
|
||||
{
|
||||
EIGEN_STATIC_ASSERT((ei_is_same_type<typename Derived::Scalar, typename OtherDerived::Scalar>::ret),
|
||||
EIGEN_STATIC_ASSERT((internal::is_same_type<typename Derived::Scalar, typename OtherDerived::Scalar>::ret),
|
||||
YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
|
||||
return ei_quat_product<Architecture::Target, Derived, OtherDerived,
|
||||
typename ei_traits<Derived>::Scalar,
|
||||
ei_traits<Derived>::PacketAccess && ei_traits<OtherDerived>::PacketAccess>::run(*this, other);
|
||||
return internal::quat_product<Architecture::Target, Derived, OtherDerived,
|
||||
typename internal::traits<Derived>::Scalar,
|
||||
internal::traits<Derived>::PacketAccess && internal::traits<OtherDerived>::PacketAccess>::run(*this, other);
|
||||
}
|
||||
|
||||
/** \sa operator*(Quaternion) */
|
||||
@@ -425,8 +433,8 @@ template<class Derived>
|
||||
EIGEN_STRONG_INLINE Derived& QuaternionBase<Derived>::operator=(const AngleAxisType& aa)
|
||||
{
|
||||
Scalar ha = Scalar(0.5)*aa.angle(); // Scalar(0.5) to suppress precision loss warnings
|
||||
this->w() = ei_cos(ha);
|
||||
this->vec() = ei_sin(ha) * aa.axis();
|
||||
this->w() = internal::cos(ha);
|
||||
this->vec() = internal::sin(ha) * aa.axis();
|
||||
return derived();
|
||||
}
|
||||
|
||||
@@ -440,9 +448,9 @@ template<class Derived>
|
||||
template<class MatrixDerived>
|
||||
inline Derived& QuaternionBase<Derived>::operator=(const MatrixBase<MatrixDerived>& xpr)
|
||||
{
|
||||
EIGEN_STATIC_ASSERT((ei_is_same_type<typename Derived::Scalar, typename MatrixDerived::Scalar>::ret),
|
||||
EIGEN_STATIC_ASSERT((internal::is_same_type<typename Derived::Scalar, typename MatrixDerived::Scalar>::ret),
|
||||
YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
|
||||
ei_quaternionbase_assign_impl<MatrixDerived>::run(*this, xpr.derived());
|
||||
internal::quaternionbase_assign_impl<MatrixDerived>::run(*this, xpr.derived());
|
||||
return derived();
|
||||
}
|
||||
|
||||
@@ -519,12 +527,12 @@ inline Derived& QuaternionBase<Derived>::setFromTwoVectors(const MatrixBase<Deri
|
||||
Vector3 axis = svd.matrixV().col(2);
|
||||
|
||||
Scalar w2 = (Scalar(1)+c)*Scalar(0.5);
|
||||
this->w() = ei_sqrt(w2);
|
||||
this->vec() = axis * ei_sqrt(Scalar(1) - w2);
|
||||
this->w() = internal::sqrt(w2);
|
||||
this->vec() = axis * internal::sqrt(Scalar(1) - w2);
|
||||
return derived();
|
||||
}
|
||||
Vector3 axis = v0.cross(v1);
|
||||
Scalar s = ei_sqrt((Scalar(1)+c)*Scalar(2));
|
||||
Scalar s = internal::sqrt((Scalar(1)+c)*Scalar(2));
|
||||
Scalar invs = Scalar(1)/s;
|
||||
this->vec() = axis * invs;
|
||||
this->w() = s * Scalar(0.5);
|
||||
@@ -539,7 +547,7 @@ inline Derived& QuaternionBase<Derived>::setFromTwoVectors(const MatrixBase<Deri
|
||||
* \sa QuaternionBase::conjugate()
|
||||
*/
|
||||
template <class Derived>
|
||||
inline Quaternion<typename ei_traits<Derived>::Scalar> QuaternionBase<Derived>::inverse() const
|
||||
inline Quaternion<typename internal::traits<Derived>::Scalar> QuaternionBase<Derived>::inverse() const
|
||||
{
|
||||
// FIXME should this function be called multiplicativeInverse and conjugate() be called inverse() or opposite() ??
|
||||
Scalar n2 = this->squaredNorm();
|
||||
@@ -559,7 +567,7 @@ inline Quaternion<typename ei_traits<Derived>::Scalar> QuaternionBase<Derived>::
|
||||
* \sa Quaternion2::inverse()
|
||||
*/
|
||||
template <class Derived>
|
||||
inline Quaternion<typename ei_traits<Derived>::Scalar>
|
||||
inline Quaternion<typename internal::traits<Derived>::Scalar>
|
||||
QuaternionBase<Derived>::conjugate() const
|
||||
{
|
||||
return Quaternion<Scalar>(this->w(),-this->x(),-this->y(),-this->z());
|
||||
@@ -570,10 +578,10 @@ QuaternionBase<Derived>::conjugate() const
|
||||
*/
|
||||
template <class Derived>
|
||||
template <class OtherDerived>
|
||||
inline typename ei_traits<Derived>::Scalar
|
||||
inline typename internal::traits<Derived>::Scalar
|
||||
QuaternionBase<Derived>::angularDistance(const QuaternionBase<OtherDerived>& other) const
|
||||
{
|
||||
double d = ei_abs(this->dot(other));
|
||||
double d = internal::abs(this->dot(other));
|
||||
if (d>=1.0)
|
||||
return Scalar(0);
|
||||
return static_cast<Scalar>(2 * std::acos(d));
|
||||
@@ -584,12 +592,12 @@ QuaternionBase<Derived>::angularDistance(const QuaternionBase<OtherDerived>& oth
|
||||
*/
|
||||
template <class Derived>
|
||||
template <class OtherDerived>
|
||||
Quaternion<typename ei_traits<Derived>::Scalar>
|
||||
Quaternion<typename internal::traits<Derived>::Scalar>
|
||||
QuaternionBase<Derived>::slerp(Scalar t, const QuaternionBase<OtherDerived>& other) const
|
||||
{
|
||||
static const Scalar one = Scalar(1) - NumTraits<Scalar>::epsilon();
|
||||
Scalar d = this->dot(other);
|
||||
Scalar absD = ei_abs(d);
|
||||
Scalar absD = internal::abs(d);
|
||||
|
||||
Scalar scale0;
|
||||
Scalar scale1;
|
||||
@@ -603,10 +611,10 @@ QuaternionBase<Derived>::slerp(Scalar t, const QuaternionBase<OtherDerived>& oth
|
||||
{
|
||||
// theta is the angle between the 2 quaternions
|
||||
Scalar theta = std::acos(absD);
|
||||
Scalar sinTheta = ei_sin(theta);
|
||||
Scalar sinTheta = internal::sin(theta);
|
||||
|
||||
scale0 = ei_sin( ( Scalar(1) - t ) * theta) / sinTheta;
|
||||
scale1 = ei_sin( ( t * theta) ) / sinTheta;
|
||||
scale0 = internal::sin( ( Scalar(1) - t ) * theta) / sinTheta;
|
||||
scale1 = internal::sin( ( t * theta) ) / sinTheta;
|
||||
if (d<0)
|
||||
scale1 = -scale1;
|
||||
}
|
||||
@@ -614,9 +622,11 @@ QuaternionBase<Derived>::slerp(Scalar t, const QuaternionBase<OtherDerived>& oth
|
||||
return Quaternion<Scalar>(scale0 * coeffs() + scale1 * other.coeffs());
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
|
||||
// set from a rotation matrix
|
||||
template<typename Other>
|
||||
struct ei_quaternionbase_assign_impl<Other,3,3>
|
||||
struct quaternionbase_assign_impl<Other,3,3>
|
||||
{
|
||||
typedef typename Other::Scalar Scalar;
|
||||
typedef DenseIndex Index;
|
||||
@@ -627,7 +637,7 @@ struct ei_quaternionbase_assign_impl<Other,3,3>
|
||||
Scalar t = mat.trace();
|
||||
if (t > Scalar(0))
|
||||
{
|
||||
t = ei_sqrt(t + Scalar(1.0));
|
||||
t = sqrt(t + Scalar(1.0));
|
||||
q.w() = Scalar(0.5)*t;
|
||||
t = Scalar(0.5)/t;
|
||||
q.x() = (mat.coeff(2,1) - mat.coeff(1,2)) * t;
|
||||
@@ -644,7 +654,7 @@ struct ei_quaternionbase_assign_impl<Other,3,3>
|
||||
DenseIndex j = (i+1)%3;
|
||||
DenseIndex k = (j+1)%3;
|
||||
|
||||
t = ei_sqrt(mat.coeff(i,i)-mat.coeff(j,j)-mat.coeff(k,k) + Scalar(1.0));
|
||||
t = sqrt(mat.coeff(i,i)-mat.coeff(j,j)-mat.coeff(k,k) + Scalar(1.0));
|
||||
q.coeffs().coeffRef(i) = Scalar(0.5) * t;
|
||||
t = Scalar(0.5)/t;
|
||||
q.w() = (mat.coeff(k,j)-mat.coeff(j,k))*t;
|
||||
@@ -656,7 +666,7 @@ struct ei_quaternionbase_assign_impl<Other,3,3>
|
||||
|
||||
// set from a vector of coefficients assumed to be a quaternion
|
||||
template<typename Other>
|
||||
struct ei_quaternionbase_assign_impl<Other,4,1>
|
||||
struct quaternionbase_assign_impl<Other,4,1>
|
||||
{
|
||||
typedef typename Other::Scalar Scalar;
|
||||
template<class Derived> inline static void run(QuaternionBase<Derived>& q, const Other& vec)
|
||||
@@ -665,5 +675,6 @@ struct ei_quaternionbase_assign_impl<Other,4,1>
|
||||
}
|
||||
};
|
||||
|
||||
} // end namespace internal
|
||||
|
||||
#endif // EIGEN_QUATERNION_H
|
||||
|
||||
@@ -41,10 +41,14 @@
|
||||
*
|
||||
* \sa class Quaternion, class Transform
|
||||
*/
|
||||
template<typename _Scalar> struct ei_traits<Rotation2D<_Scalar> >
|
||||
|
||||
namespace internal {
|
||||
|
||||
template<typename _Scalar> struct traits<Rotation2D<_Scalar> >
|
||||
{
|
||||
typedef _Scalar Scalar;
|
||||
};
|
||||
} // end namespace internal
|
||||
|
||||
template<typename _Scalar>
|
||||
class Rotation2D : public RotationBase<Rotation2D<_Scalar>,2>
|
||||
@@ -107,8 +111,8 @@ public:
|
||||
* then this function smartly returns a const reference to \c *this.
|
||||
*/
|
||||
template<typename NewScalarType>
|
||||
inline typename ei_cast_return_type<Rotation2D,Rotation2D<NewScalarType> >::type cast() const
|
||||
{ return typename ei_cast_return_type<Rotation2D,Rotation2D<NewScalarType> >::type(*this); }
|
||||
inline typename internal::cast_return_type<Rotation2D,Rotation2D<NewScalarType> >::type cast() const
|
||||
{ return typename internal::cast_return_type<Rotation2D,Rotation2D<NewScalarType> >::type(*this); }
|
||||
|
||||
/** Copy constructor with scalar type conversion */
|
||||
template<typename OtherScalarType>
|
||||
@@ -124,7 +128,7 @@ public:
|
||||
*
|
||||
* \sa MatrixBase::isApprox() */
|
||||
bool isApprox(const Rotation2D& other, typename NumTraits<Scalar>::Real prec = NumTraits<Scalar>::dummy_precision()) const
|
||||
{ return ei_isApprox(m_angle,other.m_angle, prec); }
|
||||
{ return internal::isApprox(m_angle,other.m_angle, prec); }
|
||||
};
|
||||
|
||||
/** \ingroup Geometry_Module
|
||||
@@ -143,7 +147,7 @@ template<typename Derived>
|
||||
Rotation2D<Scalar>& Rotation2D<Scalar>::fromRotationMatrix(const MatrixBase<Derived>& mat)
|
||||
{
|
||||
EIGEN_STATIC_ASSERT(Derived::RowsAtCompileTime==2 && Derived::ColsAtCompileTime==2,YOU_MADE_A_PROGRAMMING_MISTAKE)
|
||||
m_angle = ei_atan2(mat.coeff(1,0), mat.coeff(0,0));
|
||||
m_angle = internal::atan2(mat.coeff(1,0), mat.coeff(0,0));
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -153,8 +157,8 @@ template<typename Scalar>
|
||||
typename Rotation2D<Scalar>::Matrix2
|
||||
Rotation2D<Scalar>::toRotationMatrix(void) const
|
||||
{
|
||||
Scalar sinA = ei_sin(m_angle);
|
||||
Scalar cosA = ei_cos(m_angle);
|
||||
Scalar sinA = internal::sin(m_angle);
|
||||
Scalar cosA = internal::cos(m_angle);
|
||||
return (Matrix2() << cosA, -sinA, sinA, cosA).finished();
|
||||
}
|
||||
|
||||
|
||||
@@ -26,8 +26,10 @@
|
||||
#define EIGEN_ROTATIONBASE_H
|
||||
|
||||
// forward declaration
|
||||
namespace internal {
|
||||
template<typename RotationDerived, typename MatrixType, bool IsVector=MatrixType::IsVectorAtCompileTime>
|
||||
struct ei_rotation_base_generic_product_selector;
|
||||
struct rotation_base_generic_product_selector;
|
||||
}
|
||||
|
||||
/** \class RotationBase
|
||||
*
|
||||
@@ -42,7 +44,7 @@ class RotationBase
|
||||
public:
|
||||
enum { Dim = _Dim };
|
||||
/** the scalar type of the coefficients */
|
||||
typedef typename ei_traits<Derived>::Scalar Scalar;
|
||||
typedef typename internal::traits<Derived>::Scalar Scalar;
|
||||
|
||||
/** corresponding linear transformation matrix type */
|
||||
typedef Matrix<Scalar,Dim,Dim> RotationMatrixType;
|
||||
@@ -78,9 +80,9 @@ class RotationBase
|
||||
* - a vector of size Dim
|
||||
*/
|
||||
template<typename OtherDerived>
|
||||
EIGEN_STRONG_INLINE typename ei_rotation_base_generic_product_selector<Derived,OtherDerived,OtherDerived::IsVectorAtCompileTime>::ReturnType
|
||||
EIGEN_STRONG_INLINE typename internal::rotation_base_generic_product_selector<Derived,OtherDerived,OtherDerived::IsVectorAtCompileTime>::ReturnType
|
||||
operator*(const EigenBase<OtherDerived>& e) const
|
||||
{ return ei_rotation_base_generic_product_selector<Derived,OtherDerived>::run(derived(), e.derived()); }
|
||||
{ return internal::rotation_base_generic_product_selector<Derived,OtherDerived>::run(derived(), e.derived()); }
|
||||
|
||||
/** \returns the concatenation of a linear transformation \a l with the rotation \a r */
|
||||
template<typename OtherDerived> friend
|
||||
@@ -105,9 +107,11 @@ class RotationBase
|
||||
{ return toRotationMatrix() * v; }
|
||||
};
|
||||
|
||||
namespace internal {
|
||||
|
||||
// implementation of the generic product rotation * matrix
|
||||
template<typename RotationDerived, typename MatrixType>
|
||||
struct ei_rotation_base_generic_product_selector<RotationDerived,MatrixType,false>
|
||||
struct rotation_base_generic_product_selector<RotationDerived,MatrixType,false>
|
||||
{
|
||||
enum { Dim = RotationDerived::Dim };
|
||||
typedef Matrix<typename RotationDerived::Scalar,Dim,Dim> ReturnType;
|
||||
@@ -116,7 +120,7 @@ struct ei_rotation_base_generic_product_selector<RotationDerived,MatrixType,fals
|
||||
};
|
||||
|
||||
template<typename RotationDerived, typename Scalar, int Dim, int MaxDim>
|
||||
struct ei_rotation_base_generic_product_selector< RotationDerived, DiagonalMatrix<Scalar,Dim,MaxDim>, false >
|
||||
struct rotation_base_generic_product_selector< RotationDerived, DiagonalMatrix<Scalar,Dim,MaxDim>, false >
|
||||
{
|
||||
typedef Transform<Scalar,Dim,Affine> ReturnType;
|
||||
inline static ReturnType run(const RotationDerived& r, const DiagonalMatrix<Scalar,Dim,MaxDim>& m)
|
||||
@@ -128,7 +132,7 @@ struct ei_rotation_base_generic_product_selector< RotationDerived, DiagonalMatri
|
||||
};
|
||||
|
||||
template<typename RotationDerived,typename OtherVectorType>
|
||||
struct ei_rotation_base_generic_product_selector<RotationDerived,OtherVectorType,true>
|
||||
struct rotation_base_generic_product_selector<RotationDerived,OtherVectorType,true>
|
||||
{
|
||||
enum { Dim = RotationDerived::Dim };
|
||||
typedef Matrix<typename RotationDerived::Scalar,Dim,1> ReturnType;
|
||||
@@ -138,6 +142,8 @@ struct ei_rotation_base_generic_product_selector<RotationDerived,OtherVectorType
|
||||
}
|
||||
};
|
||||
|
||||
} // end namespace internal
|
||||
|
||||
/** \geometry_module
|
||||
*
|
||||
* \brief Constructs a Dim x Dim rotation matrix from the rotation \a r
|
||||
@@ -165,6 +171,8 @@ Matrix<_Scalar, _Rows, _Cols, _Storage, _MaxRows, _MaxCols>
|
||||
return *this = r.toRotationMatrix();
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
|
||||
/** \internal
|
||||
*
|
||||
* Helper function to return an arbitrary rotation object to a rotation matrix.
|
||||
@@ -179,29 +187,31 @@ Matrix<_Scalar, _Rows, _Cols, _Storage, _MaxRows, _MaxCols>
|
||||
* - any matrix expression,
|
||||
* - any type based on RotationBase (e.g., Quaternion, AngleAxis, Rotation2D)
|
||||
*
|
||||
* Currently ei_toRotationMatrix is only used by Transform.
|
||||
* Currently toRotationMatrix is only used by Transform.
|
||||
*
|
||||
* \sa class Transform, class Rotation2D, class Quaternion, class AngleAxis
|
||||
*/
|
||||
template<typename Scalar, int Dim>
|
||||
inline static Matrix<Scalar,2,2> ei_toRotationMatrix(const Scalar& s)
|
||||
inline static Matrix<Scalar,2,2> toRotationMatrix(const Scalar& s)
|
||||
{
|
||||
EIGEN_STATIC_ASSERT(Dim==2,YOU_MADE_A_PROGRAMMING_MISTAKE)
|
||||
return Rotation2D<Scalar>(s).toRotationMatrix();
|
||||
}
|
||||
|
||||
template<typename Scalar, int Dim, typename OtherDerived>
|
||||
inline static Matrix<Scalar,Dim,Dim> ei_toRotationMatrix(const RotationBase<OtherDerived,Dim>& r)
|
||||
inline static Matrix<Scalar,Dim,Dim> toRotationMatrix(const RotationBase<OtherDerived,Dim>& r)
|
||||
{
|
||||
return r.toRotationMatrix();
|
||||
}
|
||||
|
||||
template<typename Scalar, int Dim, typename OtherDerived>
|
||||
inline static const MatrixBase<OtherDerived>& ei_toRotationMatrix(const MatrixBase<OtherDerived>& mat)
|
||||
inline static const MatrixBase<OtherDerived>& toRotationMatrix(const MatrixBase<OtherDerived>& mat)
|
||||
{
|
||||
EIGEN_STATIC_ASSERT(OtherDerived::RowsAtCompileTime==Dim && OtherDerived::ColsAtCompileTime==Dim,
|
||||
YOU_MADE_A_PROGRAMMING_MISTAKE)
|
||||
return mat;
|
||||
}
|
||||
|
||||
} // end namespace internal
|
||||
|
||||
#endif // EIGEN_ROTATIONBASE_H
|
||||
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
/** Concatenates a uniform scaling and a linear transformation matrix */
|
||||
// TODO returns an expression
|
||||
template<typename Derived>
|
||||
inline typename ei_plain_matrix_type<Derived>::type operator* (const MatrixBase<Derived>& other) const
|
||||
inline typename internal::plain_matrix_type<Derived>::type operator* (const MatrixBase<Derived>& other) const
|
||||
{ return other * m_factor; }
|
||||
|
||||
template<typename Derived,int Dim>
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
*
|
||||
* \sa MatrixBase::isApprox() */
|
||||
bool isApprox(const UniformScaling& other, typename NumTraits<Scalar>::Real prec = NumTraits<Scalar>::dummy_precision()) const
|
||||
{ return ei_isApprox(m_factor, other.factor(), prec); }
|
||||
{ return internal::isApprox(m_factor, other.factor(), prec); }
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -27,8 +27,10 @@
|
||||
#ifndef EIGEN_TRANSFORM_H
|
||||
#define EIGEN_TRANSFORM_H
|
||||
|
||||
namespace internal {
|
||||
|
||||
template<typename Transform>
|
||||
struct ei_transform_traits
|
||||
struct transform_traits
|
||||
{
|
||||
enum
|
||||
{
|
||||
@@ -41,8 +43,8 @@ struct ei_transform_traits
|
||||
|
||||
template< typename TransformType,
|
||||
typename MatrixType,
|
||||
bool IsProjective = ei_transform_traits<TransformType>::IsProjective>
|
||||
struct ei_transform_right_product_impl;
|
||||
bool IsProjective = transform_traits<TransformType>::IsProjective>
|
||||
struct transform_right_product_impl;
|
||||
|
||||
template< typename Other,
|
||||
int Mode,
|
||||
@@ -50,14 +52,14 @@ template< typename Other,
|
||||
int HDim,
|
||||
int OtherRows=Other::RowsAtCompileTime,
|
||||
int OtherCols=Other::ColsAtCompileTime>
|
||||
struct ei_transform_left_product_impl;
|
||||
struct transform_left_product_impl;
|
||||
|
||||
template< typename Lhs,
|
||||
typename Rhs,
|
||||
bool AnyProjective =
|
||||
ei_transform_traits<Lhs>::IsProjective ||
|
||||
ei_transform_traits<Lhs>::IsProjective>
|
||||
struct ei_transform_transform_product_impl;
|
||||
transform_traits<Lhs>::IsProjective ||
|
||||
transform_traits<Lhs>::IsProjective>
|
||||
struct transform_transform_product_impl;
|
||||
|
||||
template< typename Other,
|
||||
int Mode,
|
||||
@@ -65,9 +67,11 @@ template< typename Other,
|
||||
int HDim,
|
||||
int OtherRows=Other::RowsAtCompileTime,
|
||||
int OtherCols=Other::ColsAtCompileTime>
|
||||
struct ei_transform_construct_from_matrix;
|
||||
struct transform_construct_from_matrix;
|
||||
|
||||
template<typename TransformType> struct ei_transform_take_affine_part;
|
||||
template<typename TransformType> struct transform_take_affine_part;
|
||||
|
||||
} // end namespace internal
|
||||
|
||||
/** \geometry_module \ingroup Geometry_Module
|
||||
*
|
||||
@@ -194,11 +198,11 @@ public:
|
||||
/** type of read/write reference to the linear part of the transformation */
|
||||
typedef Block<MatrixType,Dim,Dim> LinearPart;
|
||||
/** type of read/write reference to the affine part of the transformation */
|
||||
typedef typename ei_meta_if<int(Mode)==int(AffineCompact),
|
||||
typedef typename internal::meta_if<int(Mode)==int(AffineCompact),
|
||||
MatrixType&,
|
||||
Block<MatrixType,Dim,HDim> >::ret AffinePart;
|
||||
/** type of read/write reference to the affine part of the transformation */
|
||||
typedef typename ei_meta_if<int(Mode)==int(AffineCompact),
|
||||
typedef typename internal::meta_if<int(Mode)==int(AffineCompact),
|
||||
MatrixType&,
|
||||
Block<MatrixType,Dim,HDim> >::ret AffinePartNested;
|
||||
/** type of a vector */
|
||||
@@ -235,20 +239,20 @@ public:
|
||||
inline Transform& operator=(const Transform& other)
|
||||
{ m_matrix = other.m_matrix; return *this; }
|
||||
|
||||
typedef ei_transform_take_affine_part<Transform> take_affine_part;
|
||||
typedef internal::transform_take_affine_part<Transform> take_affine_part;
|
||||
|
||||
/** Constructs and initializes a transformation from a Dim^2 or a (Dim+1)^2 matrix. */
|
||||
template<typename OtherDerived>
|
||||
inline explicit Transform(const EigenBase<OtherDerived>& other)
|
||||
{
|
||||
ei_transform_construct_from_matrix<OtherDerived,Mode,Dim,HDim>::run(this, other.derived());
|
||||
internal::transform_construct_from_matrix<OtherDerived,Mode,Dim,HDim>::run(this, other.derived());
|
||||
}
|
||||
|
||||
/** Set \c *this from a Dim^2 or (Dim+1)^2 matrix. */
|
||||
template<typename OtherDerived>
|
||||
inline Transform& operator=(const EigenBase<OtherDerived>& other)
|
||||
{
|
||||
ei_transform_construct_from_matrix<OtherDerived,Mode,Dim,HDim>::run(this, other.derived());
|
||||
internal::transform_construct_from_matrix<OtherDerived,Mode,Dim,HDim>::run(this, other.derived());
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -280,7 +284,7 @@ public:
|
||||
else if(OtherModeIsAffineCompact)
|
||||
{
|
||||
typedef typename Transform<Scalar,Dim,OtherMode>::MatrixType OtherMatrixType;
|
||||
ei_transform_construct_from_matrix<OtherMatrixType,Mode,Dim,HDim>::run(this, other.matrix());
|
||||
internal::transform_construct_from_matrix<OtherMatrixType,Mode,Dim,HDim>::run(this, other.matrix());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -354,9 +358,9 @@ public:
|
||||
*/
|
||||
// note: this function is defined here because some compilers cannot find the respective declaration
|
||||
template<typename OtherDerived>
|
||||
EIGEN_STRONG_INLINE const typename ei_transform_right_product_impl<Transform, OtherDerived>::ResultType
|
||||
EIGEN_STRONG_INLINE const typename internal::transform_right_product_impl<Transform, OtherDerived>::ResultType
|
||||
operator * (const EigenBase<OtherDerived> &other) const
|
||||
{ return ei_transform_right_product_impl<Transform, OtherDerived>::run(*this,other.derived()); }
|
||||
{ return internal::transform_right_product_impl<Transform, OtherDerived>::run(*this,other.derived()); }
|
||||
|
||||
/** \returns the product expression of a transformation matrix \a a times a transform \a b
|
||||
*
|
||||
@@ -366,9 +370,9 @@ public:
|
||||
* \li a general transformation matrix of size Dim+1 x Dim+1.
|
||||
*/
|
||||
template<typename OtherDerived> friend
|
||||
inline const typename ei_transform_left_product_impl<OtherDerived,Mode,_Dim,_Dim+1>::ResultType
|
||||
inline const typename internal::transform_left_product_impl<OtherDerived,Mode,_Dim,_Dim+1>::ResultType
|
||||
operator * (const EigenBase<OtherDerived> &a, const Transform &b)
|
||||
{ return ei_transform_left_product_impl<OtherDerived,Mode,Dim,HDim>::run(a.derived(),b); }
|
||||
{ return internal::transform_left_product_impl<OtherDerived,Mode,Dim,HDim>::run(a.derived(),b); }
|
||||
|
||||
/** \returns The product expression of a transform \a a times a diagonal matrix \a b
|
||||
*
|
||||
@@ -407,16 +411,16 @@ public:
|
||||
/** Concatenates two transformations */
|
||||
inline const Transform operator * (const Transform& other) const
|
||||
{
|
||||
return ei_transform_transform_product_impl<Transform,Transform>::run(*this,other);
|
||||
return internal::transform_transform_product_impl<Transform,Transform>::run(*this,other);
|
||||
}
|
||||
|
||||
/** Concatenates two different transformations */
|
||||
template<int OtherMode>
|
||||
inline const typename ei_transform_transform_product_impl<
|
||||
inline const typename internal::transform_transform_product_impl<
|
||||
Transform,Transform<Scalar,Dim,OtherMode> >::ResultType
|
||||
operator * (const Transform<Scalar,Dim,OtherMode>& other) const
|
||||
{
|
||||
return ei_transform_transform_product_impl<Transform,Transform<Scalar,Dim,OtherMode> >::run(*this,other);
|
||||
return internal::transform_transform_product_impl<Transform,Transform<Scalar,Dim,OtherMode> >::run(*this,other);
|
||||
}
|
||||
|
||||
/** \sa MatrixBase::setIdentity() */
|
||||
@@ -495,8 +499,8 @@ public:
|
||||
* then this function smartly returns a const reference to \c *this.
|
||||
*/
|
||||
template<typename NewScalarType>
|
||||
inline typename ei_cast_return_type<Transform,Transform<NewScalarType,Dim,Mode> >::type cast() const
|
||||
{ return typename ei_cast_return_type<Transform,Transform<NewScalarType,Dim,Mode> >::type(*this); }
|
||||
inline typename internal::cast_return_type<Transform,Transform<NewScalarType,Dim,Mode> >::type cast() const
|
||||
{ return typename internal::cast_return_type<Transform,Transform<NewScalarType,Dim,Mode> >::type(*this); }
|
||||
|
||||
/** Copy constructor with scalar type conversion */
|
||||
template<typename OtherScalarType>
|
||||
@@ -765,7 +769,7 @@ Transform<Scalar,Dim,Mode>::pretranslate(const MatrixBase<OtherDerived> &other)
|
||||
* to \c *this and returns a reference to \c *this.
|
||||
*
|
||||
* The template parameter \a RotationType is the type of the rotation which
|
||||
* must be known by ei_toRotationMatrix<>.
|
||||
* must be known by internal::toRotationMatrix<>.
|
||||
*
|
||||
* Natively supported types includes:
|
||||
* - any scalar (2D),
|
||||
@@ -783,7 +787,7 @@ template<typename RotationType>
|
||||
Transform<Scalar,Dim,Mode>&
|
||||
Transform<Scalar,Dim,Mode>::rotate(const RotationType& rotation)
|
||||
{
|
||||
linearExt() *= ei_toRotationMatrix<Scalar,Dim>(rotation);
|
||||
linearExt() *= internal::toRotationMatrix<Scalar,Dim>(rotation);
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -799,7 +803,7 @@ template<typename RotationType>
|
||||
Transform<Scalar,Dim,Mode>&
|
||||
Transform<Scalar,Dim,Mode>::prerotate(const RotationType& rotation)
|
||||
{
|
||||
m_matrix.template block<Dim,HDim>(0,0) = ei_toRotationMatrix<Scalar,Dim>(rotation)
|
||||
m_matrix.template block<Dim,HDim>(0,0) = internal::toRotationMatrix<Scalar,Dim>(rotation)
|
||||
* m_matrix.template block<Dim,HDim>(0,0);
|
||||
return *this;
|
||||
}
|
||||
@@ -877,7 +881,7 @@ template<typename Scalar, int Dim, int Mode>
|
||||
template<typename Derived>
|
||||
inline Transform<Scalar,Dim,Mode>& Transform<Scalar,Dim,Mode>::operator=(const RotationBase<Derived,Dim>& r)
|
||||
{
|
||||
linear() = ei_toRotationMatrix<Scalar,Dim>(r);
|
||||
linear() = internal::toRotationMatrix<Scalar,Dim>(r);
|
||||
translation().setZero();
|
||||
makeAffine();
|
||||
return *this;
|
||||
@@ -980,23 +984,25 @@ Transform<Scalar,Dim,Mode>&
|
||||
Transform<Scalar,Dim,Mode>::fromPositionOrientationScale(const MatrixBase<PositionDerived> &position,
|
||||
const OrientationType& orientation, const MatrixBase<ScaleDerived> &scale)
|
||||
{
|
||||
linear() = ei_toRotationMatrix<Scalar,Dim>(orientation);
|
||||
linear() = internal::toRotationMatrix<Scalar,Dim>(orientation);
|
||||
linear() *= scale.asDiagonal();
|
||||
translation() = position;
|
||||
makeAffine();
|
||||
return *this;
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
|
||||
// selector needed to avoid taking the inverse of a 3x4 matrix
|
||||
template<typename TransformType, int Mode=TransformType::Mode>
|
||||
struct ei_projective_transform_inverse
|
||||
struct projective_transform_inverse
|
||||
{
|
||||
static inline void run(const TransformType&, TransformType&)
|
||||
{}
|
||||
};
|
||||
|
||||
template<typename TransformType>
|
||||
struct ei_projective_transform_inverse<TransformType, Projective>
|
||||
struct projective_transform_inverse<TransformType, Projective>
|
||||
{
|
||||
static inline void run(const TransformType& m, TransformType& res)
|
||||
{
|
||||
@@ -1004,6 +1010,8 @@ struct ei_projective_transform_inverse<TransformType, Projective>
|
||||
}
|
||||
};
|
||||
|
||||
} // end namespace internal
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -1031,7 +1039,7 @@ Transform<Scalar,Dim,Mode>::inverse(TransformTraits hint) const
|
||||
Transform res;
|
||||
if (hint == Projective)
|
||||
{
|
||||
ei_projective_transform_inverse<Transform>::run(*this, res);
|
||||
internal::projective_transform_inverse<Transform>::run(*this, res);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1045,7 +1053,7 @@ Transform<Scalar,Dim,Mode>::inverse(TransformTraits hint) const
|
||||
}
|
||||
else
|
||||
{
|
||||
ei_assert(false && "Invalid transform traits in Transform::Inverse");
|
||||
eigen_assert(false && "Invalid transform traits in Transform::Inverse");
|
||||
}
|
||||
// translation and remaining parts
|
||||
res.matrix().template topRightCorner<Dim,1>()
|
||||
@@ -1055,11 +1063,13 @@ Transform<Scalar,Dim,Mode>::inverse(TransformTraits hint) const
|
||||
return res;
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
|
||||
/*****************************************************
|
||||
*** Specializations of take affine part ***
|
||||
*****************************************************/
|
||||
|
||||
template<typename TransformType> struct ei_transform_take_affine_part {
|
||||
template<typename TransformType> struct transform_take_affine_part {
|
||||
typedef typename TransformType::MatrixType MatrixType;
|
||||
typedef typename TransformType::AffinePart AffinePart;
|
||||
static inline AffinePart run(MatrixType& m)
|
||||
@@ -1069,7 +1079,7 @@ template<typename TransformType> struct ei_transform_take_affine_part {
|
||||
};
|
||||
|
||||
template<typename Scalar, int Dim>
|
||||
struct ei_transform_take_affine_part<Transform<Scalar,Dim,AffineCompact> > {
|
||||
struct transform_take_affine_part<Transform<Scalar,Dim,AffineCompact> > {
|
||||
typedef typename Transform<Scalar,Dim,AffineCompact>::MatrixType MatrixType;
|
||||
static inline MatrixType& run(MatrixType& m) { return m; }
|
||||
static inline const MatrixType& run(const MatrixType& m) { return m; }
|
||||
@@ -1080,7 +1090,7 @@ struct ei_transform_take_affine_part<Transform<Scalar,Dim,AffineCompact> > {
|
||||
*****************************************************/
|
||||
|
||||
template<typename Other, int Mode, int Dim, int HDim>
|
||||
struct ei_transform_construct_from_matrix<Other, Mode,Dim,HDim, Dim,Dim>
|
||||
struct transform_construct_from_matrix<Other, Mode,Dim,HDim, Dim,Dim>
|
||||
{
|
||||
static inline void run(Transform<typename Other::Scalar,Dim,Mode> *transform, const Other& other)
|
||||
{
|
||||
@@ -1091,7 +1101,7 @@ struct ei_transform_construct_from_matrix<Other, Mode,Dim,HDim, Dim,Dim>
|
||||
};
|
||||
|
||||
template<typename Other, int Mode, int Dim, int HDim>
|
||||
struct ei_transform_construct_from_matrix<Other, Mode,Dim,HDim, Dim,HDim>
|
||||
struct transform_construct_from_matrix<Other, Mode,Dim,HDim, Dim,HDim>
|
||||
{
|
||||
static inline void run(Transform<typename Other::Scalar,Dim,Mode> *transform, const Other& other)
|
||||
{
|
||||
@@ -1101,14 +1111,14 @@ struct ei_transform_construct_from_matrix<Other, Mode,Dim,HDim, Dim,HDim>
|
||||
};
|
||||
|
||||
template<typename Other, int Mode, int Dim, int HDim>
|
||||
struct ei_transform_construct_from_matrix<Other, Mode,Dim,HDim, HDim,HDim>
|
||||
struct transform_construct_from_matrix<Other, Mode,Dim,HDim, HDim,HDim>
|
||||
{
|
||||
static inline void run(Transform<typename Other::Scalar,Dim,Mode> *transform, const Other& other)
|
||||
{ transform->matrix() = other; }
|
||||
};
|
||||
|
||||
template<typename Other, int Dim, int HDim>
|
||||
struct ei_transform_construct_from_matrix<Other, AffineCompact,Dim,HDim, HDim,HDim>
|
||||
struct transform_construct_from_matrix<Other, AffineCompact,Dim,HDim, HDim,HDim>
|
||||
{
|
||||
static inline void run(Transform<typename Other::Scalar,Dim,AffineCompact> *transform, const Other& other)
|
||||
{ transform->matrix() = other.template block<Dim,HDim>(0,0); }
|
||||
@@ -1119,7 +1129,7 @@ struct ei_transform_construct_from_matrix<Other, AffineCompact,Dim,HDim, HDim,HD
|
||||
**********************************************************/
|
||||
|
||||
template<int LhsMode,int RhsMode>
|
||||
struct ei_transform_product_result
|
||||
struct transform_product_result
|
||||
{
|
||||
enum
|
||||
{
|
||||
@@ -1132,7 +1142,7 @@ struct ei_transform_product_result
|
||||
};
|
||||
|
||||
template< typename TransformType, typename MatrixType >
|
||||
struct ei_transform_right_product_impl< TransformType, MatrixType, true >
|
||||
struct transform_right_product_impl< TransformType, MatrixType, true >
|
||||
{
|
||||
typedef typename MatrixType::PlainObject ResultType;
|
||||
|
||||
@@ -1143,7 +1153,7 @@ struct ei_transform_right_product_impl< TransformType, MatrixType, true >
|
||||
};
|
||||
|
||||
template< typename TransformType, typename MatrixType >
|
||||
struct ei_transform_right_product_impl< TransformType, MatrixType, false >
|
||||
struct transform_right_product_impl< TransformType, MatrixType, false >
|
||||
{
|
||||
enum {
|
||||
Dim = TransformType::Dim,
|
||||
@@ -1181,7 +1191,7 @@ struct ei_transform_right_product_impl< TransformType, MatrixType, false >
|
||||
|
||||
// generic HDim x HDim matrix * T => Projective
|
||||
template<typename Other,int Mode, int Dim, int HDim>
|
||||
struct ei_transform_left_product_impl<Other,Mode,Dim,HDim, HDim,HDim>
|
||||
struct transform_left_product_impl<Other,Mode,Dim,HDim, HDim,HDim>
|
||||
{
|
||||
typedef Transform<typename Other::Scalar,Dim,Mode> TransformType;
|
||||
typedef typename TransformType::MatrixType MatrixType;
|
||||
@@ -1192,7 +1202,7 @@ struct ei_transform_left_product_impl<Other,Mode,Dim,HDim, HDim,HDim>
|
||||
|
||||
// generic HDim x HDim matrix * AffineCompact => Projective
|
||||
template<typename Other, int Dim, int HDim>
|
||||
struct ei_transform_left_product_impl<Other,AffineCompact,Dim,HDim, HDim,HDim>
|
||||
struct transform_left_product_impl<Other,AffineCompact,Dim,HDim, HDim,HDim>
|
||||
{
|
||||
typedef Transform<typename Other::Scalar,Dim,AffineCompact> TransformType;
|
||||
typedef typename TransformType::MatrixType MatrixType;
|
||||
@@ -1208,7 +1218,7 @@ struct ei_transform_left_product_impl<Other,AffineCompact,Dim,HDim, HDim,HDim>
|
||||
|
||||
// affine matrix * T
|
||||
template<typename Other,int Mode, int Dim, int HDim>
|
||||
struct ei_transform_left_product_impl<Other,Mode,Dim,HDim, Dim,HDim>
|
||||
struct transform_left_product_impl<Other,Mode,Dim,HDim, Dim,HDim>
|
||||
{
|
||||
typedef Transform<typename Other::Scalar,Dim,Mode> TransformType;
|
||||
typedef typename TransformType::MatrixType MatrixType;
|
||||
@@ -1224,7 +1234,7 @@ struct ei_transform_left_product_impl<Other,Mode,Dim,HDim, Dim,HDim>
|
||||
|
||||
// affine matrix * AffineCompact
|
||||
template<typename Other, int Dim, int HDim>
|
||||
struct ei_transform_left_product_impl<Other,AffineCompact,Dim,HDim, Dim,HDim>
|
||||
struct transform_left_product_impl<Other,AffineCompact,Dim,HDim, Dim,HDim>
|
||||
{
|
||||
typedef Transform<typename Other::Scalar,Dim,AffineCompact> TransformType;
|
||||
typedef typename TransformType::MatrixType MatrixType;
|
||||
@@ -1240,7 +1250,7 @@ struct ei_transform_left_product_impl<Other,AffineCompact,Dim,HDim, Dim,HDim>
|
||||
|
||||
// linear matrix * T
|
||||
template<typename Other,int Mode, int Dim, int HDim>
|
||||
struct ei_transform_left_product_impl<Other,Mode,Dim,HDim, Dim,Dim>
|
||||
struct transform_left_product_impl<Other,Mode,Dim,HDim, Dim,Dim>
|
||||
{
|
||||
typedef Transform<typename Other::Scalar,Dim,Mode> TransformType;
|
||||
typedef typename TransformType::MatrixType MatrixType;
|
||||
@@ -1261,9 +1271,9 @@ struct ei_transform_left_product_impl<Other,Mode,Dim,HDim, Dim,Dim>
|
||||
**********************************************************/
|
||||
|
||||
template<typename Scalar, int Dim, int LhsMode, int RhsMode>
|
||||
struct ei_transform_transform_product_impl<Transform<Scalar,Dim,LhsMode>,Transform<Scalar,Dim,RhsMode>,false >
|
||||
struct transform_transform_product_impl<Transform<Scalar,Dim,LhsMode>,Transform<Scalar,Dim,RhsMode>,false >
|
||||
{
|
||||
enum { ResultMode = ei_transform_product_result<LhsMode,RhsMode>::Mode };
|
||||
enum { ResultMode = transform_product_result<LhsMode,RhsMode>::Mode };
|
||||
typedef Transform<Scalar,Dim,LhsMode> Lhs;
|
||||
typedef Transform<Scalar,Dim,RhsMode> Rhs;
|
||||
typedef Transform<Scalar,Dim,ResultMode> ResultType;
|
||||
@@ -1278,7 +1288,7 @@ struct ei_transform_transform_product_impl<Transform<Scalar,Dim,LhsMode>,Transfo
|
||||
};
|
||||
|
||||
template<typename Scalar, int Dim, int LhsMode, int RhsMode>
|
||||
struct ei_transform_transform_product_impl<Transform<Scalar,Dim,LhsMode>,Transform<Scalar,Dim,RhsMode>,true >
|
||||
struct transform_transform_product_impl<Transform<Scalar,Dim,LhsMode>,Transform<Scalar,Dim,RhsMode>,true >
|
||||
{
|
||||
typedef Transform<Scalar,Dim,LhsMode> Lhs;
|
||||
typedef Transform<Scalar,Dim,RhsMode> Rhs;
|
||||
@@ -1289,4 +1299,6 @@ struct ei_transform_transform_product_impl<Transform<Scalar,Dim,LhsMode>,Transfo
|
||||
}
|
||||
};
|
||||
|
||||
} // end namespace internal
|
||||
|
||||
#endif // EIGEN_TRANSFORM_H
|
||||
|
||||
@@ -66,14 +66,14 @@ public:
|
||||
/** */
|
||||
inline Translation(const Scalar& sx, const Scalar& sy)
|
||||
{
|
||||
ei_assert(Dim==2);
|
||||
eigen_assert(Dim==2);
|
||||
m_coeffs.x() = sx;
|
||||
m_coeffs.y() = sy;
|
||||
}
|
||||
/** */
|
||||
inline Translation(const Scalar& sx, const Scalar& sy, const Scalar& sz)
|
||||
{
|
||||
ei_assert(Dim==3);
|
||||
eigen_assert(Dim==3);
|
||||
m_coeffs.x() = sx;
|
||||
m_coeffs.y() = sy;
|
||||
m_coeffs.z() = sz;
|
||||
@@ -161,8 +161,8 @@ public:
|
||||
* then this function smartly returns a const reference to \c *this.
|
||||
*/
|
||||
template<typename NewScalarType>
|
||||
inline typename ei_cast_return_type<Translation,Translation<NewScalarType,Dim> >::type cast() const
|
||||
{ return typename ei_cast_return_type<Translation,Translation<NewScalarType,Dim> >::type(*this); }
|
||||
inline typename internal::cast_return_type<Translation,Translation<NewScalarType,Dim> >::type cast() const
|
||||
{ return typename internal::cast_return_type<Translation,Translation<NewScalarType,Dim> >::type(*this); }
|
||||
|
||||
/** Copy constructor with scalar type conversion */
|
||||
template<typename OtherScalarType>
|
||||
|
||||
@@ -36,30 +36,31 @@
|
||||
// These helpers are required since it allows to use mixed types as parameters
|
||||
// for the Umeyama. The problem with mixed parameters is that the return type
|
||||
// cannot trivially be deduced when float and double types are mixed.
|
||||
namespace
|
||||
namespace internal {
|
||||
|
||||
// Compile time return type deduction for different MatrixBase types.
|
||||
// Different means here different alignment and parameters but the same underlying
|
||||
// real scalar type.
|
||||
template<typename MatrixType, typename OtherMatrixType>
|
||||
struct umeyama_transform_matrix_type
|
||||
{
|
||||
// Compile time return type deduction for different MatrixBase types.
|
||||
// Different means here different alignment and parameters but the same underlying
|
||||
// real scalar type.
|
||||
template<typename MatrixType, typename OtherMatrixType>
|
||||
struct ei_umeyama_transform_matrix_type
|
||||
{
|
||||
enum {
|
||||
MinRowsAtCompileTime = EIGEN_SIZE_MIN_PREFER_DYNAMIC(MatrixType::RowsAtCompileTime, OtherMatrixType::RowsAtCompileTime),
|
||||
enum {
|
||||
MinRowsAtCompileTime = EIGEN_SIZE_MIN_PREFER_DYNAMIC(MatrixType::RowsAtCompileTime, OtherMatrixType::RowsAtCompileTime),
|
||||
|
||||
// When possible we want to choose some small fixed size value since the result
|
||||
// is likely to fit on the stack. So here, EIGEN_SIZE_MIN_PREFER_DYNAMIC is not what we want.
|
||||
HomogeneousDimension = int(MinRowsAtCompileTime) == Dynamic ? Dynamic : int(MinRowsAtCompileTime)+1
|
||||
};
|
||||
|
||||
typedef Matrix<typename ei_traits<MatrixType>::Scalar,
|
||||
HomogeneousDimension,
|
||||
HomogeneousDimension,
|
||||
AutoAlign | (ei_traits<MatrixType>::Flags & RowMajorBit ? RowMajor : ColMajor),
|
||||
HomogeneousDimension,
|
||||
HomogeneousDimension
|
||||
> type;
|
||||
// When possible we want to choose some small fixed size value since the result
|
||||
// is likely to fit on the stack. So here, EIGEN_SIZE_MIN_PREFER_DYNAMIC is not what we want.
|
||||
HomogeneousDimension = int(MinRowsAtCompileTime) == Dynamic ? Dynamic : int(MinRowsAtCompileTime)+1
|
||||
};
|
||||
|
||||
typedef Matrix<typename traits<MatrixType>::Scalar,
|
||||
HomogeneousDimension,
|
||||
HomogeneousDimension,
|
||||
AutoAlign | (traits<MatrixType>::Flags & RowMajorBit ? RowMajor : ColMajor),
|
||||
HomogeneousDimension,
|
||||
HomogeneousDimension
|
||||
> type;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -103,23 +104,23 @@ namespace
|
||||
* Eigen::Matrix.
|
||||
*/
|
||||
template <typename Derived, typename OtherDerived>
|
||||
typename ei_umeyama_transform_matrix_type<Derived, OtherDerived>::type
|
||||
typename internal::umeyama_transform_matrix_type<Derived, OtherDerived>::type
|
||||
umeyama(const MatrixBase<Derived>& src, const MatrixBase<OtherDerived>& dst, bool with_scaling = true)
|
||||
{
|
||||
typedef typename ei_umeyama_transform_matrix_type<Derived, OtherDerived>::type TransformationMatrixType;
|
||||
typedef typename ei_traits<TransformationMatrixType>::Scalar Scalar;
|
||||
typedef typename internal::umeyama_transform_matrix_type<Derived, OtherDerived>::type TransformationMatrixType;
|
||||
typedef typename internal::traits<TransformationMatrixType>::Scalar Scalar;
|
||||
typedef typename NumTraits<Scalar>::Real RealScalar;
|
||||
typedef typename Derived::Index Index;
|
||||
|
||||
EIGEN_STATIC_ASSERT(!NumTraits<Scalar>::IsComplex, NUMERIC_TYPE_MUST_BE_REAL)
|
||||
EIGEN_STATIC_ASSERT((ei_is_same_type<Scalar, typename ei_traits<OtherDerived>::Scalar>::ret),
|
||||
EIGEN_STATIC_ASSERT((internal::is_same_type<Scalar, typename internal::traits<OtherDerived>::Scalar>::ret),
|
||||
YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
|
||||
|
||||
enum { Dimension = EIGEN_SIZE_MIN_PREFER_DYNAMIC(Derived::RowsAtCompileTime, OtherDerived::RowsAtCompileTime) };
|
||||
|
||||
typedef Matrix<Scalar, Dimension, 1> VectorType;
|
||||
typedef Matrix<Scalar, Dimension, Dimension> MatrixType;
|
||||
typedef typename ei_plain_matrix_type_row_major<Derived>::type RowMajorMatrixType;
|
||||
typedef typename internal::plain_matrix_type_row_major<Derived>::type RowMajorMatrixType;
|
||||
|
||||
const Index m = src.rows(); // dimension
|
||||
const Index n = src.cols(); // number of measurements
|
||||
@@ -152,7 +153,7 @@ umeyama(const MatrixBase<Derived>& src, const MatrixBase<OtherDerived>& dst, boo
|
||||
|
||||
// Eq. (40) and (43)
|
||||
const VectorType& d = svd.singularValues();
|
||||
Index rank = 0; for (Index i=0; i<m; ++i) if (!ei_isMuchSmallerThan(d.coeff(i),d.coeff(0))) ++rank;
|
||||
Index rank = 0; for (Index i=0; i<m; ++i) if (!internal::isMuchSmallerThan(d.coeff(i),d.coeff(0))) ++rank;
|
||||
if (rank == m-1) {
|
||||
if ( svd.matrixU().determinant() * svd.matrixV().determinant() > 0 ) {
|
||||
Rt.block(0,0,m,m).noalias() = svd.matrixU()*svd.matrixV().transpose();
|
||||
|
||||
@@ -26,8 +26,10 @@
|
||||
#ifndef EIGEN_GEOMETRY_SSE_H
|
||||
#define EIGEN_GEOMETRY_SSE_H
|
||||
|
||||
namespace internal {
|
||||
|
||||
template<class Derived, class OtherDerived>
|
||||
struct ei_quat_product<Architecture::SSE, Derived, OtherDerived, float, Aligned>
|
||||
struct quat_product<Architecture::SSE, Derived, OtherDerived, float, Aligned>
|
||||
{
|
||||
inline static Quaternion<float> run(const QuaternionBase<Derived>& _a, const QuaternionBase<OtherDerived>& _b)
|
||||
{
|
||||
@@ -35,31 +37,31 @@ struct ei_quat_product<Architecture::SSE, Derived, OtherDerived, float, Aligned>
|
||||
Quaternion<float> res;
|
||||
__m128 a = _a.coeffs().template packet<Aligned>(0);
|
||||
__m128 b = _b.coeffs().template packet<Aligned>(0);
|
||||
__m128 flip1 = _mm_xor_ps(_mm_mul_ps(ei_vec4f_swizzle1(a,1,2,0,2),
|
||||
ei_vec4f_swizzle1(b,2,0,1,2)),mask);
|
||||
__m128 flip2 = _mm_xor_ps(_mm_mul_ps(ei_vec4f_swizzle1(a,3,3,3,1),
|
||||
ei_vec4f_swizzle1(b,0,1,2,1)),mask);
|
||||
ei_pstore(&res.x(),
|
||||
_mm_add_ps(_mm_sub_ps(_mm_mul_ps(a,ei_vec4f_swizzle1(b,3,3,3,3)),
|
||||
_mm_mul_ps(ei_vec4f_swizzle1(a,2,0,1,0),
|
||||
ei_vec4f_swizzle1(b,1,2,0,0))),
|
||||
__m128 flip1 = _mm_xor_ps(_mm_mul_ps(vec4f_swizzle1(a,1,2,0,2),
|
||||
vec4f_swizzle1(b,2,0,1,2)),mask);
|
||||
__m128 flip2 = _mm_xor_ps(_mm_mul_ps(vec4f_swizzle1(a,3,3,3,1),
|
||||
vec4f_swizzle1(b,0,1,2,1)),mask);
|
||||
pstore(&res.x(),
|
||||
_mm_add_ps(_mm_sub_ps(_mm_mul_ps(a,vec4f_swizzle1(b,3,3,3,3)),
|
||||
_mm_mul_ps(vec4f_swizzle1(a,2,0,1,0),
|
||||
vec4f_swizzle1(b,1,2,0,0))),
|
||||
_mm_add_ps(flip1,flip2)));
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename VectorLhs,typename VectorRhs>
|
||||
struct ei_cross3_impl<Architecture::SSE,VectorLhs,VectorRhs,float,true>
|
||||
struct cross3_impl<Architecture::SSE,VectorLhs,VectorRhs,float,true>
|
||||
{
|
||||
inline static typename ei_plain_matrix_type<VectorLhs>::type
|
||||
inline static typename plain_matrix_type<VectorLhs>::type
|
||||
run(const VectorLhs& lhs, const VectorRhs& rhs)
|
||||
{
|
||||
__m128 a = lhs.template packet<VectorLhs::Flags&AlignedBit ? Aligned : Unaligned>(0);
|
||||
__m128 b = rhs.template packet<VectorRhs::Flags&AlignedBit ? Aligned : Unaligned>(0);
|
||||
__m128 mul1=_mm_mul_ps(ei_vec4f_swizzle1(a,1,2,0,3),ei_vec4f_swizzle1(b,2,0,1,3));
|
||||
__m128 mul2=_mm_mul_ps(ei_vec4f_swizzle1(a,2,0,1,3),ei_vec4f_swizzle1(b,1,2,0,3));
|
||||
typename ei_plain_matrix_type<VectorLhs>::type res;
|
||||
ei_pstore(&res.x(),_mm_sub_ps(mul1,mul2));
|
||||
__m128 mul1=_mm_mul_ps(vec4f_swizzle1(a,1,2,0,3),vec4f_swizzle1(b,2,0,1,3));
|
||||
__m128 mul2=_mm_mul_ps(vec4f_swizzle1(a,2,0,1,3),vec4f_swizzle1(b,1,2,0,3));
|
||||
typename plain_matrix_type<VectorLhs>::type res;
|
||||
pstore(&res.x(),_mm_sub_ps(mul1,mul2));
|
||||
return res;
|
||||
}
|
||||
};
|
||||
@@ -68,7 +70,7 @@ struct ei_cross3_impl<Architecture::SSE,VectorLhs,VectorRhs,float,true>
|
||||
|
||||
|
||||
template<class Derived, class OtherDerived>
|
||||
struct ei_quat_product<Architecture::SSE, Derived, OtherDerived, double, Aligned>
|
||||
struct quat_product<Architecture::SSE, Derived, OtherDerived, double, Aligned>
|
||||
{
|
||||
inline static Quaternion<double> run(const QuaternionBase<Derived>& _a, const QuaternionBase<OtherDerived>& _b)
|
||||
{
|
||||
@@ -79,10 +81,10 @@ struct ei_quat_product<Architecture::SSE, Derived, OtherDerived, double, Aligned
|
||||
const double* a = _a.coeffs().data();
|
||||
Packet2d b_xy = _b.coeffs().template packet<Aligned>(0);
|
||||
Packet2d b_zw = _b.coeffs().template packet<Aligned>(2);
|
||||
Packet2d a_xx = ei_pset1<Packet2d>(a[0]);
|
||||
Packet2d a_yy = ei_pset1<Packet2d>(a[1]);
|
||||
Packet2d a_zz = ei_pset1<Packet2d>(a[2]);
|
||||
Packet2d a_ww = ei_pset1<Packet2d>(a[3]);
|
||||
Packet2d a_xx = pset1<Packet2d>(a[0]);
|
||||
Packet2d a_yy = pset1<Packet2d>(a[1]);
|
||||
Packet2d a_zz = pset1<Packet2d>(a[2]);
|
||||
Packet2d a_ww = pset1<Packet2d>(a[3]);
|
||||
|
||||
// two temporaries:
|
||||
Packet2d t1, t2;
|
||||
@@ -92,13 +94,13 @@ struct ei_quat_product<Architecture::SSE, Derived, OtherDerived, double, Aligned
|
||||
* t2 = zz*xy - xx*zw
|
||||
* res.xy = t1 +/- swap(t2)
|
||||
*/
|
||||
t1 = ei_padd(ei_pmul(a_ww, b_xy), ei_pmul(a_yy, b_zw));
|
||||
t2 = ei_psub(ei_pmul(a_zz, b_xy), ei_pmul(a_xx, b_zw));
|
||||
t1 = padd(pmul(a_ww, b_xy), pmul(a_yy, b_zw));
|
||||
t2 = psub(pmul(a_zz, b_xy), pmul(a_xx, b_zw));
|
||||
#ifdef __SSE3__
|
||||
EIGEN_UNUSED_VARIABLE(mask)
|
||||
ei_pstore(&res.x(), _mm_addsub_pd(t1, ei_preverse(t2)));
|
||||
pstore(&res.x(), _mm_addsub_pd(t1, preverse(t2)));
|
||||
#else
|
||||
ei_pstore(&res.x(), ei_padd(t1, ei_pxor(mask,ei_preverse(t2))));
|
||||
pstore(&res.x(), padd(t1, pxor(mask,preverse(t2))));
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -106,18 +108,19 @@ struct ei_quat_product<Architecture::SSE, Derived, OtherDerived, double, Aligned
|
||||
* t2 = zz*zw + xx*xy
|
||||
* res.zw = t1 -/+ swap(t2) = swap( swap(t1) +/- t2)
|
||||
*/
|
||||
t1 = ei_psub(ei_pmul(a_ww, b_zw), ei_pmul(a_yy, b_xy));
|
||||
t2 = ei_padd(ei_pmul(a_zz, b_zw), ei_pmul(a_xx, b_xy));
|
||||
t1 = psub(pmul(a_ww, b_zw), pmul(a_yy, b_xy));
|
||||
t2 = padd(pmul(a_zz, b_zw), pmul(a_xx, b_xy));
|
||||
#ifdef __SSE3__
|
||||
EIGEN_UNUSED_VARIABLE(mask)
|
||||
ei_pstore(&res.z(), ei_preverse(_mm_addsub_pd(ei_preverse(t1), t2)));
|
||||
pstore(&res.z(), preverse(_mm_addsub_pd(preverse(t1), t2)));
|
||||
#else
|
||||
ei_pstore(&res.z(), ei_psub(t1, ei_pxor(mask,ei_preverse(t2))));
|
||||
pstore(&res.z(), psub(t1, pxor(mask,preverse(t2))));
|
||||
#endif
|
||||
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
} // end namespace internal
|
||||
|
||||
#endif // EIGEN_GEOMETRY_SSE_H
|
||||
|
||||
Reference in New Issue
Block a user