Use the Epick_d kernel in two examples, and for 4d and not 2D

This commit is contained in:
Andreas Fabri 2015-02-26 18:07:37 +01:00
parent 803415f2f1
commit af84e62b6c
5 changed files with 46 additions and 33 deletions

View File

@ -18,6 +18,11 @@ find_package(CGAL QUIET COMPONENTS Core )
if ( CGAL_FOUND )
include( ${CGAL_USE_FILE} )
find_package(Eigen3 3.1.91) #(requires 3.2.0 or greater)
if (EIGEN3_FOUND)
include( ${EIGEN3_USE_FILE} )
endif()
include( CGAL_CreateSingleSourceCGALProgram )
@ -35,6 +40,7 @@ create_single_source_cgal_program( "binary.cpp" )
create_single_source_cgal_program( "Nearest_neighbor_searching_2D_user_defined.cpp" )
create_single_source_cgal_program( "Split_data.cpp" )
create_single_source_cgal_program( "nn3cgal.cpp" )
create_single_source_cgal_program( "nn4cgal.cpp" )
create_single_source_cgal_program( "nn3nanoflan.cpp" )
create_single_source_cgal_program( "sizeof.cpp" )
create_single_source_cgal_program( "deque.cpp" )

View File

@ -163,7 +163,7 @@ which is a template method with an output iterator and a model of the
concept `FuzzyQueryItem` as `Fuzzy_iso_box`
or `Fuzzy_sphere`.
For range searching of large data sets the user may set the parameter `bucket_size`
used in building the `k-d` tree to a large value (e.g. 100),
used in building the `kd` tree to a large value (e.g. 100),
because in general the query time will be less then using the default value.
\section Spatial_SearchingSplitting_rule_section Splitting Rules
@ -273,7 +273,7 @@ using a `d`-dimensional iso-rectangle as an query object. Approximate
range searching is illustrated by the fourth example. The fifth
example illustrates k neighbor searching for a user defined point
class. The sixth example shows how to choose another splitting rule in the
`k-d` tree that is used as search tree. The last example shows two worst-case
`kd` tree that is used as search tree. The last example shows two worst-case
scenarios for different splitter types.
\subsection Spatial_searchingExampleforKNeighborSearching Example for K Neighbor Searching
@ -307,7 +307,7 @@ iterator category, that is one can make only one pass over the data.
This example program illustrates approximate nearest and furthest
neighbor searching using 4-dimensional %Cartesian coordinates. Five
approximate nearest neighbors of the query rectangle
approximate furthest neighbors of the query rectangle
\f$ [0.1,0.2]^4\f$ are computed. Because the query object is a rectangle
we cannot use the orthogonal neighbor search. As in the previous
examples we first initialize a search tree, create the search object
@ -318,9 +318,9 @@ with the query, and obtain the result of the search as iterator range.
\subsection Spatial_searchingExampleforaRangeQuery Example for a Range Query
This example program illustrates approximate range querying for
4-dimensional fuzzy iso-rectangles and spheres using homogeneous
coordinates. The range queries are member functions of the `k-d`
tree class.
4-dimensional fuzzy iso-rectangles and spheres using the higher
dimensional kernel `Epick_d`.
The range queries are member functions of the `kd` tree class.
\cgalExample{Spatial_searching/fuzzy_range_query.cpp}
@ -435,21 +435,21 @@ Blue: Gargoyle surface. Green: Gargoyle bbox random.
\section Spatial_searchingSoftware Software Design
\subsection Kd_tree_subsection The k-d tree
\subsection Kd_tree_subsection The kd Tree
Bentley \cgalCite{b-mbstu-75} introduced the `k-d` tree as a
generalization of the binary search tree in higher dimensions. `k-d`
Bentley \cgalCite{b-mbstu-75} introduced the `kd` tree as a
generalization of the binary search tree in higher dimensions. `kd`
trees hierarchically decompose space into a relatively small number of
rectangles such that no rectangle contains too many input objects.
For our purposes, a <I>rectangle</I> in real `d` dimensional space,
\f$ \mathbb{R}^d\f$, is the product of `d` closed intervals on the coordinate axes.
`k-d` trees are obtained by partitioning point sets in \f$ \mathbb{R}^d\f$ using
`kd` trees are obtained by partitioning point sets in \f$ \mathbb{R}^d\f$ using
`(d-1)`-dimensional hyperplanes. Each node in the tree is split into
two children by one such separating hyperplane. Several splitting
rules (see Section \ref Spatial_SearchingSplitting_rule_section can
be used to compute a separating `(d-1)`-dimensional hyperplane.
Each internal node of the `k-d` tree is associated with a rectangle
Each internal node of the `kd` tree is associated with a rectangle
and a hyperplane orthogonal to one of the coordinate axis, which
splits the rectangle into two parts. Therefore, such a hyperplane,
defined by a splitting dimension and a splitting value, is called a
@ -463,7 +463,7 @@ tree, not in the internal nodes.
Friedmann, Bentley and Finkel \cgalCite{fbf-afbml-77} described the
standard search algorithm to find the `k`th nearest neighbor by
searching a `k-d` tree recursively.
searching a `kd` tree recursively.
When encountering a node of the tree, the algorithm first visits the
child that is closest to the query point. On return, if the rectangle

View File

@ -33,7 +33,12 @@ endif()
# include helper file
include( ${CGAL_USE_FILE} )
find_package(Eigen3 3.1.91) #(requires 3.2.0 or greater)
if (EIGEN3_FOUND)
include( ${EIGEN3_USE_FILE} )
endif()
if (MSVC)
# Turn off VC++ warning
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4244")

View File

@ -1,13 +1,15 @@
#include <CGAL/Cartesian_d.h>
#include <CGAL/Epick_d.h>
#include <CGAL/point_generators_d.h>
#include <CGAL/Kd_tree.h>
#include <CGAL/Fuzzy_sphere.h>
#include <CGAL/Fuzzy_iso_box.h>
#include <CGAL/Search_traits_d.h>
typedef CGAL::Cartesian_d<double> K;
const int D = 4;
typedef CGAL::Epick_d<CGAL::Dimension_tag<D> > K;
typedef K::Point_d Point_d;
typedef CGAL::Search_traits_d<K> Traits;
typedef CGAL::Search_traits_d<K,CGAL::Dimension_tag<D> > Traits;
typedef CGAL::Random_points_in_cube_d<Point_d> Random_points_iterator;
typedef CGAL::Counting_iterator<Random_points_iterator> N_Random_points_iterator;
typedef CGAL::Kd_tree<Traits> Tree;
@ -15,7 +17,7 @@ typedef CGAL::Fuzzy_sphere<Traits> Fuzzy_sphere;
typedef CGAL::Fuzzy_iso_box<Traits> Fuzzy_iso_box;
int main() {
const int D = 4;
const int N = 1000;
// generator for random data points in the square ( (-1000,-1000), (1000,1000) )
Random_points_iterator rpit(4, 1000.0);
@ -27,8 +29,8 @@ int main() {
// define range query objects
double pcoord[D] = { 300, 300, 300, 300 };
double qcoord[D] = { 900.0, 900.0, 900.0, 900.0 };
Point_d p(D, pcoord, pcoord+D);
Point_d q(D, qcoord, qcoord+D);
Point_d p(D, pcoord+0, pcoord+D);
Point_d q(D, qcoord+0, qcoord+D);
Fuzzy_sphere fs(p, 700.0, 100.0);
Fuzzy_iso_box fib(p, q, 100.0);

View File

@ -1,14 +1,14 @@
#include <CGAL/Cartesian_d.h>
#include <CGAL/point_generators_2.h>
#include <CGAL/Epick_d.h>
#include <CGAL/point_generators_d.h>
#include <CGAL/Manhattan_distance_iso_box_point.h>
#include <CGAL/K_neighbor_search.h>
#include <CGAL/Search_traits_2.h>
#include <CGAL/Search_traits_d.h>
typedef CGAL::Cartesian_d<double> K;
typedef K::Point_d Point_d;
typedef CGAL::Random_points_in_square_2<Point_d> Random_points_iterator;
typedef K::Iso_box_d Iso_box_d;
typedef K TreeTraits;
typedef CGAL::Epick_d<CGAL::Dimension_tag<4> > Kernel;
typedef Kernel::Point_d Point_d;
typedef CGAL::Random_points_in_cube_d<Point_d> Random_points_iterator;
typedef Kernel::Iso_box_d Iso_box_d;
typedef Kernel TreeTraits;
typedef CGAL::Manhattan_distance_iso_box_point<TreeTraits> Distance;
typedef CGAL::K_neighbor_search<TreeTraits, Distance> Neighbor_search;
typedef Neighbor_search::Tree Tree;
@ -18,18 +18,18 @@ int main() {
const unsigned int K = 10;
Tree tree;
Random_points_iterator rpg;
Random_points_iterator rpit(4,1000.0);
for(int i = 0; i < N; i++){
tree.insert(*rpg++);
tree.insert(*rpit++);
}
Point_d pp(0.1,0.1);
Point_d qq(0.2,0.2);
Point_d pp(0.1,0.1,0.1,0.1);
Point_d qq(0.2,0.2,0.2,0.2);
Iso_box_d query(pp,qq);
Distance tr_dist;
Neighbor_search N1(tree, query, K, 0.0, false); // eps=10.0, nearest=false
Neighbor_search N1(tree, query, 5, 0.0, false); // eps=10.0, nearest=false
std::cout << "For query rectange = [0.1,0.2]^2 " << std::endl
std::cout << "For query rectange = [0.1,0.2]^4 " << std::endl
<< "The " << K << " approximate furthest neighbors are: " << std::endl;
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) << std::endl;