CGAL 6.2 - dD Spatial Searching

Loading...
Searching...
No Matches
Spatial_searching/searching_sphere_orthogonally.cpp
#include <CGAL/Simple_cartesian.h>
#include <CGAL/point_generators_2.h>
#include <CGAL/Euclidean_distance.h>
#include <CGAL/Orthogonal_k_neighbor_search.h>
#include <CGAL/Search_traits_2.h>
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_2 Point_2;
typedef CGAL::Random_points_in_square_2<Point_2> Random_points_iterator;
typedef Kernel::Circle_2 Sphere_2;
typedef CGAL::Search_traits_2<Kernel> TreeTraits;
typedef CGAL::Euclidean_distance<TreeTraits> Distance;
typedef CGAL::Orthogonal_k_neighbor_search<TreeTraits, Distance> Neighbor_search;
typedef TreeTraits::Construct_center_d Construct_center_d;
typedef TreeTraits::Compute_squared_radius_d Compute_squared_radius_d;
typedef Neighbor_search::Tree Tree;
int main()
{
const int N = 1000;
const unsigned int K = 10;
Tree tree;
Random_points_iterator rpg;
for(int i = 0; i < N; ++i)
tree.insert(*rpg++);
Sphere_2 query(*rpg,0.5);
Distance tr_dist;
Point_2 center = Construct_center_d()(query);
Neighbor_search N1(tree, center, K, 0.0, false); // eps=0.0, nearest=false
std::cout << "For the query circle " << std::endl
<< "The " << K << " approximate furthest neighbors are: " << std::endl;
double radius = Compute_squared_radius_d()(query);
for (Neighbor_search::iterator it = N1.begin();it != N1.end();it++)
std::cout << " Point " << it->first << " at distance = " << tr_dist.inverse_of_transformed_distance(it->second - radius) << std::endl;
return 0;
}
CGAL::Euclidean_distance
The class Euclidean_distance provides an implementation of the concept OrthogonalDistance,...
Definition: Euclidean_distance.h:20
CGAL::Orthogonal_k_neighbor_search
The class Orthogonal_k_neighbor_search implements approximatek-nearest and k-furthest neighbor search...
Definition: Orthogonal_k_neighbor_search.h:31
CGAL::Random_points_in_square_2
CGAL::Search_traits_2
The class Search_traits_2 can be used as a template parameter of the kd tree and the search classes.
Definition: Search_traits_2.h:19
Kernel::Circle_2
Kernel::Point_2
Kernel
CGAL::Simple_cartesian