11 #include <Eigen/StdVector> 12 #include <Eigen/Geometry> 13 #include <unsupported/Eigen/BVH> 38 inline double SQR(
double x) {
return x * x; }
60 bool intersectVolumeVolume(
const BoxType &r1,
const BoxType &r2) { ++calls;
return !(r1.intersection(r2)).isNull(); }
77 double minimumOnVolume(
const BoxType &r) { ++calls;
return r.squaredExteriorDistance(p); }
79 double minimumOnVolumeVolume(
const BoxType &r1,
const BoxType &r2) { ++calls;
return r1.squaredExteriorDistance(r2); }
83 double minimumOnVolumeObject(
const BoxType &r,
const VectorType &v) { ++calls;
return r.squaredExteriorDistance(v); }
96 typedef std::vector<VectorType, aligned_allocator<VectorType> >
VectorTypeList;
98 typedef std::vector<BallType, aligned_allocator<BallType> >
BallTypeList;
104 for(
int i = 0; i < 500; ++i) {
105 b.push_back(BallType(VectorType::Random(), 0.5 *
internal::random(0., 1.)));
107 KdBVH<double, Dim, BallType>
tree(b.begin(), b.end());
109 VectorType pt = VectorType::Random();
112 for(
int i = 0; i < (int)b.size(); ++i)
113 i1.intersectObject(b[i]);
117 VERIFY(i1.count == i2.
count);
123 for(
int i = 0; i < 500; ++i) {
124 b.push_back(BallType(VectorType::Random(), 0.01 *
internal::random(0., 1.)));
126 KdBVH<double, Dim, BallType>
tree(b.begin(), b.end());
128 VectorType pt = VectorType::Random();
133 for(
int i = 0; i < (int)b.size(); ++i)
134 m1 = (std::min)(m1, i1.minimumOnObject(b[i]));
138 VERIFY_IS_APPROX(m1, m2);
146 for(
int i = 0; i < 50; ++i) {
147 b.push_back(BallType(VectorType::Random(), 0.5 *
internal::random(0., 1.)));
148 for(
int j = 0; j < 3; ++j)
149 v.push_back(VectorType::Random());
152 KdBVH<double, Dim, BallType>
tree(b.begin(), b.end());
153 KdBVH<double, Dim, VectorType> vTree(v.begin(), v.end());
157 for(
int i = 0; i < (int)b.size(); ++i)
158 for(
int j = 0; j < (int)v.size(); ++j)
163 VERIFY(i1.count == i2.count);
171 for(
int i = 0; i < 50; ++i) {
172 b.push_back(BallType(VectorType::Random(), 1e-7 + 1e-6 *
internal::random(0., 1.)));
173 for(
int j = 0; j < 3; ++j)
174 v.push_back(VectorType::Random());
177 KdBVH<double, Dim, BallType>
tree(b.begin(), b.end());
178 KdBVH<double, Dim, VectorType> vTree(v.begin(), v.end());
184 for(
int i = 0; i < (int)b.size(); ++i)
185 for(
int j = 0; j < (int)v.size(); ++j)
186 m1 = (std::min)(m1, i1.minimumOnObjectObject(b[i], v[j]));
190 VERIFY_IS_APPROX(m1, m2);
197 for(
int i = 0; i < g_repeat; i++) {
198 #ifdef EIGEN_TEST_PART_1 206 #ifdef EIGEN_TEST_PART_2 208 CALL_SUBTEST(test3.testIntersect1());
209 CALL_SUBTEST(test3.testMinimize1());
210 CALL_SUBTEST(test3.testIntersect2());
211 CALL_SUBTEST(test3.testMinimize2());
214 #ifdef EIGEN_TEST_PART_3 216 CALL_SUBTEST(test4.testIntersect1());
217 CALL_SUBTEST(test4.testMinimize1());
218 CALL_SUBTEST(test4.testIntersect2());
219 CALL_SUBTEST(test4.testMinimize2());
double minimumOnObjectObject(const BallType &b, const VectorType &v)
BallPointStuff(const VectorType &inP)
double minimumOnVolumeVolume(const BoxType &r1, const BoxType &r2)
Box2d bounding_box(const Vector2d &v)
std::vector< BallType, aligned_allocator< BallType > > BallTypeList
AlignedBox< double, Dim > BoxType
double minimumOnObjectObject(const BallType &b1, const BallType &b2)
Minimizer::Scalar BVMinimize(const BVH &tree, Minimizer &minimizer)
Ball(const VectorType &c, double r)
bool intersectObjectVolume(const BallType &b, const BoxType &r)
bool intersectObjectObject(const BallType &b, const VectorType &v)
double minimumOnObjectVolume(const BallType &b, const BoxType &r)
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(Scalar, Size)
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC half() max(const half &a, const half &b)
double minimumOnVolume(const BoxType &r)
std::vector< VectorType, aligned_allocator< VectorType > > VectorTypeList
bool intersectVolume(const BoxType &r)
bool intersectObjectObject(const BallType &b1, const BallType &b2)
bool intersectVolumeObject(const BoxType &r, const BallType &b)
Matrix< double, Dim, 1 > VectorType
double minimumOnObject(const BallType &b)
double minimumOnVolumeObject(const BoxType &r, const VectorType &v)
void BVIntersect(const BVH &tree, Intersector &intersector)
bool intersectObject(const BallType &b)
bool intersectVolumeVolume(const BoxType &r1, const BoxType &r2)
AlignedBox< double, Dim > BoxType
Matrix< double, Dim, 1 > VectorType
const mpreal random(unsigned int seed=0)
EIGEN_DEVICE_FUNC const Scalar & b
double minimumOnVolumeObject(const BoxType &r, const BallType &b)
bool intersectVolumeObject(const BoxType &r, const VectorType &v)