cs.ROOct 10, 2026

nanoflann: A Header-Only KD-Tree Library for Exact Nearest-Neighbor Search on Compile-Time Product Manifolds

Authors: José Luis Blanco-Claraco

Organizations: the Department of Engineering, CIESOL, CeiA3. University of Almería, 04120, Almería, Spain

Abstract

Nearest-neighbor (NN) search underlies countless robotics algorithms, but many state spaces are not Euclidean: orientations live on SO(2)SO(2) or SO(3)SO(3) and poses on SE(2)SE(2) or SE(3)SE(3), and a Euclidean KD-tree on their raw coordinates returns wrong neighbors. We present a header-only, dependency-free C++ KD-tree library for exact NN search on user-defined product manifolds declared at compile time: the space is composed from base manifolds (Rn\mathbb{R}^n, SO(2)SO(2), SO(3)SO(3), SnS^n; products SE(2)SE(2), SE(3)SE(3), tori) with a single type alias, and the library synthesizes a metric whose pruning is provably admissible, wrap-aware for circular coordinates and double-cover-aware for unit quaternions. Experiments confirm exactness (recall 1.01.0 vs an exhaustive scan under the same product metric), where the Euclidean-on-raw shortcut collapses to recall ≈0.5m\approx 0.5^{m} for mm rotation blocks, with up to three orders of magnitude speedup over brute force. We further contribute an incremental, self-balancing single-tree index for points under heavy churn (e.g. sliding-window LiDAR maps) or SE(3)SE(3) trajectories: bounded memory and faster updates than prior work, with an optional asynchronous tail-latency-bounding mode. The implementation is open source: https://github.com/jlblancoc/nanoflann

Figures & tables

Explore similar work

CardsList
  1. Panorama: Fast-Track Nearest Neighbors

    Oct 1, 2025Vansh Ramani, Alexis Schlomer, Akash Nayar +3Product QuantizationApproximate Nearest Neighbor Search

  2. KNN Implementation Details Can Dramatically Change Performance: An Example from Cover Trees

    Oct 12, 2026Amol Khanna, Edward RaffExact Nearest Neighbor Searchk-Nearest Neighbors

  3. ANNLib: A Development Framework for Efficient Approximate Nearest Neighbor Search

    Jul 20, 2026Zheqi Shen, Jingbo Su, Zijin Wan +2Exact Nearest Neighbor SearchGraph-Based Retrieval