* Add Hyperplane::transform(Matrix/Transform)

* Fix compilations with gcc 3.4, ICC and doxygen
* Fix krazy directives (hopefully)
This commit is contained in:
Gael Guennebaud
2008-08-31 13:32:29 +00:00
parent 5c34d8e20a
commit 7e8aa63bb7
20 changed files with 118 additions and 48 deletions

View File

@@ -234,7 +234,7 @@ MatrixBase<Derived>::Constant(const Scalar& value)
template<typename Derived>
bool MatrixBase<Derived>::isApproxToConstant
(const Scalar& value, typename NumTraits<Scalar>::Real prec) const
(const Scalar& value, RealScalar prec) const
{
for(int j = 0; j < cols(); j++)
for(int i = 0; i < rows(); i++)
@@ -328,7 +328,7 @@ MatrixBase<Derived>::Zero()
*/
template<typename Derived>
bool MatrixBase<Derived>::isZero
(typename NumTraits<Scalar>::Real prec) const
(RealScalar prec) const
{
for(int j = 0; j < cols(); j++)
for(int i = 0; i < rows(); i++)
@@ -425,7 +425,7 @@ MatrixBase<Derived>::Ones()
*/
template<typename Derived>
bool MatrixBase<Derived>::isOnes
(typename NumTraits<Scalar>::Real prec) const
(RealScalar prec) const
{
return isApproxToConstant(Scalar(1), prec);
}
@@ -497,7 +497,7 @@ MatrixBase<Derived>::Identity()
*/
template<typename Derived>
bool MatrixBase<Derived>::isIdentity
(typename NumTraits<Scalar>::Real prec) const
(RealScalar prec) const
{
for(int j = 0; j < cols(); j++)
{

View File

@@ -108,7 +108,7 @@ MatrixBase<Derived>::asDiagonal() const
*/
template<typename Derived>
bool MatrixBase<Derived>::isDiagonal
(typename NumTraits<Scalar>::Real prec) const
(RealScalar prec) const
{
if(cols() != rows()) return false;
RealScalar maxAbsOnDiagonal = static_cast<RealScalar>(-1);

View File

@@ -177,8 +177,10 @@ struct ei_dot_impl<Derived1, Derived2, LinearVectorization, NoUnrolling>
const int size = v1.size();
const int packetSize = ei_packet_traits<Scalar>::size;
const int alignedSize = (size/packetSize)*packetSize;
const int alignment1 = (Derived1::Flags & AlignedBit) ? Aligned : Unaligned;
const int alignment2 = (Derived2::Flags & AlignedBit) ? Aligned : Unaligned;
enum {
alignment1 = (Derived1::Flags & AlignedBit) ? Aligned : Unaligned,
alignment2 = (Derived2::Flags & AlignedBit) ? Aligned : Unaligned
};
Scalar res;
// do the vectorizable part of the sum

View File

@@ -195,8 +195,10 @@ struct ei_sum_impl<Derived, LinearVectorization, NoUnrolling>
|| !(Derived::Flags & DirectAccessBit)
? 0
: ei_alignmentOffset(&mat.const_cast_derived().coeffRef(0), size);
const int alignment = (Derived::Flags & DirectAccessBit) || (Derived::Flags & AlignedBit)
? Aligned : Unaligned;
enum {
alignment = (Derived::Flags & DirectAccessBit) || (Derived::Flags & AlignedBit)
? Aligned : Unaligned
};
const int alignedSize = ((size-alignedStart)/packetSize)*packetSize;
const int alignedEnd = alignedStart + alignedSize;
Scalar res;

View File

@@ -28,7 +28,7 @@
const int Dynamic = 10000;
/** \defgroup flags
/** \defgroup flags flags
* \ingroup Core_Module
*
* These are the possible bits which can be OR'ed to constitute the flags of a matrix or

View File

@@ -60,9 +60,11 @@ template<typename _Scalar>
class AngleAxis : public RotationBase<AngleAxis<_Scalar>,3>
{
typedef RotationBase<AngleAxis<_Scalar>,3> Base;
using Base::operator*;
public:
using Base::operator*;
enum { Dim = 3 };
/** the scalar type of the coefficients */
typedef _Scalar Scalar;

View File

@@ -48,7 +48,7 @@ class ParametrizedLine
ParametrizedLine(const VectorType& origin, const VectorType& direction)
: m_origin(origin), m_direction(direction) {}
ParametrizedLine(const Hyperplane<_Scalar, _AmbientDim>& hyperplane);
explicit ParametrizedLine(const Hyperplane<_Scalar, _AmbientDim>& hyperplane);
~ParametrizedLine() {}
@@ -227,22 +227,41 @@ class Hyperplane
invdet*(other.coeffs().coeff(0)*coeffs().coeff(2)-coeffs().coeff(0)*other.coeffs().coeff(2)));
}
}
#if 0
template<typename XprType>
inline Hyperplane operator* (const MatrixBase<XprType>& mat) const
{ return Hyperplane(mat.inverse().transpose() * normal(), offset()); }
inline Hyperplane& transform(const MatrixBase<XprType>& mat, TransformTraits traits = GenericAffine)
{
if (traits==GenericAffine)
normal() = mat.inverse().transpose() * normal();
else if (traits==NoShear)
normal() = (mat.colwise().norm2().cwise().inverse().eval().asDiagonal()
* mat.transpose()).transpose() * normal();
else if (traits==NoScaling)
normal() = mat * normal();
else
{
ei_assert("invalid traits value in Hyperplane::transform()");
}
return *this;
}
template<typename XprType>
inline Hyperplane& operator*= (const MatrixBase<XprType>& mat) const
{ normal() = mat.inverse().transpose() * normal(); return *this; }
#endif
inline Hyperplane& transform(const Transform<Scalar,AmbientDimAtCompileTime>& t,
TransformTraits traits = GenericAffine)
{
transform(t.linear(), traits);
offset() -= t.translation().dot(normal());
return *this;
}
protected:
Coefficients m_coeffs;
};
/** Construct a parametrized line from a 2D hyperplane
*
* \warning the ambient space must have dimension 2 such that the hyperplane actually describes a line
*/
template <typename _Scalar, int _AmbientDim>
ParametrizedLine<_Scalar, _AmbientDim>::ParametrizedLine(const Hyperplane<_Scalar, _AmbientDim>& hyperplane)
{

View File

@@ -61,12 +61,13 @@ template<typename _Scalar>
class Quaternion : public RotationBase<Quaternion<_Scalar>,3>
{
typedef RotationBase<Quaternion<_Scalar>,3> Base;
using Base::operator*;
typedef Matrix<_Scalar, 4, 1> Coefficients;
Coefficients m_coeffs;
public:
using Base::operator*;
/** the scalar type of the coefficients */
typedef _Scalar Scalar;

View File

@@ -50,9 +50,11 @@ template<typename _Scalar>
class Rotation2D : public RotationBase<Rotation2D<_Scalar>,2>
{
typedef RotationBase<Rotation2D<_Scalar>,2> Base;
using Base::operator*;
public:
using Base::operator*;
enum { Dim = 2 };
/** the scalar type of the coefficients */
typedef _Scalar Scalar;

View File

@@ -539,10 +539,11 @@ Transform<Scalar,Dim>::extractRotation(TransformTraits traits) const
}
else if (traits == NoScaling) // though that's stupid let's handle it !
return linear();
else {
else
{
ei_assert("invalid traits value in Transform::inverse()");
return LinearMatrixType();
}
return LinearMatrixType();
}
/** Convenient method to set \c *this from a position, orientation and scale

View File

@@ -216,7 +216,7 @@ struct ei_compute_inverse<MatrixType, 4>
* \sa inverse()
*/
template<typename Derived>
inline void MatrixBase<Derived>::computeInverse(typename MatrixBase<Derived>::EvalType *result) const
inline void MatrixBase<Derived>::computeInverse(EvalType *result) const
{
typedef typename ei_eval<Derived>::type MatrixType;
ei_assert(rows() == cols());