c678e8658b9c09954285bdf9687bd4b195ab1c97
Adds igl::simplex_simplex_squared_distance, which computes the squared distance between the closest pair of points on two simplices along with the barycentric coordinates of that pair. The simplices may have different sizes (point, segment, triangle, tet, ...) and may be degenerate; they only have to share a dimension. Ported from gptoolbox's simplex_simplex_squared_distance.m. The algorithm parameterizes both affine hulls, finds their closest pair by minimum-norm least squares, and recurses over codimension-one facets when that pair falls outside either simplex. The affine-hull distance is a lower bound for the whole subproblem, so it doubles as a pruning test. The implementation is templated on the corner counts so that statically sized inputs (e.g. Matrix3d in, Vector3d out) unroll into fixed-size linear algebra with no heap allocation. Faces are represented as bitmasks and memoized, which is exact here because the running best only decreases: a face pair that was pruned once stays pruned, and one that was explored cannot improve on a second visit. A closest-corner seed and a per-node bounding-box bound give the pruning test something to bite on, and single-unknown nodes use the closed-form projection, which is already the minimum-norm solution. Relative to a straightforward dynamically sized recursion this is ~14x faster for triangle-triangle queries on Matrix3d, ~74x for tet-tet, and ~5x even for MatrixXd, with zero allocations on the static path. Tested against analytic point/segment/triangle/tet cases, degenerate simplices, mixed and fixed-size scalar types, and an exhaustive unpruned enumeration of every face-pair subproblem over random inputs. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
libigl - A simple C++ geometry processing library
Documentation, tutorial, and instructions at https://libigl.github.io.
| 🆕 Doxygen Documentation |
|---|
| The latest version of libigl (v2.5.0) introduces doxygen generated detailed documentation |
Languages
C++
96.4%
CMake
2.6%
C
1%
