aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/hyperplane.cpp
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2008-10-25 23:10:21 +0000
committerGravatar Gael Guennebaud <g.gael@free.fr>2008-10-25 23:10:21 +0000
commitec0a423862d74cea10e2b33f7b37f43957adb465 (patch)
tree041c07641467df69289ef429fa7e3ce3a49752ea /test/hyperplane.cpp
parent505ce85814f9291b7d242ef57582d7b15e673f26 (diff)
Add isApprox in Geometry module's classes.
Complete unit tests wrt previous commits.
Diffstat (limited to 'test/hyperplane.cpp')
-rw-r--r--test/hyperplane.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/test/hyperplane.cpp b/test/hyperplane.cpp
index 0418c71b2..90312ca6e 100644
--- a/test/hyperplane.cpp
+++ b/test/hyperplane.cpp
@@ -46,7 +46,7 @@ template<typename HyperplaneType> void hyperplane(const HyperplaneType& _plane)
VectorType n0 = VectorType::Random(dim).normalized();
VectorType n1 = VectorType::Random(dim).normalized();
-
+
HyperplaneType pl0(n0, p0);
HyperplaneType pl1(n1, p1);
HyperplaneType pl2 = pl1;
@@ -55,7 +55,7 @@ template<typename HyperplaneType> void hyperplane(const HyperplaneType& _plane)
Scalar s1 = ei_random<Scalar>();
VERIFY_IS_APPROX( n1.dot(n1), Scalar(1) );
-
+
VERIFY_IS_MUCH_SMALLER_THAN( pl0.absDistance(p0), Scalar(1) );
VERIFY_IS_APPROX( pl1.signedDistance(p1 + n1 * s0), s0 );
VERIFY_IS_MUCH_SMALLER_THAN( pl1.signedDistance(pl1.projection(p0)), Scalar(1) );
@@ -67,7 +67,7 @@ template<typename HyperplaneType> void hyperplane(const HyperplaneType& _plane)
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;
@@ -81,6 +81,14 @@ template<typename HyperplaneType> void hyperplane(const HyperplaneType& _plane)
VERIFY_IS_MUCH_SMALLER_THAN( pl2.transform(rot*translation,Isometry)
.absDistance((rot*translation) * p1), Scalar(1) );
}
+
+ // casting
+ const int Dim = HyperplaneType::AmbientDimAtCompileTime;
+ typedef typename GetDifferentType<Scalar>::type OtherScalar;
+ Hyperplane<OtherScalar,Dim> hp1f = pl1.template cast<OtherScalar>();
+ VERIFY_IS_APPROX(hp1f.template cast<Scalar>(),pl1);
+ Hyperplane<Scalar,Dim> hp1d = pl1.template cast<Scalar>();
+ VERIFY_IS_APPROX(hp1d.template cast<Scalar>(),pl1);
}
template<typename Scalar> void lines()