import { getCoeffs } from './roots/certified/getpoly/get-coeffs.js'; // import { getCoeffs } from './roots/certified/getpoly/get-coeffs-copy.js'; import { getCoeffsExact } from './roots/certified/getpoly/get-coeffs-exact.js'; import { eCompress } from 'big-float-ts'; import { getRandomCubic, getRandomCubics } from './roots/mobius/get-random-cubics.js'; import { Poly } from './poly.js'; import { getControlPointBox } from './helpers/bezier/get-control-point-box.js'; import { areBoxesIntersecting } from './helpers/bezier/are-boxes-intersecting.js'; /** * Returns realistic polynomial (the intersection polynomial of the given beziers) */ function getPoly( ps1: number[][], ps2: number[][]) { let { coeffs: pDd, errBound } = getCoeffs(ps1, ps2); const p = pDd.map(c => c[0] + c[1]); const p_ = p.map((_,idx) => Math.abs(p[idx])); let getPExact = () => (getCoeffsExact(ps1, ps2).map(eCompress)); return { pDd, p, p_, pDd_: errBound, getPExact }; } /** * Returns `N` realistic polynomials (the intersection polynomials of beziers) */ function getPolys_BezierIntersections( N: number, shift: number, maxBitLength = 60, maxCoordinate = 16384) { // find random cubic beziers (used later to generate realistic polynomials) const polys: Poly[] = []; for (let i=0; i { const { p, pDd, p_, pDd_, getPExact } = pp; const $p = p.slice(0, maxCoeffs); const $pDd = pDd.slice(0, maxCoeffs); const $p_ = p_.slice(0, maxCoeffs); const $pDd_ = pDd_.slice(0, maxCoeffs); const pExact = getPExact().slice(0, maxCoeffs); const $getPExact = () => pExact; return { p: $p, pDd: $pDd, p_: $p_, pDd_: $pDd_, getPExact: $getPExact }; }); } export { getPolys_BezierIntersections, getPolys_BezierIntersections_PreFiltered, getPolys_BezierIntersections_MaxCoeffs }