Skip to content

Nanoflann KD-tree spatial indexing for SVA/SRA#18

Open
adthoms wants to merge 1 commit into
MIT-SPARK:masterfrom
adthoms:worktree-agent-a6d01b06
Open

Nanoflann KD-tree spatial indexing for SVA/SRA#18
adthoms wants to merge 1 commit into
MIT-SPARK:masterfrom
adthoms:worktree-agent-a6d01b06

Conversation

@adthoms
Copy link
Copy Markdown

@adthoms adthoms commented Apr 15, 2026

Summary

  • Replace O(N^2) brute-force pairwise compatibility checks in MakeVecAvgInvGraph (SVA) and MakeRotAvgInvGraph (SRA) with nanoflann KD-tree radius searches, reducing complexity to O(N log N) build + O(N * k * log N) queries
  • For SVA: direct KD-tree radius search in measurement space using squared L2 distance
  • For SRA: embed rotations as 9D vectors (flattened 3x3 matrices), use chordal distance as the KD-tree metric; for geodesic mode, use chordal upper bound as a pre-filter then refine with exact geodesic distance check via existing So3GeodesicDist functor
  • Add shared BuildGraphFromHalfEdges helper that converts half-edge adjacency lists to any GraphsStorageType (ADJ_LIST, CSR, ATOMIC_CSR)
  • Add nanoflann v1.6.2 as a new dependency via download_project (same pattern as xenium)

Test plan

  • New SVA KD-tree produces correct results across graph types test validates all three graph storage types (ADJ_LIST, CSR, ATOMIC_CSR) produce identical inlier results
  • New SRA KD-tree chordal equivalence test validates chordal distance mode with and without outliers
  • New SRA KD-tree geodesic equivalence test validates geodesic distance mode with and without outliers (using CSR storage)
  • Existing SVA/SRA tests continue to pass (same API, same expected results)

🤖 Generated with Claude Code

…ruction

Replace O(N^2) brute-force pairwise compatibility checks in MakeVecAvgInvGraph
and MakeRotAvgInvGraph with nanoflann KD-tree radius searches, reducing
complexity to O(N log N) build + O(N * k * log N) queries.

For SVA: direct radius search in measurement space.
For SRA: embed rotations as 9D vectors (flattened 3x3 matrices), use chordal
distance as KD-tree metric. For geodesic mode, use chordal upper bound as
pre-filter then refine with exact geodesic check.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant