import type { CurvePiece } from "../mat/curve-piece.js"; import { evalDeCasteljau } from 'flo-bezier3'; import { squaredDistanceBetween } from 'flo-vector2d'; const { min } = Math; const TOLERANCE = 1 + 2**-20; /** * Finds an initial distance such that the closest point can not be further than * this distance away. * * @internal */ function getBestDistanceSquared( curvePieces: CurvePiece[], xO: number[]) { let bestSquaredDistance = Infinity; for (let i=0; i