summaryrefslogtreecommitdiffhomepage
path: root/eigen/test/geo_alignedbox.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'eigen/test/geo_alignedbox.cpp')
-rw-r--r--eigen/test/geo_alignedbox.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/eigen/test/geo_alignedbox.cpp b/eigen/test/geo_alignedbox.cpp
index 84663ad..223ff5e 100644
--- a/eigen/test/geo_alignedbox.cpp
+++ b/eigen/test/geo_alignedbox.cpp
@@ -15,8 +15,17 @@
#include<iostream>
using namespace std;
+// NOTE the following workaround was needed on some 32 bits builds to kill extra precision of x87 registers.
+// It seems that it os not needed anymore, but let's keep it here, just in case...
+
template<typename T> EIGEN_DONT_INLINE
-void kill_extra_precision(T& x) { eigen_assert(&x != 0); }
+void kill_extra_precision(T& /* x */) {
+ // This one worked but triggered a warning:
+ /* eigen_assert((void*)(&x) != (void*)0); */
+ // An alternative could be:
+ /* volatile T tmp = x; */
+ /* x = tmp; */
+}
template<typename BoxType> void alignedbox(const BoxType& _box)
@@ -48,12 +57,21 @@ template<typename BoxType> void alignedbox(const BoxType& _box)
b0.extend(p0);
b0.extend(p1);
VERIFY(b0.contains(p0*s1+(Scalar(1)-s1)*p1));
+ VERIFY(b0.contains(b0.center()));
+ VERIFY_IS_APPROX(b0.center(),(p0+p1)/Scalar(2));
(b2 = b0).extend(b1);
VERIFY(b2.contains(b0));
VERIFY(b2.contains(b1));
VERIFY_IS_APPROX(b2.clamp(b0), b0);
+ // intersection
+ BoxType box1(VectorType::Random(dim));
+ box1.extend(VectorType::Random(dim));
+ BoxType box2(VectorType::Random(dim));
+ box2.extend(VectorType::Random(dim));
+
+ VERIFY(box1.intersects(box2) == !box1.intersection(box2).isEmpty());
// alignment -- make sure there is no memory alignment assertion
BoxType *bp0 = new BoxType(dim);