* 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

@@ -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>() );
}
}

View File

@@ -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()

View File

@@ -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;

View File

@@ -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");
}