import { getInterfaceRotation } from '../simultaneous-properties/get-interface-rotation.js'; import { fromTo2InclErrorBound } from "../transformation/split/from-to/from-to-2-incl-error-bound.js"; import { fromTo3InclErrorBound } from "../transformation/split/from-to/from-to-3-incl-error-bound.js"; import { classify } from './classification/classify.js'; import { getInflections } from "./get-inflections.js"; const { abs, PI: 𝜋 } = Math; /** * Returns the total absolute curvature of the given bezier curve over the * given interval * * * the result is given in radians. * * @param ps an order 0,1,2 or 3 bezier curve given as an array of its control * points, e.g. `[[1,2],[3,4],[5,6],[7,8]]` * @param interval * * @doc mdx */ function totalAbsoluteCurvature( ps: number[][], interval = [0,1]): number { if (ps.length <= 3) { return abs(totalCurvature(ps, interval)); } if (ps.length === 4) { const [tS,tE] = interval; if (tS === tE) { return 0; } const ps_ = fromTo3InclErrorBound(ps, tS, tE).ps; const ts = [0, ...getInflections(ps_), 1]; let total = 0; for (let i=0; i= +𝜋 ? cpθ - 2*𝜋 : cpθ; } return cpθ; } throw new Error('The given bezier curve must be of order <= 3.'); } export { totalCurvature, totalAbsoluteCurvature }