|
HighMap library (C++)
|
2D KD-Tree for spatial point queries. More...
#include <kd_tree.hpp>
Classes | |
| struct | Impl |
Public Member Functions | |
| KDTree () | |
| Construct an empty KD-tree. | |
| ~KDTree () | |
| Destructor. | |
| KDTree (const std::vector< float > &x, const std::vector< float > &y) | |
| Construct a KD-tree referencing separate coordinate arrays. | |
| KDTree (const std::vector< Point > &points) | |
| Construct a KD-tree referencing a vector of points. | |
| KDTree (const Cloud &cloud) | |
| Construct a KD-tree referencing a Cloud. | |
| KDTree (KDTree &&other) noexcept | |
| Move constructor. | |
| KDTree & | operator= (KDTree &&other) noexcept |
| Move assignment operator. | |
| KDTree (const KDTree &)=delete | |
| KDTree & | operator= (const KDTree &)=delete |
| bool | empty () const noexcept |
| Check whether the KD-tree is empty. | |
| size_t | size () const noexcept |
| Get the number of points indexed by the KD-tree. | |
| glm::vec2 | compute_neighbor_distance_range (size_t k_neighbors) const |
| Estimate the range of neighbor distances across the dataset. | |
| size_t | nearest (float x_query, float y_query) const |
| Find the index of the nearest neighbor to a 2D query position. | |
| size_t | nearest (const Point &p) const |
| Find the index of the nearest neighbor to a Point. | |
| size_t | nearest (const glm::vec2 &xy) const |
| Find the index of the nearest neighbor to a glm::vec2. | |
| std::pair< size_t, float > | nearest_with_distance_squared (float x_query, float y_query) const |
| Find the index and squared distance of the nearest neighbor. | |
| std::pair< size_t, float > | nearest_with_distance_squared (const Point &p) const |
| Find the index and squared distance of the nearest neighbor to a Point. | |
| std::pair< size_t, float > | nearest_with_distance_squared (const glm::vec2 &xy) const |
| Find the index and squared distance of the nearest neighbor to a glm::vec2. | |
| void | neighbor_search (float x_query, float y_query, size_t k_neighbors, std::vector< size_t > &indices, std::vector< float > &distances) const |
| Perform a k-nearest neighbor search. | |
| void | neighbor_search (const Point &p, size_t k_neighbors, std::vector< size_t > &indices, std::vector< float > &distances) const |
| Perform a k-nearest neighbor search for a Point. | |
| void | neighbor_search (const glm::vec2 &xy, size_t k_neighbors, std::vector< size_t > &indices, std::vector< float > &distances) const |
| Perform a k-nearest neighbor search for a glm::vec2. | |
| std::vector< std::pair< size_t, float > > | radius_search (float x_query, float y_query, float radius) const |
| Perform a radius-based neighbor search. | |
| std::vector< std::pair< size_t, float > > | radius_search (const Point &p, float radius) const |
| Perform a radius-based neighbor search for a Point. | |
| std::vector< std::pair< size_t, float > > | radius_search (const glm::vec2 &xy, float radius) const |
| Perform a radius-based neighbor search for a glm::vec2. | |
2D KD-Tree for spatial point queries.
Supports construction from separate coordinate arrays (x, y), point vectors (std::vector<Point>), and Cloud objects.
|
default |
Construct an empty KD-tree.
|
default |
Destructor.
| hmap::KDTree::KDTree | ( | const std::vector< float > & | x, |
| const std::vector< float > & | y ) |
Construct a KD-tree referencing separate coordinate arrays.
| x | Vector of x coordinates. |
| y | Vector of y coordinates. |
|
explicit |
Construct a KD-tree referencing a vector of points.
| points | Vector of Point objects. |
|
explicit |
|
defaultnoexcept |
Move constructor.
|
delete |
|
noexcept |
Check whether the KD-tree is empty.
|
noexcept |
Get the number of points indexed by the KD-tree.
| glm::vec2 hmap::KDTree::compute_neighbor_distance_range | ( | size_t | k_neighbors | ) | const |
Estimate the range of neighbor distances across the dataset.
Computes the minimum and maximum Euclidean distance to the k-th nearest neighbor across all indexed points.
| k_neighbors | Number of neighbors considered. |
| size_t hmap::KDTree::nearest | ( | float | x_query, |
| float | y_query ) const |
Find the index of the nearest neighbor to a 2D query position.
Fast 1-nearest-neighbor query that performs no heap allocations.
| x_query | Query x coordinate. |
| y_query | Query y coordinate. |
| size_t hmap::KDTree::nearest | ( | const Point & | p | ) | const |
Find the index of the nearest neighbor to a Point.
| size_t hmap::KDTree::nearest | ( | const glm::vec2 & | xy | ) | const |
Find the index of the nearest neighbor to a glm::vec2.
| std::pair< size_t, float > hmap::KDTree::nearest_with_distance_squared | ( | float | x_query, |
| float | y_query ) const |
Find the index and squared distance of the nearest neighbor.
| x_query | Query x coordinate. |
| y_query | Query y coordinate. |
| std::pair< size_t, float > hmap::KDTree::nearest_with_distance_squared | ( | const Point & | p | ) | const |
Find the index and squared distance of the nearest neighbor to a Point.
| std::pair< size_t, float > hmap::KDTree::nearest_with_distance_squared | ( | const glm::vec2 & | xy | ) | const |
Find the index and squared distance of the nearest neighbor to a glm::vec2.
| void hmap::KDTree::neighbor_search | ( | float | x_query, |
| float | y_query, | ||
| size_t | k_neighbors, | ||
| std::vector< size_t > & | indices, | ||
| std::vector< float > & | distances ) const |
Perform a k-nearest neighbor search.
| x_query | Query x coordinate. | |
| y_query | Query y coordinate. | |
| k_neighbors | Number of neighbors to retrieve. | |
| [out] | indices | Output indices of neighbors. |
| [out] | distances | Output squared distances to neighbors. |
| void hmap::KDTree::neighbor_search | ( | const Point & | p, |
| size_t | k_neighbors, | ||
| std::vector< size_t > & | indices, | ||
| std::vector< float > & | distances ) const |
Perform a k-nearest neighbor search for a Point.
| void hmap::KDTree::neighbor_search | ( | const glm::vec2 & | xy, |
| size_t | k_neighbors, | ||
| std::vector< size_t > & | indices, | ||
| std::vector< float > & | distances ) const |
Perform a k-nearest neighbor search for a glm::vec2.
| std::vector< std::pair< size_t, float > > hmap::KDTree::radius_search | ( | float | x_query, |
| float | y_query, | ||
| float | radius ) const |
Perform a radius-based neighbor search.
| x_query | Query x coordinate. |
| y_query | Query y coordinate. |
| radius | Search radius (Euclidean distance). |
| std::vector< std::pair< size_t, float > > hmap::KDTree::radius_search | ( | const Point & | p, |
| float | radius ) const |
Perform a radius-based neighbor search for a Point.
| std::vector< std::pair< size_t, float > > hmap::KDTree::radius_search | ( | const glm::vec2 & | xy, |
| float | radius ) const |
Perform a radius-based neighbor search for a glm::vec2.