CGAL 6.0 - 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 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 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;
}
The class Euclidean_distance provides an implementation of the concept OrthogonalDistance,...
Definition: Euclidean_distance.h:20
The class Orthogonal_k_neighbor_search implements approximatek-nearest and k-furthest neighbor search...
Definition: Orthogonal_k_neighbor_search.h:31
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