import type { Loop } from 'flo-boolean'; import type { PrePointOnShape } from '../point-on-shape/point-on-shape.js'; import { getCurvatureExtremaDd, controlPointLinesLength } from 'flo-bezier3'; import { distanceBetween } from 'flo-vector2d'; import { toP } from '../point-on-shape/to-p.js'; /** * @internal * Curvature maxima closer than this (in parameter space) to a curve endpoint * are ignored - they are handled by the corner logic. */ const EDGE_T_TOLERANCE = 2**-20; /** * @internal * Curvature maxima closer than this fraction of the curve's control polygon * length to a curve endpoint are ignored. A curve with (near) coincident * control points at an end has (near) zero speed there and its curvature * blows up towards that end; the resulting "maximum" (that can be well * inside the parameter tolerance above) is an artifact and not a feature of * the shape. */ const EDGE_DISTANCE_TOLERANCE = 2**-20; /** * Get points of maximum curvature. * * @param loop * * @internal */ function getFor1ProngsOnLoop( minBezLength: number) { return function(loop: Loop) { const poss: PrePointOnShape[] = []; for (let i=0; i 1 - EDGE_T_TOLERANCE) { continue; } const pDd = toP(ps, t); const p = pDd.map(c => c[0] + c[1]); // keep away from edges (in distance) if (distanceBetween(p, pS) < edgeDistanceTolerance || distanceBetween(p, pE) < edgeDistanceTolerance) { continue; } poss.push({ curve, t, isSource: true, p, pDd }); } } return poss; } } export { getFor1ProngsOnLoop }