From ec0a423862d74cea10e2b33f7b37f43957adb465 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Sat, 25 Oct 2008 23:10:21 +0000 Subject: Add isApprox in Geometry module's classes. Complete unit tests wrt previous commits. --- test/hyperplane.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'test/hyperplane.cpp') 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 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 void hyperplane(const HyperplaneType& _plane) Scalar s1 = ei_random(); 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 void hyperplane(const HyperplaneType& _plane) MatrixType rot = MatrixType::Random(dim,dim).qr().matrixQ(); Scaling scaling(VectorType::Random()); Translation 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 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::type OtherScalar; + Hyperplane hp1f = pl1.template cast(); + VERIFY_IS_APPROX(hp1f.template cast(),pl1); + Hyperplane hp1d = pl1.template cast(); + VERIFY_IS_APPROX(hp1d.template cast(),pl1); } template void lines() -- cgit v1.2.3