Nanoflann
nanoflann: a C++11 header-only library for Nearest Neighbor (NN) search with KD-trees
Install / Use
npx skills add jlblancoc/nanoflannInstalls into whichever agent you are using.
README

nanoflann
| Distro | Build dev | Build releases | Stable version |
| --- | --- | --- | --- |
| ROS 2 Humble (u22.04) | |
<br/>
|
|
| ROS 2 Jazzy (u24.04) |
|
<br/>
|
|
| ROS 2 Kilted (u24.04) |
|
<br/>
|
|
| ROS 2 Lyrical (u26.04) |
|
<br/>
|
|
| ROS 2 Rolling (u26.04) |
|
<br/>
|
|
(Binary build badges are for amd64 and arm64, respectively)
1. About
nanoflann is a C++11 header-only library for building KD-Trees of datasets with different topologies: R<sup>2</sup>, R<sup>3</sup> (point clouds), SO(2) and SO(3) (2D and 3D rotation groups). No support for approximate NN is provided. nanoflann does not require compiling or installing. You just need to #include <nanoflann.hpp> in your code.
This library is a fork of the flann library by Marius Muja and David G. Lowe, and born as a child project of MRPT. Following the original license terms, nanoflann is distributed under the BSD license. Please, for bugs use the issues button or fork and open a pull request.
Cite as:
@misc{blanco2014nanoflann,
title = {nanoflann: a {C}++ header-only fork of {FLANN}, a library for Nearest Neighbor ({NN}) with KD-trees},
author = {Blanco, Jose Luis and Rai, Pranjal Kumar},
howpublished = {\url{https://github.com/jlblancoc/nanoflann}},
year = {2014}
}
See the release CHANGELOG for a list of project changes.
1.1. Obtaining the code
- Easiest way: clone this GIT repository and take the
include/nanoflann.hppfile for use where you need it. - Debian or Ubuntu (21.04 or newer) users can install it simply with:
$ sudo apt install libnanoflann-dev - macOS users can install
nanoflannwith Homebrew with:
or$ brew install brewsci/science/nanoflann
MacPorts users can use:$ brew tap brewsci/science $ brew install nanoflann$ sudo port install nanoflann - Linux users can also install it with Linuxbrew with:
brew install homebrew/science/nanoflann - List of stable releases. Check out the CHANGELOG
Although nanoflann itself doesn't have to be compiled, you can build some examples and tests with:
$ sudo apt-get install build-essential cmake libgtest-dev libeigen3-dev
$ mkdir build && cd build && cmake ..
$ make && make test
1.2. C++ API reference
-
Browse the Doxygen documentation.
-
Important note: If L2 norms are used, notice that search radius and all passed and returned distances are actually squared distances.
1.3. Code examples
- KD-tree look-up with
knnSearch()andradiusSearch(): pointcloud_kdd_radius.cpp - KD-tree look-up on a point cloud dataset: pointcloud_example.cpp
- KD-tree look-up on a dynamic point cloud dataset: dynamic_pointcloud_example.cpp
- KD-tree look-up on a rotation group (SO2): SO2_example.cpp
- KD-tree look-up on a rotation group (SO3): SO3_example.cpp
- KD-tree look-up on a point cloud dataset with an external adaptor class: pointcloud_adaptor_example.cpp
- KD-tree look-up directly on an
Eigen::Matrix<>: matrix_example.cpp - KD-tree look-up directly on
std::vector<std::vector<T> >orstd::vector<Eigen::VectorXd>: vector_of_vectors_example.cpp - Example with a
Makefilefor usage throughpkg-config(for example, after doing a "make install" or after installing from Ubuntu repositories): example_with_pkgconfig/ - Example of how to build an index and save it to disk for later usage: saveload_example.cpp
- GUI examples (requires
mrpt-gui, e.g.sudo apt install libmrpt-gui-dev):

1.4. Why a fork?
- Execution time efficiency:
- The power of the original
flannlibrary comes from the possibility of choosing between different ANN algorithms. The cost of this flexibility is the declaration of pure virtual methods which (in some circumstances) impose [run-time penalties](http://www.cs.cmu.edu/~g
- The power of the original
Related Skills
node-connect
385.5kDiagnose OpenClaw Android, iOS, or macOS node pairing, QR/setup code, route, auth, and connection failures.
blender-python-addon
40.5kBlender Python add-on rules for operators, panels, properties, registration, testing, and API-safe scripting
flutter-development-guidelines-cursorrules-prompt-file
40.5kCursor rules for Flutter development with MVVM architecture, Riverpod state management, Material widgets, and Dart style guidelines.
commit-push-pr
140.6kCommit, push, and open a PR
