aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2008-08-31 13:32:29 +0000
committerGravatar Gael Guennebaud <g.gael@free.fr>2008-08-31 13:32:29 +0000
commit7e8aa63bb7083c1f465be0b42460f49559ee6b7a (patch)
treeed1c2db0373330f1d05b9e2f554dedbfc0cd307e
parent5c34d8e20a4263bb387e19da4209137bfe519a54 (diff)
* Add Hyperplane::transform(Matrix/Transform)
* Fix compilations with gcc 3.4, ICC and doxygen * Fix krazy directives (hopefully)
-rw-r--r--.krazy4
-rw-r--r--Eigen/src/Core/CwiseNullaryOp.h8
-rw-r--r--Eigen/src/Core/DiagonalMatrix.h2
-rw-r--r--Eigen/src/Core/Dot.h6
-rw-r--r--Eigen/src/Core/Sum.h6
-rw-r--r--Eigen/src/Core/util/Constants.h2
-rw-r--r--Eigen/src/Geometry/AngleAxis.h4
-rw-r--r--Eigen/src/Geometry/Hyperplane.h37
-rw-r--r--Eigen/src/Geometry/Quaternion.h3
-rw-r--r--Eigen/src/Geometry/Rotation2D.h4
-rw-r--r--Eigen/src/Geometry/Transform.h5
-rw-r--r--Eigen/src/LU/Inverse.h2
-rw-r--r--doc/QuickStartGuide.dox40
-rwxr-xr-xdoc/cleanhierarchy.sh1
-rw-r--r--doc/examples/.krazy2
-rw-r--r--doc/snippets/.krazy3
-rw-r--r--test/geometry.cpp2
-rw-r--r--test/hyperplane.cpp30
-rw-r--r--test/main.h2
-rw-r--r--test/packetmath.cpp3
20 files changed, 118 insertions, 48 deletions
diff --git a/.krazy b/.krazy
index cee8846bb..d719866a6 100644
--- a/.krazy
+++ b/.krazy
@@ -1 +1,3 @@
-IGNORESUBS disabled,bench,build \ No newline at end of file
+SKIP /disabled/
+SKIP /bench/
+SKIP /build/
diff --git a/Eigen/src/Core/CwiseNullaryOp.h b/Eigen/src/Core/CwiseNullaryOp.h
index caa86fa97..005340213 100644
--- a/Eigen/src/Core/CwiseNullaryOp.h
+++ b/Eigen/src/Core/CwiseNullaryOp.h
@@ -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++)
{
diff --git a/Eigen/src/Core/DiagonalMatrix.h b/Eigen/src/Core/DiagonalMatrix.h
index 06507dc68..4ea21c835 100644
--- a/Eigen/src/Core/DiagonalMatrix.h
+++ b/Eigen/src/Core/DiagonalMatrix.h
@@ -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);
diff --git a/Eigen/src/Core/Dot.h b/Eigen/src/Core/Dot.h
index a3e1229f8..4a729aaea 100644
--- a/Eigen/src/Core/Dot.h
+++ b/Eigen/src/Core/Dot.h
@@ -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
diff --git a/Eigen/src/Core/Sum.h b/Eigen/src/Core/Sum.h
index 3b073b95e..12a84e3f1 100644
--- a/Eigen/src/Core/Sum.h
+++ b/Eigen/src/Core/Sum.h
@@ -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;
diff --git a/Eigen/src/Core/util/Constants.h b/Eigen/src/Core/util/Constants.h
index 7aa626f95..9576ac6d8 100644
--- a/Eigen/src/Core/util/Constants.h
+++ b/Eigen/src/Core/util/Constants.h
@@ -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
diff --git a/Eigen/src/Geometry/AngleAxis.h b/Eigen/src/Geometry/AngleAxis.h
index 0b4fd03d0..662ae95fb 100644
--- a/Eigen/src/Geometry/AngleAxis.h
+++ b/Eigen/src/Geometry/AngleAxis.h
@@ -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;
diff --git a/Eigen/src/Geometry/Hyperplane.h b/Eigen/src/Geometry/Hyperplane.h
index 65700cc32..5a8657f31 100644
--- a/Eigen/src/Geometry/Hyperplane.h
+++ b/Eigen/src/Geometry/Hyperplane.h
@@ -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)
{
diff --git a/Eigen/src/Geometry/Quaternion.h b/Eigen/src/Geometry/Quaternion.h
index 8fbc645ea..a2cc785c7 100644
--- a/Eigen/src/Geometry/Quaternion.h
+++ b/Eigen/src/Geometry/Quaternion.h
@@ -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;
diff --git a/Eigen/src/Geometry/Rotation2D.h b/Eigen/src/Geometry/Rotation2D.h
index 1c3cbc05d..c0bda5f69 100644
--- a/Eigen/src/Geometry/Rotation2D.h
+++ b/Eigen/src/Geometry/Rotation2D.h
@@ -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;
diff --git a/Eigen/src/Geometry/Transform.h b/Eigen/src/Geometry/Transform.h
index a857eff53..b003f20ed 100644
--- a/Eigen/src/Geometry/Transform.h
+++ b/Eigen/src/Geometry/Transform.h
@@ -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
diff --git a/Eigen/src/LU/Inverse.h b/Eigen/src/LU/Inverse.h
index f2bf98f8a..5a52086e6 100644
--- a/Eigen/src/LU/Inverse.h
+++ b/Eigen/src/LU/Inverse.h
@@ -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());
diff --git a/doc/QuickStartGuide.dox b/doc/QuickStartGuide.dox
index cf37f02be..b7cbf3046 100644
--- a/doc/QuickStartGuide.dox
+++ b/doc/QuickStartGuide.dox
@@ -637,42 +637,50 @@ mat2x2 = t.linear();
Eigen's geometry module offer two different ways to build and update transformation objects.
<table class="tutorial_code">
<tr><td></td><td>\b procedurale \b API </td><td>\b natural \b API </td></tr>
-<tr><td>Applies a translation</td><td>\code
-t.translate(Vector3(tx, ty, ...));
-t.pretranslate(Vector3(tx, ty, ...));
+<tr><td>Translation</td><td>\code
+t.translate(Vector_(tx, ty, ...));
+
+t.pretranslate(Vector_(tx, ty, ...));
\endcode</td><td>\code
-t *= Translation(tx, ty, ...);
-t = Translation(tx, ty, ...) * t;
+t *= Translation_(tx, ty, ...);
+t2 = t1 * Translation_(vec);
+t = Translation_(tx, ty, ...) * t;
\endcode</td></tr>
-<tr><td>Applies a rotation \n <span class="note">In 2D, any_rotation can also be \n an angle in radian</span></td><td>\code
+<tr><td>Rotation \n <span class="note">In 2D, any_rotation can also \n be an angle in radian</span></td><td>\code
t.rotate(any_rotation);
+
t.prerotate(any_rotation);
\endcode</td><td>\code
t *= any_rotation;
+t2 = t1 * any_rotation;
t = any_rotation * t;
\endcode</td></tr>
-<tr><td>Applies a scaling</td><td>\code
-t.scale(Vector(sx, sy, ...));
-t.scale(Vector::Constant(s));
-t.prescale(Vector3f(sx, sy, ...));
+<tr><td>Scaling</td><td>\code
+t.scale(Vector_(sx, sy, ...));
+
+t.scale(s);
+t.prescale(Vector_(sx, sy, ...));
+t.prescale(s);
\endcode</td><td>\code
-t *= Scaling(sx, sy, ...);
-t *= Scaling(s);
-t = Scaling(sx, sy, ...) * t;
+t *= Scaling_(sx, sy, ...);
+t2 = t1 * Scaling_(vec);
+t *= Scaling_(s);
+t = Scaling_(sx, sy, ...) * t;
+t = Scaling_(s) * t;
\endcode</td></tr>
-<tr><td>Applies a shear transformation \n ( \b 2D \b only ! )</td><td>\code
+<tr><td>Shear transformation \n ( \b 2D \b only ! )</td><td>\code
t.shear(sx,sy);
t.preshear(sx,sy);
\endcode</td><td></td></tr>
</table>
-Note that in both API, any many transformations can be concatenated in a single lines as shown in the two following equivalent examples:
+Note that in both API, any many transformations can be concatenated in a single expression as shown in the two following equivalent examples:
<table class="tutorial_code">
<tr><td>\code
t.pretranslate(..).rotate(..).translate(..).scale(..);
\endcode</td></tr>
<tr><td>\code
-t = Translation(..) * t * RotationType(..) * Translation(..) * Scaling(..);
+t = Translation_(..) * t * RotationType(..) * Translation_(..) * Scaling_(..);
\endcode</td></tr>
</table>
diff --git a/doc/cleanhierarchy.sh b/doc/cleanhierarchy.sh
index 892cf393c..fe44891b9 100755
--- a/doc/cleanhierarchy.sh
+++ b/doc/cleanhierarchy.sh
@@ -2,3 +2,4 @@
sed -i 's/^.li.*MatrixBase\&lt.*gt.*a.$/ /g' $1
sed -i 's/^.li.*MapBase\&lt.*gt.*a.$/ /g' $1
+sed -i 's/^.li.*RotationBase\&lt.*gt.*a.$/ /g' $1
diff --git a/doc/examples/.krazy b/doc/examples/.krazy
new file mode 100644
index 000000000..00b99405d
--- /dev/null
+++ b/doc/examples/.krazy
@@ -0,0 +1,2 @@
+EXCLUDE copyright
+EXCLUDE license
diff --git a/doc/snippets/.krazy b/doc/snippets/.krazy
index 60f6bcaf3..00b99405d 100644
--- a/doc/snippets/.krazy
+++ b/doc/snippets/.krazy
@@ -1 +1,2 @@
-EXCLUDE copyright,license \ No newline at end of file
+EXCLUDE copyright
+EXCLUDE license
diff --git a/test/geometry.cpp b/test/geometry.cpp
index 0654bed65..6b507880e 100644
--- a/test/geometry.cpp
+++ b/test/geometry.cpp
@@ -284,6 +284,6 @@ void test_geometry()
{
for(int i = 0; i < g_repeat; i++) {
CALL_SUBTEST( geometry<float>() );
-// CALL_SUBTEST( geometry<double>() );
+ CALL_SUBTEST( geometry<double>() );
}
}
diff --git a/test/hyperplane.cpp b/test/hyperplane.cpp
index 3d001c7d9..ebf9f17a7 100644
--- a/test/hyperplane.cpp
+++ b/test/hyperplane.cpp
@@ -25,6 +25,7 @@
#include "main.h"
#include <Eigen/Geometry>
#include <Eigen/LU>
+#include <Eigen/QR>
template<typename HyperplaneType> void hyperplane(const HyperplaneType& _plane)
{
@@ -36,6 +37,8 @@ template<typename HyperplaneType> void hyperplane(const HyperplaneType& _plane)
typedef typename HyperplaneType::Scalar Scalar;
typedef typename NumTraits<Scalar>::Real RealScalar;
typedef Matrix<Scalar, HyperplaneType::AmbientDimAtCompileTime, 1> VectorType;
+ typedef Matrix<Scalar, HyperplaneType::AmbientDimAtCompileTime,
+ HyperplaneType::AmbientDimAtCompileTime> MatrixType;
VectorType p0 = VectorType::Random(dim);
VectorType p1 = VectorType::Random(dim);
@@ -45,6 +48,7 @@ template<typename HyperplaneType> void hyperplane(const HyperplaneType& _plane)
HyperplaneType pl0(n0, p0);
HyperplaneType pl1(n1, p1);
+ HyperplaneType pl2 = pl1;
Scalar s0 = ei_random<Scalar>();
Scalar s1 = ei_random<Scalar>();
@@ -56,6 +60,32 @@ template<typename HyperplaneType> void hyperplane(const HyperplaneType& _plane)
VERIFY_IS_APPROX( pl1.signedDistance(p1 + n1 * s0), s0 );
VERIFY_IS_MUCH_SMALLER_THAN( pl1.signedDistance(pl1.projection(p0)), Scalar(1) );
VERIFY_IS_MUCH_SMALLER_THAN( pl1.absDistance(p1 + pl1.normal().unitOrthogonal() * s1), Scalar(1) );
+
+ // transform
+ if (!NumTraits<Scalar>::IsComplex)
+ {
+ MatrixType rot = MatrixType::Random(dim,dim).qr().matrixQ();
+ Scaling<Scalar,HyperplaneType::AmbientDimAtCompileTime> scaling(VectorType::Random());
+ Translation<Scalar,HyperplaneType::AmbientDimAtCompileTime> translation(VectorType::Random());
+
+ pl2 = pl1;
+ VERIFY_IS_MUCH_SMALLER_THAN( pl2.transform(rot).absDistance(rot * p1), Scalar(1) );
+ pl2 = pl1;
+ VERIFY_IS_MUCH_SMALLER_THAN( pl2.transform(rot,NoScaling).absDistance(rot * p1), Scalar(1) );
+ pl2 = pl1;
+ VERIFY_IS_MUCH_SMALLER_THAN( pl2.transform(rot*scaling).absDistance((rot*scaling) * p1), Scalar(1) );
+ pl2 = pl1;
+ VERIFY_IS_MUCH_SMALLER_THAN( pl2.transform(rot*scaling, NoShear).absDistance((rot*scaling) * p1), Scalar(1) );
+ pl2 = pl1;
+ VERIFY_IS_MUCH_SMALLER_THAN( pl2.transform(rot*scaling*translation)
+ .absDistance((rot*scaling*translation) * p1), Scalar(1) );
+ pl2 = pl1;
+ VERIFY_IS_MUCH_SMALLER_THAN( pl2.transform(rot*scaling*translation,NoShear)
+ .absDistance((rot*scaling*translation) * p1), Scalar(1) );
+ pl2 = pl1;
+ VERIFY_IS_MUCH_SMALLER_THAN( pl2.transform(rot*translation,NoScaling)
+ .absDistance((rot*translation) * p1), Scalar(1) );
+ }
}
template<typename Scalar> void lines()
diff --git a/test/main.h b/test/main.h
index d4cdced60..b1410386f 100644
--- a/test/main.h
+++ b/test/main.h
@@ -54,7 +54,7 @@ namespace Eigen
static const bool should_raise_an_assert = false;
// Used to avoid to raise two exceptions at a time in which
- // case the exception is not properly catched.
+ // case the exception is not properly caught.
// This may happen when a second exceptions is raise in a destructor.
static bool no_more_assert = false;
diff --git a/test/packetmath.cpp b/test/packetmath.cpp
index d7cc4f61e..00b438c16 100644
--- a/test/packetmath.cpp
+++ b/test/packetmath.cpp
@@ -100,9 +100,6 @@ template<typename Scalar> void packetmath()
ref[i] = data1[i+offset];
typedef Matrix<Scalar, PacketSize, 1> Vector;
- std::cout << Vector(data1).transpose() << " | " << Vector(data1+PacketSize).transpose() << "\n";
- std::cout << " " << offset << " => " << Vector(ref).transpose() << " == " << Vector(data2).transpose() << "\n";
-
VERIFY(areApprox(ref, data2, PacketSize) && "ei_palign");
}