BVH_Example.cpp File Reference

Go to the source code of this file.

Namespaces

 Eigen
 : TensorContractionSycl.h, provides various tensor contraction kernel for SYCL backend
 

Typedefs

typedef AlignedBox< double, 2 > Box2d
 

Functions

Box2d Eigen::bounding_box (const Vector2d &v)
 
int main ()
 

Typedef Documentation

◆ Box2d

typedef AlignedBox<double, 2> Box2d

Definition at line 6 of file BVH_Example.cpp.

Function Documentation

◆ main()

int main ( )

Definition at line 25 of file BVH_Example.cpp.

26 {
27  typedef std::vector<Vector2d, aligned_allocator<Vector2d> > StdVectorOfVector2d;
28  StdVectorOfVector2d redPoints, bluePoints;
29  for(int i = 0; i < 100; ++i) { //initialize random set of red points and blue points
30  redPoints.push_back(Vector2d::Random());
31  bluePoints.push_back(Vector2d::Random());
32  }
33 
34  PointPointMinimizer minimizer;
35  double minDistSq = std::numeric_limits<double>::max();
36 
37  //brute force to find closest red-blue pair
38  for(int i = 0; i < (int)redPoints.size(); ++i)
39  for(int j = 0; j < (int)bluePoints.size(); ++j)
40  minDistSq = std::min(minDistSq, minimizer.minimumOnObjectObject(redPoints[i], bluePoints[j]));
41  std::cout << "Brute force distance = " << sqrt(minDistSq) << ", calls = " << minimizer.calls << std::endl;
42 
43  //using BVH to find closest red-blue pair
44  minimizer.calls = 0;
45  KdBVH<double, 2, Vector2d> redTree(redPoints.begin(), redPoints.end()), blueTree(bluePoints.begin(), bluePoints.end()); //construct the trees
46  minDistSq = BVMinimize(redTree, blueTree, minimizer); //actual BVH minimization call
47  std::cout << "BVH distance = " << sqrt(minDistSq) << ", calls = " << minimizer.calls << std::endl;
48 
49  return 0;
50 }
int i
static const RandomReturnType Random()
A simple bounding volume hierarchy based on AlignedBox.
Definition: KdBVH.h:71
Eigen::AutoDiffScalar< EIGEN_EXPR_BINARYOP_SCALAR_RETURN_TYPE(Eigen::internal::remove_all_t< DerType >, typename Eigen::internal::traits< Eigen::internal::remove_all_t< DerType >>::Scalar, product) > sqrt(const Eigen::AutoDiffScalar< DerType > &x)
CleanedUpDerType< DerType >::type() min(const AutoDiffScalar< DerType > &x, const T &y)
CleanedUpDerType< DerType >::type() max(const AutoDiffScalar< DerType > &x, const T &y)
Minimizer::Scalar BVMinimize(const BVH &tree, Minimizer &minimizer)
Definition: BVAlgorithms.h:221
std::ptrdiff_t j