Skip to main content

curve_could_contain

Function curve_could_contain 

Source
pub fn curve_could_contain<S: Scalar, const D: usize, const C: usize>(
    curve: &NurbCurve<S, D>,
    point: &Vector<S, C>,
    max_nodes: usize,
    min_subdivision_size: S,
) -> GeopResult<Option<S>>
where NurbCurve<S, D>: HasConvexHull<S, C>,
Expand description

BFS over subdivisions of curve, exploring every node up to the max_nodes budget (never stopping early at the first hit) and returning the [Scalar::union] of every converged segment’s own domain — a segment converges once its convex hull could contain point and its chord length is no longer definitely greater than min_subdivision_size. None if no segment converged within budget.

Exploring to completion (rather than returning on the first match) matters because more than one segment can independently converge on point — e.g. near a curve self-intersection, or simply because more than one leaf of the subdivision tree ends up within tolerance of it — and stopping early would silently narrow the answer to whichever one the BFS happened to visit first instead of the true (possibly wider) set of parameters that could contain it.

epsilon is compared against the Euclidean length of each segment’s chord (first to last control point), so it should be in the same units as the control points.

Generic over the curve’s homogeneous dimension D (e.g. D=4 for 3-D curves, D=3 for 2-D pcurves); point is in the matching Cartesian dimension C = D - 1.