curvy 2.0.0-alpha.5 → 2.0.0-alpha.7
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.
- package/dist/characteristic/characteristic.d.ts +3 -3
- package/dist/characteristic/index.d.ts +1 -1
- package/dist/characteristic/index.mjs +1 -1
- package/dist/curve/cubic2d.d.ts +10 -14
- package/dist/curve/cubic2d.internal.d.ts +2 -0
- package/dist/curve/index.d.ts +8 -8
- package/dist/curve/index.mjs +1 -1
- package/dist/curve/linear2d.d.ts +11 -15
- package/dist/curve/linear2d.internal.d.ts +2 -0
- package/dist/curve/quadratic2d.d.ts +11 -15
- package/dist/curve/quadratic2d.internal.d.ts +2 -0
- package/dist/curve/rationalCubic2d.d.ts +63 -22
- package/dist/curve/rationalCubic2d.internal.d.ts +2 -0
- package/dist/interval/index.d.ts +4 -4
- package/dist/interval/index.mjs +2 -2
- package/dist/interval/interval.d.ts +1 -1
- package/dist/interval/interval.internal.d.ts +1 -0
- package/dist/interval/interval2d.d.ts +45 -8
- package/dist/interval/interval2d.internal.d.ts +2 -0
- package/dist/matrix/index.d.ts +6 -6
- package/dist/matrix/index.mjs +1 -1
- package/dist/matrix/index.mjs.map +1 -1
- package/dist/matrix/matrix2x2.d.ts +4 -8
- package/dist/matrix/matrix2x2.internal.d.ts +2 -0
- package/dist/matrix/matrix3x3.d.ts +5 -9
- package/dist/matrix/matrix3x3.internal.d.ts +4 -0
- package/dist/matrix/matrix4x4.d.ts +5 -9
- package/dist/matrix/matrix4x4.internal.d.ts +2 -0
- package/dist/number.mjs.map +1 -1
- package/dist/path/cubic2d.d.ts +119 -12
- package/dist/path/cubic2d.internal.d.ts +2 -0
- package/dist/path/index.d.ts +8 -8
- package/dist/path/index.mjs +413 -4
- package/dist/path/index.mjs.map +1 -1
- package/dist/path/linear2d.d.ts +122 -12
- package/dist/path/linear2d.internal.d.ts +2 -0
- package/dist/path/quadratic2d.d.ts +119 -12
- package/dist/path/quadratic2d.internal.d.ts +2 -0
- package/dist/path/rationalCubic2d.d.ts +5 -9
- package/dist/path/rationalCubic2d.internal.d.ts +2 -0
- package/dist/path/traits.d.ts +64 -0
- package/dist/polynomial/cubic.d.ts +10 -14
- package/dist/polynomial/cubic.internal.circular.d.ts +2 -0
- package/dist/polynomial/cubic.internal.d.ts +1 -0
- package/dist/polynomial/index.d.ts +6 -6
- package/dist/polynomial/index.mjs +2 -2
- package/dist/polynomial/linear.d.ts +9 -13
- package/dist/polynomial/linear.internal.d.ts +2 -0
- package/dist/polynomial/quadratic.d.ts +11 -15
- package/dist/polynomial/quadratic.internal.circular.d.ts +2 -0
- package/dist/polynomial/quadratic.internal.d.ts +1 -0
- package/dist/shared/{characteristic-DLlhja-I.mjs → characteristic-D9yZWCym.mjs} +3 -3
- package/dist/shared/characteristic-D9yZWCym.mjs.map +1 -0
- package/dist/shared/{cubic-CMonq6bg.mjs → cubic-BK8xjSkd.mjs} +79 -4
- package/dist/shared/cubic-BK8xjSkd.mjs.map +1 -0
- package/dist/shared/{interval-X1EYuf-T.mjs → interval-CqC3ZIqj.mjs} +40 -1
- package/dist/shared/interval-CqC3ZIqj.mjs.map +1 -0
- package/dist/shared/{interval2d-ca0J1NMr.mjs → interval2d-BMDmeL1M.mjs} +45 -4
- package/dist/shared/interval2d-BMDmeL1M.mjs.map +1 -0
- package/dist/shared/{matrix4x4-Ck2WROK-.mjs → matrix4x4-qyRufxfs.mjs} +62 -3
- package/dist/shared/matrix4x4-qyRufxfs.mjs.map +1 -0
- package/dist/shared/{quadratic-DyeMtvET.mjs → quadratic-CWXIRh42.mjs} +2 -2
- package/dist/shared/quadratic-CWXIRh42.mjs.map +1 -0
- package/dist/shared/{rationalCubic2d-Vw4qGPZj.mjs → rationalCubic2d-BZvT9s5N.mjs} +218 -5
- package/dist/shared/rationalCubic2d-BZvT9s5N.mjs.map +1 -0
- package/dist/shared/{rationalCubic2d-D658ltUM.mjs → rationalCubic2d-DaFTrUXw.mjs} +250 -36
- package/dist/shared/rationalCubic2d-DaFTrUXw.mjs.map +1 -0
- package/dist/shared/{solution-3TDATEMn.mjs → solution-UKGK826h.mjs} +22 -2
- package/dist/shared/solution-UKGK826h.mjs.map +1 -0
- package/dist/shared/{vector2-CCuJx1rX.mjs → vector2-CWU3cPB2.mjs} +12 -2
- package/dist/shared/vector2-CWU3cPB2.mjs.map +1 -0
- package/dist/shared/{vector2.internal-DU_E808S.mjs → vector2.internal-BL8hFl1c.mjs} +31 -2
- package/dist/shared/vector2.internal-BL8hFl1c.mjs.map +1 -0
- package/dist/shared/{vector3-C-qgKAjR.mjs → vector3-DmMm6pX8.mjs} +12 -2
- package/dist/shared/vector3-DmMm6pX8.mjs.map +1 -0
- package/dist/shared/{vector4-BhOKDhD5.mjs → vector4-oqPPp45j.mjs} +12 -2
- package/dist/shared/vector4-oqPPp45j.mjs.map +1 -0
- package/dist/shared/{vector4.internal-5XcaX12X.mjs → vector4.internal-BnnTjVIr.mjs} +45 -2
- package/dist/shared/vector4.internal-BnnTjVIr.mjs.map +1 -0
- package/dist/solution/index.d.ts +1 -3
- package/dist/solution/index.mjs +1 -1
- package/dist/solution/solution.d.ts +2 -2
- package/dist/solution/solution.internal.d.ts +2 -0
- package/dist/splines/basis2d.d.ts +5 -9
- package/dist/splines/basis2d.internal.d.ts +2 -0
- package/dist/splines/bezier2d.d.ts +6 -10
- package/dist/splines/bezier2d.internal.d.ts +2 -0
- package/dist/splines/cardinal2d.d.ts +5 -9
- package/dist/splines/cardinal2d.internal.d.ts +2 -0
- package/dist/splines/hermite2d.d.ts +5 -9
- package/dist/splines/hermite2d.internal.d.ts +2 -0
- package/dist/splines/index.d.ts +10 -10
- package/dist/splines/index.mjs +62 -8
- package/dist/splines/index.mjs.map +1 -1
- package/dist/splines/rationalBezier2d.d.ts +5 -9
- package/dist/splines/rationalBezier2d.internal.d.ts +2 -0
- package/dist/splines/util.d.ts +3 -3
- package/dist/vector/index.d.ts +6 -6
- package/dist/vector/index.mjs +3 -3
- package/dist/vector/vector2.d.ts +12 -9
- package/dist/vector/vector2.internal.d.ts +4 -0
- package/dist/vector/vector3.d.ts +12 -7
- package/dist/vector/vector3.internal.d.ts +2 -0
- package/dist/vector/vector4.d.ts +12 -7
- package/dist/vector/vector4.internal.d.ts +2 -0
- package/package.json +2 -2
- package/dist/shared/characteristic-DLlhja-I.mjs.map +0 -1
- package/dist/shared/cubic-CMonq6bg.mjs.map +0 -1
- package/dist/shared/interval-X1EYuf-T.mjs.map +0 -1
- package/dist/shared/interval2d-ca0J1NMr.mjs.map +0 -1
- package/dist/shared/matrix4x4-Ck2WROK-.mjs.map +0 -1
- package/dist/shared/quadratic-DyeMtvET.mjs.map +0 -1
- package/dist/shared/rationalCubic2d-D658ltUM.mjs.map +0 -1
- package/dist/shared/rationalCubic2d-Vw4qGPZj.mjs.map +0 -1
- package/dist/shared/solution-3TDATEMn.mjs.map +0 -1
- package/dist/shared/vector2-CCuJx1rX.mjs.map +0 -1
- package/dist/shared/vector2.internal-DU_E808S.mjs.map +0 -1
- package/dist/shared/vector3-C-qgKAjR.mjs.map +0 -1
- package/dist/shared/vector4-BhOKDhD5.mjs.map +0 -1
- package/dist/shared/vector4.internal-5XcaX12X.mjs.map +0 -1
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
import type { Closed, Interval } from '../interval/interval';
|
|
2
|
-
import type { Pipeable } from '../utils';
|
|
3
|
-
import type * as Solution from '../solution/solution';
|
|
4
|
-
import type { Vector2 } from '../vector/vector2';
|
|
5
|
-
|
|
6
|
-
import type { GuaranteedMonotonicity } from './monotonicity';
|
|
7
|
-
import type { QuadraticPolynomial } from './quadratic';
|
|
8
|
-
import type { Decreasing, Increasing, Monotonic, PolynomialTraits } from './traits';
|
|
9
|
-
|
|
10
|
-
declare const LinearPolynomialTypeId: unique symbol;
|
|
11
|
-
type LinearPolynomialTypeId = typeof LinearPolynomialTypeId;
|
|
12
|
-
|
|
13
|
-
export type { Monotonic, Increasing, Decreasing } from './traits';
|
|
1
|
+
import type { Closed, Interval } from '../interval/interval.ts';
|
|
2
|
+
import type { Pipeable } from '../utils.ts';
|
|
3
|
+
import type * as Solution from '../solution/solution.ts';
|
|
4
|
+
import type { Vector2 } from '../vector/vector2.ts';
|
|
5
|
+
import type { LinearPolynomialTypeId } from './linear.internal.ts';
|
|
6
|
+
import type { GuaranteedMonotonicity } from './monotonicity.ts';
|
|
7
|
+
import type { QuadraticPolynomial } from './quadratic.ts';
|
|
8
|
+
import type { Decreasing, Increasing, Monotonic, PolynomialTraits } from './traits.ts';
|
|
9
|
+
export type { Monotonic, Increasing, Decreasing } from './traits.ts';
|
|
14
10
|
/**
|
|
15
11
|
* A linear polynomial.
|
|
16
12
|
*
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import type { Closed, Interval } from '../interval/interval';
|
|
2
|
-
import type { Pipeable } from '../utils';
|
|
3
|
-
import type * as Solution from '../solution/solution';
|
|
4
|
-
import type { Vector2 } from '../vector/vector2';
|
|
5
|
-
import type { Vector3 } from '../vector/vector3';
|
|
6
|
-
import type { CubicPolynomial } from './cubic';
|
|
7
|
-
import type { LinearPolynomial } from './linear';
|
|
8
|
-
import type { Monotonicity } from './monotonicity';
|
|
9
|
-
|
|
10
|
-
import type { Decreasing, Increasing, Monotonic, PolynomialTraits } from './traits';
|
|
11
|
-
|
|
12
|
-
declare const QuadraticPolynomialTypeId: unique symbol;
|
|
13
|
-
type QuadraticPolynomialTypeId = typeof QuadraticPolynomialTypeId;
|
|
14
|
-
|
|
15
|
-
export type { Monotonic, Increasing, Decreasing } from './traits';
|
|
1
|
+
import type { Closed, Interval } from '../interval/interval.ts';
|
|
2
|
+
import type { Pipeable } from '../utils.ts';
|
|
3
|
+
import type * as Solution from '../solution/solution.ts';
|
|
4
|
+
import type { Vector2 } from '../vector/vector2.ts';
|
|
5
|
+
import type { Vector3 } from '../vector/vector3.ts';
|
|
6
|
+
import type { CubicPolynomial } from './cubic.ts';
|
|
7
|
+
import type { LinearPolynomial } from './linear.ts';
|
|
8
|
+
import type { Monotonicity } from './monotonicity.ts';
|
|
9
|
+
import type { QuadraticPolynomialTypeId } from './quadratic.internal.circular.ts';
|
|
10
|
+
import type { Decreasing, Increasing, Monotonic, PolynomialTraits } from './traits.ts';
|
|
11
|
+
export type { Monotonic, Increasing, Decreasing } from './traits.ts';
|
|
16
12
|
/**
|
|
17
13
|
* A quadratic polynomial.
|
|
18
14
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as __exportAll } from "./chunk-25Hzd3z8.mjs";
|
|
2
2
|
import { roundDown } from "../number.mjs";
|
|
3
|
-
import { a as vectorProductLeft, n as make } from "./matrix4x4-
|
|
4
|
-
import { r as fromVector } from "./cubic-
|
|
3
|
+
import { a as vectorProductLeft, n as make } from "./matrix4x4-qyRufxfs.mjs";
|
|
4
|
+
import { r as fromVector } from "./cubic-BK8xjSkd.mjs";
|
|
5
5
|
//#region src/characteristic/characteristic.ts
|
|
6
6
|
var characteristic_exports = /* @__PURE__ */ __exportAll({
|
|
7
7
|
apply: () => apply,
|
|
@@ -101,4 +101,4 @@ const apply = (matrix, ...channels) => {
|
|
|
101
101
|
//#endregion
|
|
102
102
|
export { cubicHermite as a, cubicBezier as i, characteristic_exports as n, cubicBasisSpline as r, apply as t };
|
|
103
103
|
|
|
104
|
-
//# sourceMappingURL=characteristic-
|
|
104
|
+
//# sourceMappingURL=characteristic-D9yZWCym.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"characteristic-D9yZWCym.mjs","names":["Matrix4x4.make","CubicPolynomial.fromVector","Matrix4x4.vectorProductLeft"],"sources":["../../src/characteristic/characteristic.ts"],"sourcesContent":["import * as Matrix4x4 from '../matrix/matrix4x4.ts'\nimport * as CubicPolynomial from '../polynomial/cubic.ts'\nimport { roundDown } from '../number.ts'\nimport type * as Vector4 from '../vector/vector4.ts'\n\n/**\n * The cubic Bézier characteristic matrix.\n *\n * Maps Bernstein-basis control points `(P₀, P₁, P₂, P₃)` to monomial cubic\n * coefficients `(c₀, c₁, c₂, c₃)` for `c₀ + c₁·t + c₂·t² + c₃·t³`. The matrix\n * IS the Bézier spline family — combined with control points (via {@link apply}),\n * it produces the cubic polynomial that parameterizes the curve.\n *\n * @since 2.0.0\n */\nexport const cubicBezier: Matrix4x4.Matrix4x4 = Matrix4x4.make(\n 1,\n 0,\n 0,\n 0,\n -3,\n 3,\n 0,\n 0,\n 3,\n -6,\n 3,\n 0,\n -1,\n 3,\n -3,\n 1,\n)\n\n/**\n * The cubic Hermite characteristic matrix.\n *\n * Maps Hermite control data `(P₀, V₀, P₁, V₁)` — two endpoints and two\n * tangent vectors — to monomial cubic coefficients.\n *\n * @since 2.0.0\n */\nexport const cubicHermite: Matrix4x4.Matrix4x4 = Matrix4x4.make(\n 1,\n 0,\n 0,\n 0,\n 0,\n 1,\n 0,\n 0,\n -3,\n -2,\n 3,\n -1,\n 2,\n 1,\n -2,\n 1,\n)\n\n/**\n * The uniform cubic B-spline (basis spline) characteristic matrix.\n *\n * Maps a window of four control points to the monomial cubic coefficients\n * of one segment of the corresponding uniform cubic B-spline. Stride-1\n * application produces a C² piecewise spline; the curve does not generally\n * pass through the control points.\n *\n * @since 2.0.0\n */\nexport const cubicBasisSpline: Matrix4x4.Matrix4x4 = Matrix4x4.make(\n 1 / 6,\n 4 / 6,\n roundDown(1 / 6),\n 0,\n -0.5,\n 0,\n 0.5,\n 0,\n 0.5,\n -1,\n 0.5,\n 0,\n -1 / 6,\n 0.5,\n -0.5,\n 1 / 6,\n)\n\nconst cardinalCache = new Map<number, Matrix4x4.Matrix4x4>()\n\n/**\n * The cubic Cardinal spline characteristic matrix, parameterized by tension.\n *\n * Maps four control points to the monomial cubic coefficients of one\n * Cardinal segment. The tension `s` controls how tightly the curve hugs\n * the control points: `s = 0` produces straight-line segments between\n * adjacent points, `s = 0.5` is the Catmull-Rom variant (see\n * {@link cubicCatmullRom}), and higher values produce looser, more curved\n * shapes.\n *\n * Cached per tension value — repeated calls with the same tension return\n * the same matrix instance.\n *\n * @param tension - The tension parameter.\n * @returns The characteristic matrix for that tension.\n * @since 2.0.0\n */\nexport const cubicCardinal = (tension: number): Matrix4x4.Matrix4x4 => {\n let m = cardinalCache.get(tension)\n if (m === undefined) {\n m = Matrix4x4.make(\n 0,\n 1,\n 0,\n 0,\n -tension,\n 0,\n tension,\n 0,\n 2 * tension,\n tension - 3,\n 3 - 2 * tension,\n -tension,\n -tension,\n 2 - tension,\n tension - 2,\n tension,\n )\n cardinalCache.set(tension, m)\n }\n return m\n}\n\n/**\n * The cubic Catmull-Rom characteristic matrix — Cardinal with tension `0.5`.\n * The most common Cardinal-family variant; reused widely enough to deserve\n * a constant.\n *\n * @since 2.0.0\n */\nexport const cubicCatmullRom: Matrix4x4.Matrix4x4 = cubicCardinal(0.5)\n\n/**\n * Applies a characteristic matrix to N channels of control values, producing\n * N cubic polynomials in monomial form.\n *\n * Each channel is a `Vector4` packing one axis's values across the four\n * control points: `(v₀, v₁, v₂, v₃)`. The result tuple has the same arity\n * as the input.\n *\n * The polynomial 2D spline pipeline applies this with two channels (x, y);\n * the rational 2D pipeline uses three (x, y, w) where `w` is the projective\n * denominator. Higher channel counts generalize to 3D, rational 3D, and\n * beyond — the characteristic matrix doesn't care about the geometric\n * domain, only about how to combine four samples per channel.\n *\n * @param matrix - The characteristic matrix of the spline family.\n * @param channels - One `Vector4` per output polynomial, packing the four control values for that channel.\n * @returns A tuple of cubic polynomials, one per input channel.\n * @since 2.0.0\n */\nexport const apply = <const Channels extends ReadonlyArray<Vector4.Vector4>>(\n matrix: Matrix4x4.Matrix4x4,\n ...channels: Channels\n): { readonly [K in keyof Channels]: CubicPolynomial.CubicPolynomial } => {\n const result = channels.map((c) =>\n CubicPolynomial.fromVector(Matrix4x4.vectorProductLeft(matrix, c)),\n )\n return result as { readonly [K in keyof Channels]: CubicPolynomial.CubicPolynomial }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAeA,MAAa,cAAmCA,KAC9C,GACA,GACA,GACA,GACA,IACA,GACA,GACA,GACA,GACA,IACA,GACA,GACA,IACA,GACA,IACA,EACD;;;;;;;;;AAUD,MAAa,eAAoCA,KAC/C,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,IACA,IACA,GACA,IACA,GACA,GACA,IACA,EACD;;;;;;;;;;;AAYD,MAAa,mBAAwCA,KACnD,IAAI,GACJ,IAAI,GACJ,UAAU,IAAI,EAAE,EAChB,GACA,KACA,GACA,IACA,GACA,IACA,IACA,IACA,GACA,KAAK,GACL,IACA,KACA,IAAI,EACL;AAED,MAAM,gCAAgB,IAAI,KAAkC;;;;;;;;;;;;;;;;;;AAmB5D,MAAa,iBAAiB,YAAyC;CACrE,IAAI,IAAI,cAAc,IAAI,QAAQ;CAClC,IAAI,MAAM,KAAA,GAAW;EACnB,IAAIA,KACF,GACA,GACA,GACA,GACA,CAAC,SACD,GACA,SACA,GACA,IAAI,SACJ,UAAU,GACV,IAAI,IAAI,SACR,CAAC,SACD,CAAC,SACD,IAAI,SACJ,UAAU,GACV,QACD;EACD,cAAc,IAAI,SAAS,EAAE;;CAE/B,OAAO;;;;;;;;;AAUT,MAAa,kBAAuC,cAAc,GAAI;;;;;;;;;;;;;;;;;;;;AAqBtE,MAAa,SACX,QACA,GAAG,aACqE;CAIxE,OAHe,SAAS,KAAK,MAC3BC,WAA2BC,kBAA4B,QAAQ,EAAE,CAAC,CAEvD"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { t as __exportAll } from "./chunk-25Hzd3z8.mjs";
|
|
2
2
|
import { Pipeable, dual, invariant } from "../utils.mjs";
|
|
3
3
|
import { clampToZero, epsEquals } from "../number.mjs";
|
|
4
|
-
import { a as make$4 } from "./vector2-
|
|
5
|
-
import { a as filter, c as make$5, d as toOpen, l as scaleShift, n as contains, o as fromMinMax, t as biunit, u as size } from "./interval-
|
|
6
|
-
import { a as match, l as two, n as fromArray, o as none, r as isNone, s as one } from "./solution-
|
|
4
|
+
import { a as make$4 } from "./vector2-CWU3cPB2.mjs";
|
|
5
|
+
import { a as filter, c as make$5, d as toOpen, l as scaleShift, n as contains, o as fromMinMax, t as biunit, u as size } from "./interval-CqC3ZIqj.mjs";
|
|
6
|
+
import { a as match, l as two, n as fromArray, o as none, r as isNone, s as one } from "./solution-UKGK826h.mjs";
|
|
7
7
|
//#region src/polynomial/quadratic.internal.circular.ts
|
|
8
8
|
const QuadraticPolynomialTypeId = Symbol.for("curvy/polynomial/quadratic");
|
|
9
|
+
/** @internal */
|
|
9
10
|
var QuadraticPolynomialImpl = class extends Pipeable {
|
|
10
11
|
[QuadraticPolynomialTypeId] = QuadraticPolynomialTypeId;
|
|
11
12
|
c0;
|
|
@@ -31,38 +32,59 @@ var LinearPolynomialImpl = class extends Pipeable {
|
|
|
31
32
|
this.c1 = c1;
|
|
32
33
|
}
|
|
33
34
|
};
|
|
35
|
+
/** @internal */
|
|
34
36
|
const isLinearPolynomial = (v) => typeof v === "object" && v !== null && LinearPolynomialTypeId in v;
|
|
37
|
+
/** @internal */
|
|
35
38
|
const equals$3 = dual(2, (a, b) => epsEquals(a.c0, b.c0) && epsEquals(a.c1, b.c1));
|
|
39
|
+
/** @internal */
|
|
36
40
|
const make$3 = (c0 = 0, c1 = 0) => new LinearPolynomialImpl(c0, c1);
|
|
41
|
+
/** @internal */
|
|
37
42
|
const fromVector$3 = (v) => new LinearPolynomialImpl(v.x, v.y);
|
|
43
|
+
/** @internal */
|
|
38
44
|
const fromPointSlope = (p, slope) => new LinearPolynomialImpl(p.y - slope * p.x, slope);
|
|
45
|
+
/** @internal */
|
|
39
46
|
const fromPoints$3 = (p1, p2) => fromPointSlope(p1, (p2.y - p1.y) / (p2.x - p1.x));
|
|
47
|
+
/** @internal */
|
|
40
48
|
const solve$3 = dual(2, (p, x) => p.c0 + x * p.c1);
|
|
49
|
+
/** @internal */
|
|
41
50
|
const toSolver$3 = (p) => (x) => solve$3(p, x);
|
|
51
|
+
/** @internal */
|
|
42
52
|
const solveInverse$3 = dual(2, (p, y) => {
|
|
43
53
|
if (p.c1 === 0) return none;
|
|
44
54
|
return one((y - p.c0) / p.c1);
|
|
45
55
|
});
|
|
56
|
+
/** @internal */
|
|
46
57
|
const toInverseSolver$3 = (p) => (y) => solveInverse$3(p, y);
|
|
58
|
+
/** @internal */
|
|
47
59
|
const monotonicity$3 = (p) => p.c1 === 0 ? "constant" : p.c1 > 0 ? "increasing" : "decreasing";
|
|
60
|
+
/** @internal */
|
|
48
61
|
const isMonotonic$3 = (p) => p.c1 !== 0;
|
|
62
|
+
/** @internal */
|
|
49
63
|
const isIncreasing$3 = (p) => p.c1 > 0;
|
|
64
|
+
/** @internal */
|
|
50
65
|
const isDecreasing$3 = (p) => p.c1 < 0;
|
|
66
|
+
/** @internal */
|
|
51
67
|
const asMonotonic$3 = (p) => {
|
|
52
68
|
invariant(isMonotonic$3(p), "linear polynomial is not monotonic");
|
|
53
69
|
return p;
|
|
54
70
|
};
|
|
71
|
+
/** @internal */
|
|
55
72
|
const asIncreasing$3 = (p) => {
|
|
56
73
|
invariant(isIncreasing$3(p), "linear polynomial is not increasing");
|
|
57
74
|
return p;
|
|
58
75
|
};
|
|
76
|
+
/** @internal */
|
|
59
77
|
const asDecreasing$3 = (p) => {
|
|
60
78
|
invariant(isDecreasing$3(p), "linear polynomial is not decreasing");
|
|
61
79
|
return p;
|
|
62
80
|
};
|
|
81
|
+
/** @internal */
|
|
63
82
|
const coefficients$3 = (p) => [p.c0, p.c1];
|
|
83
|
+
/** @internal */
|
|
64
84
|
const derivative$3 = (p) => p.c1;
|
|
85
|
+
/** @internal */
|
|
65
86
|
const antiderivative$1 = dual((args) => isLinearPolynomial(args[0]), (p, integrationConstant = 0) => new QuadraticPolynomialImpl(integrationConstant, p.c0, p.c1 / 2));
|
|
87
|
+
/** @internal */
|
|
66
88
|
const domain$3 = dual(2, (p, r) => {
|
|
67
89
|
if (p.c1 === 0) {
|
|
68
90
|
if (r.start === p.c0 && r.end === p.c0) return one(make$5(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY));
|
|
@@ -73,7 +95,9 @@ const domain$3 = dual(2, (p, r) => {
|
|
|
73
95
|
if (isNone(start) || isNone(end)) return none;
|
|
74
96
|
return one(make$5(start.value, end.value));
|
|
75
97
|
});
|
|
98
|
+
/** @internal */
|
|
76
99
|
const range$3 = dual(2, (p, d) => fromMinMax(solve$3(p, d.start), solve$3(p, d.end)));
|
|
100
|
+
/** @internal */
|
|
77
101
|
const length$3 = dual(2, (p, d) => {
|
|
78
102
|
if (size(d) === 0) return 0;
|
|
79
103
|
if (p.c1 === 0) return size(d);
|
|
@@ -82,6 +106,7 @@ const length$3 = dual(2, (p, d) => {
|
|
|
82
106
|
//#endregion
|
|
83
107
|
//#region src/polynomial/cubic.internal.circular.ts
|
|
84
108
|
const CubicPolynomialTypeId = Symbol.for("curvy/polynomial/cubic");
|
|
109
|
+
/** @internal */
|
|
85
110
|
var CubicPolynomialImpl = class extends Pipeable {
|
|
86
111
|
[CubicPolynomialTypeId] = CubicPolynomialTypeId;
|
|
87
112
|
c0;
|
|
@@ -105,17 +130,25 @@ function guaranteedMonotonicityFromComparison(s0, s1) {
|
|
|
105
130
|
}
|
|
106
131
|
//#endregion
|
|
107
132
|
//#region src/polynomial/quadratic.internal.ts
|
|
133
|
+
/** @internal */
|
|
108
134
|
const fromPoints$2 = (p0, p1, p2) => {
|
|
109
135
|
const f01 = (p1.y - p0.y) / (p1.x - p0.x);
|
|
110
136
|
const f012 = ((p2.y - p1.y) / (p2.x - p1.x) - f01) / (p2.x - p0.x);
|
|
111
137
|
return new QuadraticPolynomialImpl(p0.y - f01 * p0.x + f012 * p0.x * p1.x, f01 - f012 * (p0.x + p1.x), f012);
|
|
112
138
|
};
|
|
139
|
+
/** @internal */
|
|
113
140
|
const make$2 = (c0 = 0, c1 = 0, c2 = 0) => new QuadraticPolynomialImpl(c0, c1, c2);
|
|
141
|
+
/** @internal */
|
|
114
142
|
const isQuadraticPolynomial = (v) => typeof v === "object" && v !== null && QuadraticPolynomialTypeId in v;
|
|
143
|
+
/** @internal */
|
|
115
144
|
const equals$2 = dual(2, (a, b) => epsEquals(a.c0, b.c0) && epsEquals(a.c1, b.c1) && epsEquals(a.c2, b.c2));
|
|
145
|
+
/** @internal */
|
|
116
146
|
const fromVector$2 = (v) => new QuadraticPolynomialImpl(v.x, v.y, v.z);
|
|
147
|
+
/** @internal */
|
|
117
148
|
const solve$2 = dual(2, (p, x) => p.c0 + x * p.c1 + x ** 2 * p.c2);
|
|
149
|
+
/** @internal */
|
|
118
150
|
const toSolver$2 = (p) => (x) => solve$2(p, x);
|
|
151
|
+
/** @internal */
|
|
119
152
|
const solveInverse$2 = dual(2, (p, y) => {
|
|
120
153
|
if (p.c2 === 0) return solveInverse$3(make$3(p.c0, p.c1), y);
|
|
121
154
|
const discriminant = p.c1 ** 2 - 4 * p.c2 * (p.c0 - y);
|
|
@@ -126,18 +159,24 @@ const solveInverse$2 = dual(2, (p, y) => {
|
|
|
126
159
|
const b = (-p.c1 - sqrtDiscriminant) / (2 * p.c2);
|
|
127
160
|
return a < b ? two(a, b) : two(b, a);
|
|
128
161
|
});
|
|
162
|
+
/** @internal */
|
|
129
163
|
const toInverseSolver$2 = (p) => (y) => solveInverse$2(p, y);
|
|
164
|
+
/** @internal */
|
|
130
165
|
const coefficients$2 = (p) => [
|
|
131
166
|
p.c0,
|
|
132
167
|
p.c1,
|
|
133
168
|
p.c2
|
|
134
169
|
];
|
|
170
|
+
/** @internal */
|
|
135
171
|
const derivative$2 = (p) => make$3(p.c1, p.c2 * 2);
|
|
172
|
+
/** @internal */
|
|
136
173
|
const roots$2 = (p) => solveInverse$2(p, 0);
|
|
174
|
+
/** @internal */
|
|
137
175
|
const extreme = (p) => derivative$2(p).pipe(solveInverse$3(0), match({
|
|
138
176
|
onNone: () => null,
|
|
139
177
|
onSome: ({ value: t }) => make$4(t, solve$2(p, t))
|
|
140
178
|
}));
|
|
179
|
+
/** @internal */
|
|
141
180
|
const monotonicity$2 = dual((args) => isQuadraticPolynomial(args[0]), (p, i) => {
|
|
142
181
|
invariant(i === void 0 || size(i) > 0, "monotonicity is undefined over a zero-width interval");
|
|
143
182
|
if (p.c2 === 0 && p.c1 === 0) return "constant";
|
|
@@ -146,36 +185,46 @@ const monotonicity$2 = dual((args) => isQuadraticPolynomial(args[0]), (p, i) =>
|
|
|
146
185
|
if (i === void 0 || contains(toOpen(i), e.x)) return "none";
|
|
147
186
|
return guaranteedMonotonicityFromComparison(solve$2(p, i.start), solve$2(p, i.end));
|
|
148
187
|
});
|
|
188
|
+
/** @internal */
|
|
149
189
|
const isMonotonic$2 = dual((args) => isQuadraticPolynomial(args[0]), ((p, i) => {
|
|
150
190
|
const m = monotonicity$2(p, i);
|
|
151
191
|
return m === "increasing" || m === "decreasing";
|
|
152
192
|
}));
|
|
193
|
+
/** @internal */
|
|
153
194
|
const isIncreasing$2 = dual((args) => isQuadraticPolynomial(args[0]), ((p, i) => monotonicity$2(p, i) === "increasing"));
|
|
195
|
+
/** @internal */
|
|
154
196
|
const isDecreasing$2 = dual((args) => isQuadraticPolynomial(args[0]), ((p, i) => monotonicity$2(p, i) === "decreasing"));
|
|
197
|
+
/** @internal */
|
|
155
198
|
const asMonotonic$2 = (p, i) => {
|
|
156
199
|
invariant(isMonotonic$2(p, i), "quadratic polynomial is not monotonic");
|
|
157
200
|
return p;
|
|
158
201
|
};
|
|
202
|
+
/** @internal */
|
|
159
203
|
const asIncreasing$2 = (p, i) => {
|
|
160
204
|
invariant(isIncreasing$2(p, i), "quadratic polynomial is not increasing");
|
|
161
205
|
return p;
|
|
162
206
|
};
|
|
207
|
+
/** @internal */
|
|
163
208
|
const asDecreasing$2 = (p, i) => {
|
|
164
209
|
invariant(isDecreasing$2(p, i), "quadratic polynomial is not decreasing");
|
|
165
210
|
return p;
|
|
166
211
|
};
|
|
212
|
+
/** @internal */
|
|
167
213
|
const antiderivative = dual(2, (p, integrationConstant = 0) => new CubicPolynomialImpl(integrationConstant, p.c0, p.c1 / 2, p.c2 / 3));
|
|
214
|
+
/** @internal */
|
|
168
215
|
const domain$2 = dual(2, (p, r) => {
|
|
169
216
|
const start = solveInverse$2(p, r.start);
|
|
170
217
|
const end = solveInverse$2(p, r.end);
|
|
171
218
|
if (start.length === 0 && end.length === 0) return none;
|
|
172
219
|
return one(fromMinMax(...start, ...end));
|
|
173
220
|
});
|
|
221
|
+
/** @internal */
|
|
174
222
|
const range$2 = dual(2, (p, d) => {
|
|
175
223
|
if (p.c2 === 0) return range$3(make$3(p.c0, p.c1), d);
|
|
176
224
|
const e = extreme(p);
|
|
177
225
|
return e !== null && contains(d, e.x) ? fromMinMax(solve$2(p, d.start), solve$2(p, d.end), e.y) : fromMinMax(solve$2(p, d.start), solve$2(p, d.end));
|
|
178
226
|
});
|
|
227
|
+
/** @internal */
|
|
179
228
|
const length$2 = dual(2, (p, dom) => {
|
|
180
229
|
if (size(dom) === 0) return 0;
|
|
181
230
|
if (p.c2 === 0) return length$3(make$3(p.c0, p.c1), dom);
|
|
@@ -187,6 +236,7 @@ const length$2 = dual(2, (p, dom) => {
|
|
|
187
236
|
const sqrtEnd = Math.sqrt(1 + derivativeEnd ** 2);
|
|
188
237
|
return (derivativeEnd * sqrtEnd + Math.log(Math.abs(derivativeEnd + sqrtEnd))) / (4 * p.c2) - evalStart;
|
|
189
238
|
});
|
|
239
|
+
/** @internal */
|
|
190
240
|
const curvature$2 = dual(2, (p, x) => Math.abs(2 * p.c2) / (1 + (solve$3(derivative$2(p), x) ** 2) ** 1.5));
|
|
191
241
|
//#endregion
|
|
192
242
|
//#region src/length.ts
|
|
@@ -224,10 +274,15 @@ const GL32_W14 = .09563872007927485;
|
|
|
224
274
|
const GL32_W15 = .09654008851472785;
|
|
225
275
|
//#endregion
|
|
226
276
|
//#region src/polynomial/cubic.internal.ts
|
|
277
|
+
/** @internal */
|
|
227
278
|
const make$1 = (c0 = 0, c1 = 0, c2 = 0, c3 = 0) => new CubicPolynomialImpl(c0, c1, c2, c3);
|
|
279
|
+
/** @internal */
|
|
228
280
|
const isCubicPolynomial$1 = (v) => typeof v === "object" && v !== null && CubicPolynomialTypeId in v;
|
|
281
|
+
/** @internal */
|
|
229
282
|
const equals$1 = dual(2, (a, b) => epsEquals(a.c0, b.c0) && epsEquals(a.c1, b.c1) && epsEquals(a.c2, b.c2) && epsEquals(a.c3, b.c3));
|
|
283
|
+
/** @internal */
|
|
230
284
|
const fromVector$1 = (v) => new CubicPolynomialImpl(v.x, v.y, v.z, v.w);
|
|
285
|
+
/** @internal */
|
|
231
286
|
const fromPoints$1 = (p0, p1, p2, p3) => {
|
|
232
287
|
const f01 = (p1.y - p0.y) / (p1.x - p0.x);
|
|
233
288
|
const f12 = (p2.y - p1.y) / (p2.x - p1.x);
|
|
@@ -236,8 +291,11 @@ const fromPoints$1 = (p0, p1, p2, p3) => {
|
|
|
236
291
|
const f0123 = ((f23 - f12) / (p3.x - p1.x) - f012) / (p3.x - p0.x);
|
|
237
292
|
return new CubicPolynomialImpl(p0.y - f01 * p0.x + f012 * p0.x * p1.x - f0123 * p0.x * p1.x * p2.x, f01 - f012 * (p0.x + p1.x) + f0123 * (p0.x * p1.x + p0.x * p2.x + p1.x * p2.x), f012 - f0123 * (p0.x + p1.x + p2.x), f0123);
|
|
238
293
|
};
|
|
294
|
+
/** @internal */
|
|
239
295
|
const solve$1 = dual(2, (p, x) => p.c0 + x * p.c1 + x ** 2 * p.c2 + x ** 3 * p.c3);
|
|
296
|
+
/** @internal */
|
|
240
297
|
const toSolver$1 = (p) => (x) => solve$1(p, x);
|
|
298
|
+
/** @internal */
|
|
241
299
|
const solveInverse$1 = dual(2, (self, y) => {
|
|
242
300
|
if (self.c3 === 0) return solveInverse$2(make$2(self.c0, self.c1, self.c2), y);
|
|
243
301
|
const shift = self.c2 / (3 * self.c3);
|
|
@@ -266,21 +324,28 @@ const solveInverse$1 = dual(2, (self, y) => {
|
|
|
266
324
|
}
|
|
267
325
|
return fromArray(Array.from(roots).toSorted((a, b) => a - b));
|
|
268
326
|
});
|
|
327
|
+
/** @internal */
|
|
269
328
|
const toInverseSolver$1 = (p) => (y) => solveInverse$1(p, y);
|
|
329
|
+
/** @internal */
|
|
270
330
|
const coefficients$1 = (p) => [
|
|
271
331
|
p.c0,
|
|
272
332
|
p.c1,
|
|
273
333
|
p.c2,
|
|
274
334
|
p.c3
|
|
275
335
|
];
|
|
336
|
+
/** @internal */
|
|
276
337
|
const derivative$1 = (p) => make$2(p.c1, p.c2 * 2, p.c3 * 3);
|
|
338
|
+
/** @internal */
|
|
277
339
|
const subdivide$1 = dual(2, (p, t) => {
|
|
278
340
|
invariant(t > 0 && t < 1, "subdivide parameter t must be in the open interval (0, 1)");
|
|
279
341
|
const r = 1 - t;
|
|
280
342
|
return [make$1(p.c0, p.c1 * t, p.c2 * t * t, p.c3 * t * t * t), make$1(p.c0 + p.c1 * t + p.c2 * t * t + p.c3 * t * t * t, p.c1 * r + 2 * p.c2 * t * r + 3 * p.c3 * t * t * r, p.c2 * r * r + 3 * p.c3 * t * r * r, p.c3 * r * r * r)];
|
|
281
343
|
});
|
|
344
|
+
/** @internal */
|
|
282
345
|
const roots$1 = (p) => solveInverse$1(p, 0);
|
|
346
|
+
/** @internal */
|
|
283
347
|
const extrema$1 = (p) => roots$2(derivative$1(p));
|
|
348
|
+
/** @internal */
|
|
284
349
|
const monotonicity$1 = dual((args) => isCubicPolynomial$1(args[0]), (p, i) => {
|
|
285
350
|
invariant(i === void 0 || size(i) > 0, "monotonicity is undefined over a zero-width interval");
|
|
286
351
|
if (p.c3 === 0 && p.c2 === 0 && p.c1 === 0) return "constant";
|
|
@@ -290,26 +355,35 @@ const monotonicity$1 = dual((args) => isCubicPolynomial$1(args[0]), (p, i) => {
|
|
|
290
355
|
if (filter(toOpen(i), [...extrema$1(p)]).length > 0) return "none";
|
|
291
356
|
return guaranteedMonotonicityFromComparison(solve$1(p, i.start), solve$1(p, i.end));
|
|
292
357
|
});
|
|
358
|
+
/** @internal */
|
|
293
359
|
const isMonotonic$1 = dual((args) => isCubicPolynomial$1(args[0]), ((p, i) => {
|
|
294
360
|
const m = monotonicity$1(p, i);
|
|
295
361
|
return m === "increasing" || m === "decreasing";
|
|
296
362
|
}));
|
|
363
|
+
/** @internal */
|
|
297
364
|
const isIncreasing$1 = dual((args) => isCubicPolynomial$1(args[0]), ((p, i) => monotonicity$1(p, i) === "increasing"));
|
|
365
|
+
/** @internal */
|
|
298
366
|
const isDecreasing$1 = dual((args) => isCubicPolynomial$1(args[0]), ((p, i) => monotonicity$1(p, i) === "decreasing"));
|
|
367
|
+
/** @internal */
|
|
299
368
|
const asMonotonic$1 = (p, i) => {
|
|
300
369
|
invariant(isMonotonic$1(p, i), "cubic polynomial is not monotonic");
|
|
301
370
|
return p;
|
|
302
371
|
};
|
|
372
|
+
/** @internal */
|
|
303
373
|
const asIncreasing$1 = (p, i) => {
|
|
304
374
|
invariant(isIncreasing$1(p, i), "cubic polynomial is not increasing");
|
|
305
375
|
return p;
|
|
306
376
|
};
|
|
377
|
+
/** @internal */
|
|
307
378
|
const asDecreasing$1 = (p, i) => {
|
|
308
379
|
invariant(isDecreasing$1(p, i), "cubic polynomial is not decreasing");
|
|
309
380
|
return p;
|
|
310
381
|
};
|
|
382
|
+
/** @internal */
|
|
311
383
|
const domain$1 = dual(2, (p, r) => fromMinMax(...solveInverse$1(p, r.start), ...solveInverse$1(p, r.end)));
|
|
384
|
+
/** @internal */
|
|
312
385
|
const range$1 = dual(2, (p, d) => fromMinMax(solve$1(p, d.start), solve$1(p, d.end), ...filter(d, [...extrema$1(p)]).map((e) => solve$1(p, e))));
|
|
386
|
+
/** @internal */
|
|
313
387
|
const length$1 = dual(2, (p, dom) => {
|
|
314
388
|
if (size(dom) === 0) return 0;
|
|
315
389
|
if (p.c3 === 0) {
|
|
@@ -320,6 +394,7 @@ const length$1 = dual(2, (p, dom) => {
|
|
|
320
394
|
const { scale, shift } = scaleShift(biunit, dom);
|
|
321
395
|
return (GL32_W0 * Math.sqrt(1 + solve$2(d, shift + scale * -GL32_X0) ** 2) + GL32_W0 * Math.sqrt(1 + solve$2(d, shift + scale * GL32_X0) ** 2) + GL32_W1 * Math.sqrt(1 + solve$2(d, shift + scale * -GL32_X1) ** 2) + GL32_W1 * Math.sqrt(1 + solve$2(d, shift + scale * GL32_X1) ** 2) + GL32_W2 * Math.sqrt(1 + solve$2(d, shift + scale * -GL32_X2) ** 2) + GL32_W2 * Math.sqrt(1 + solve$2(d, shift + scale * GL32_X2) ** 2) + GL32_W3 * Math.sqrt(1 + solve$2(d, shift + scale * -GL32_X3) ** 2) + GL32_W3 * Math.sqrt(1 + solve$2(d, shift + scale * GL32_X3) ** 2) + GL32_W4 * Math.sqrt(1 + solve$2(d, shift + scale * -GL32_X4) ** 2) + GL32_W4 * Math.sqrt(1 + solve$2(d, shift + scale * GL32_X4) ** 2) + GL32_W5 * Math.sqrt(1 + solve$2(d, shift + scale * -GL32_X5) ** 2) + GL32_W5 * Math.sqrt(1 + solve$2(d, shift + scale * GL32_X5) ** 2) + GL32_W6 * Math.sqrt(1 + solve$2(d, shift + scale * -GL32_X6) ** 2) + GL32_W6 * Math.sqrt(1 + solve$2(d, shift + scale * GL32_X6) ** 2) + GL32_W7 * Math.sqrt(1 + solve$2(d, shift + scale * -GL32_X7) ** 2) + GL32_W7 * Math.sqrt(1 + solve$2(d, shift + scale * GL32_X7) ** 2) + GL32_W8 * Math.sqrt(1 + solve$2(d, shift + scale * -GL32_X8) ** 2) + GL32_W8 * Math.sqrt(1 + solve$2(d, shift + scale * GL32_X8) ** 2) + GL32_W9 * Math.sqrt(1 + solve$2(d, shift + scale * -GL32_X9) ** 2) + GL32_W9 * Math.sqrt(1 + solve$2(d, shift + scale * GL32_X9) ** 2) + GL32_W10 * Math.sqrt(1 + solve$2(d, shift + scale * -GL32_X10) ** 2) + GL32_W10 * Math.sqrt(1 + solve$2(d, shift + scale * GL32_X10) ** 2) + GL32_W11 * Math.sqrt(1 + solve$2(d, shift + scale * -GL32_X11) ** 2) + GL32_W11 * Math.sqrt(1 + solve$2(d, shift + scale * GL32_X11) ** 2) + GL32_W12 * Math.sqrt(1 + solve$2(d, shift + scale * -GL32_X12) ** 2) + GL32_W12 * Math.sqrt(1 + solve$2(d, shift + scale * GL32_X12) ** 2) + GL32_W13 * Math.sqrt(1 + solve$2(d, shift + scale * -GL32_X13) ** 2) + GL32_W13 * Math.sqrt(1 + solve$2(d, shift + scale * GL32_X13) ** 2) + GL32_W14 * Math.sqrt(1 + solve$2(d, shift + scale * -GL32_X14) ** 2) + GL32_W14 * Math.sqrt(1 + solve$2(d, shift + scale * GL32_X14) ** 2) + GL32_W15 * Math.sqrt(1 + solve$2(d, shift + scale * -GL32_X15) ** 2) + GL32_W15 * Math.sqrt(1 + solve$2(d, shift + scale * GL32_X15) ** 2)) * scale;
|
|
322
396
|
});
|
|
397
|
+
/** @internal */
|
|
323
398
|
const curvature$1 = dual(2, (p, x) => {
|
|
324
399
|
const d = derivative$1(p);
|
|
325
400
|
const dd = derivative$2(d);
|
|
@@ -497,4 +572,4 @@ const curvature = curvature$1;
|
|
|
497
572
|
//#endregion
|
|
498
573
|
export { equals$2 as $, GL32_X1 as A, isMonotonic$3 as At, GL32_X5 as B, GL32_W4 as C, equals$3 as Ct, GL32_W8 as D, isDecreasing$3 as Dt, GL32_W7 as E, fromVector$3 as Et, GL32_X14 as F, solve$3 as Ft, antiderivative as G, GL32_X7 as H, GL32_X15 as I, solveInverse$3 as It, asMonotonic$2 as J, asDecreasing$2 as K, GL32_X2 as L, toInverseSolver$3 as Lt, GL32_X11 as M, make$3 as Mt, GL32_X12 as N, monotonicity$3 as Nt, GL32_W9 as O, isIncreasing$3 as Ot, GL32_X13 as P, range$3 as Pt, domain$2 as Q, GL32_X3 as R, toSolver$3 as Rt, GL32_W3 as S, domain$3 as St, GL32_W6 as T, fromPoints$3 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 _, asDecreasing$3 as _t, isIncreasing as a, isMonotonic$2 as at, GL32_W15 as b, coefficients$3 as bt, range as c, make$2 as ct, solveInverse as d, roots$2 as dt, extreme as et, subdivide as f, solve$2 as ft, GL32_W11 as g, antiderivative$1 as gt, GL32_W10 as h, toSolver$2 as ht, isDecreasing as i, isIncreasing$2 as it, GL32_X10 as j, length$3 as jt, GL32_X0 as k, isLinearPolynomial as kt, roots 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, solve as u, range$2 as ut, GL32_W13 as v, asIncreasing$3 as vt, GL32_W5 as w, fromPointSlope as wt, GL32_W2 as x, derivative$3 as xt, GL32_W14 as y, asMonotonic$3 as yt, GL32_X4 as z };
|
|
499
574
|
|
|
500
|
-
//# sourceMappingURL=cubic-
|
|
575
|
+
//# sourceMappingURL=cubic-BK8xjSkd.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cubic-BK8xjSkd.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","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","isMonotonic","isIncreasing","isDecreasing","asMonotonic","asIncreasing","asDecreasing","domain","Interval.fromMinMax","range","Linear.range","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","isMonotonic","isIncreasing","isDecreasing","asMonotonic","asIncreasing","asDecreasing","domain","Interval.fromMinMax","range","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.length","internal.curvature"],"sources":["../../src/polynomial/quadratic.internal.circular.ts","../../src/polynomial/linear.internal.ts","../../src/polynomial/cubic.internal.circular.ts","../../src/polynomial/monotonicity.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 { 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) =>\n p.c1 === 0 ? 'constant' : p.c1 > 0 ? 'increasing' : '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 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","export type Monotonicity = 'none' | 'increasing' | 'decreasing' | 'constant'\nexport type GuaranteedMonotonicity = 'increasing' | 'decreasing' | 'constant'\n\nexport function guaranteedMonotonicityFromComparison(\n s0: number,\n s1: number,\n): GuaranteedMonotonicity {\n if (s0 < s1) {\n return 'increasing'\n }\n\n if (s0 > s1) {\n return 'decreasing'\n }\n\n return 'constant'\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 { guaranteedMonotonicityFromComparison, type Monotonicity } from './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,\n (p: QuadraticPolynomial, i?: Interval.Interval) => 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 '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 'none'\n }\n\n return guaranteedMonotonicityFromComparison(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 const m = monotonicity(p, i as Interval.Interval)\n return m === 'increasing' || m === 'decreasing'\n}) 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) === '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) === '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 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 { 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 { guaranteedMonotonicityFromComparison, type Monotonicity } from './monotonicity.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,\n (p: CubicPolynomial, i?: Interval.Interval) => 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 '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 '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 'none'\n }\n\n return guaranteedMonotonicityFromComparison(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 const m = monotonicity(p, i as Interval.Interval)\n return m === 'increasing' || m === 'decreasing'\n}) 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) === '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) === '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 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.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\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;;;;;ACTd,MAAa,yBAAwC,OAAO,IAAI,eAAe;AAG/E,IAAM,uBAAN,cAAmC,SAA8C;CAC/E,CAAU,0BAAkD;CAG5D;CACA;CAEA,YAAY,KAAK,GAAG,KAAK,GAAG;EAC1B,OAAO;EAEP,KAAK,KAAK;EACV,KAAK,KAAK;;;;AAKd,MAAa,sBAAsB,MACjC,OAAO,MAAM,YAAY,MAAM,QAAQ,0BAA0B;;AAGnE,MAAaA,WAAS,KAGpB,IAAI,GAAqB,MAAwB,UAAU,E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