curvy 2.0.0-alpha.12 → 2.0.0-alpha.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/characteristic/index.mjs +1 -1
  2. package/dist/curve/index.mjs +1 -1
  3. package/dist/curve/rationalCubic2d.d.ts +195 -11
  4. package/dist/interval/index.mjs +1 -1
  5. package/dist/monotonicity/index.d.ts +4 -0
  6. package/dist/monotonicity/index.mjs +2 -0
  7. package/dist/monotonicity/monotonicity.d.ts +80 -0
  8. package/dist/path/index.mjs +5 -5
  9. package/dist/path/rationalCubic2d.d.ts +27 -0
  10. package/dist/polynomial/cubic.d.ts +2 -2
  11. package/dist/polynomial/index.mjs +2 -2
  12. package/dist/polynomial/linear.d.ts +7 -7
  13. package/dist/polynomial/quadratic.d.ts +2 -2
  14. package/dist/shared/{characteristic-Hb7F8SBw.mjs → characteristic-BkEr-rr8.mjs} +2 -2
  15. package/dist/shared/{characteristic-Hb7F8SBw.mjs.map → characteristic-BkEr-rr8.mjs.map} +1 -1
  16. package/dist/shared/{cubic-DHJrzZJN.mjs → cubic-BL6dpuHh.mjs} +18 -30
  17. package/dist/shared/cubic-BL6dpuHh.mjs.map +1 -0
  18. package/dist/shared/{interval2d-DPmvk_Qe.mjs → interval2d-AtneyI45.mjs} +1 -1
  19. package/dist/shared/{interval2d-DPmvk_Qe.mjs.map → interval2d-AtneyI45.mjs.map} +1 -1
  20. package/dist/shared/monotonicity-BdebFOtv.mjs +34 -0
  21. package/dist/shared/monotonicity-BdebFOtv.mjs.map +1 -0
  22. package/dist/shared/{quadratic-BZmfZE71.mjs → quadratic-DPrUsFCp.mjs} +9 -9
  23. package/dist/shared/quadratic-DPrUsFCp.mjs.map +1 -0
  24. package/dist/shared/{rationalCubic2d-D5g3_hTV.mjs → rationalCubic2d-CeHgpNht.mjs} +373 -79
  25. package/dist/shared/rationalCubic2d-CeHgpNht.mjs.map +1 -0
  26. package/dist/shared/{rationalCubic2d-MojACId0.mjs → rationalCubic2d-H1J2Fjyy.mjs} +25 -16
  27. package/dist/shared/rationalCubic2d-H1J2Fjyy.mjs.map +1 -0
  28. package/dist/shared/{solution-B6KY1E7M.mjs → solution-B2JdOZpe.mjs} +1 -1
  29. package/dist/shared/{solution-B6KY1E7M.mjs.map → solution-B2JdOZpe.mjs.map} +1 -1
  30. package/dist/solution/index.mjs +1 -1
  31. package/dist/splines/index.mjs +4 -4
  32. package/package.json +5 -1
  33. package/dist/polynomial/monotonicity.d.ts +0 -3
  34. package/dist/shared/cubic-DHJrzZJN.mjs.map +0 -1
  35. package/dist/shared/quadratic-BZmfZE71.mjs.map +0 -1
  36. package/dist/shared/rationalCubic2d-D5g3_hTV.mjs.map +0 -1
  37. package/dist/shared/rationalCubic2d-MojACId0.mjs.map +0 -1
@@ -3,7 +3,8 @@ import { Pipeable, dual, invariant } from "../utils.mjs";
3
3
  import { clampToZero, epsEquals } from "../number.mjs";
4
4
  import { a as make$4 } from "./vector2-CSkaMXvp.mjs";
5
5
  import { a as filter, c as make$5, d as toOpen, l as scaleShift, n as contains, o as fromMinMax, p as unit, t as biunit, u as size } from "./interval-Dm35Xhy4.mjs";
6
- import { a as match, l as two, n as fromArray, o as none, r as isNone, s as one } from "./solution-B6KY1E7M.mjs";
6
+ import { n as isStrict, t as fromComparison } from "./monotonicity-BdebFOtv.mjs";
7
+ import { a as match, l as two, n as fromArray, o as none, r as isNone, s as one } from "./solution-B2JdOZpe.mjs";
7
8
  //#region src/polynomial/quadratic.internal.circular.ts
8
9
  const QuadraticPolynomialTypeId = Symbol.for("curvy/polynomial/quadratic");
9
10
  /** @internal */
@@ -56,7 +57,7 @@ const solveInverse$3 = dual(2, (p, y) => {
56
57
  /** @internal */
57
58
  const toInverseSolver$3 = (p) => (y) => solveInverse$3(p, y);
58
59
  /** @internal */
59
- const monotonicity$3 = (p) => p.c1 === 0 ? "constant" : p.c1 > 0 ? "increasing" : "decreasing";
60
+ const monotonicity$3 = (p) => p.c1 === 0 ? 0 : p.c1 > 0 ? 1 : 2;
60
61
  /** @internal */
61
62
  const isMonotonic$3 = (p) => p.c1 !== 0;
62
63
  /** @internal */
@@ -124,13 +125,6 @@ var CubicPolynomialImpl = class extends Pipeable {
124
125
  }
125
126
  };
126
127
  //#endregion
127
- //#region src/polynomial/monotonicity.ts
128
- function guaranteedMonotonicityFromComparison(s0, s1) {
129
- if (s0 < s1) return "increasing";
130
- if (s0 > s1) return "decreasing";
131
- return "constant";
132
- }
133
- //#endregion
134
128
  //#region src/polynomial/quadratic.internal.ts
135
129
  /** @internal */
136
130
  const fromPoints$2 = (p0, p1, p2) => {
@@ -181,21 +175,18 @@ const extreme = (p) => derivative$2(p).pipe(solveInverse$3(0), match({
181
175
  /** @internal */
182
176
  const monotonicity$2 = dual((args) => isQuadraticPolynomial(args[0]), (p, i) => {
183
177
  invariant(i === void 0 || size(i) > 0, "monotonicity is undefined over a zero-width interval");
184
- if (p.c2 === 0 && p.c1 === 0) return "constant";
178
+ if (p.c2 === 0 && p.c1 === 0) return 0;
185
179
  if (p.c2 === 0) return monotonicity$3(make$3(p.c0, p.c1));
186
180
  const e = extreme(p);
187
- if (i === void 0 || contains(toOpen(i), e.x)) return "none";
188
- return guaranteedMonotonicityFromComparison(solve$2(p, i.start), solve$2(p, i.end));
181
+ if (i === void 0 || contains(toOpen(i), e.x)) return 3;
182
+ return fromComparison(solve$2(p, i.start), solve$2(p, i.end));
189
183
  });
190
184
  /** @internal */
191
- const isMonotonic$2 = dual((args) => isQuadraticPolynomial(args[0]), ((p, i) => {
192
- const m = monotonicity$2(p, i);
193
- return m === "increasing" || m === "decreasing";
194
- }));
185
+ const isMonotonic$2 = dual((args) => isQuadraticPolynomial(args[0]), ((p, i) => isStrict(monotonicity$2(p, i))));
195
186
  /** @internal */
196
- const isIncreasing$2 = dual((args) => isQuadraticPolynomial(args[0]), ((p, i) => monotonicity$2(p, i) === "increasing"));
187
+ const isIncreasing$2 = dual((args) => isQuadraticPolynomial(args[0]), ((p, i) => monotonicity$2(p, i) === 1));
197
188
  /** @internal */
198
- const isDecreasing$2 = dual((args) => isQuadraticPolynomial(args[0]), ((p, i) => monotonicity$2(p, i) === "decreasing"));
189
+ const isDecreasing$2 = dual((args) => isQuadraticPolynomial(args[0]), ((p, i) => monotonicity$2(p, i) === 2));
199
190
  /** @internal */
200
191
  const asMonotonic$2 = (p, i) => {
201
192
  invariant(isMonotonic$2(p, i), "quadratic polynomial is not monotonic");
@@ -352,22 +343,19 @@ const extrema$1 = (p) => roots$2(derivative$1(p));
352
343
  /** @internal */
353
344
  const monotonicity$1 = dual((args) => isCubicPolynomial$1(args[0]), (p, i) => {
354
345
  invariant(i === void 0 || size(i) > 0, "monotonicity is undefined over a zero-width interval");
355
- if (p.c3 === 0 && p.c2 === 0 && p.c1 === 0) return "constant";
346
+ if (p.c3 === 0 && p.c2 === 0 && p.c1 === 0) return 0;
356
347
  if (p.c3 === 0 && p.c2 === 0) return monotonicity$3(make$3(p.c0, p.c1));
357
- if (i === void 0) return "none";
348
+ if (i === void 0) return 3;
358
349
  if (p.c3 === 0) return monotonicity$2(make$2(p.c0, p.c1, p.c2), i);
359
- if (filter(toOpen(i), [...extrema$1(p)]).length > 0) return "none";
360
- return guaranteedMonotonicityFromComparison(solve$1(p, i.start), solve$1(p, i.end));
350
+ if (filter(toOpen(i), [...extrema$1(p)]).length > 0) return 3;
351
+ return fromComparison(solve$1(p, i.start), solve$1(p, i.end));
361
352
  });
362
353
  /** @internal */
363
- const isMonotonic$1 = dual((args) => isCubicPolynomial$1(args[0]), ((p, i) => {
364
- const m = monotonicity$1(p, i);
365
- return m === "increasing" || m === "decreasing";
366
- }));
354
+ const isMonotonic$1 = dual((args) => isCubicPolynomial$1(args[0]), ((p, i) => isStrict(monotonicity$1(p, i))));
367
355
  /** @internal */
368
- const isIncreasing$1 = dual((args) => isCubicPolynomial$1(args[0]), ((p, i) => monotonicity$1(p, i) === "increasing"));
356
+ const isIncreasing$1 = dual((args) => isCubicPolynomial$1(args[0]), ((p, i) => monotonicity$1(p, i) === 1));
369
357
  /** @internal */
370
- const isDecreasing$1 = dual((args) => isCubicPolynomial$1(args[0]), ((p, i) => monotonicity$1(p, i) === "decreasing"));
358
+ const isDecreasing$1 = dual((args) => isCubicPolynomial$1(args[0]), ((p, i) => monotonicity$1(p, i) === 2));
371
359
  /** @internal */
372
360
  const asMonotonic$1 = (p, i) => {
373
361
  invariant(isMonotonic$1(p, i), "cubic polynomial is not monotonic");
@@ -534,7 +522,7 @@ const monotonicity = monotonicity$1;
534
522
  *
535
523
  * @param p - The cubic polynomial to check.
536
524
  * @param i - Optional interval over which to check monotonicity.
537
- * @returns `true` when monotonicity is `'increasing'` or `'decreasing'`.
525
+ * @returns `true` when monotonicity is `Increasing` or `Decreasing`.
538
526
  * @since 2.0.0
539
527
  */
540
528
  const isMonotonic = isMonotonic$1;
@@ -589,4 +577,4 @@ const curvature = curvature$1;
589
577
  //#endregion
590
578
  export { equals$2 as $, GL32_X1 as A, isLinearPolynomial as At, GL32_X5 as B, unitRange$3 as Bt, GL32_W4 as C, domain$3 as Ct, GL32_W8 as D, fromVector$3 as Dt, GL32_W7 as E, fromPoints$3 as Et, GL32_X14 as F, range$3 as Ft, antiderivative as G, GL32_X7 as H, GL32_X15 as I, solve$3 as It, asMonotonic$2 as J, asDecreasing$2 as K, GL32_X2 as L, solveInverse$3 as Lt, GL32_X11 as M, length$3 as Mt, GL32_X12 as N, make$3 as Nt, GL32_W9 as O, isDecreasing$3 as Ot, GL32_X13 as P, monotonicity$3 as Pt, domain$2 as Q, GL32_X3 as R, toInverseSolver$3 as Rt, GL32_W3 as S, derivative$3 as St, GL32_W6 as T, fromPointSlope as Tt, GL32_X8 as U, GL32_X6 as V, GL32_X9 as W, curvature$2 as X, coefficients$2 as Y, derivative$2 as Z, GL32_W12 as _, antiderivative$1 as _t, isIncreasing as a, isMonotonic$2 as at, GL32_W15 as b, asMonotonic$3 as bt, roots as c, make$2 as ct, subdivide as d, roots$2 as dt, extreme as et, unitRange as f, solve$2 as ft, GL32_W11 as g, unitRange$2 as gt, GL32_W10 as h, toSolver$2 as ht, isDecreasing as i, isIncreasing$2 as it, GL32_X10 as j, isMonotonic$3 as jt, GL32_X0 as k, isIncreasing$3 as kt, solve as l, monotonicity$2 as lt, GL32_W1 as m, toInverseSolver$2 as mt, derivative as n, fromVector$2 as nt, isMonotonic as o, isQuadraticPolynomial as ot, GL32_W0 as p, solveInverse$2 as pt, asIncreasing$2 as q, fromVector as r, isDecreasing$2 as rt, make as s, length$2 as st, cubic_exports as t, fromPoints$2 as tt, solveInverse as u, range$2 as ut, GL32_W13 as v, asDecreasing$3 as vt, GL32_W5 as w, equals$3 as wt, GL32_W2 as x, coefficients$3 as xt, GL32_W14 as y, asIncreasing$3 as yt, GL32_X4 as z, toSolver$3 as zt };
591
579
 
592
- //# sourceMappingURL=cubic-DHJrzZJN.mjs.map
580
+ //# sourceMappingURL=cubic-BL6dpuHh.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cubic-BL6dpuHh.mjs","names":["equals","make","fromVector","fromPoints","solve","toSolver","solveInverse","Solution.none","Solution.one","toInverseSolver","monotonicity","isMonotonic","isIncreasing","isDecreasing","asMonotonic","asIncreasing","asDecreasing","coefficients","derivative","antiderivative","domain","Interval.make","Solution.isNone","range","Interval.fromMinMax","unitRange","length","Interval.size","fromPoints","make","equals","fromVector","solve","toSolver","solveInverse","Linear.solveInverse","Linear.make","Solution.none","Solution.one","Solution.two","toInverseSolver","coefficients","derivative","roots","Solution.match","Vector2.make","monotonicity","Interval.size","Linear.monotonicity","Interval.contains","Interval.toOpen","Monotonicity.fromComparison","isMonotonic","Monotonicity.isStrict","isIncreasing","isDecreasing","asMonotonic","asIncreasing","asDecreasing","domain","Interval.fromMinMax","range","Linear.range","unitRange","Interval.unit","length","Linear.length","Linear.solve","curvature","make","isCubicPolynomial","equals","fromVector","fromPoints","solve","toSolver","solveInverse","Quadratic.solveInverse","Quadratic.make","Solution.fromArray","toInverseSolver","coefficients","derivative","subdivide","roots","extrema","Quadratic.roots","monotonicity","Interval.size","Linear.monotonicity","Linear.make","Quadratic.monotonicity","Interval.filter","Interval.toOpen","Monotonicity.fromComparison","isMonotonic","Monotonicity.isStrict","isIncreasing","isDecreasing","asMonotonic","asIncreasing","asDecreasing","domain","Interval.fromMinMax","range","unitRange","Interval.unit","length","Linear.length","Quadratic.length","Interval.scaleShift","Interval.biunit","Quadratic.solve","curvature","Quadratic.derivative","Linear.solve","internal.isCubicPolynomial","internal.equals","internal.make","internal.fromVector","internal.fromPoints","internal.solve","internal.toSolver","internal.solveInverse","internal.toInverseSolver","internal.coefficients","internal.derivative","internal.subdivide","internal.roots","internal.extrema","internal.monotonicity","internal.isMonotonic","internal.isIncreasing","internal.isDecreasing","internal.asMonotonic","internal.asIncreasing","internal.asDecreasing","internal.domain","internal.range","internal.unitRange","internal.length","internal.curvature"],"sources":["../../src/polynomial/quadratic.internal.circular.ts","../../src/polynomial/linear.internal.ts","../../src/polynomial/cubic.internal.circular.ts","../../src/polynomial/quadratic.internal.ts","../../src/length.ts","../../src/polynomial/cubic.internal.ts","../../src/polynomial/cubic.ts"],"sourcesContent":["import { Pipeable } from '../utils.ts'\nimport type { QuadraticPolynomial } from './quadratic.ts'\nimport { PolynomialTraits } from './traits.ts'\n\nexport const QuadraticPolynomialTypeId: unique symbol = Symbol.for('curvy/polynomial/quadratic')\nexport type QuadraticPolynomialTypeId = typeof QuadraticPolynomialTypeId\n\n/** @internal */\nexport class QuadraticPolynomialImpl extends Pipeable implements QuadraticPolynomial<unknown> {\n readonly [QuadraticPolynomialTypeId]: QuadraticPolynomialTypeId = QuadraticPolynomialTypeId\n declare readonly [PolynomialTraits]: unknown\n\n readonly c0: number\n readonly c1: number\n readonly c2: number\n\n constructor(c0 = 0, c1 = 0, c2 = 0) {\n super()\n\n this.c0 = c0\n this.c1 = c1\n this.c2 = c2\n }\n}\n","import * as Interval from '../interval/interval.ts'\nimport * as Monotonicity from '../monotonicity/monotonicity.ts'\nimport { dual, Pipeable } from '../utils.ts'\nimport * as Solution from '../solution/solution.ts'\nimport { invariant } from '../utils.ts'\nimport { epsEquals } from '../number.ts'\nimport type { Vector2 } from '../vector/vector2.ts'\nimport type { LinearPolynomial } from './linear.ts'\nimport type { Decreasing, Increasing, Monotonic } from './traits.ts'\nimport { PolynomialTraits } from './traits.ts'\nimport type { QuadraticPolynomial } from './quadratic.ts'\nimport { QuadraticPolynomialImpl } from './quadratic.internal.circular.ts'\n\nexport const LinearPolynomialTypeId: unique symbol = Symbol.for('curvy/linear')\nexport type LinearPolynomialTypeId = typeof LinearPolynomialTypeId\n\nclass LinearPolynomialImpl extends Pipeable implements LinearPolynomial<unknown> {\n readonly [LinearPolynomialTypeId]: LinearPolynomialTypeId = LinearPolynomialTypeId\n declare readonly [PolynomialTraits]: unknown\n\n readonly c0: number\n readonly c1: number\n\n constructor(c0 = 0, c1 = 0) {\n super()\n\n this.c0 = c0\n this.c1 = c1\n }\n}\n\n/** @internal */\nexport const isLinearPolynomial = (v: unknown): v is LinearPolynomial =>\n typeof v === 'object' && v !== null && LinearPolynomialTypeId in v\n\n/** @internal */\nexport const equals = dual<\n (b: LinearPolynomial) => (a: LinearPolynomial) => boolean,\n (a: LinearPolynomial, b: LinearPolynomial) => boolean\n>(2, (a: LinearPolynomial, b: LinearPolynomial) => epsEquals(a.c0, b.c0) && epsEquals(a.c1, b.c1))\n\n/** @internal */\nexport const make = (c0 = 0, c1 = 0): LinearPolynomial => new LinearPolynomialImpl(c0, c1)\n\n/** @internal */\nexport const fromVector = (v: Vector2) => new LinearPolynomialImpl(v.x, v.y)\n\n/** @internal */\nexport const fromPointSlope = (p: Vector2, slope: number) =>\n new LinearPolynomialImpl(p.y - slope * p.x, slope)\n\n/** @internal */\nexport const fromPoints = (p1: Vector2, p2: Vector2) =>\n fromPointSlope(p1, (p2.y - p1.y) / (p2.x - p1.x))\n\n/** @internal */\nexport const solve = dual<\n (x: number) => (p: LinearPolynomial) => number,\n (p: LinearPolynomial, x: number) => number\n>(2, (p: LinearPolynomial, x: number) => p.c0 + x * p.c1)\n\n/** @internal */\nexport const toSolver = (p: LinearPolynomial) => (x: number) => solve(p, x)\n\n/** @internal */\nexport const solveInverse = dual<\n (y: number) => (p: LinearPolynomial) => Solution.AtMostOne<number>,\n (p: LinearPolynomial, y: number) => Solution.AtMostOne<number>\n>(2, (p: LinearPolynomial, y: number) => {\n if (p.c1 === 0) {\n return Solution.none\n }\n return Solution.one((y - p.c0) / p.c1)\n})\n\n/** @internal */\nexport const toInverseSolver = (p: LinearPolynomial) => (y: number) => solveInverse(p, y)\n\n/** @internal */\nexport const monotonicity = (p: LinearPolynomial): Monotonicity.GuaranteedMonotonicity =>\n p.c1 === 0 ? Monotonicity.Constant : p.c1 > 0 ? Monotonicity.Increasing : Monotonicity.Decreasing\n\n/** @internal */\nexport const isMonotonic = <T>(p: LinearPolynomial<T>): p is LinearPolynomial<T & Monotonic> =>\n p.c1 !== 0\n\n/** @internal */\nexport const isIncreasing = <T>(p: LinearPolynomial<T>): p is LinearPolynomial<T & Increasing> =>\n p.c1 > 0\n\n/** @internal */\nexport const isDecreasing = <T>(p: LinearPolynomial<T>): p is LinearPolynomial<T & Decreasing> =>\n p.c1 < 0\n\n/** @internal */\nexport const asMonotonic = <T>(p: LinearPolynomial<T>): LinearPolynomial<T & Monotonic> => {\n invariant(isMonotonic(p), 'linear polynomial is not monotonic')\n return p\n}\n\n/** @internal */\nexport const asIncreasing = <T>(p: LinearPolynomial<T>): LinearPolynomial<T & Increasing> => {\n invariant(isIncreasing(p), 'linear polynomial is not increasing')\n return p\n}\n\n/** @internal */\nexport const asDecreasing = <T>(p: LinearPolynomial<T>): LinearPolynomial<T & Decreasing> => {\n invariant(isDecreasing(p), 'linear polynomial is not decreasing')\n return p\n}\n\n/** @internal */\nexport const coefficients = (p: LinearPolynomial): readonly [number, number] => [p.c0, p.c1]\n\n/** @internal */\nexport const derivative = (p: LinearPolynomial) => p.c1\n\n/** @internal */\nexport const antiderivative = dual<\n (integrationConstant: number) => (p: LinearPolynomial) => QuadraticPolynomial,\n (p: LinearPolynomial, integrationConstant?: number) => QuadraticPolynomial\n>(\n (args) => isLinearPolynomial(args[0]),\n (p: LinearPolynomial, integrationConstant = 0) =>\n new QuadraticPolynomialImpl(integrationConstant, p.c0, p.c1 / 2),\n)\n\n/** @internal */\nexport const domain = dual<\n (range: Interval.Interval) => (p: LinearPolynomial) => Solution.AtMostOne<Interval.Interval>,\n (p: LinearPolynomial, range: Interval.Interval) => Solution.AtMostOne<Interval.Interval>\n>(2, (p: LinearPolynomial, r: Interval.Interval) => {\n if (p.c1 === 0) {\n if (r.start === p.c0 && r.end === p.c0) {\n return Solution.one(Interval.make(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY))\n }\n return Solution.none\n }\n\n const start = solveInverse(p, r.start)\n const end = solveInverse(p, r.end)\n\n if (Solution.isNone(start) || Solution.isNone(end)) {\n return Solution.none\n }\n\n return Solution.one(Interval.make(start.value, end.value))\n})\n\n/** @internal */\nexport const range = dual<\n (domain: Interval.Interval) => (p: LinearPolynomial) => Interval.Closed,\n (p: LinearPolynomial, domain: Interval.Interval) => Interval.Closed\n>(2, (p: LinearPolynomial, d: Interval.Interval) =>\n Interval.fromMinMax(solve(p, d.start), solve(p, d.end)),\n)\n\n/** @internal */\nexport const unitRange = (p: LinearPolynomial): Interval.Closed =>\n Interval.fromMinMax(p.c0, p.c0 + p.c1)\n\n/** @internal */\nexport const length = dual<\n (domain: Interval.Interval) => (p: LinearPolynomial) => number,\n (p: LinearPolynomial, domain: Interval.Interval) => number\n>(2, (p: LinearPolynomial, d: Interval.Interval) => {\n if (Interval.size(d) === 0) {\n return 0\n }\n\n if (p.c1 === 0) {\n return Interval.size(d)\n }\n\n return Math.sqrt(1 + p.c1 ** 2) * Interval.size(d)\n})\n","import { Pipeable } from '../utils.ts'\nimport type { CubicPolynomial } from './cubic.ts'\nimport { PolynomialTraits } from './traits.ts'\n\nexport const CubicPolynomialTypeId: unique symbol = Symbol.for('curvy/polynomial/cubic')\nexport type CubicPolynomialTypeId = typeof CubicPolynomialTypeId\n\n/** @internal */\nexport class CubicPolynomialImpl extends Pipeable implements CubicPolynomial<unknown> {\n readonly [CubicPolynomialTypeId]: CubicPolynomialTypeId = CubicPolynomialTypeId\n declare readonly [PolynomialTraits]: unknown\n\n readonly c0: number\n readonly c1: number\n readonly c2: number\n readonly c3: number\n\n constructor(c0 = 0, c1 = 0, c2 = 0, c3 = 0) {\n super()\n\n this.c0 = c0\n this.c1 = c1\n this.c2 = c2\n this.c3 = c3\n }\n}\n","import * as Interval from '../interval/interval.ts'\nimport { dual } from '../utils.ts'\nimport * as Solution from '../solution/solution.ts'\nimport { invariant } from '../utils.ts'\nimport { epsEquals } from '../number.ts'\nimport * as Vector2 from '../vector/vector2.ts'\nimport type { Vector3 } from '../vector/vector3.ts'\nimport type { CubicPolynomial } from './cubic.ts'\nimport { CubicPolynomialImpl } from './cubic.internal.circular.ts'\nimport * as Linear from './linear.internal.ts'\nimport * as Monotonicity from '../monotonicity/monotonicity.ts'\nimport type { QuadraticPolynomial } from './quadratic.ts'\nimport {\n QuadraticPolynomialImpl,\n QuadraticPolynomialTypeId,\n} from './quadratic.internal.circular.ts'\nimport type { Decreasing, Increasing, Monotonic } from './traits.ts'\n\n/** @internal */\nexport const fromPoints = (\n p0: Vector2.Vector2,\n p1: Vector2.Vector2,\n p2: Vector2.Vector2,\n): QuadraticPolynomial => {\n // Newton's divided differences, then collected to monomial form.\n const f01 = (p1.y - p0.y) / (p1.x - p0.x)\n const f12 = (p2.y - p1.y) / (p2.x - p1.x)\n const f012 = (f12 - f01) / (p2.x - p0.x)\n\n return new QuadraticPolynomialImpl(\n p0.y - f01 * p0.x + f012 * p0.x * p1.x,\n f01 - f012 * (p0.x + p1.x),\n f012,\n )\n}\n\n/** @internal */\nexport const make = (c0 = 0, c1 = 0, c2 = 0): QuadraticPolynomial =>\n new QuadraticPolynomialImpl(c0, c1, c2)\n\n/** @internal */\nexport const isQuadraticPolynomial = (v: unknown): v is QuadraticPolynomial =>\n typeof v === 'object' && v !== null && QuadraticPolynomialTypeId in v\n\n/** @internal */\nexport const equals = dual<\n (b: QuadraticPolynomial) => (a: QuadraticPolynomial) => boolean,\n (a: QuadraticPolynomial, b: QuadraticPolynomial) => boolean\n>(\n 2,\n (a: QuadraticPolynomial, b: QuadraticPolynomial) =>\n epsEquals(a.c0, b.c0) && epsEquals(a.c1, b.c1) && epsEquals(a.c2, b.c2),\n)\n\n/** @internal */\nexport const fromVector = (v: Vector3) => new QuadraticPolynomialImpl(v.x, v.y, v.z)\n\n/** @internal */\nexport const solve = dual<\n (x: number) => (p: QuadraticPolynomial) => number,\n (p: QuadraticPolynomial, x: number) => number\n>(2, (p: QuadraticPolynomial, x: number) => p.c0 + x * p.c1 + x ** 2 * p.c2)\n\n/** @internal */\nexport const toSolver = (p: QuadraticPolynomial) => (x: number) => solve(p, x)\n\n/** @internal */\nexport const solveInverse: {\n (p: QuadraticPolynomial, y: number): Solution.AtMostTwo<number>\n (y: number): (p: QuadraticPolynomial) => Solution.AtMostTwo<number>\n} = dual<\n (y: number) => (p: QuadraticPolynomial) => Solution.AtMostTwo<number>,\n (p: QuadraticPolynomial, y: number) => Solution.AtMostTwo<number>\n>(2, (p: QuadraticPolynomial, y: number) => {\n // c2 = 0: the polynomial is actually linear in disguise. Defer rather than\n // dividing by zero in the quadratic formula.\n if (p.c2 === 0) {\n return Linear.solveInverse(Linear.make(p.c0, p.c1), y)\n }\n\n const discriminant = p.c1 ** 2 - 4 * p.c2 * (p.c0 - y)\n\n if (discriminant < 0) {\n return Solution.none\n }\n\n if (discriminant === 0) {\n return Solution.one(-p.c1 / (2 * p.c2))\n }\n\n const sqrtDiscriminant = Math.sqrt(discriminant)\n const a = (-p.c1 + sqrtDiscriminant) / (2 * p.c2)\n const b = (-p.c1 - sqrtDiscriminant) / (2 * p.c2)\n return a < b ? Solution.two(a, b) : Solution.two(b, a)\n})\n\n/** @internal */\nexport const toInverseSolver =\n (p: QuadraticPolynomial) =>\n (y: number): Solution.AtMostTwo<number> =>\n solveInverse(p, y)\n\n/** @internal */\nexport const coefficients = (p: QuadraticPolynomial): readonly [number, number, number] => [\n p.c0,\n p.c1,\n p.c2,\n]\n\n/** @internal */\nexport const derivative = (p: QuadraticPolynomial) => Linear.make(p.c1, p.c2 * 2)\n\n/** @internal */\nexport const roots = (p: QuadraticPolynomial) => solveInverse(p, 0)\n\n/** @internal */\nexport const extreme = (p: QuadraticPolynomial) =>\n derivative(p).pipe(\n Linear.solveInverse(0),\n Solution.match({\n onNone: () => null,\n onSome: ({ value: t }) => Vector2.make(t, solve(p, t)),\n }),\n )\n\n/** @internal */\nexport const monotonicity = dual<\n (i: Interval.Interval) => (p: QuadraticPolynomial) => Monotonicity.Monotonicity,\n (p: QuadraticPolynomial, i?: Interval.Interval) => Monotonicity.Monotonicity\n>(\n (args) => isQuadraticPolynomial(args[0]),\n (p: QuadraticPolynomial, i?: Interval.Interval) => {\n invariant(\n i === undefined || Interval.size(i) > 0,\n 'monotonicity is undefined over a zero-width interval',\n )\n\n if (p.c2 === 0 && p.c1 === 0) {\n return Monotonicity.Constant\n }\n\n if (p.c2 === 0) {\n return Linear.monotonicity(Linear.make(p.c0, p.c1))\n }\n\n // c2 is non-zero, so the extreme is guaranteed to be non-null\n const e = extreme(p) as Vector2.Vector2\n\n // if there is no interval, or the extreme is within the interval,\n // the monotonicity is none\n if (i === undefined || Interval.contains(Interval.toOpen(i), e.x)) {\n return Monotonicity.None\n }\n\n return Monotonicity.fromComparison(solve(p, i.start), solve(p, i.end))\n },\n)\n\n/** @internal */\nexport const isMonotonic = dual<\n (\n i: Interval.Interval,\n ) => <T>(p: QuadraticPolynomial<T>) => p is QuadraticPolynomial<T & Monotonic>,\n <T>(p: QuadraticPolynomial<T>, i?: Interval.Interval) => p is QuadraticPolynomial<T & Monotonic>\n>((args) => isQuadraticPolynomial(args[0]), ((p: QuadraticPolynomial, i?: Interval.Interval) =>\n Monotonicity.isStrict(monotonicity(p, i as Interval.Interval))) as never)\n\n/** @internal */\nexport const isIncreasing = dual<\n (\n i: Interval.Interval,\n ) => <T>(p: QuadraticPolynomial<T>) => p is QuadraticPolynomial<T & Increasing>,\n <T>(p: QuadraticPolynomial<T>, i?: Interval.Interval) => p is QuadraticPolynomial<T & Increasing>\n>(\n (args) => isQuadraticPolynomial(args[0]),\n ((p: QuadraticPolynomial, i?: Interval.Interval) =>\n monotonicity(p, i as Interval.Interval) === Monotonicity.Increasing) as never,\n)\n\n/** @internal */\nexport const isDecreasing = dual<\n (\n i: Interval.Interval,\n ) => <T>(p: QuadraticPolynomial<T>) => p is QuadraticPolynomial<T & Decreasing>,\n <T>(p: QuadraticPolynomial<T>, i?: Interval.Interval) => p is QuadraticPolynomial<T & Decreasing>\n>(\n (args) => isQuadraticPolynomial(args[0]),\n ((p: QuadraticPolynomial, i?: Interval.Interval) =>\n monotonicity(p, i as Interval.Interval) === Monotonicity.Decreasing) as never,\n)\n\n/** @internal */\nexport const asMonotonic = <T>(\n p: QuadraticPolynomial<T>,\n i?: Interval.Interval,\n): QuadraticPolynomial<T & Monotonic> => {\n invariant(isMonotonic(p, i as Interval.Interval), 'quadratic polynomial is not monotonic')\n return p\n}\n\n/** @internal */\nexport const asIncreasing = <T>(\n p: QuadraticPolynomial<T>,\n i?: Interval.Interval,\n): QuadraticPolynomial<T & Increasing> => {\n invariant(isIncreasing(p, i as Interval.Interval), 'quadratic polynomial is not increasing')\n return p\n}\n\n/** @internal */\nexport const asDecreasing = <T>(\n p: QuadraticPolynomial<T>,\n i?: Interval.Interval,\n): QuadraticPolynomial<T & Decreasing> => {\n invariant(isDecreasing(p, i as Interval.Interval), 'quadratic polynomial is not decreasing')\n return p\n}\n\n/** @internal */\nexport const antiderivative = dual<\n (integrationConstant: number) => (p: QuadraticPolynomial) => CubicPolynomial,\n (p: QuadraticPolynomial, integrationConstant?: number) => CubicPolynomial\n>(\n 2,\n (p: QuadraticPolynomial, integrationConstant = 0) =>\n new CubicPolynomialImpl(integrationConstant, p.c0, p.c1 / 2, p.c2 / 3),\n)\n\n/** @internal */\nexport const domain = dual<\n (range: Interval.Interval) => (p: QuadraticPolynomial) => Solution.AtMostOne<Interval.Interval>,\n (p: QuadraticPolynomial, range: Interval.Interval) => Solution.AtMostOne<Interval.Interval>\n>(2, (p: QuadraticPolynomial, r: Interval.Interval) => {\n const start = solveInverse(p, r.start)\n const end = solveInverse(p, r.end)\n\n if (start.length === 0 && end.length === 0) {\n return Solution.none\n }\n\n return Solution.one(Interval.fromMinMax(...start, ...end))\n})\n\n/** @internal */\nexport const range = dual<\n (domain: Interval.Interval) => (p: QuadraticPolynomial) => Interval.Closed,\n (p: QuadraticPolynomial, domain: Interval.Interval) => Interval.Closed\n>(2, (p: QuadraticPolynomial, d: Interval.Interval) => {\n if (p.c2 === 0) {\n return Linear.range(Linear.make(p.c0, p.c1), d)\n }\n\n const e = extreme(p)\n\n return e !== null && Interval.contains(d, e.x)\n ? Interval.fromMinMax(solve(p, d.start), solve(p, d.end), e.y)\n : Interval.fromMinMax(solve(p, d.start), solve(p, d.end))\n})\n\n/** @internal */\nexport const unitRange = (p: QuadraticPolynomial): Interval.Closed => range(p, Interval.unit)\n\n/** @internal */\nexport const length = dual<\n (domain: Interval.Interval) => (p: QuadraticPolynomial) => number,\n (p: QuadraticPolynomial, domain: Interval.Interval) => number\n>(2, (p: QuadraticPolynomial, dom: Interval.Interval) => {\n if (Interval.size(dom) === 0) {\n return 0\n }\n\n if (p.c2 === 0) {\n return Linear.length(Linear.make(p.c0, p.c1), dom)\n }\n\n const dp = derivative(p)\n\n const derivativeStart = Linear.solve(dp, dom.start)\n const sqrtStart = Math.sqrt(1 + derivativeStart ** 2)\n const evalStart =\n (derivativeStart * sqrtStart + Math.log(Math.abs(derivativeStart + sqrtStart))) / (4 * p.c2)\n\n const derivativeEnd = Linear.solve(dp, dom.end)\n const sqrtEnd = Math.sqrt(1 + derivativeEnd ** 2)\n const evalEnd =\n (derivativeEnd * sqrtEnd + Math.log(Math.abs(derivativeEnd + sqrtEnd))) / (4 * p.c2)\n\n return evalEnd - evalStart\n})\n\n/** @internal */\nexport const curvature = dual<\n (x: number) => (p: QuadraticPolynomial) => number,\n (p: QuadraticPolynomial, x: number) => number\n>(\n 2,\n (p: QuadraticPolynomial, x: number) =>\n Math.abs(2 * p.c2) / (1 + (Linear.solve(derivative(p), x) ** 2) ** 1.5),\n)\n","export const GL32_X0 = 0.9972638618494816\nexport const GL32_X1 = 0.9856115115452684\nexport const GL32_X2 = 0.9647622555875064\nexport const GL32_X3 = 0.9349060759377397\nexport const GL32_X4 = 0.8963211557660521\nexport const GL32_X5 = 0.84936761373257\nexport const GL32_X6 = 0.7944837959679424\nexport const GL32_X7 = 0.7321821187402897\nexport const GL32_X8 = 0.6630442669302152\nexport const GL32_X9 = 0.5877157572407623\nexport const GL32_X10 = 0.5068999089322294\nexport const GL32_X11 = 0.42135127613063533\nexport const GL32_X12 = 0.33186860228212767\nexport const GL32_X13 = 0.23928736225213706\nexport const GL32_X14 = 0.1444719615827965\nexport const GL32_X15 = 0.04830766568773831\nexport const GL32_W0 = 0.007018610009470136\nexport const GL32_W1 = 0.01627439473090571\nexport const GL32_W2 = 0.02539206530926214\nexport const GL32_W3 = 0.03427386291302141\nexport const GL32_W4 = 0.042835898022226704\nexport const GL32_W5 = 0.050998059262376154\nexport const GL32_W6 = 0.05868409347853558\nexport const GL32_W7 = 0.06582222277636195\nexport const GL32_W8 = 0.07234579410884862\nexport const GL32_W9 = 0.07819389578707044\nexport const GL32_W10 = 0.08331192422694672\nexport const GL32_W11 = 0.08765209300440374\nexport const GL32_W12 = 0.0911738786957639\nexport const GL32_W13 = 0.09384439908080454\nexport const GL32_W14 = 0.09563872007927485\nexport const GL32_W15 = 0.09654008851472785\n","import * as Interval from '../interval/interval.ts'\nimport {\n GL32_W0,\n GL32_W1,\n GL32_W2,\n GL32_W3,\n GL32_W4,\n GL32_W5,\n GL32_W6,\n GL32_W7,\n GL32_W8,\n GL32_W9,\n GL32_W10,\n GL32_W11,\n GL32_W12,\n GL32_W13,\n GL32_W14,\n GL32_W15,\n GL32_X0,\n GL32_X1,\n GL32_X2,\n GL32_X3,\n GL32_X4,\n GL32_X5,\n GL32_X6,\n GL32_X7,\n GL32_X8,\n GL32_X9,\n GL32_X10,\n GL32_X11,\n GL32_X12,\n GL32_X13,\n GL32_X14,\n GL32_X15,\n} from '../length.ts'\nimport * as Monotonicity from '../monotonicity/monotonicity.ts'\nimport { dual } from '../utils.ts'\nimport * as Solution from '../solution/solution.ts'\nimport { invariant } from '../utils.ts'\nimport { clampToZero, epsEquals } from '../number.ts'\nimport type * as Vector2 from '../vector/vector2.ts'\nimport type { Vector4 } from '../vector/vector4.ts'\nimport type { CubicPolynomial } from './cubic.ts'\nimport { CubicPolynomialImpl, CubicPolynomialTypeId } from './cubic.internal.circular.ts'\nimport type { Decreasing, Increasing, Monotonic } from './traits.ts'\nimport * as Linear from './linear.internal.ts'\nimport * as Quadratic from './quadratic.internal.ts'\n\n/** @internal */\nexport const make = (c0 = 0, c1 = 0, c2 = 0, c3 = 0): CubicPolynomial =>\n new CubicPolynomialImpl(c0, c1, c2, c3)\n\n/** @internal */\nexport const isCubicPolynomial = (v: unknown): v is CubicPolynomial =>\n typeof v === 'object' && v !== null && CubicPolynomialTypeId in v\n\n/** @internal */\nexport const equals = dual<\n (b: CubicPolynomial) => (a: CubicPolynomial) => boolean,\n (a: CubicPolynomial, b: CubicPolynomial) => boolean\n>(\n 2,\n (a: CubicPolynomial, b: CubicPolynomial) =>\n epsEquals(a.c0, b.c0) &&\n epsEquals(a.c1, b.c1) &&\n epsEquals(a.c2, b.c2) &&\n epsEquals(a.c3, b.c3),\n)\n\n/** @internal */\nexport const fromVector = (v: Vector4) => new CubicPolynomialImpl(v.x, v.y, v.z, v.w)\n\n/** @internal */\nexport const fromPoints = (\n p0: Vector2.Vector2,\n p1: Vector2.Vector2,\n p2: Vector2.Vector2,\n p3: Vector2.Vector2,\n): CubicPolynomial => {\n // Newton's divided differences, then collected to monomial form.\n const f01 = (p1.y - p0.y) / (p1.x - p0.x)\n const f12 = (p2.y - p1.y) / (p2.x - p1.x)\n const f23 = (p3.y - p2.y) / (p3.x - p2.x)\n const f012 = (f12 - f01) / (p2.x - p0.x)\n const f123 = (f23 - f12) / (p3.x - p1.x)\n const f0123 = (f123 - f012) / (p3.x - p0.x)\n\n return new CubicPolynomialImpl(\n p0.y - f01 * p0.x + f012 * p0.x * p1.x - f0123 * p0.x * p1.x * p2.x,\n f01 - f012 * (p0.x + p1.x) + f0123 * (p0.x * p1.x + p0.x * p2.x + p1.x * p2.x),\n f012 - f0123 * (p0.x + p1.x + p2.x),\n f0123,\n )\n}\n\n/** @internal */\nexport const solve = dual<\n (x: number) => (p: CubicPolynomial) => number,\n (p: CubicPolynomial, x: number) => number\n>(2, (p: CubicPolynomial, x: number) => p.c0 + x * p.c1 + x ** 2 * p.c2 + x ** 3 * p.c3)\n\n/** @internal */\nexport const toSolver = (p: CubicPolynomial) => (x: number) => solve(p, x)\n\n/** @internal */\nexport const solveInverse = dual<\n (y: number) => (p: CubicPolynomial) => Solution.AtMostThree<number>,\n (p: CubicPolynomial, y: number) => Solution.AtMostThree<number>\n>(2, (self: CubicPolynomial, y: number) => {\n // c3 = 0: the polynomial is actually quadratic-or-less in disguise. Defer to\n // the quadratic solver (which itself handles c2 = 0 by deferring to linear).\n if (self.c3 === 0) {\n return Quadratic.solveInverse(Quadratic.make(self.c0, self.c1, self.c2), y)\n }\n\n const shift = self.c2 / (3 * self.c3)\n\n const d0 = self.c2 ** 2 - 3 * self.c3 * self.c1\n const d1 = 2 * self.c2 ** 3 - 9 * self.c3 * self.c2 * self.c1 + 27 * self.c3 ** 2 * (self.c0 - y)\n\n const p = -d0 / (3 * self.c3 ** 2)\n const q = d1 / (27 * self.c3 ** 3)\n\n const discriminant = clampToZero(-(4 * p ** 3 + 27 * q ** 2), 1e-12)\n\n const roots = new Set<number>()\n\n if (discriminant > 0) {\n const r = 2 * Math.sqrt(-p / 3)\n const theta = Math.acos(((3 * q) / (2 * p)) * Math.sqrt(-3 / p)) / 3\n const offset = (2 * Math.PI) / 3\n\n roots.add(r * Math.cos(theta + offset) - shift)\n roots.add(r * Math.cos(theta) - shift)\n roots.add(r * Math.cos(theta - offset) - shift)\n } else if (discriminant < 0) {\n const u = Math.sqrt(q ** 2 / 4 + p ** 3 / 27)\n\n const u1 = Math.cbrt(-q / 2 + u)\n const u2 = Math.cbrt(-q / 2 - u)\n\n roots.add(u1 + u2 - shift)\n } else if (d0 === 0) {\n roots.add(-shift)\n } else {\n roots.add((9 * self.c3 * (self.c0 - y) - self.c2 * self.c1) / (2 * d0))\n roots.add(\n (4 * self.c3 * self.c2 * self.c1 - 9 * self.c3 ** 2 * (self.c0 - y) - self.c2 ** 3) /\n (self.c3 * d0),\n )\n }\n\n return Solution.fromArray(Array.from(roots).toSorted((a, b) => a - b))\n})\n\n/** @internal */\nexport const toInverseSolver = (p: CubicPolynomial) => (y: number) => solveInverse(p, y)\n\n/** @internal */\nexport const coefficients = (p: CubicPolynomial): readonly [number, number, number, number] => [\n p.c0,\n p.c1,\n p.c2,\n p.c3,\n]\n\n/** @internal */\nexport const derivative = (p: CubicPolynomial) => Quadratic.make(p.c1, p.c2 * 2, p.c3 * 3)\n\n// Subdivides a cubic polynomial at parameter `t ∈ (0, 1)` into two new cubic\n// polynomials. The first polynomial's evaluation on `[0, 1]` matches the\n// original's evaluation on `[0, t]`; the second matches the original's\n// evaluation on `[t, 1]`. Concretely: `left(u) = p(t·u)` and\n// `right(u) = p(t + (1-t)·u)`. The left half is a uniform scale of the input\n// parameter by powers of `t`; the right half is a binomial expansion in\n// `(s + r·u)` with `s = t` and `r = 1 - t`.\n/** @internal */\nexport const subdivide = dual<\n (t: number) => (p: CubicPolynomial) => [CubicPolynomial, CubicPolynomial],\n (p: CubicPolynomial, t: number) => [CubicPolynomial, CubicPolynomial]\n>(2, (p: CubicPolynomial, t: number): [CubicPolynomial, CubicPolynomial] => {\n invariant(t > 0 && t < 1, 'subdivide parameter t must be in the open interval (0, 1)')\n\n const r = 1 - t\n const left = make(p.c0, p.c1 * t, p.c2 * t * t, p.c3 * t * t * t)\n const right = make(\n p.c0 + p.c1 * t + p.c2 * t * t + p.c3 * t * t * t,\n p.c1 * r + 2 * p.c2 * t * r + 3 * p.c3 * t * t * r,\n p.c2 * r * r + 3 * p.c3 * t * r * r,\n p.c3 * r * r * r,\n )\n return [left, right]\n})\n\n/** @internal */\nexport const roots = (p: CubicPolynomial): Solution.AtMostThree<number> => solveInverse(p, 0)\n\n/** @internal */\nexport const extrema = (p: CubicPolynomial): Solution.AtMostTwo<number> =>\n Quadratic.roots(derivative(p))\n\n/** @internal */\nexport const monotonicity = dual<\n (i: Interval.Interval) => (p: CubicPolynomial) => Monotonicity.Monotonicity,\n (p: CubicPolynomial, i?: Interval.Interval) => Monotonicity.Monotonicity\n>(\n (args) => isCubicPolynomial(args[0]),\n (p: CubicPolynomial, i?: Interval.Interval) => {\n invariant(\n i === undefined || Interval.size(i) > 0,\n 'monotonicity is undefined over a zero-width interval',\n )\n\n // shortcut to check for a horizontal line\n if (p.c3 === 0 && p.c2 === 0 && p.c1 === 0) {\n return Monotonicity.Constant\n }\n\n // shortcut to check for a non-horizontal line\n if (p.c3 === 0 && p.c2 === 0) {\n return Linear.monotonicity(Linear.make(p.c0, p.c1))\n }\n\n // without an interval, the monotonicity will be none if c3 or c2 are nonzero\n if (i === undefined) {\n return Monotonicity.None\n }\n\n if (p.c3 === 0) {\n return Quadratic.monotonicity(Quadratic.make(p.c0, p.c1, p.c2), i)\n }\n\n const e = Interval.filter(Interval.toOpen(i), [...extrema(p)])\n\n if (e.length > 0) {\n return Monotonicity.None\n }\n\n return Monotonicity.fromComparison(solve(p, i.start), solve(p, i.end))\n },\n)\n\n/** @internal */\nexport const isMonotonic = dual<\n (i: Interval.Interval) => <T>(p: CubicPolynomial<T>) => p is CubicPolynomial<T & Monotonic>,\n <T>(p: CubicPolynomial<T>, i?: Interval.Interval) => p is CubicPolynomial<T & Monotonic>\n>((args) => isCubicPolynomial(args[0]), ((p: CubicPolynomial, i?: Interval.Interval) =>\n Monotonicity.isStrict(monotonicity(p, i as Interval.Interval))) as never)\n\n/** @internal */\nexport const isIncreasing = dual<\n (i: Interval.Interval) => <T>(p: CubicPolynomial<T>) => p is CubicPolynomial<T & Increasing>,\n <T>(p: CubicPolynomial<T>, i?: Interval.Interval) => p is CubicPolynomial<T & Increasing>\n>(\n (args) => isCubicPolynomial(args[0]),\n ((p: CubicPolynomial, i?: Interval.Interval) =>\n monotonicity(p, i as Interval.Interval) === Monotonicity.Increasing) as never,\n)\n\n/** @internal */\nexport const isDecreasing = dual<\n (i: Interval.Interval) => <T>(p: CubicPolynomial<T>) => p is CubicPolynomial<T & Decreasing>,\n <T>(p: CubicPolynomial<T>, i?: Interval.Interval) => p is CubicPolynomial<T & Decreasing>\n>(\n (args) => isCubicPolynomial(args[0]),\n ((p: CubicPolynomial, i?: Interval.Interval) =>\n monotonicity(p, i as Interval.Interval) === Monotonicity.Decreasing) as never,\n)\n\n/** @internal */\nexport const asMonotonic = <T>(\n p: CubicPolynomial<T>,\n i?: Interval.Interval,\n): CubicPolynomial<T & Monotonic> => {\n invariant(isMonotonic(p, i as Interval.Interval), 'cubic polynomial is not monotonic')\n return p\n}\n\n/** @internal */\nexport const asIncreasing = <T>(\n p: CubicPolynomial<T>,\n i?: Interval.Interval,\n): CubicPolynomial<T & Increasing> => {\n invariant(isIncreasing(p, i as Interval.Interval), 'cubic polynomial is not increasing')\n return p\n}\n\n/** @internal */\nexport const asDecreasing = <T>(\n p: CubicPolynomial<T>,\n i?: Interval.Interval,\n): CubicPolynomial<T & Decreasing> => {\n invariant(isDecreasing(p, i as Interval.Interval), 'cubic polynomial is not decreasing')\n return p\n}\n\n/** @internal */\nexport const domain = dual<\n (range: Interval.Interval) => (p: CubicPolynomial) => Interval.Interval,\n (p: CubicPolynomial, range: Interval.Interval) => Interval.Interval\n>(2, (p: CubicPolynomial, r: Interval.Interval) =>\n Interval.fromMinMax(...solveInverse(p, r.start), ...solveInverse(p, r.end)),\n)\n\n/** @internal */\nexport const range = dual<\n (domain: Interval.Interval) => (p: CubicPolynomial) => Interval.Closed,\n (p: CubicPolynomial, domain: Interval.Interval) => Interval.Closed\n>(2, (p: CubicPolynomial, d: Interval.Interval) =>\n Interval.fromMinMax(\n solve(p, d.start),\n solve(p, d.end),\n ...Interval.filter(d, [...extrema(p)]).map((e) => solve(p, e)),\n ),\n)\n\n/** @internal */\nexport const unitRange = (p: CubicPolynomial): Interval.Closed => range(p, Interval.unit)\n\n/** @internal */\nexport const length = dual<\n (domain: Interval.Interval) => (p: CubicPolynomial) => number,\n (p: CubicPolynomial, domain: Interval.Interval) => number\n>(2, (p: CubicPolynomial, dom: Interval.Interval) => {\n if (Interval.size(dom) === 0) {\n return 0\n }\n\n if (p.c3 === 0) {\n if (p.c2 === 0) {\n return Linear.length(Linear.make(p.c0, p.c1), dom)\n }\n\n return Quadratic.length(Quadratic.make(p.c0, p.c1, p.c2), dom)\n }\n\n const d = derivative(p)\n\n const { scale, shift } = Interval.scaleShift(Interval.biunit, dom)\n\n return (\n (GL32_W0 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * -GL32_X0) ** 2) +\n GL32_W0 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * GL32_X0) ** 2) +\n GL32_W1 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * -GL32_X1) ** 2) +\n GL32_W1 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * GL32_X1) ** 2) +\n GL32_W2 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * -GL32_X2) ** 2) +\n GL32_W2 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * GL32_X2) ** 2) +\n GL32_W3 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * -GL32_X3) ** 2) +\n GL32_W3 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * GL32_X3) ** 2) +\n GL32_W4 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * -GL32_X4) ** 2) +\n GL32_W4 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * GL32_X4) ** 2) +\n GL32_W5 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * -GL32_X5) ** 2) +\n GL32_W5 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * GL32_X5) ** 2) +\n GL32_W6 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * -GL32_X6) ** 2) +\n GL32_W6 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * GL32_X6) ** 2) +\n GL32_W7 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * -GL32_X7) ** 2) +\n GL32_W7 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * GL32_X7) ** 2) +\n GL32_W8 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * -GL32_X8) ** 2) +\n GL32_W8 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * GL32_X8) ** 2) +\n GL32_W9 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * -GL32_X9) ** 2) +\n GL32_W9 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * GL32_X9) ** 2) +\n GL32_W10 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * -GL32_X10) ** 2) +\n GL32_W10 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * GL32_X10) ** 2) +\n GL32_W11 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * -GL32_X11) ** 2) +\n GL32_W11 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * GL32_X11) ** 2) +\n GL32_W12 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * -GL32_X12) ** 2) +\n GL32_W12 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * GL32_X12) ** 2) +\n GL32_W13 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * -GL32_X13) ** 2) +\n GL32_W13 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * GL32_X13) ** 2) +\n GL32_W14 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * -GL32_X14) ** 2) +\n GL32_W14 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * GL32_X14) ** 2) +\n GL32_W15 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * -GL32_X15) ** 2) +\n GL32_W15 * Math.sqrt(1 + Quadratic.solve(d, shift + scale * GL32_X15) ** 2)) *\n scale\n )\n})\n\n/** @internal */\nexport const curvature = dual(2, (p: CubicPolynomial, x: number) => {\n const d = derivative(p)\n const dd = Quadratic.derivative(d)\n\n return Math.abs(Linear.solve(dd, x)) / (1 + Quadratic.solve(d, x) ** 2) ** 1.5\n})\n","import type { Closed, Interval } from '../interval/interval.ts'\nimport type { Pipeable } from '../utils.ts'\nimport type * as Solution from '../solution/solution.ts'\nimport type { Vector2 } from '../vector/vector2.ts'\nimport type { Vector4 } from '../vector/vector4.ts'\nimport * as internal from './cubic.internal.ts'\nimport type { CubicPolynomialTypeId } from './cubic.internal.circular.ts'\nimport type { Monotonicity } from '../monotonicity/monotonicity.ts'\nimport type { QuadraticPolynomial } from './quadratic.ts'\nimport type { Decreasing, Increasing, Monotonic, PolynomialTraits } from './traits.ts'\n\nexport type { Monotonic, Increasing, Decreasing } from './traits.ts'\n\n/**\n * A cubic polynomial.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * The `Traits` type parameter is a phantom marker that accumulates trait\n * brands as the polynomial is refined via `isMonotonic` / `asMonotonic` and\n * friends. A cubic is monotonic only over an interval that avoids both of its\n * extrema (or globally, when c2 = c3 = 0 and c1 ≠ 0).\n *\n * @since 1.0.0\n */\nexport interface CubicPolynomial<out Traits = unknown> extends Pipeable {\n readonly [CubicPolynomialTypeId]: CubicPolynomialTypeId\n readonly [PolynomialTraits]: Traits\n\n /**\n * The coefficient of the x^0 term.\n */\n readonly c0: number\n /**\n * The coefficient of the x^1 term.\n */\n readonly c1: number\n /**\n * The coefficient of the x^2 term.\n */\n readonly c2: number\n /**\n * The coefficient of the x^3 term.\n */\n readonly c3: number\n}\n\n/**\n * Checks if a value is a `CubicPolynomial`.\n *\n * @param value - The value to check.\n * @returns `true` if the value is a `CubicPolynomial`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isCubicPolynomial: (value: unknown) => value is CubicPolynomial =\n internal.isCubicPolynomial\n\nexport const equals: {\n /**\n * Checks if two `CubicPolynomial` instances are approximately equal within\n * the default absolute tolerance ({@link EPSILON}).\n *\n * @param a - The first polynomial.\n * @param b - The second polynomial.\n * @returns `true` when each pair of coefficients is within tolerance.\n * @since 1.1.0\n */\n (a: CubicPolynomial, b: CubicPolynomial): boolean\n /**\n * Checks if two `CubicPolynomial` instances are approximately equal within\n * the default absolute tolerance ({@link EPSILON}).\n *\n * @param b - The second polynomial.\n * @returns A function that takes the first polynomial and returns the comparison result.\n * @since 1.1.0\n */\n (b: CubicPolynomial): (a: CubicPolynomial) => boolean\n} = internal.equals\n\n/**\n * Creates a new `CubicPolynomial` instance.\n *\n * @param c0 - The coefficient of the x^0 term.\n * @param c1 - The coefficient of the x^1 term.\n * @param c2 - The coefficient of the x^2 term.\n * @param c3 - The coefficient of the x^3 term.\n */\nexport const make: (c0: number, c1: number, c2: number, c3: number) => CubicPolynomial =\n internal.make\n\n/**\n * Creates a new `CubicPolynomial` instance from a vector.\n *\n * @param v - The vector to convert.\n * @returns A new `CubicPolynomial` instance.\n * @since 1.0.0\n */\nexport const fromVector: (v: Vector4) => CubicPolynomial = internal.fromVector\n\n/**\n * Creates a new `CubicPolynomial` that interpolates the four given points,\n * treating each `Vector2` as an `(x, y)` pair. The four input `x` values must\n * be distinct.\n *\n * @param p0 - The first point.\n * @param p1 - The second point.\n * @param p2 - The third point.\n * @param p3 - The fourth point.\n * @returns The unique cubic polynomial passing through the four points.\n * @since 2.0.0\n */\nexport const fromPoints: (p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2) => CubicPolynomial =\n internal.fromPoints\n\nexport const solve: {\n /**\n * Solves a cubic polynomial for a given value of x.\n *\n * @param p - The cubic polynomial to solve.\n * @param x - The value of x to solve for.\n * @returns The result of the polynomial evaluation at x.\n * @since 1.0.0\n */\n (p: CubicPolynomial, x: number): number\n /**\n * Solves a cubic polynomial for a given value of x.\n *\n * @param x - The value of x to solve for.\n * @returns A function that takes a cubic polynomial and returns the result of the polynomial evaluation at x.\n * @since 1.0.0\n */\n (x: number): (p: CubicPolynomial) => number\n} = internal.solve\n\n/**\n * Converts a cubic polynomial to a solver function.\n *\n * @param p - The cubic polynomial to convert.\n * @returns A function that takes a value of x and returns the result of the polynomial evaluation at x.\n * @since 1.0.0\n */\nexport const toSolver: (p: CubicPolynomial) => (x: number) => number = internal.toSolver\n\nexport const solveInverse: {\n /**\n * Solves a monotonic cubic polynomial for a given value of y. Because the\n * polynomial is strictly monotonic, the inverse has at most one solution.\n *\n * @param p - The monotonic cubic polynomial.\n * @param y - The value of y to solve for.\n * @returns Zero or one solutions.\n * @since 2.0.0\n */\n <T extends Monotonic>(p: CubicPolynomial<T>, y: number): Solution.AtMostOne<number>\n /**\n * Solves a cubic polynomial for a given value of y.\n *\n * @param p - The cubic polynomial to solve.\n * @param y - The value of y to solve for.\n * @returns The roots of the polynomial equation p(x) = y.\n * @since 1.0.0\n */\n <T>(p: CubicPolynomial<T>, y: number): Solution.AtMostThree<number>\n /**\n * Solves a cubic polynomial for a given value of y.\n *\n * @param y - The value of y to solve for.\n * @returns A function that takes a cubic polynomial and returns the roots\n * of the polynomial equation p(x) = y. Tightens to `Solution.AtMostOne<number>` for\n * monotonic inputs.\n * @since 1.0.0\n */\n (y: number): {\n <T extends Monotonic>(p: CubicPolynomial<T>): Solution.AtMostOne<number>\n <T>(p: CubicPolynomial<T>): Solution.AtMostThree<number>\n }\n} = internal.solveInverse as never\n\n/**\n * Converts a cubic polynomial to an inverse solver function.\n *\n * @param p - The cubic polynomial to convert.\n * @returns A function that takes a value of y and returns the roots of the polynomial equation p(x) = y.\n * @since 1.0.0\n */\nexport const toInverseSolver: (p: CubicPolynomial) => (y: number) => Solution.AtMostThree<number> =\n internal.toInverseSolver\n\n/**\n * Returns the polynomial's coefficients as a tuple `[c0, c1, c2, c3]`.\n *\n * @param p - The cubic polynomial.\n * @returns The coefficients in monomial order.\n * @since 2.0.0\n */\nexport const coefficients: (p: CubicPolynomial) => readonly [number, number, number, number] =\n internal.coefficients\n\n/**\n * Calculates the derivative of a cubic polynomial.\n *\n * @param p - The cubic polynomial to differentiate.\n * @returns The derivative of the cubic polynomial.\n * @since 1.0.0\n */\nexport const derivative: (p: CubicPolynomial) => QuadraticPolynomial = internal.derivative\n\nexport const subdivide: {\n /**\n * Subdivides a cubic polynomial at parameter `t ∈ (0, 1)` into two new\n * cubic polynomials. The first polynomial's evaluation on `[0, 1]` matches\n * the original's on `[0, t]`; the second matches the original's on\n * `[t, 1]`. Equivalent to de Casteljau subdivision in Bernstein form,\n * performed directly in monomial form.\n *\n * @param p - The cubic polynomial to subdivide.\n * @param t - The split parameter; must be in the open interval `(0, 1)`.\n * @returns A `[left, right]` tuple of cubic polynomials.\n * @since 2.0.0\n */\n (p: CubicPolynomial, t: number): [CubicPolynomial, CubicPolynomial]\n /**\n * Subdivides a cubic polynomial at parameter `t ∈ (0, 1)`.\n *\n * @param t - The split parameter; must be in the open interval `(0, 1)`.\n * @returns A function that takes a polynomial and returns its `[left, right]` halves.\n * @since 2.0.0\n */\n (t: number): (p: CubicPolynomial) => [CubicPolynomial, CubicPolynomial]\n} = internal.subdivide\n\n/**\n * Calculates the roots of a cubic polynomial.\n *\n * @param p - The cubic polynomial to find the roots of.\n * @returns The roots of the cubic polynomial.\n * @since 1.0.0\n */\nexport const roots: (p: CubicPolynomial) => Solution.AtMostThree<number> = internal.roots\n\n/**\n * Calculates the extrema of a cubic polynomial.\n *\n * @param p - The cubic polynomial to find the extrema of.\n * @returns The extrema of the cubic polynomial.\n * @since 1.0.0\n */\nexport const extrema: (p: CubicPolynomial) => Solution.AtMostTwo<number> = internal.extrema\n\nexport const monotonicity: {\n /**\n * Calculates the monotonicity of a cubic polynomial. Throws when the\n * interval has zero width — the question is undefined at a single point.\n *\n * @param p - The cubic polynomial to analyze.\n * @param i - The interval to restrict the analysis to.\n * @returns The monotonicity of the cubic polynomial in the specified interval.\n * @since 1.0.0\n */\n (p: CubicPolynomial, i?: Interval): Monotonicity\n /**\n * Calculates the monotonicity of a cubic polynomial. Throws when the\n * interval has zero width.\n *\n * @param i - The interval to restrict the analysis to.\n * @returns A function that takes a cubic polynomial and returns the\n * monotonicity of the cubic polynomial in the specified interval.\n * @since 1.0.0\n */\n (i: Interval): (p: CubicPolynomial) => Monotonicity\n} = internal.monotonicity\n\n/**\n * Type-narrowing predicate: refines a `CubicPolynomial<T>` to\n * `CubicPolynomial<T & Monotonic>` when the polynomial is strictly monotonic\n * over the given interval (or globally, when no interval is given).\n *\n * @param p - The cubic polynomial to check.\n * @param i - Optional interval over which to check monotonicity.\n * @returns `true` when monotonicity is `Increasing` or `Decreasing`.\n * @since 2.0.0\n */\nexport const isMonotonic: {\n <T>(p: CubicPolynomial<T>, i?: Interval): p is CubicPolynomial<T & Monotonic>\n (i: Interval): <T>(p: CubicPolynomial<T>) => p is CubicPolynomial<T & Monotonic>\n} = internal.isMonotonic\n\n/**\n * Type-narrowing predicate: refines to `CubicPolynomial<T & Increasing>`.\n *\n * @since 2.0.0\n */\nexport const isIncreasing: {\n <T>(p: CubicPolynomial<T>, i?: Interval): p is CubicPolynomial<T & Increasing>\n (i: Interval): <T>(p: CubicPolynomial<T>) => p is CubicPolynomial<T & Increasing>\n} = internal.isIncreasing\n\n/**\n * Type-narrowing predicate: refines to `CubicPolynomial<T & Decreasing>`.\n *\n * @since 2.0.0\n */\nexport const isDecreasing: {\n <T>(p: CubicPolynomial<T>, i?: Interval): p is CubicPolynomial<T & Decreasing>\n (i: Interval): <T>(p: CubicPolynomial<T>) => p is CubicPolynomial<T & Decreasing>\n} = internal.isDecreasing\n\n/**\n * Asserts that the cubic polynomial is monotonic, throwing on failure.\n *\n * @param p - The cubic polynomial to assert against.\n * @param i - Optional interval over which to check monotonicity.\n * @returns The same polynomial, typed with the `Monotonic` brand.\n * @throws When the polynomial is not monotonic over the given (or global) interval.\n * @since 2.0.0\n */\nexport const asMonotonic: <T>(\n p: CubicPolynomial<T>,\n i?: Interval,\n) => CubicPolynomial<T & Monotonic> = internal.asMonotonic\n\n/**\n * Asserts that the cubic polynomial is increasing, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asIncreasing: <T>(\n p: CubicPolynomial<T>,\n i?: Interval,\n) => CubicPolynomial<T & Increasing> = internal.asIncreasing\n\n/**\n * Asserts that the cubic polynomial is decreasing, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asDecreasing: <T>(\n p: CubicPolynomial<T>,\n i?: Interval,\n) => CubicPolynomial<T & Decreasing> = internal.asDecreasing\n\nexport const domain: {\n /**\n * Calculates the domain of a cubic polynomial.\n *\n * @param p - The cubic polynomial to analyze.\n * @param range - The range to restrict the analysis to.\n * @returns The domain of the cubic polynomial in the specified range.\n * @since 1.0.0\n */\n (p: CubicPolynomial, range: Interval): Interval\n /**\n * Calculates the domain of a cubic polynomial.\n *\n * @param range - The range to restrict the analysis to.\n * @returns A function that takes a cubic polynomial and returns the domain of the cubic polynomial in the specified range.\n * @since 1.0.0\n */\n (range: Interval): (p: CubicPolynomial) => Interval\n} = internal.domain\n\nexport const range: {\n /**\n * Calculates the range of a cubic polynomial.\n *\n * @param p - The cubic polynomial to analyze.\n * @param domain - The domain to restrict the analysis to.\n * @returns The range of the cubic polynomial in the specified domain.\n * @since 1.0.0\n */\n (p: CubicPolynomial, domain: Interval): Closed\n /**\n * Calculates the range of a cubic polynomial.\n *\n * @param domain - The domain to restrict the analysis to.\n * @returns A function that takes a cubic polynomial and returns the range of the cubic polynomial in the specified domain.\n * @since 1.0.0\n */\n (domain: Interval): (p: CubicPolynomial) => Closed\n} = internal.range\n\n/**\n * Calculates the range of a cubic polynomial over the unit interval `[0, 1]`.\n * Equivalent to `range(p, Interval.unit)` — accounts for up to two interior\n * extrema in `[0, 1]`.\n *\n * @param p - The cubic polynomial.\n * @returns The closed range of the polynomial over `[0, 1]`.\n * @since 2.0.0\n */\nexport const unitRange: (p: CubicPolynomial) => Closed = internal.unitRange\n\nexport const length: {\n /**\n * Calculates the length of a cubic polynomial.\n *\n * @param p - The cubic polynomial to analyze.\n * @param domain - The domain to restrict the analysis to.\n * @returns The length of the cubic polynomial in the specified domain.\n * @since 1.0.0\n */\n (p: CubicPolynomial, domain: Interval): number\n /**\n * Calculates the length of a cubic polynomial.\n *\n * @param domain - The domain to restrict the analysis to.\n * @returns A function that takes a cubic polynomial and returns the length of the cubic polynomial in the specified domain.\n * @since 1.0.0\n */\n (domain: Interval): (p: CubicPolynomial) => number\n} = internal.length\n\nexport const curvature: {\n /**\n * Calculates the curvature of a cubic polynomial.\n *\n * @param p - The cubic polynomial to analyze.\n * @param x - The value of x to calculate the curvature at.\n * @returns The curvature of the cubic polynomial at the specified value of x.\n * @since 1.0.0\n */\n (p: CubicPolynomial, x: number): number\n /**\n * Calculates the curvature of a cubic polynomial.\n *\n * @param x - The value of x to calculate the curvature at.\n * @returns A function that takes a cubic polynomial and returns the curvature of the cubic polynomial at the specified value of x.\n * @since 1.0.0\n */\n (x: number): (p: CubicPolynomial) => number\n} = internal.curvature\n"],"mappings":";;;;;;;;AAIA,MAAa,4BAA2C,OAAO,IAAI,6BAA6B;;AAIhG,IAAa,0BAAb,cAA6C,SAAiD;CAC5F,CAAU,6BAAwD;CAGlE;CACA;CACA;CAEA,YAAY,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG;EAClC,OAAO;EAEP,KAAK,KAAK;EACV,KAAK,KAAK;EACV,KAAK,KAAK;;;;;ACRd,MAAa,yBAAwC,OAAO,IAAI,eAAe;AAG/E,IAAM,uBAAN,cAAmC,SAA8C;CAC/E,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_exports as n, make as r, fromVectors as t };
148
148
 
149
- //# sourceMappingURL=interval2d-DPmvk_Qe.mjs.map
149
+ //# sourceMappingURL=interval2d-AtneyI45.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"interval2d-DPmvk_Qe.mjs","names":["isInterval2d","make","fromCorners","Interval.fromMinMax","fromVectors","containsVector","Interval.contains","containsInterval2d","Interval.containsInterval","size","Vector2.make","union","Interval.union","equals","Interval.equals","minDistance","maxDistance","internal.isInterval2d","internal.make","internal.fromCorners","internal.fromVectors","internal.containsVector","internal.containsInterval2d","internal.size","internal.union","internal.equals","internal.minDistance","internal.maxDistance"],"sources":["../../src/interval/interval2d.internal.ts","../../src/interval/interval2d.ts"],"sourcesContent":["import { dual, invariant, Pipeable } from '../utils.ts'\nimport * as Vector2 from '../vector/vector2.ts'\nimport * as Interval from './interval.ts'\nimport type { Bounds2d, Interval2d } from './interval2d.ts'\n\nexport const Interval2dTypeId: unique symbol = Symbol('curvy/interval/interval2d')\nexport type Interval2dTypeId = typeof Interval2dTypeId\n\nclass Interval2dImpl<X extends Interval.Interval, Y extends Interval.Interval>\n extends Pipeable\n implements Interval2d<X, Y>\n{\n readonly [Interval2dTypeId]: Interval2dTypeId = Interval2dTypeId\n\n readonly x: X\n readonly y: Y\n\n constructor(x: X, y: Y) {\n super()\n this.x = x\n this.y = y\n }\n\n get [Symbol.toStringTag]() {\n return `Interval2d(${String(this.x)} × ${String(this.y)})`\n }\n\n get [Symbol.for('nodejs.util.inspect.custom')]() {\n return this[Symbol.toStringTag]\n }\n}\n\n/** @internal */\nexport const isInterval2d = (v: unknown): v is Interval2d =>\n typeof v === 'object' && v !== null && Interval2dTypeId in v\n\n/** @internal */\nexport const make = <X extends Interval.Interval, Y extends Interval.Interval>(\n x: X,\n y: Y,\n): Interval2d<X, Y> => new Interval2dImpl(x, y)\n\n/** @internal */\nexport const fromCorners = (\n p0: Vector2.Vector2,\n p1: Vector2.Vector2,\n): Interval2d<Interval.Closed, Interval.Closed> =>\n new Interval2dImpl(Interval.fromMinMax(p0.x, p1.x), Interval.fromMinMax(p0.y, p1.y))\n\n/** @internal */\nexport const fromVectors = (\n ...points: ReadonlyArray<Vector2.Vector2>\n): Interval2d<Interval.Closed, Interval.Closed> => {\n invariant(points.length > 0, 'fromVectors requires at least one point')\n const xs: Array<number> = []\n const ys: Array<number> = []\n for (const p of points) {\n xs.push(p.x)\n ys.push(p.y)\n }\n return new Interval2dImpl(Interval.fromMinMax(...xs), Interval.fromMinMax(...ys))\n}\n\n/** @internal */\nexport const containsVector = dual<\n (v: Vector2.Vector2) => (box: Interval2d) => boolean,\n (box: Interval2d, v: Vector2.Vector2) => boolean\n>(\n 2,\n (box: Interval2d, v: Vector2.Vector2): boolean =>\n Interval.contains(box.x, v.x) && Interval.contains(box.y, v.y),\n)\n\n/** @internal */\nexport const containsInterval2d = dual<\n (inner: Interval2d) => (outer: Interval2d) => boolean,\n (outer: Interval2d, inner: Interval2d) => boolean\n>(\n 2,\n (outer: Interval2d, inner: Interval2d): boolean =>\n Interval.containsInterval(outer.x, inner.x) && Interval.containsInterval(outer.y, inner.y),\n)\n\n// Accepts the structural minimum because size doesn't read kind.\n/** @internal */\nexport const size = (box: Bounds2d): Vector2.Vector2 =>\n Vector2.make(Math.abs(box.x.end - box.x.start), Math.abs(box.y.end - box.y.start))\n\n// Per-axis union — the runtime delegates to `Interval.union`, which is\n// kind-correct (the resulting endpoint openness reflects which input\n// contributed each side). The conditional return type collapses to the\n// shared kind when both inputs match on an axis and falls back to `Interval`\n// when they differ — at runtime the result genuinely could be any of the four\n// kinds depending on which endpoint wins.\n/** @internal */\nexport const union: {\n <\n AX extends Interval.Interval,\n AY extends Interval.Interval,\n BX extends Interval.Interval,\n BY extends Interval.Interval,\n >(\n a: Interval2d<AX, AY>,\n b: Interval2d<BX, BY>,\n ): Interval2d<\n AX extends BX ? (BX extends AX ? AX : Interval.Interval) : Interval.Interval,\n AY extends BY ? (BY extends AY ? AY : Interval.Interval) : Interval.Interval\n >\n <BX extends Interval.Interval, BY extends Interval.Interval>(\n b: Interval2d<BX, BY>,\n ): <AX extends Interval.Interval, AY extends Interval.Interval>(\n a: Interval2d<AX, AY>,\n ) => Interval2d<\n AX extends BX ? (BX extends AX ? AX : Interval.Interval) : Interval.Interval,\n AY extends BY ? (BY extends AY ? AY : Interval.Interval) : Interval.Interval\n >\n} = dual(\n 2,\n (a: Interval2d, b: Interval2d) =>\n new Interval2dImpl(Interval.union(a.x, b.x), Interval.union(a.y, b.y)),\n) as never\n\n/** @internal */\nexport const equals = dual<\n (b: Interval2d) => (a: Interval2d) => boolean,\n (a: Interval2d, b: Interval2d) => boolean\n>(\n 2,\n (a: Interval2d, b: Interval2d): boolean => Interval.equals(a.x, b.x) && Interval.equals(a.y, b.y),\n)\n\n// For two axis-aligned 2D intervals the closest-pair and farthest-pair\n// distances decompose per-axis: the closest pair has the per-axis minimum\n// gap on each axis, the farthest pair has the per-axis maximum gap on each\n// axis. Combining via `hypot` gives the 2D distance because the per-axis\n// extrema are independently achievable at the corresponding box corners.\n//\n// Inputs are normalized with `min`/`max` so callers can pass `Bounds`-shaped\n// values whose `start`/`end` may not be ordered.\n\n/** @internal */\nexport const minDistance = dual<\n (b: Bounds2d) => (a: Bounds2d) => number,\n (a: Bounds2d, b: Bounds2d) => number\n>(2, (a: Bounds2d, b: Bounds2d): number => {\n const aXLo = Math.min(a.x.start, a.x.end)\n const aXHi = Math.max(a.x.start, a.x.end)\n const aYLo = Math.min(a.y.start, a.y.end)\n const aYHi = Math.max(a.y.start, a.y.end)\n const bXLo = Math.min(b.x.start, b.x.end)\n const bXHi = Math.max(b.x.start, b.x.end)\n const bYLo = Math.min(b.y.start, b.y.end)\n const bYHi = Math.max(b.y.start, b.y.end)\n const dx = Math.max(0, Math.max(aXLo, bXLo) - Math.min(aXHi, bXHi))\n const dy = Math.max(0, Math.max(aYLo, bYLo) - Math.min(aYHi, bYHi))\n return Math.hypot(dx, dy)\n})\n\n/** @internal */\nexport const maxDistance = dual<\n (b: Bounds2d) => (a: Bounds2d) => number,\n (a: Bounds2d, b: Bounds2d) => number\n>(2, (a: Bounds2d, b: Bounds2d): number => {\n const aXLo = Math.min(a.x.start, a.x.end)\n const aXHi = Math.max(a.x.start, a.x.end)\n const aYLo = Math.min(a.y.start, a.y.end)\n const aYHi = Math.max(a.y.start, a.y.end)\n const bXLo = Math.min(b.x.start, b.x.end)\n const bXHi = Math.max(b.x.start, b.x.end)\n const bYLo = Math.min(b.y.start, b.y.end)\n const bYHi = Math.max(b.y.start, b.y.end)\n const dx = Math.max(aXHi, bXHi) - Math.min(aXLo, bXLo)\n const dy = Math.max(aYHi, bYHi) - Math.min(aYLo, bYLo)\n return Math.hypot(dx, dy)\n})\n","import type { Pipeable } from '../utils.ts'\nimport type { Vector2 } from '../vector/vector2.ts'\nimport type { Bounds, Closed, Interval } from './interval.ts'\nimport type { Interval2dTypeId } from './interval2d.internal.ts'\nimport * as internal from './interval2d.internal.ts'\n\n/**\n * An axis-aligned 2D interval — the Cartesian product of two 1D intervals.\n * Used as a bounding box for curves and paths, and as a region for\n * containment tests.\n *\n * The two type parameters carry the per-axis interval subtype so that a value\n * built from closed intervals stays `Interval2d<Closed, Closed>` and a value\n * with mixed openness preserves that information at the type level.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * @since 2.0.0\n */\nexport interface Interval2d<\n X extends Interval = Interval,\n Y extends Interval = Interval,\n> extends Pipeable {\n readonly [Interval2dTypeId]: Interval2dTypeId\n readonly x: X\n readonly y: Y\n}\n\n/**\n * The structural minimum: any value with `x` and `y` fields shaped like\n * {@link Bounds}. Operations that don't read endpoint inclusivity (e.g.\n * {@link size}) accept `Bounds2d` so the signature itself documents what the\n * operation depends on. Mirrors the {@link Bounds}/{@link Interval} split in 1D.\n *\n * @since 2.0.0\n */\nexport interface Bounds2d {\n readonly x: Bounds\n readonly y: Bounds\n}\n\n/**\n * Checks if a value is an `Interval2d`.\n *\n * @param v - The value to check.\n * @returns `true` if the value is an `Interval2d`, `false` otherwise.\n * @since 2.0.0\n */\nexport const isInterval2d: (v: unknown) => v is Interval2d = internal.isInterval2d\n\n/**\n * Creates a new `Interval2d` from two intervals — one for the x axis, one\n * for the y axis. Preserves both interval subtypes at the type level.\n *\n * @param x - The x-axis interval.\n * @param y - The y-axis interval.\n * @returns A new `Interval2d` instance.\n * @since 2.0.0\n */\nexport const make: <X extends Interval, Y extends Interval>(x: X, y: Y) => Interval2d<X, Y> =\n internal.make\n\n/**\n * Creates a closed `Interval2d` from two corner points. The corners can be in\n * any order — each axis is built from the min and max of the coordinate.\n *\n * @param p0 - The first corner.\n * @param p1 - The second corner.\n * @returns A new `Interval2d<Closed, Closed>` enclosing both corners.\n * @since 2.0.0\n */\nexport const fromCorners: (p0: Vector2, p1: Vector2) => Interval2d<Closed, Closed> =\n internal.fromCorners\n\n/**\n * Creates the smallest closed `Interval2d` enclosing the given points. Useful\n * for computing a bounding box from sampled points.\n *\n * @param points - One or more points to enclose.\n * @returns A new `Interval2d<Closed, Closed>` enclosing all input points.\n * @throws When called with zero points.\n * @since 2.0.0\n */\nexport const fromVectors: (...points: ReadonlyArray<Vector2>) => Interval2d<Closed, Closed> =\n internal.fromVectors\n\nexport const containsVector: {\n /**\n * Checks if a vector lies within the 2D interval. Per-axis endpoint\n * inclusivity follows each axis interval's `kind`.\n *\n * @param box - The 2D interval to test against.\n * @param v - The vector to test.\n * @returns `true` when the vector lies within the box on both axes.\n * @since 2.0.0\n */\n (box: Interval2d, v: Vector2): boolean\n /**\n * @param v - The vector to test.\n * @returns A function that takes a 2D interval and returns the containment result.\n * @since 2.0.0\n */\n (v: Vector2): (box: Interval2d) => boolean\n} = internal.containsVector\n\nexport const containsInterval2d: {\n /**\n * Checks if `inner` is a subset of `outer`. The check is per-axis interval\n * containment — for each axis, every point of the inner interval must also\n * be in the outer interval, respecting endpoint inclusivity on both sides.\n *\n * @param outer - The enclosing 2D interval.\n * @param inner - The candidate inner 2D interval.\n * @returns `true` when every point of `inner` is also in `outer`.\n * @since 2.0.0\n */\n (outer: Interval2d, inner: Interval2d): boolean\n /**\n * @param inner - The candidate inner 2D interval.\n * @returns A function that takes the outer 2D interval and returns the containment result.\n * @since 2.0.0\n */\n (inner: Interval2d): (outer: Interval2d) => boolean\n} = internal.containsInterval2d\n\n/**\n * Returns the size as a vector `(width, height)`. Accepts the broader\n * {@link Bounds2d} type because size does not depend on endpoint inclusivity.\n *\n * @param box - The 2D interval (or bounds-shaped value) to measure.\n * @returns The size as a `Vector2`.\n * @since 2.0.0\n */\nexport const size: (box: Bounds2d) => Vector2 = internal.size\n\nexport const union: {\n /**\n * Returns the smallest 2D interval enclosing both inputs.\n *\n * The per-axis return kind is determined by which input's endpoint wins on\n * each side, with the contributor's openness preserved (or unioned to\n * \"closed\" when endpoints are numerically equal and either is closed at\n * that point).\n *\n * When both inputs share the same kind on an axis, the result collapses\n * back to that kind. Otherwise the axis falls back to the open\n * {@link Interval} type since the runtime kind depends on the values.\n *\n * @param a - The first 2D interval.\n * @param b - The second 2D interval.\n * @returns A new `Interval2d` enclosing both inputs.\n * @since 2.0.0\n */\n <AX extends Interval, AY extends Interval, BX extends Interval, BY extends Interval>(\n a: Interval2d<AX, AY>,\n b: Interval2d<BX, BY>,\n ): Interval2d<\n AX extends BX ? (BX extends AX ? AX : Interval) : Interval,\n AY extends BY ? (BY extends AY ? AY : Interval) : Interval\n >\n /**\n * @param b - The second 2D interval.\n * @returns A function that takes the first 2D interval and returns the union.\n * @since 2.0.0\n */\n <BX extends Interval, BY extends Interval>(\n b: Interval2d<BX, BY>,\n ): <AX extends Interval, AY extends Interval>(\n a: Interval2d<AX, AY>,\n ) => Interval2d<\n AX extends BX ? (BX extends AX ? AX : Interval) : Interval,\n AY extends BY ? (BY extends AY ? AY : Interval) : Interval\n >\n} = internal.union\n\nexport const equals: {\n /**\n * Checks if two `Interval2d` values are approximately equal within the\n * default absolute tolerance ({@link EPSILON}). Both the numeric endpoints\n * AND the per-axis kinds must match.\n *\n * @param a - The first 2D interval.\n * @param b - The second 2D interval.\n * @returns `true` when both axes are equal.\n * @since 2.0.0\n */\n (a: Interval2d, b: Interval2d): boolean\n /**\n * @param b - The second 2D interval.\n * @returns A function that takes the first 2D interval and returns the comparison result.\n * @since 2.0.0\n */\n (b: Interval2d): (a: Interval2d) => boolean\n} = internal.equals\n\nexport const minDistance: {\n /**\n * Euclidean distance between the two closest points of two axis-aligned 2D\n * intervals. Returns `0` when the boxes overlap (including edge or corner\n * touching). Accepts the broader {@link Bounds2d} type — endpoint\n * inclusivity is not consulted, so a \"touching\" pair of open intervals still\n * returns `0` because the closest *points* coincide geometrically.\n *\n * @param a - The first 2D interval.\n * @param b - The second 2D interval.\n * @returns The minimum Euclidean distance between any point of `a` and any point of `b`.\n * @since 2.0.0\n */\n (a: Bounds2d, b: Bounds2d): number\n /**\n * @param b - The second 2D interval.\n * @returns A function that takes the first 2D interval and returns the minimum distance.\n * @since 2.0.0\n */\n (b: Bounds2d): (a: Bounds2d) => number\n} = internal.minDistance\n\nexport const maxDistance: {\n /**\n * Euclidean distance between the two farthest points of two axis-aligned 2D\n * intervals. Equals the diagonal of the union AABB enclosing both inputs.\n * Accepts the broader {@link Bounds2d} type — endpoint inclusivity is not\n * consulted.\n *\n * @param a - The first 2D interval.\n * @param b - The second 2D interval.\n * @returns The maximum Euclidean distance between any point of `a` and any point of `b`.\n * @since 2.0.0\n */\n (a: Bounds2d, b: Bounds2d): number\n /**\n * @param b - The second 2D interval.\n * @returns A function that takes the first 2D interval and returns the maximum distance.\n * @since 2.0.0\n */\n (b: Bounds2d): (a: Bounds2d) => number\n} = internal.maxDistance\n"],"mappings":";;;;;AAKA,MAAa,mBAAkC,OAAO,4BAA4B;AAGlF,IAAM,iBAAN,cACU,SAEV;CACE,CAAU,oBAAsC;CAEhD;CACA;CAEA,YAAY,GAAM,GAAM;EACtB,OAAO;EACP,KAAK,IAAI;EACT,KAAK,IAAI;;CAGX,KAAK,OAAO,eAAe;EACzB,OAAO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,OAAO,KAAK,IAAI,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI;CACzC,MAAM,OAAO,KAAK,IAAI,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI;CACzC,MAAM,OAAO,KAAK,IAAI,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI;CACzC,MAAM,OAAO,KAAK,IAAI,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI;CACzC,MAAM,KAAK,KAAK,IAAI,MAAM,KAAK,GAAG,KAAK,IAAI,MAAM,KAAK;CACtD,MAAM,KAAK,KAAK,IAAI,MAAM,KAAK,GAAG,KAAK,IAAI,MAAM,KAAK;CACtD,OAAO,KAAK,MAAM,IAAI,GAAG;EACzB;;;;;;;;;;;;;;;;;;;;;;;AC9HF,MAAa,eAAgDC;;;;;;;;;;AAW7D,MAAa,OACXC;;;;;;;;;;AAWF,MAAa,cACXC;;;;;;;;;;AAWF,MAAa,cACXC;AAEF,MAAa,iBAiBTC;AAEJ,MAAa,qBAkBTC;;;;;;;;;AAUJ,MAAa,OAAmCC;AAEhD,MAAa,QAsCTC;AAEJ,MAAa,SAkBTC;AAEJ,MAAa,cAoBTC;AAEJ,MAAa,cAmBTC"}
1
+ {"version":3,"file":"interval2d-AtneyI45.mjs","names":["isInterval2d","make","fromCorners","Interval.fromMinMax","fromVectors","containsVector","Interval.contains","containsInterval2d","Interval.containsInterval","size","Vector2.make","union","Interval.union","equals","Interval.equals","minDistance","maxDistance","internal.isInterval2d","internal.make","internal.fromCorners","internal.fromVectors","internal.containsVector","internal.containsInterval2d","internal.size","internal.union","internal.equals","internal.minDistance","internal.maxDistance"],"sources":["../../src/interval/interval2d.internal.ts","../../src/interval/interval2d.ts"],"sourcesContent":["import { dual, invariant, Pipeable } from '../utils.ts'\nimport * as Vector2 from '../vector/vector2.ts'\nimport * as Interval from './interval.ts'\nimport type { Bounds2d, Interval2d } from './interval2d.ts'\n\nexport const Interval2dTypeId: unique symbol = Symbol('curvy/interval/interval2d')\nexport type Interval2dTypeId = typeof Interval2dTypeId\n\nclass Interval2dImpl<X extends Interval.Interval, Y extends Interval.Interval>\n extends Pipeable\n implements Interval2d<X, Y>\n{\n readonly [Interval2dTypeId]: Interval2dTypeId = Interval2dTypeId\n\n readonly x: X\n readonly y: Y\n\n constructor(x: X, y: Y) {\n super()\n this.x = x\n this.y = y\n }\n\n get [Symbol.toStringTag]() {\n return `Interval2d(${String(this.x)} × ${String(this.y)})`\n }\n\n get [Symbol.for('nodejs.util.inspect.custom')]() {\n return this[Symbol.toStringTag]\n }\n}\n\n/** @internal */\nexport const isInterval2d = (v: unknown): v is Interval2d =>\n typeof v === 'object' && v !== null && Interval2dTypeId in v\n\n/** @internal */\nexport const make = <X extends Interval.Interval, Y extends Interval.Interval>(\n x: X,\n y: Y,\n): Interval2d<X, Y> => new Interval2dImpl(x, y)\n\n/** @internal */\nexport const fromCorners = (\n p0: Vector2.Vector2,\n p1: Vector2.Vector2,\n): Interval2d<Interval.Closed, Interval.Closed> =>\n new Interval2dImpl(Interval.fromMinMax(p0.x, p1.x), Interval.fromMinMax(p0.y, p1.y))\n\n/** @internal */\nexport const fromVectors = (\n ...points: ReadonlyArray<Vector2.Vector2>\n): Interval2d<Interval.Closed, Interval.Closed> => {\n invariant(points.length > 0, 'fromVectors requires at least one point')\n const xs: Array<number> = []\n const ys: Array<number> = []\n for (const p of points) {\n xs.push(p.x)\n ys.push(p.y)\n }\n return new Interval2dImpl(Interval.fromMinMax(...xs), Interval.fromMinMax(...ys))\n}\n\n/** @internal */\nexport const containsVector = dual<\n (v: Vector2.Vector2) => (box: Interval2d) => boolean,\n (box: Interval2d, v: Vector2.Vector2) => boolean\n>(\n 2,\n (box: Interval2d, v: Vector2.Vector2): boolean =>\n Interval.contains(box.x, v.x) && Interval.contains(box.y, v.y),\n)\n\n/** @internal */\nexport const containsInterval2d = dual<\n (inner: Interval2d) => (outer: Interval2d) => boolean,\n (outer: Interval2d, inner: Interval2d) => boolean\n>(\n 2,\n (outer: Interval2d, inner: Interval2d): boolean =>\n Interval.containsInterval(outer.x, inner.x) && Interval.containsInterval(outer.y, inner.y),\n)\n\n// Accepts the structural minimum because size doesn't read kind.\n/** @internal */\nexport const size = (box: Bounds2d): Vector2.Vector2 =>\n Vector2.make(Math.abs(box.x.end - box.x.start), Math.abs(box.y.end - box.y.start))\n\n// Per-axis union — the runtime delegates to `Interval.union`, which is\n// kind-correct (the resulting endpoint openness reflects which input\n// contributed each side). The conditional return type collapses to the\n// shared kind when both inputs match on an axis and falls back to `Interval`\n// when they differ — at runtime the result genuinely could be any of the four\n// kinds depending on which endpoint wins.\n/** @internal */\nexport const union: {\n <\n AX extends Interval.Interval,\n AY extends Interval.Interval,\n BX extends Interval.Interval,\n BY extends Interval.Interval,\n >(\n a: Interval2d<AX, AY>,\n b: Interval2d<BX, BY>,\n ): Interval2d<\n AX extends BX ? (BX extends AX ? AX : Interval.Interval) : Interval.Interval,\n AY extends BY ? (BY extends AY ? AY : Interval.Interval) : Interval.Interval\n >\n <BX extends Interval.Interval, BY extends Interval.Interval>(\n b: Interval2d<BX, BY>,\n ): <AX extends Interval.Interval, AY extends Interval.Interval>(\n a: Interval2d<AX, AY>,\n ) => Interval2d<\n AX extends BX ? (BX extends AX ? AX : Interval.Interval) : Interval.Interval,\n AY extends BY ? (BY extends AY ? AY : Interval.Interval) : Interval.Interval\n >\n} = dual(\n 2,\n (a: Interval2d, b: Interval2d) =>\n new Interval2dImpl(Interval.union(a.x, b.x), Interval.union(a.y, b.y)),\n) as never\n\n/** @internal */\nexport const equals = dual<\n (b: Interval2d) => (a: Interval2d) => boolean,\n (a: Interval2d, b: Interval2d) => boolean\n>(\n 2,\n (a: Interval2d, b: Interval2d): boolean => Interval.equals(a.x, b.x) && Interval.equals(a.y, b.y),\n)\n\n// For two axis-aligned 2D intervals the closest-pair and farthest-pair\n// distances decompose per-axis: the closest pair has the per-axis minimum\n// gap on each axis, the farthest pair has the per-axis maximum gap on each\n// axis. Combining via `hypot` gives the 2D distance because the per-axis\n// extrema are independently achievable at the corresponding box corners.\n//\n// Inputs are normalized with `min`/`max` so callers can pass `Bounds`-shaped\n// values whose `start`/`end` may not be ordered.\n\n/** @internal */\nexport const minDistance = dual<\n (b: Bounds2d) => (a: Bounds2d) => number,\n (a: Bounds2d, b: Bounds2d) => number\n>(2, (a: Bounds2d, b: Bounds2d): number => {\n const aXLo = Math.min(a.x.start, a.x.end)\n const aXHi = Math.max(a.x.start, a.x.end)\n const aYLo = Math.min(a.y.start, a.y.end)\n const aYHi = Math.max(a.y.start, a.y.end)\n const bXLo = Math.min(b.x.start, b.x.end)\n const bXHi = Math.max(b.x.start, b.x.end)\n const bYLo = Math.min(b.y.start, b.y.end)\n const bYHi = Math.max(b.y.start, b.y.end)\n const dx = Math.max(0, Math.max(aXLo, bXLo) - Math.min(aXHi, bXHi))\n const dy = Math.max(0, Math.max(aYLo, bYLo) - Math.min(aYHi, bYHi))\n return Math.hypot(dx, dy)\n})\n\n/** @internal */\nexport const maxDistance = dual<\n (b: Bounds2d) => (a: Bounds2d) => number,\n (a: Bounds2d, b: Bounds2d) => number\n>(2, (a: Bounds2d, b: Bounds2d): number => {\n const aXLo = Math.min(a.x.start, a.x.end)\n const aXHi = Math.max(a.x.start, a.x.end)\n const aYLo = Math.min(a.y.start, a.y.end)\n const aYHi = Math.max(a.y.start, a.y.end)\n const bXLo = Math.min(b.x.start, b.x.end)\n const bXHi = Math.max(b.x.start, b.x.end)\n const bYLo = Math.min(b.y.start, b.y.end)\n const bYHi = Math.max(b.y.start, b.y.end)\n const dx = Math.max(aXHi, bXHi) - Math.min(aXLo, bXLo)\n const dy = Math.max(aYHi, bYHi) - Math.min(aYLo, bYLo)\n return Math.hypot(dx, dy)\n})\n","import type { Pipeable } from '../utils.ts'\nimport type { Vector2 } from '../vector/vector2.ts'\nimport type { Bounds, Closed, Interval } from './interval.ts'\nimport type { Interval2dTypeId } from './interval2d.internal.ts'\nimport * as internal from './interval2d.internal.ts'\n\n/**\n * An axis-aligned 2D interval — the Cartesian product of two 1D intervals.\n * Used as a bounding box for curves and paths, and as a region for\n * containment tests.\n *\n * The two type parameters carry the per-axis interval subtype so that a value\n * built from closed intervals stays `Interval2d<Closed, Closed>` and a value\n * with mixed openness preserves that information at the type level.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * @since 2.0.0\n */\nexport interface Interval2d<\n X extends Interval = Interval,\n Y extends Interval = Interval,\n> extends Pipeable {\n readonly [Interval2dTypeId]: Interval2dTypeId\n readonly x: X\n readonly y: Y\n}\n\n/**\n * The structural minimum: any value with `x` and `y` fields shaped like\n * {@link Bounds}. Operations that don't read endpoint inclusivity (e.g.\n * {@link size}) accept `Bounds2d` so the signature itself documents what the\n * operation depends on. Mirrors the {@link Bounds}/{@link Interval} split in 1D.\n *\n * @since 2.0.0\n */\nexport interface Bounds2d {\n readonly x: Bounds\n readonly y: Bounds\n}\n\n/**\n * Checks if a value is an `Interval2d`.\n *\n * @param v - The value to check.\n * @returns `true` if the value is an `Interval2d`, `false` otherwise.\n * @since 2.0.0\n */\nexport const isInterval2d: (v: unknown) => v is Interval2d = internal.isInterval2d\n\n/**\n * Creates a new `Interval2d` from two intervals — one for the x axis, one\n * for the y axis. Preserves both interval subtypes at the type level.\n *\n * @param x - The x-axis interval.\n * @param y - The y-axis interval.\n * @returns A new `Interval2d` instance.\n * @since 2.0.0\n */\nexport const make: <X extends Interval, Y extends Interval>(x: X, y: Y) => Interval2d<X, Y> =\n internal.make\n\n/**\n * Creates a closed `Interval2d` from two corner points. The corners can be in\n * any order — each axis is built from the min and max of the coordinate.\n *\n * @param p0 - The first corner.\n * @param p1 - The second corner.\n * @returns A new `Interval2d<Closed, Closed>` enclosing both corners.\n * @since 2.0.0\n */\nexport const fromCorners: (p0: Vector2, p1: Vector2) => Interval2d<Closed, Closed> =\n internal.fromCorners\n\n/**\n * Creates the smallest closed `Interval2d` enclosing the given points. Useful\n * for computing a bounding box from sampled points.\n *\n * @param points - One or more points to enclose.\n * @returns A new `Interval2d<Closed, Closed>` enclosing all input points.\n * @throws When called with zero points.\n * @since 2.0.0\n */\nexport const fromVectors: (...points: ReadonlyArray<Vector2>) => Interval2d<Closed, Closed> =\n internal.fromVectors\n\nexport const containsVector: {\n /**\n * Checks if a vector lies within the 2D interval. Per-axis endpoint\n * inclusivity follows each axis interval's `kind`.\n *\n * @param box - The 2D interval to test against.\n * @param v - The vector to test.\n * @returns `true` when the vector lies within the box on both axes.\n * @since 2.0.0\n */\n (box: Interval2d, v: Vector2): boolean\n /**\n * @param v - The vector to test.\n * @returns A function that takes a 2D interval and returns the containment result.\n * @since 2.0.0\n */\n (v: Vector2): (box: Interval2d) => boolean\n} = internal.containsVector\n\nexport const containsInterval2d: {\n /**\n * Checks if `inner` is a subset of `outer`. The check is per-axis interval\n * containment — for each axis, every point of the inner interval must also\n * be in the outer interval, respecting endpoint inclusivity on both sides.\n *\n * @param outer - The enclosing 2D interval.\n * @param inner - The candidate inner 2D interval.\n * @returns `true` when every point of `inner` is also in `outer`.\n * @since 2.0.0\n */\n (outer: Interval2d, inner: Interval2d): boolean\n /**\n * @param inner - The candidate inner 2D interval.\n * @returns A function that takes the outer 2D interval and returns the containment result.\n * @since 2.0.0\n */\n (inner: Interval2d): (outer: Interval2d) => boolean\n} = internal.containsInterval2d\n\n/**\n * Returns the size as a vector `(width, height)`. Accepts the broader\n * {@link Bounds2d} type because size does not depend on endpoint inclusivity.\n *\n * @param box - The 2D interval (or bounds-shaped value) to measure.\n * @returns The size as a `Vector2`.\n * @since 2.0.0\n */\nexport const size: (box: Bounds2d) => Vector2 = internal.size\n\nexport const union: {\n /**\n * Returns the smallest 2D interval enclosing both inputs.\n *\n * The per-axis return kind is determined by which input's endpoint wins on\n * each side, with the contributor's openness preserved (or unioned to\n * \"closed\" when endpoints are numerically equal and either is closed at\n * that point).\n *\n * When both inputs share the same kind on an axis, the result collapses\n * back to that kind. Otherwise the axis falls back to the open\n * {@link Interval} type since the runtime kind depends on the values.\n *\n * @param a - The first 2D interval.\n * @param b - The second 2D interval.\n * @returns A new `Interval2d` enclosing both inputs.\n * @since 2.0.0\n */\n <AX extends Interval, AY extends Interval, BX extends Interval, BY extends Interval>(\n a: Interval2d<AX, AY>,\n b: Interval2d<BX, BY>,\n ): Interval2d<\n AX extends BX ? (BX extends AX ? AX : Interval) : Interval,\n AY extends BY ? (BY extends AY ? AY : Interval) : Interval\n >\n /**\n * @param b - The second 2D interval.\n * @returns A function that takes the first 2D interval and returns the union.\n * @since 2.0.0\n */\n <BX extends Interval, BY extends Interval>(\n b: Interval2d<BX, BY>,\n ): <AX extends Interval, AY extends Interval>(\n a: Interval2d<AX, AY>,\n ) => Interval2d<\n AX extends BX ? (BX extends AX ? AX : Interval) : Interval,\n AY extends BY ? (BY extends AY ? AY : Interval) : Interval\n >\n} = internal.union\n\nexport const equals: {\n /**\n * Checks if two `Interval2d` values are approximately equal within the\n * default absolute tolerance ({@link EPSILON}). Both the numeric endpoints\n * AND the per-axis kinds must match.\n *\n * @param a - The first 2D interval.\n * @param b - The second 2D interval.\n * @returns `true` when both axes are equal.\n * @since 2.0.0\n */\n (a: Interval2d, b: Interval2d): boolean\n /**\n * @param b - The second 2D interval.\n * @returns A function that takes the first 2D interval and returns the comparison result.\n * @since 2.0.0\n */\n (b: Interval2d): (a: Interval2d) => boolean\n} = internal.equals\n\nexport const minDistance: {\n /**\n * Euclidean distance between the two closest points of two axis-aligned 2D\n * intervals. Returns `0` when the boxes overlap (including edge or corner\n * touching). Accepts the broader {@link Bounds2d} type — endpoint\n * inclusivity is not consulted, so a \"touching\" pair of open intervals still\n * returns `0` because the closest *points* coincide geometrically.\n *\n * @param a - The first 2D interval.\n * @param b - The second 2D interval.\n * @returns The minimum Euclidean distance between any point of `a` and any point of `b`.\n * @since 2.0.0\n */\n (a: Bounds2d, b: Bounds2d): number\n /**\n * @param b - The second 2D interval.\n * @returns A function that takes the first 2D interval and returns the minimum distance.\n * @since 2.0.0\n */\n (b: Bounds2d): (a: Bounds2d) => number\n} = internal.minDistance\n\nexport const maxDistance: {\n /**\n * Euclidean distance between the two farthest points of two axis-aligned 2D\n * intervals. Equals the diagonal of the union AABB enclosing both inputs.\n * Accepts the broader {@link Bounds2d} type — endpoint inclusivity is not\n * consulted.\n *\n * @param a - The first 2D interval.\n * @param b - The second 2D interval.\n * @returns The maximum Euclidean distance between any point of `a` and any point of `b`.\n * @since 2.0.0\n */\n (a: Bounds2d, b: Bounds2d): number\n /**\n * @param b - The second 2D interval.\n * @returns A function that takes the first 2D interval and returns the maximum distance.\n * @since 2.0.0\n */\n (b: Bounds2d): (a: Bounds2d) => number\n} = internal.maxDistance\n"],"mappings":";;;;;AAKA,MAAa,mBAAkC,OAAO,4BAA4B;AAGlF,IAAM,iBAAN,cACU,SAEV;CACE,CAAU,oBAAsC;CAEhD;CACA;CAEA,YAAY,GAAM,GAAM;EACtB,OAAO;EACP,KAAK,IAAI;EACT,KAAK,IAAI;;CAGX,KAAK,OAAO,eAAe;EACzB,OAAO,cAAc,OAAO,KAAK,EAAE,CAAC,KAAK,OAAO,KAAK,EAAE,CAAC;;CAG1D,KAAK,OAAO,IAAI,6BAA6B,IAAI;EAC/C,OAAO,KAAK,OAAO;;;;AAKvB,MAAaA,kBAAgB,MAC3B,OAAO,MAAM,YAAY,MAAM,QAAQ,oBAAoB;;AAG7D,MAAaC,UACX,GACA,MACqB,IAAI,eAAe,GAAG,EAAE;;AAG/C,MAAaC,iBACX,IACA,OAEA,IAAI,eAAeC,WAAoB,GAAG,GAAG,GAAG,EAAE,EAAEA,WAAoB,GAAG,GAAG,GAAG,EAAE,CAAC;;AAGtF,MAAaC,iBACX,GAAG,WAC8C;CACjD,UAAU,OAAO,SAAS,GAAG,0CAA0C;CACvE,MAAM,KAAoB,EAAE;CAC5B,MAAM,KAAoB,EAAE;CAC5B,KAAK,MAAM,KAAK,QAAQ;EACtB,GAAG,KAAK,EAAE,EAAE;EACZ,GAAG,KAAK,EAAE,EAAE;;CAEd,OAAO,IAAI,eAAe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;;;;;;;;;AAUJ,MAAa,OAAmCC;AAEhD,MAAa,QAsCTC;AAEJ,MAAa,SAkBTC;AAEJ,MAAa,cAoBTC;AAEJ,MAAa,cAmBTC"}
@@ -0,0 +1,34 @@
1
+ import { t as __exportAll } from "./chunk-25Hzd3z8.mjs";
2
+ //#region src/monotonicity/monotonicity.ts
3
+ var monotonicity_exports = /* @__PURE__ */ __exportAll({
4
+ Constant: () => 0,
5
+ Decreasing: () => 2,
6
+ Increasing: () => 1,
7
+ None: () => 3,
8
+ fromComparison: () => fromComparison,
9
+ isStrict: () => isStrict
10
+ });
11
+ /**
12
+ * Type-narrowing predicate: refines a `Monotonicity` to `Increasing |
13
+ * Decreasing` — the strict cases that admit a unique inverse.
14
+ *
15
+ * @param m - The monotonicity classification.
16
+ * @returns `true` when `m` is `Increasing` or `Decreasing`.
17
+ * @since 2.0.0
18
+ */
19
+ const isStrict = (m) => m === 1 || m === 2;
20
+ /**
21
+ * Classifies the monotonicity of a function given its values at two interval
22
+ * endpoints, when the function is known a priori to be monotonic on the
23
+ * spanning interval (e.g. a linear polynomial).
24
+ *
25
+ * @param s0 - The function value at the start of the interval.
26
+ * @param s1 - The function value at the end of the interval.
27
+ * @returns The classification — `Increasing`, `Decreasing`, or `Constant`.
28
+ * @since 2.0.0
29
+ */
30
+ const fromComparison = (s0, s1) => s0 < s1 ? 1 : s0 > s1 ? 2 : 0;
31
+ //#endregion
32
+ export { isStrict as n, monotonicity_exports as r, fromComparison as t };
33
+
34
+ //# sourceMappingURL=monotonicity-BdebFOtv.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monotonicity-BdebFOtv.mjs","names":[],"sources":["../../src/monotonicity/monotonicity.ts"],"sourcesContent":["/**\n * Classification of a function's monotonicity on an interval.\n *\n * Encoded as a 2-bit sign-coverage bitmask of the function's derivative:\n * - bit 0 (`Increasing`) — derivative takes positive values\n * - bit 1 (`Decreasing`) — derivative takes negative values\n *\n * The four states fall out of the encoding:\n *\n * | value | name | derivative on the interval |\n * |-------|--------------|-----------------------------------|\n * | `0` | `Constant` | ≡ 0 |\n * | `1` | `Increasing` | ≥ 0, with at least one `> 0` |\n * | `2` | `Decreasing` | ≤ 0, with at least one `< 0` |\n * | `3` | `None` | crosses zero |\n *\n * The numeric encoding is principled, not arbitrary: the bitwise OR of two\n * adjacent subintervals' classifications gives the classification of their\n * union, which lets monotonicity be computed by recursive subdivision\n * without any custom combine logic.\n *\n * @since 2.0.0\n */\nexport type Monotonicity = 0 | 1 | 2 | 3\n\n/**\n * Subset of {@link Monotonicity} excluding the indeterminate `None` state.\n * Returned by classifiers operating on functions whose derivative cannot\n * change sign on the interval (e.g. linear polynomials, whose derivative is\n * constant).\n *\n * @since 2.0.0\n */\nexport type GuaranteedMonotonicity = 0 | 1 | 2\n\n/**\n * Derivative is identically zero on the interval. The function is constant.\n *\n * @since 2.0.0\n */\nexport const Constant = 0 as const\n\n/**\n * Derivative is non-negative on the interval with at least one strictly\n * positive sample. The function is strictly increasing.\n *\n * @since 2.0.0\n */\nexport const Increasing = 1 as const\n\n/**\n * Derivative is non-positive on the interval with at least one strictly\n * negative sample. The function is strictly decreasing.\n *\n * @since 2.0.0\n */\nexport const Decreasing = 2 as const\n\n/**\n * Derivative crosses zero on the interval. The function has at least one\n * interior extremum and is not monotonic in either direction.\n *\n * @since 2.0.0\n */\nexport const None = 3 as const\n\n/**\n * Type-narrowing predicate: refines a `Monotonicity` to `Increasing |\n * Decreasing` — the strict cases that admit a unique inverse.\n *\n * @param m - The monotonicity classification.\n * @returns `true` when `m` is `Increasing` or `Decreasing`.\n * @since 2.0.0\n */\nexport const isStrict = (m: Monotonicity): m is 1 | 2 => m === Increasing || m === Decreasing\n\n/**\n * Classifies the monotonicity of a function given its values at two interval\n * endpoints, when the function is known a priori to be monotonic on the\n * spanning interval (e.g. a linear polynomial).\n *\n * @param s0 - The function value at the start of the interval.\n * @param s1 - The function value at the end of the interval.\n * @returns The classification — `Increasing`, `Decreasing`, or `Constant`.\n * @since 2.0.0\n */\nexport const fromComparison = (s0: number, s1: number): GuaranteedMonotonicity =>\n s0 < s1 ? Increasing : s0 > s1 ? Decreasing : Constant\n"],"mappings":";;;;;;;;;;;;;;;;;;AA0EA,MAAa,YAAY,MAAgC,MAAA,KAAoB,MAAA;;;;;;;;;;;AAY7E,MAAa,kBAAkB,IAAY,OACzC,KAAK,KAAA,IAAkB,KAAK,KAAA,IAAA"}
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./chunk-25Hzd3z8.mjs";
2
- import { $ as equals$3, At as isLinearPolynomial$1, Bt as unitRange$2, Ct as domain$2, Dt as fromVector$2, Et as fromPoints$2, Ft as range$2, G as antiderivative$3, It as solve$2, J as asMonotonic$3, K as asDecreasing$3, Lt as solveInverse$2, Mt as length$2, Nt as make$2, Ot as isDecreasing$2, Pt as monotonicity$2, Q as domain$3, Rt as toInverseSolver$2, St as derivative$2, Tt as fromPointSlope$1, X as curvature$1, Y as coefficients$3, Z as derivative$3, _t as antiderivative$2, at as isMonotonic$3, bt as asMonotonic$2, ct as make$3, dt as roots$1, et as extreme$1, ft as solve$3, gt as unitRange$3, ht as toSolver$3, it as isIncreasing$3, jt as isMonotonic$2, kt as isIncreasing$2, lt as monotonicity$3, mt as toInverseSolver$3, nt as fromVector$3, ot as isQuadraticPolynomial$1, pt as solveInverse$3, q as asIncreasing$3, rt as isDecreasing$3, st as length$3, tt as fromPoints$3, ut as range$3, vt as asDecreasing$2, wt as equals$2, xt as coefficients$2, yt as asIncreasing$2, zt as toSolver$2 } from "./cubic-DHJrzZJN.mjs";
2
+ import { $ as equals$3, At as isLinearPolynomial$1, Bt as unitRange$2, Ct as domain$2, Dt as fromVector$2, Et as fromPoints$2, Ft as range$2, G as antiderivative$3, It as solve$2, J as asMonotonic$3, K as asDecreasing$3, Lt as solveInverse$2, Mt as length$2, Nt as make$2, Ot as isDecreasing$2, Pt as monotonicity$2, Q as domain$3, Rt as toInverseSolver$2, St as derivative$2, Tt as fromPointSlope$1, X as curvature$1, Y as coefficients$3, Z as derivative$3, _t as antiderivative$2, at as isMonotonic$3, bt as asMonotonic$2, ct as make$3, dt as roots$1, et as extreme$1, ft as solve$3, gt as unitRange$3, ht as toSolver$3, it as isIncreasing$3, jt as isMonotonic$2, kt as isIncreasing$2, lt as monotonicity$3, mt as toInverseSolver$3, nt as fromVector$3, ot as isQuadraticPolynomial$1, pt as solveInverse$3, q as asIncreasing$3, rt as isDecreasing$3, st as length$3, tt as fromPoints$3, ut as range$3, vt as asDecreasing$2, wt as equals$2, xt as coefficients$2, yt as asIncreasing$2, zt as toSolver$2 } from "./cubic-BL6dpuHh.mjs";
3
3
  //#region src/polynomial/linear.ts
4
4
  var linear_exports = /* @__PURE__ */ __exportAll({
5
5
  antiderivative: () => antiderivative$1,
@@ -109,7 +109,7 @@ const monotonicity$1 = monotonicity$2;
109
109
  * `LinearPolynomial<T & Monotonic>` when the polynomial is strictly monotonic.
110
110
  *
111
111
  * @param p - The linear polynomial to check.
112
- * @returns `true` when `monotonicity(p)` is `'increasing'` or `'decreasing'`.
112
+ * @returns `true` when `monotonicity(p)` is `Increasing` or `Decreasing`.
113
113
  * @since 2.0.0
114
114
  */
115
115
  const isMonotonic$1 = isMonotonic$2;
@@ -117,7 +117,7 @@ const isMonotonic$1 = isMonotonic$2;
117
117
  * Type-narrowing predicate: refines to `LinearPolynomial<T & Increasing>`.
118
118
  *
119
119
  * @param p - The linear polynomial to check.
120
- * @returns `true` when `monotonicity(p)` is `'increasing'`.
120
+ * @returns `true` when `monotonicity(p)` is `Increasing`.
121
121
  * @since 2.0.0
122
122
  */
123
123
  const isIncreasing$1 = isIncreasing$2;
@@ -125,7 +125,7 @@ const isIncreasing$1 = isIncreasing$2;
125
125
  * Type-narrowing predicate: refines to `LinearPolynomial<T & Decreasing>`.
126
126
  *
127
127
  * @param p - The linear polynomial to check.
128
- * @returns `true` when `monotonicity(p)` is `'decreasing'`.
128
+ * @returns `true` when `monotonicity(p)` is `Decreasing`.
129
129
  * @since 2.0.0
130
130
  */
131
131
  const isDecreasing$1 = isDecreasing$2;
@@ -134,7 +134,7 @@ const isDecreasing$1 = isDecreasing$2;
134
134
  *
135
135
  * @param p - The linear polynomial to assert against.
136
136
  * @returns The same polynomial, typed with the `Monotonic` brand.
137
- * @throws When `monotonicity(p)` is `'constant'`.
137
+ * @throws When `monotonicity(p)` is `Constant`.
138
138
  * @since 2.0.0
139
139
  */
140
140
  const asMonotonic$1 = asMonotonic$2;
@@ -143,7 +143,7 @@ const asMonotonic$1 = asMonotonic$2;
143
143
  *
144
144
  * @param p - The linear polynomial to assert against.
145
145
  * @returns The same polynomial, typed with the `Increasing` brand.
146
- * @throws When `monotonicity(p)` is not `'increasing'`.
146
+ * @throws When `monotonicity(p)` is not `Increasing`.
147
147
  * @since 2.0.0
148
148
  */
149
149
  const asIncreasing$1 = asIncreasing$2;
@@ -152,7 +152,7 @@ const asIncreasing$1 = asIncreasing$2;
152
152
  *
153
153
  * @param p - The linear polynomial to assert against.
154
154
  * @returns The same polynomial, typed with the `Decreasing` brand.
155
- * @throws When `monotonicity(p)` is not `'decreasing'`.
155
+ * @throws When `monotonicity(p)` is not `Decreasing`.
156
156
  * @since 2.0.0
157
157
  */
158
158
  const asDecreasing$1 = asDecreasing$2;
@@ -311,7 +311,7 @@ const monotonicity = monotonicity$3;
311
311
  *
312
312
  * @param p - The quadratic polynomial to check.
313
313
  * @param i - Optional interval over which to check monotonicity.
314
- * @returns `true` when monotonicity is `'increasing'` or `'decreasing'`.
314
+ * @returns `true` when monotonicity is `Increasing` or `Decreasing`.
315
315
  * @since 2.0.0
316
316
  */
317
317
  const isMonotonic = isMonotonic$3;
@@ -367,4 +367,4 @@ const curvature = curvature$1;
367
367
  //#endregion
368
368
  export { unitRange$1 as _, make as a, solveInverse as c, isIncreasing$1 as d, isMonotonic$1 as f, solveInverse$1 as g, solve$1 as h, isMonotonic as i, unitRange as l, make$1 as m, isDecreasing as n, quadratic_exports as o, linear_exports as p, isIncreasing as r, solve as s, derivative as t, isDecreasing$1 as u };
369
369
 
370
- //# sourceMappingURL=quadratic-BZmfZE71.mjs.map
370
+ //# sourceMappingURL=quadratic-DPrUsFCp.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quadratic-DPrUsFCp.mjs","names":["internal.isLinearPolynomial","equals","internal.equals","make","internal.make","fromVector","internal.fromVector","internal.fromPointSlope","fromPoints","internal.fromPoints","solve","internal.solve","toSolver","internal.toSolver","solveInverse","internal.solveInverse","toInverseSolver","internal.toInverseSolver","monotonicity","internal.monotonicity","isMonotonic","internal.isMonotonic","isIncreasing","internal.isIncreasing","isDecreasing","internal.isDecreasing","asMonotonic","internal.asMonotonic","asIncreasing","internal.asIncreasing","asDecreasing","internal.asDecreasing","coefficients","internal.coefficients","derivative","internal.derivative","antiderivative","internal.antiderivative","domain","internal.domain","range","internal.range","unitRange","internal.unitRange","length","internal.length","internal.isQuadraticPolynomial","internal.equals","internal.make","internal.fromVector","internal.fromPoints","internal.solve","internal.toSolver","internal.solveInverse","internal.toInverseSolver","internal.coefficients","internal.derivative","internal.roots","internal.extreme","internal.monotonicity","internal.isMonotonic","internal.isIncreasing","internal.isDecreasing","internal.asMonotonic","internal.asIncreasing","internal.asDecreasing","internal.antiderivative","internal.domain","internal.range","internal.unitRange","internal.length","internal.curvature"],"sources":["../../src/polynomial/linear.ts","../../src/polynomial/quadratic.ts"],"sourcesContent":["import type { Closed, Interval } from '../interval/interval.ts'\nimport type { Pipeable } from '../utils.ts'\nimport type * as Solution from '../solution/solution.ts'\nimport type { Vector2 } from '../vector/vector2.ts'\nimport type { LinearPolynomialTypeId } from './linear.internal.ts'\nimport * as internal from './linear.internal.ts'\nimport type { GuaranteedMonotonicity } from '../monotonicity/monotonicity.ts'\nimport type { QuadraticPolynomial } from './quadratic.ts'\nimport type { Decreasing, Increasing, Monotonic, PolynomialTraits } from './traits.ts'\n\nexport type { Monotonic, Increasing, Decreasing } from './traits.ts'\n\n/**\n * A linear polynomial.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * The `Traits` type parameter is a phantom marker that accumulates trait\n * brands as the polynomial is refined via `isMonotonic` / `asMonotonic` and\n * friends. The runtime value carries no trait data — `Traits` only flows\n * through the type system to enable tighter return types on operations like\n * `solveInverse`.\n *\n * @since 1.0.0\n */\nexport interface LinearPolynomial<out Traits = unknown> extends Pipeable {\n readonly [LinearPolynomialTypeId]: LinearPolynomialTypeId\n readonly [PolynomialTraits]: Traits\n\n /**\n * The coefficient of the x^0 term.\n */\n readonly c0: number\n\n /**\n * The coefficient of the x^1 term.\n */\n readonly c1: number\n}\n\n/**\n * Checks if a value is a `LinearPolynomial`.\n *\n * @param v - The value to check.\n * @returns `true` if the value is a `LinearPolynomial`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isLinearPolynomial: (v: unknown) => v is LinearPolynomial = internal.isLinearPolynomial\n\nexport const equals: {\n /**\n * Checks if two `LinearPolynomial` instances are approximately equal within\n * the default absolute tolerance ({@link EPSILON}).\n *\n * @param a - The first polynomial.\n * @param b - The second polynomial.\n * @returns `true` when each pair of coefficients is within tolerance.\n * @since 1.1.0\n */\n (a: LinearPolynomial, b: LinearPolynomial): boolean\n /**\n * Checks if two `LinearPolynomial` instances are approximately equal within\n * the default absolute tolerance ({@link EPSILON}).\n *\n * @param b - The second polynomial.\n * @returns A function that takes the first polynomial and returns the comparison result.\n * @since 1.1.0\n */\n (b: LinearPolynomial): (a: LinearPolynomial) => boolean\n} = internal.equals\n\n/**\n * Creates a new `LinearPolynomial` instance.\n *\n * @param c0 - The coefficient of the x^0 term. Defaults to 0.\n * @param c1 - The coefficient of the x^1 term. Defaults to 0.\n * @returns A new `LinearPolynomial` instance.\n * @since 1.0.0\n */\nexport const make: (c0?: number, c1?: number) => LinearPolynomial = internal.make\n\n/**\n * Creates a new `LinearPolynomial` instance from a vector.\n *\n * @param v - The vector to create the polynomial from.\n * @returns A new `LinearPolynomial` instance.\n * @since 1.0.0\n */\nexport const fromVector: (v: Vector2) => LinearPolynomial = internal.fromVector\n\n/**\n * Creates a new `LinearPolynomial` instance from a point and slope.\n *\n * @param p - The point on the line.\n * @param slope - The slope of the line.\n * @returns A new `LinearPolynomial` instance.\n * @since 1.0.0\n */\nexport const fromPointSlope: (p: Vector2, slope: number) => LinearPolynomial =\n internal.fromPointSlope\n\n/**\n * Creates a new `LinearPolynomial` instance from two points.\n *\n * @param p1 - The first point.\n * @param p2 - The second point.\n * @returns A new `LinearPolynomial` instance.\n * @since 1.0.0\n */\nexport const fromPoints: (p1: Vector2, p2: Vector2) => LinearPolynomial = internal.fromPoints\n\nexport const solve: {\n /**\n * Solves a linear polynomial for a given value of x.\n *\n * @param p - The linear polynomial to solve.\n * @param x - The value of x to solve for.\n * @returns The result of the polynomial evaluated at x.\n * @since 1.0.0\n */\n (p: LinearPolynomial, x: number): number\n /**\n * Solves a linear polynomial for a given value of x.\n *\n * @param x - The value of x to solve for.\n * @returns A function that takes a `LinearPolynomial` and returns the result of the polynomial evaluated at x.\n * @since 1.0.0\n */\n (x: number): (p: LinearPolynomial) => number\n} = internal.solve\n\n/**\n * Converts a linear polynomial to a solver function.\n *\n * @param p - The linear polynomial to convert.\n * @returns A function that takes a value of x and returns the result of the polynomial evaluated at x.\n * @since 1.0.0\n */\nexport const toSolver: (p: LinearPolynomial) => (x: number) => number = internal.toSolver\n\n// The implementation always runs the same `c1 === 0 ? Solution.none : ...`\n// branch. For `Monotonic`-branded polynomials the empty branch is provably\n// unreachable, but TS can't see that — the cast pairs the type-level promise\n// with the runtime brand check.\nexport const solveInverse: {\n /**\n * Solves a monotonic linear polynomial for a given value of y. Because the\n * polynomial is strictly monotonic, the inverse always has exactly one\n * solution — wrapped in `Solution.One`.\n *\n * @param p - The monotonic linear polynomial to solve.\n * @param y - The value of y to solve for.\n * @since 2.0.0\n */\n <T extends Monotonic>(p: LinearPolynomial<T>, y: number): Solution.One<number>\n /**\n * Solves a linear polynomial for a given value of y. Returns `Solution.none`\n * for constant polynomials (no inverse).\n *\n * @param p - The linear polynomial to solve.\n * @param y - The value of y to solve for.\n * @since 1.0.0\n */\n <T>(p: LinearPolynomial<T>, y: number): Solution.AtMostOne<number>\n /** @since 1.0.0 */\n (y: number): {\n <T extends Monotonic>(p: LinearPolynomial<T>): Solution.One<number>\n <T>(p: LinearPolynomial<T>): Solution.AtMostOne<number>\n }\n} = internal.solveInverse as never\n\n/**\n * Converts a linear polynomial to an inverse solver function.\n *\n * @param p - The linear polynomial to convert.\n * @since 1.0.0\n */\nexport const toInverseSolver: (p: LinearPolynomial) => (y: number) => Solution.AtMostOne<number> =\n internal.toInverseSolver\n\n/**\n * Finds the roots of a linear polynomial.\n *\n * @param p - The linear polynomial to find the roots of.\n * @since 1.0.0\n */\nexport const root: (p: LinearPolynomial) => Solution.AtMostOne<number> = (p) =>\n internal.solveInverse(p, 0)\n\n/**\n * Calculates the monotonicity of a linear polynomial.\n *\n * @param p - The linear polynomial to check.\n * @returns The guaranteed monotonicity of the polynomial.\n * @since 1.0.0\n */\nexport const monotonicity: (p: LinearPolynomial) => GuaranteedMonotonicity = internal.monotonicity\n\n/**\n * Type-narrowing predicate: refines a `LinearPolynomial<T>` to\n * `LinearPolynomial<T & Monotonic>` when the polynomial is strictly monotonic.\n *\n * @param p - The linear polynomial to check.\n * @returns `true` when `monotonicity(p)` is `Increasing` or `Decreasing`.\n * @since 2.0.0\n */\nexport const isMonotonic: <T>(p: LinearPolynomial<T>) => p is LinearPolynomial<T & Monotonic> =\n internal.isMonotonic\n\n/**\n * Type-narrowing predicate: refines to `LinearPolynomial<T & Increasing>`.\n *\n * @param p - The linear polynomial to check.\n * @returns `true` when `monotonicity(p)` is `Increasing`.\n * @since 2.0.0\n */\nexport const isIncreasing: <T>(p: LinearPolynomial<T>) => p is LinearPolynomial<T & Increasing> =\n internal.isIncreasing\n\n/**\n * Type-narrowing predicate: refines to `LinearPolynomial<T & Decreasing>`.\n *\n * @param p - The linear polynomial to check.\n * @returns `true` when `monotonicity(p)` is `Decreasing`.\n * @since 2.0.0\n */\nexport const isDecreasing: <T>(p: LinearPolynomial<T>) => p is LinearPolynomial<T & Decreasing> =\n internal.isDecreasing\n\n/**\n * Asserts that the linear polynomial is monotonic, throwing on failure.\n *\n * @param p - The linear polynomial to assert against.\n * @returns The same polynomial, typed with the `Monotonic` brand.\n * @throws When `monotonicity(p)` is `Constant`.\n * @since 2.0.0\n */\nexport const asMonotonic: <T>(p: LinearPolynomial<T>) => LinearPolynomial<T & Monotonic> =\n internal.asMonotonic\n\n/**\n * Asserts that the linear polynomial is increasing, throwing on failure.\n *\n * @param p - The linear polynomial to assert against.\n * @returns The same polynomial, typed with the `Increasing` brand.\n * @throws When `monotonicity(p)` is not `Increasing`.\n * @since 2.0.0\n */\nexport const asIncreasing: <T>(p: LinearPolynomial<T>) => LinearPolynomial<T & Increasing> =\n internal.asIncreasing\n\n/**\n * Asserts that the linear polynomial is decreasing, throwing on failure.\n *\n * @param p - The linear polynomial to assert against.\n * @returns The same polynomial, typed with the `Decreasing` brand.\n * @throws When `monotonicity(p)` is not `Decreasing`.\n * @since 2.0.0\n */\nexport const asDecreasing: <T>(p: LinearPolynomial<T>) => LinearPolynomial<T & Decreasing> =\n internal.asDecreasing\n\n/**\n * Returns the polynomial's coefficients as a tuple `[c0, c1]`.\n *\n * @param p - The linear polynomial.\n * @returns The coefficients in monomial order.\n * @since 2.0.0\n */\nexport const coefficients: (p: LinearPolynomial) => readonly [number, number] =\n internal.coefficients\n\n/**\n * Calculates the derivative of a linear polynomial.\n *\n * @param p - The linear polynomial to differentiate.\n * @returns The derivative of the linear polynomial.\n * @since 1.0.0\n */\nexport const derivative: (p: LinearPolynomial) => number = internal.derivative\n\nexport const antiderivative: {\n /**\n * Calculates the antiderivative of a linear polynomial.\n *\n * @param p - The linear polynomial to integrate.\n * @param constant - The constant of integration. Defaults to 0.\n * @returns The antiderivative of the linear polynomial.\n * @since 1.0.0\n */\n (p: LinearPolynomial, constant?: number): QuadraticPolynomial\n /**\n * Calculates the antiderivative of a linear polynomial.\n *\n * @param constant - The constant of integration. Defaults to 0.\n * @returns A function that takes a `LinearPolynomial` and returns the antiderivative of the polynomial.\n * @since 1.0.0\n */\n (constant: number): (p: LinearPolynomial) => QuadraticPolynomial\n} = internal.antiderivative\n\nexport const domain: {\n /**\n * Calculates the domain of a linear polynomial.\n *\n * @param p - The linear polynomial to check.\n * @param range - The range to check against.\n * @returns The domain of the polynomial within the given range.\n * @since 1.0.0\n */\n (p: LinearPolynomial, range: Interval): Solution.AtMostOne<Interval>\n /**\n * Calculates the domain of a linear polynomial.\n *\n * @param range - The range to check against.\n * @returns A function that takes a `LinearPolynomial` and returns the domain of the polynomial within the given range.\n * @since 1.0.0\n */\n (range: Interval): (p: LinearPolynomial) => Solution.AtMostOne<Interval>\n} = internal.domain\n\nexport const range: {\n /**\n * Calculates the range of a linear polynomial.\n *\n * @param p - The linear polynomial to check.\n * @param domain - The domain to check against.\n * @returns The range of the polynomial within the given domain.\n * @since 1.0.0\n */\n (p: LinearPolynomial, domain: Interval): Closed\n /**\n * Calculates the range of a linear polynomial.\n *\n * @param domain - The domain to check against.\n * @returns A function that takes a `LinearPolynomial` and returns the range of the polynomial within the given domain.\n * @since 1.0.0\n */\n (domain: Interval): (p: LinearPolynomial) => Closed\n} = internal.range\n\n/**\n * Calculates the range of a linear polynomial over the unit interval `[0, 1]`.\n * Equivalent to `range(p, Interval.unit)` but without the import and call\n * overhead — directly evaluates the endpoints.\n *\n * @param p - The linear polynomial.\n * @returns The closed range of the polynomial over `[0, 1]`.\n * @since 2.0.0\n */\nexport const unitRange: (p: LinearPolynomial) => Closed = internal.unitRange\n\nexport const length: {\n /**\n * Calculates the length of a linear polynomial within a particular domain `Interval`.\n *\n * @param p - The linear polynomial to analyze.\n * @param domain - The domain to restrict the analysis to.\n * @returns The length of the linear polynomial in the specified domain.\n * @since 1.0.0\n */\n (p: LinearPolynomial, domain: Interval): number\n /**\n * Calculates the length of a linear polynomial within a particular domain `Interval`.\n *\n * @param domain - The domain to restrict the analysis to.\n * @returns A function that takes a `LinearPolynomial` and returns the length of the polynomial in the specified domain.\n * @since 1.0.0\n */\n (domain: Interval): (p: LinearPolynomial) => number\n} = internal.length\n","import type { Closed, Interval } from '../interval/interval.ts'\nimport type { Pipeable } from '../utils.ts'\nimport type * as Solution from '../solution/solution.ts'\nimport type { Vector2 } from '../vector/vector2.ts'\nimport type { Vector3 } from '../vector/vector3.ts'\nimport type { CubicPolynomial } from './cubic.ts'\nimport type { LinearPolynomial } from './linear.ts'\nimport type { Monotonicity } from '../monotonicity/monotonicity.ts'\nimport * as internal from './quadratic.internal.ts'\nimport type { QuadraticPolynomialTypeId } from './quadratic.internal.circular.ts'\nimport type { Decreasing, Increasing, Monotonic, PolynomialTraits } from './traits.ts'\n\nexport type { Monotonic, Increasing, Decreasing } from './traits.ts'\n\n/**\n * A quadratic polynomial.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * The `Traits` type parameter is a phantom marker that accumulates trait\n * brands as the polynomial is refined via `isMonotonic` / `asMonotonic` and\n * friends. Refinements may be parameterized by an `Interval` — a quadratic is\n * monotonic on an interval that avoids its extremum, even though it is not\n * monotonic globally.\n *\n * @since 1.0.0\n */\nexport interface QuadraticPolynomial<out Traits = unknown> extends Pipeable {\n readonly [QuadraticPolynomialTypeId]: QuadraticPolynomialTypeId\n readonly [PolynomialTraits]: Traits\n\n /**\n * The coefficient of the x^0 term.\n */\n readonly c0: number\n /**\n * The coefficient of the x^1 term.\n */\n readonly c1: number\n /**\n * The coefficient of the x^2 term.\n */\n readonly c2: number\n}\n\n/**\n * Checks if a value is a `QuadraticPolynomial`.\n *\n * @param v - The value to check.\n * @returns `true` if the value is a `QuadraticPolynomial`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isQuadraticPolynomial: (v: unknown) => v is QuadraticPolynomial =\n internal.isQuadraticPolynomial\n\nexport const equals: {\n /**\n * Checks if two `QuadraticPolynomial` instances are approximately equal\n * within the default absolute tolerance ({@link EPSILON}).\n *\n * @param a - The first polynomial.\n * @param b - The second polynomial.\n * @returns `true` when each pair of coefficients is within tolerance.\n * @since 1.1.0\n */\n (a: QuadraticPolynomial, b: QuadraticPolynomial): boolean\n /**\n * Checks if two `QuadraticPolynomial` instances are approximately equal\n * within the default absolute tolerance ({@link EPSILON}).\n *\n * @param b - The second polynomial.\n * @returns A function that takes the first polynomial and returns the comparison result.\n * @since 1.1.0\n */\n (b: QuadraticPolynomial): (a: QuadraticPolynomial) => boolean\n} = internal.equals\n\n/**\n * Creates a new `QuadraticPolynomial` instance.\n *\n * @param c0 - The coefficient of the x^0 term. Defaults to 0.\n * @param c1 - The coefficient of the x^1 term. Defaults to 0.\n * @param c2 - The coefficient of the x^2 term. Defaults to 1.\n * @returns A new `QuadraticPolynomial` instance.\n * @since 1.0.0\n */\nexport const make: (c0?: number, c1?: number, c2?: number) => QuadraticPolynomial = internal.make\n\n/**\n * Creates a new `QuadraticPolynomial` instance from a vector.\n *\n * @param v - The vector to create the polynomial from.\n * @returns A new `QuadraticPolynomial` instance.\n * @since 1.0.0\n */\nexport const fromVector: (v: Vector3) => QuadraticPolynomial = internal.fromVector\n\n/**\n * Creates a new `QuadraticPolynomial` that interpolates the three given\n * points, treating each `Vector2` as an `(x, y)` pair. The three input `x`\n * values must be distinct.\n *\n * @param p0 - The first point.\n * @param p1 - The second point.\n * @param p2 - The third point.\n * @returns The unique quadratic polynomial passing through the three points.\n * @since 2.0.0\n */\nexport const fromPoints: (p0: Vector2, p1: Vector2, p2: Vector2) => QuadraticPolynomial =\n internal.fromPoints\n\nexport const solve: {\n /**\n * Solves the quadratic polynomial for a given x value.\n *\n * @param p - The quadratic polynomial.\n * @param x - The x value to solve for.\n * @returns The result of the polynomial at the given x value.\n * @since 1.0.0\n */\n (p: QuadraticPolynomial, x: number): number\n /**\n * Solves the quadratic polynomial for a given x value.\n *\n * @param x - The x value to solve for.\n * @returns A function that takes a quadratic polynomial and returns the result of the polynomial at the given x value.\n * @since 1.0.0\n */\n (x: number): (p: QuadraticPolynomial) => number\n} = internal.solve\n\n/**\n * Creates a solver function for the quadratic polynomial.\n *\n * @param p - The quadratic polynomial.\n * @returns A function that takes an x value and returns the result of the polynomial at that x value.\n */\nexport const toSolver: (p: QuadraticPolynomial) => (x: number) => number = internal.toSolver\n\nexport const solveInverse: {\n /**\n * Solves a monotonic quadratic polynomial for a given y value. Because the\n * polynomial is strictly monotonic (either globally, or over the interval\n * the `Monotonic` brand was attached for), the inverse has at most one\n * solution.\n *\n * @param p - The monotonic quadratic polynomial.\n * @param y - The y value to solve for.\n * @returns Zero or one solutions.\n * @since 2.0.0\n */\n <T extends Monotonic>(p: QuadraticPolynomial<T>, y: number): Solution.AtMostOne<number>\n /**\n * Solves the quadratic polynomial for a given y value.\n *\n * @param p - The quadratic polynomial.\n * @param y - The y value to solve for.\n * @returns The solutions to the polynomial at the given y value.\n * @since 1.0.0\n */\n <T>(p: QuadraticPolynomial<T>, y: number): Solution.AtMostTwo<number>\n /**\n * Solves the quadratic polynomial for a given y value.\n *\n * @param y - The y value to solve for.\n * @returns A function that takes a quadratic polynomial and returns the\n * solutions. Tightens to `Solution.AtMostOne<number>` for monotonic inputs.\n * @since 1.0.0\n */\n (y: number): {\n <T extends Monotonic>(p: QuadraticPolynomial<T>): Solution.AtMostOne<number>\n <T>(p: QuadraticPolynomial<T>): Solution.AtMostTwo<number>\n }\n} = internal.solveInverse as never\n\n/**\n * Creates an inverse solver function for the quadratic polynomial.\n *\n * @param p - The quadratic polynomial.\n * @returns A function that takes a y value and returns the solutions to the polynomial at that y value.\n */\nexport const toInverseSolver: (\n p: QuadraticPolynomial,\n) => (y: number) => Solution.AtMostTwo<number> = internal.toInverseSolver\n\n/**\n * Returns the polynomial's coefficients as a tuple `[c0, c1, c2]`.\n *\n * @param p - The quadratic polynomial.\n * @returns The coefficients in monomial order.\n * @since 2.0.0\n */\nexport const coefficients: (p: QuadraticPolynomial) => readonly [number, number, number] =\n internal.coefficients\n\n/**\n * Computes the derivative of the quadratic polynomial.\n *\n * @param p - The quadratic polynomial.\n * @returns The derivative of the polynomial as a linear polynomial.\n * @since 1.0.0\n */\nexport const derivative: (p: QuadraticPolynomial) => LinearPolynomial = internal.derivative\n\n/**\n * Finds the roots of the quadratic polynomial.\n *\n * @param p - The quadratic polynomial.\n * @returns The roots of the polynomial as a tuple of solutions.\n * @since 1.0.0\n */\nexport const roots: (p: QuadraticPolynomial) => Solution.AtMostTwo<number> = internal.roots\n\n/**\n * Finds the extreme point of the quadratic polynomial.\n *\n * @param p - The quadratic polynomial.\n * @returns The extreme point of the polynomial as a solution.\n * @since 1.0.0\n */\nexport const extreme: (p: QuadraticPolynomial) => Vector2 | null = internal.extreme\n\nexport const monotonicity: {\n /**\n * Computes the monotonicity of the quadratic polynomial over a given\n * interval. Throws when the interval has zero width — the question is\n * undefined at a single point.\n *\n * @param p - The quadratic polynomial.\n * @param i - The interval to compute the monotonicity over.\n * @returns The monotonicity of the polynomial over the interval.\n * @since 1.0.0\n */\n (p: QuadraticPolynomial, i?: Interval): Monotonicity\n /**\n * Computes the monotonicity of the quadratic polynomial over a given\n * interval. Throws when the interval has zero width.\n *\n * @param i - The interval to compute the monotonicity over.\n * @returns A function that takes a quadratic polynomial and returns the\n * monotonicity of the polynomial over the interval.\n * @since 1.0.0\n */\n (i: Interval): (p: QuadraticPolynomial) => Monotonicity\n} = internal.monotonicity\n\n/**\n * Type-narrowing predicate: refines a `QuadraticPolynomial<T>` to\n * `QuadraticPolynomial<T & Monotonic>` when the polynomial is strictly\n * monotonic over the given interval (or globally, when no interval is given).\n *\n * @param p - The quadratic polynomial to check.\n * @param i - Optional interval over which to check monotonicity.\n * @returns `true` when monotonicity is `Increasing` or `Decreasing`.\n * @since 2.0.0\n */\nexport const isMonotonic: {\n <T>(p: QuadraticPolynomial<T>, i?: Interval): p is QuadraticPolynomial<T & Monotonic>\n (i: Interval): <T>(p: QuadraticPolynomial<T>) => p is QuadraticPolynomial<T & Monotonic>\n} = internal.isMonotonic\n\n/**\n * Type-narrowing predicate: refines to `QuadraticPolynomial<T & Increasing>`.\n *\n * @since 2.0.0\n */\nexport const isIncreasing: {\n <T>(p: QuadraticPolynomial<T>, i?: Interval): p is QuadraticPolynomial<T & Increasing>\n (i: Interval): <T>(p: QuadraticPolynomial<T>) => p is QuadraticPolynomial<T & Increasing>\n} = internal.isIncreasing\n\n/**\n * Type-narrowing predicate: refines to `QuadraticPolynomial<T & Decreasing>`.\n *\n * @since 2.0.0\n */\nexport const isDecreasing: {\n <T>(p: QuadraticPolynomial<T>, i?: Interval): p is QuadraticPolynomial<T & Decreasing>\n (i: Interval): <T>(p: QuadraticPolynomial<T>) => p is QuadraticPolynomial<T & Decreasing>\n} = internal.isDecreasing\n\n/**\n * Asserts that the quadratic polynomial is monotonic, throwing on failure.\n *\n * @param p - The quadratic polynomial to assert against.\n * @param i - Optional interval over which to check monotonicity.\n * @returns The same polynomial, typed with the `Monotonic` brand.\n * @throws When the polynomial is not monotonic over the given (or global) interval.\n * @since 2.0.0\n */\nexport const asMonotonic: <T>(\n p: QuadraticPolynomial<T>,\n i?: Interval,\n) => QuadraticPolynomial<T & Monotonic> = internal.asMonotonic\n\n/**\n * Asserts that the quadratic polynomial is increasing, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asIncreasing: <T>(\n p: QuadraticPolynomial<T>,\n i?: Interval,\n) => QuadraticPolynomial<T & Increasing> = internal.asIncreasing\n\n/**\n * Asserts that the quadratic polynomial is decreasing, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asDecreasing: <T>(\n p: QuadraticPolynomial<T>,\n i?: Interval,\n) => QuadraticPolynomial<T & Decreasing> = internal.asDecreasing\n\nexport const antiderivative: {\n /**\n * Computes the antiderivative of the quadratic polynomial.\n *\n * @param p - The quadratic polynomial.\n * @param constant - The constant of integration. Defaults to 0.\n * @returns The antiderivative of the polynomial as a cubic polynomial.\n * @since 1.0.0\n */\n (p: QuadraticPolynomial, constant?: number): CubicPolynomial\n /**\n * Computes the antiderivative of the quadratic polynomial.\n *\n * @param constant - The constant of integration. Defaults to 0.\n * @returns A function that takes a quadratic polynomial and returns the antiderivative of the polynomial as a cubic polynomial.\n * @since 1.0.0\n */\n (constant: number): (p: QuadraticPolynomial) => CubicPolynomial\n} = internal.antiderivative\n\nexport const domain: {\n /**\n * Computes the domain of the quadratic polynomial over a given range.\n *\n * @param p - The quadratic polynomial.\n * @param range - The range to compute the domain over.\n * @returns The domain of the polynomial over the range.\n * @since 1.0.0\n */\n (p: QuadraticPolynomial, range: Interval): Solution.AtMostOne<Interval>\n /**\n * Computes the domain of the quadratic polynomial over a given range.\n *\n * @param range - The range to compute the domain over.\n * @returns A function that takes a quadratic polynomial and returns the domain of the polynomial over the range.\n * @since 1.0.0\n */\n (range: Interval): (p: QuadraticPolynomial) => Solution.AtMostOne<Interval>\n} = internal.domain\n\nexport const range: {\n /**\n * Computes the range of the quadratic polynomial over a given domain.\n *\n * @param p - The quadratic polynomial.\n * @param domain - The domain to compute the range over.\n * @returns The range of the polynomial over the domain.\n * @since 1.0.0\n */\n (p: QuadraticPolynomial, domain: Interval): Closed\n /**\n * Computes the range of the quadratic polynomial over a given domain.\n *\n * @param domain - The domain to compute the range over.\n * @returns A function that takes a quadratic polynomial and returns the range of the polynomial over the domain.\n * @since 1.0.0\n */\n (domain: Interval): (p: QuadraticPolynomial) => Closed\n} = internal.range\n\n/**\n * Computes the range of the quadratic polynomial over the unit interval\n * `[0, 1]`. Equivalent to `range(p, Interval.unit)` — accounts for any\n * interior extremum in `[0, 1]`.\n *\n * @param p - The quadratic polynomial.\n * @returns The closed range of the polynomial over `[0, 1]`.\n * @since 2.0.0\n */\nexport const unitRange: (p: QuadraticPolynomial) => Closed = internal.unitRange\n\nexport const length: {\n /**\n * Computes the length of the quadratic polynomial over a given interval.\n *\n * @param p - The quadratic polynomial.\n * @param i - The interval to compute the length over.\n * @returns The length of the polynomial over the interval.\n * @since 1.0.0\n */\n (p: QuadraticPolynomial, i: Interval): number\n /**\n * Computes the length of the quadratic polynomial over a given interval.\n *\n * @param i - The interval to compute the length over.\n * @returns A function that takes a quadratic polynomial and returns the length of the polynomial over the interval.\n * @since 1.0.0\n */\n (i: Interval): (p: QuadraticPolynomial) => number\n} = internal.length\n\nexport const curvature: {\n /**\n * Computes the curvature of the quadratic polynomial at a given x value.\n *\n * @param p - The quadratic polynomial.\n * @param x - The x value to compute the curvature at.\n * @returns The curvature of the polynomial at the given x value.\n * @since 1.0.0\n */\n (p: QuadraticPolynomial, x: number): number\n /**\n * Computes the curvature of the quadratic polynomial at a given x value.\n *\n * @param x - The x value to compute the curvature at.\n * @returns A function that takes a quadratic polynomial and returns the curvature of the polynomial at the given x value.\n * @since 1.0.0\n */\n (x: number): (p: QuadraticPolynomial) => number\n} = internal.curvature\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,MAAa,qBAA4DA;AAEzE,MAAaC,WAoBTC;;;;;;;;;AAUJ,MAAaC,SAAuDC;;;;;;;;AASpE,MAAaC,eAA+CC;;;;;;;;;AAU5D,MAAa,iBACXC;;;;;;;;;AAUF,MAAaC,eAA6DC;AAE1E,MAAaC,UAkBTC;;;;;;;;AASJ,MAAaC,aAA2DC;AAMxE,MAAaC,iBAyBTC;;;;;;;AAQJ,MAAaC,oBACXC;;;;;;;AAQF,MAAa,QAA6D,MACxEF,eAAsB,GAAG,EAAE;;;;;;;;AAS7B,MAAaG,iBAAgEC;;;;;;;;;AAU7E,MAAaC,gBACXC;;;;;;;;AASF,MAAaC,iBACXC;;;;;;;;AASF,MAAaC,iBACXC;;;;;;;;;AAUF,MAAaC,gBACXC;;;;;;;;;AAUF,MAAaC,iBACXC;;;;;;;;;AAUF,MAAaC,iBACXC;;;;;;;;AASF,MAAaC,iBACXC;;;;;;;;AASF,MAAaC,eAA8CC;AAE3D,MAAaC,mBAkBTC;AAEJ,MAAaC,WAkBTC;AAEJ,MAAaC,UAkBTC;;;;;;;;;;AAWJ,MAA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