diff options
Diffstat (limited to 'Eigen/src/Geometry/OrthoMethods.h')
-rw-r--r-- | Eigen/src/Geometry/OrthoMethods.h | 72 |
1 files changed, 40 insertions, 32 deletions
diff --git a/Eigen/src/Geometry/OrthoMethods.h b/Eigen/src/Geometry/OrthoMethods.h index d03d85beb..f4695827d 100644 --- a/Eigen/src/Geometry/OrthoMethods.h +++ b/Eigen/src/Geometry/OrthoMethods.h @@ -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 |