curvy 2.0.0-alpha.11 → 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.
- package/dist/characteristic/index.mjs +1 -1
- package/dist/curve/index.mjs +1 -1
- package/dist/curve/rationalCubic2d.d.ts +195 -11
- package/dist/interval/index.mjs +1 -1
- package/dist/monotonicity/index.d.ts +4 -0
- package/dist/monotonicity/index.mjs +2 -0
- package/dist/monotonicity/monotonicity.d.ts +80 -0
- package/dist/path/index.mjs +16 -387
- package/dist/path/index.mjs.map +1 -1
- package/dist/path/rationalCubic2d.d.ts +27 -0
- package/dist/polynomial/cubic.d.ts +2 -2
- package/dist/polynomial/index.mjs +2 -2
- package/dist/polynomial/linear.d.ts +7 -7
- package/dist/polynomial/quadratic.d.ts +2 -2
- package/dist/shared/{characteristic-Hb7F8SBw.mjs → characteristic-BkEr-rr8.mjs} +2 -2
- package/dist/shared/{characteristic-Hb7F8SBw.mjs.map → characteristic-BkEr-rr8.mjs.map} +1 -1
- package/dist/shared/{cubic-DHJrzZJN.mjs → cubic-BL6dpuHh.mjs} +18 -30
- package/dist/shared/cubic-BL6dpuHh.mjs.map +1 -0
- package/dist/shared/{interval2d-DPmvk_Qe.mjs → interval2d-AtneyI45.mjs} +1 -1
- package/dist/shared/{interval2d-DPmvk_Qe.mjs.map → interval2d-AtneyI45.mjs.map} +1 -1
- package/dist/shared/monotonicity-BdebFOtv.mjs +34 -0
- package/dist/shared/monotonicity-BdebFOtv.mjs.map +1 -0
- package/dist/shared/{quadratic-BZmfZE71.mjs → quadratic-DPrUsFCp.mjs} +9 -9
- package/dist/shared/quadratic-DPrUsFCp.mjs.map +1 -0
- package/dist/shared/{rationalCubic2d-IroMR6AA.mjs → rationalCubic2d-CeHgpNht.mjs} +373 -79
- package/dist/shared/rationalCubic2d-CeHgpNht.mjs.map +1 -0
- package/dist/shared/{rationalCubic2d-nN-oSrLr.mjs → rationalCubic2d-H1J2Fjyy.mjs} +404 -23
- package/dist/shared/rationalCubic2d-H1J2Fjyy.mjs.map +1 -0
- package/dist/shared/{solution-B6KY1E7M.mjs → solution-B2JdOZpe.mjs} +1 -1
- package/dist/shared/{solution-B6KY1E7M.mjs.map → solution-B2JdOZpe.mjs.map} +1 -1
- package/dist/solution/index.mjs +1 -1
- package/dist/splines/index.d.ts +3 -0
- package/dist/splines/index.mjs +218 -120
- package/dist/splines/index.mjs.map +1 -1
- package/dist/splines/linear2d.d.ts +102 -0
- package/dist/splines/linear2d.internal.d.ts +2 -0
- package/package.json +5 -1
- package/dist/polynomial/monotonicity.d.ts +0 -3
- package/dist/shared/cubic-DHJrzZJN.mjs.map +0 -1
- package/dist/shared/quadratic-BZmfZE71.mjs.map +0 -1
- package/dist/shared/rationalCubic2d-IroMR6AA.mjs.map +0 -1
- package/dist/shared/rationalCubic2d-nN-oSrLr.mjs.map +0 -1
|
@@ -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-
|
|
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 `
|
|
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 `
|
|
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 `
|
|
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 `
|
|
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 `
|
|
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 `
|
|
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 `
|
|
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-
|
|
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,MAAaC,cAA6CC;AAE1D,MAAaC,WAkBTC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC9TJ,MAAa,wBACXC;AAEF,MAAa,SAoBTC;;;;;;;;;;AAWJ,MAAa,OAAuEC;;;;;;;;AASpF,MAAa,aAAkDC;;;;;;;;;;;;AAa/D,MAAa,aACXC;AAEF,MAAa,QAkBTC;;;;;;;AAQJ,MAAa,WAA8DC;AAE3E,MAAa,eAkCTC;;;;;;;AAQJ,MAAa,kBAEoCC;;;;;;;;AASjD,MAAa,eACXC;;;;;;;;AASF,MAAa,aAA2DC;;;;;;;;AASxE,MAAa,QAAgEC;;;;;;;;AAS7E,MAAa,UAAsDC;AAEnE,MAAa,eAsBTC;;;;;;;;;;;AAYJ,MAAa,cAGTC;;;;;;AAOJ,MAAa,eAGTC;;;;;;AAOJ,MAAa,eAGTC;;;;;;;;;;AAWJ,MAAa,cAG6BC;;;;;;AAO1C,MAAa,eAG8BC;;;;;;AAO3C,MAAa,eAG8BC;AAE3C,MAAa,iBAkBTC;AAEJ,MAAa,SAkBTC;AAEJ,MAAa,QAkBTC;;;;;;;;;;AAWJ,MAAa,YAAgDC;AAE7D,MAAa,SAkBTC;AAEJ,MAAa,YAkBTC"}
|