Skip to content

cycodebase: reuse AABB / precomputed bases for fast repeated distance queries - #309

Open
alecjacobson wants to merge 1 commit into
mainfrom
cycodebase-aabb-reuse
Open

cycodebase: reuse AABB / precomputed bases for fast repeated distance queries#309
alecjacobson wants to merge 1 commit into
mainfrom
cycodebase-aabb-reuse

Conversation

@alecjacobson

Copy link
Copy Markdown
Contributor

point_spline_squared_distance and point_cubic_squared_distance rebuilt their acceleration data on every call. This binds the libigl overloads that accept the precomputed structures, so you build once and query many times without rebuilding.

New overloads

Reuse the Eytzinger AABB across spline queries:

B1, B2, leaf = igl.cycodebase.spline_eytzinger_aabb(P, C)   # build once
sqrD, I, S, K = igl.cycodebase.point_spline_squared_distance(Q1, P, C, B1, B2, leaf)
sqrD, I, S, K = igl.cycodebase.point_spline_squared_distance(Q2, P, C, B1, B2, leaf)  # no rebuild

Reuse the monomial bases across single-cubic queries:

M, D, B = igl.cubic_monomial_bases(C)                        # precompute once
sqrD, S, K = igl.cycodebase.point_cubic_squared_distance(Q, C, D, B)

Both are added as overloads of the existing function names (nanobind dispatches by arity), so the original 3-/2-argument calls are unchanged.

Testing

New tests confirm the accelerated results are identical to the unaccelerated overloads and that one prebuilt structure serves multiple query sets. Full suite: 93 passed.

🤖 Generated with Claude Code

…queries

point_spline_squared_distance and point_cubic_squared_distance rebuilt their
acceleration data on every call. Bind the libigl overloads that accept the
precomputed structures so repeated queries against the same spline/curve don't
rebuild:

- point_spline_squared_distance(Q, P, C, B1, B2, leaf): reuse the Eytzinger AABB
  from igl.cycodebase.spline_eytzinger_aabb(P, C).
- point_cubic_squared_distance(Q, C, D, B): reuse the monomial bases from
  igl.cubic_monomial_bases(C).

Both are added as overloads of the existing names (nanobind dispatches by
arity). Tests confirm the accelerated results match the unaccelerated ones and
that one prebuilt structure serves multiple query sets. Full suite: 93 passed.

Co-Authored-By: Claude Opus 4.8 (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