AutoMovie API
    Preparing search index...

    Variable closestPointsBetweenSegmentsConst

    closestPointsBetweenSegments: (
        a: IAutoMovieVector3,
        b: IAutoMovieVector3,
        c: IAutoMovieVector3,
        d: IAutoMovieVector3,
    ) => IAutoMovieClosestSegmentPoints = ...

    Closest witnesses on bounded segments in one metre coordinate frame. Inputs are unchanged; each result owns its points. segmentSegmentDistance consumes this same calculation, including its precision and failure contract.

    Minimise |r+su-tv| over [0,1]^2. The four boundary minima and the minimum on the clipped stationary line u.(r+su-tv)=0 contain a global minimiser. On that line the residual is affine: project its origin onto that residual segment without dividing by |u|^2*|v|^2-(u.v)^2. This avoids cancellation and the absolute parallel threshold that lost small interior closest pairs. The constrained-quadratic construction follows Eberly, Robust Computation of Distance Between Line Segments (2023), sections 2 and 4; here the clipped stationary line is minimised by its residual segment directly.

    Local differences are scaled by their largest component before dot products. Math.hypot retains tiny residual lengths without squaring them to zero. Exact zero-length segments remain points. Nonfinite coordinates, overflowed differences, a nonzero span whose scaled squared length underflows, or an unrepresentable witness distance refuse rather than fabricate separation. Binary64 witnesses still round: this is not an exact contact predicate or a certified distance lower bound. Callers own their precision allowance and represented-output verification. Equal computed residual distances choose the lowest first-segment parameter, then the lowest second parameter. Reversing a segment changes that canonical orientation on a nonunique minimum; it does not change the separation.

    https://www.geometrictools.com/Documentation/DistanceLine3Line3.pdf (modified September 21, 2023), sections 2 and 4.