UNPKG

@thi.ng/geom-arc

Version:

2D circular / elliptic arc operations

12 lines (11 loc) 417 B
import { fit01 } from "@thi.ng/math/fit"; import { minError } from "@thi.ng/math/min-error"; import { distSq2 } from "@thi.ng/vectors/distsq"; import { pointAtTheta } from "./point-at.js"; const closestPoint = (p, o, r, axis, start, end, out = [], res, iter) => { const fn = (t) => pointAtTheta(o, r, axis, fit01(t, start, end), out); return fn(minError(fn, distSq2, p, res, iter)); }; export { closestPoint };