curvy 2.0.0-alpha.2 → 2.0.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/dist/characteristic/{index.d.mts → characteristic.d.ts} +15 -23
  2. package/dist/characteristic/index.d.ts +1 -0
  3. package/dist/characteristic/index.mjs +1 -1
  4. package/dist/curve/cubic2d.d.ts +219 -0
  5. package/dist/curve/index.d.ts +12 -0
  6. package/dist/curve/index.mjs +1 -1
  7. package/dist/curve/linear2d.d.ts +199 -0
  8. package/dist/curve/quadratic2d.d.ts +227 -0
  9. package/dist/curve/rationalCubic2d.d.ts +200 -0
  10. package/dist/dimensions.d.ts +23 -0
  11. package/dist/interval/index.d.ts +6 -0
  12. package/dist/interval/index.mjs +2 -2
  13. package/dist/interval/interval.d.ts +525 -0
  14. package/dist/interval/interval2d.d.ts +167 -0
  15. package/dist/length.d.ts +32 -0
  16. package/dist/matrix/index.d.ts +9 -0
  17. package/dist/matrix/matrix2x2.d.ts +339 -0
  18. package/dist/matrix/matrix3x3.d.ts +400 -0
  19. package/dist/matrix/matrix4x4.d.ts +443 -0
  20. package/dist/number.d.ts +276 -0
  21. package/dist/path/cubic2d.d.ts +155 -0
  22. package/dist/path/index.d.ts +12 -0
  23. package/dist/path/index.mjs +6 -6
  24. package/dist/path/index.mjs.map +1 -1
  25. package/dist/path/linear2d.d.ts +135 -0
  26. package/dist/path/quadratic2d.d.ts +127 -0
  27. package/dist/path/rationalCubic2d.d.ts +120 -0
  28. package/dist/path/traits.d.ts +31 -0
  29. package/dist/polynomial/cubic.d.ts +381 -0
  30. package/dist/polynomial/index.d.ts +9 -0
  31. package/dist/polynomial/index.mjs +2 -2
  32. package/dist/polynomial/linear.d.ts +321 -0
  33. package/dist/polynomial/monotonicity.d.ts +3 -0
  34. package/dist/polynomial/quadratic.d.ts +375 -0
  35. package/dist/polynomial/traits.d.ts +56 -0
  36. package/dist/shared/{characteristic-B9nCh_cx.mjs → characteristic-DLlhja-I.mjs} +9 -9
  37. package/dist/shared/{characteristic-B9nCh_cx.mjs.map → characteristic-DLlhja-I.mjs.map} +1 -1
  38. package/dist/shared/{cubic-CpHAx8cC.mjs → cubic-CMonq6bg.mjs} +26 -5
  39. package/dist/shared/cubic-CMonq6bg.mjs.map +1 -0
  40. package/dist/shared/{interval-05CR6eBf.mjs → interval-X1EYuf-T.mjs} +2 -2
  41. package/dist/shared/{interval-05CR6eBf.mjs.map → interval-X1EYuf-T.mjs.map} +1 -1
  42. package/dist/shared/{interval2d-8IBZnUOq.mjs → interval2d-ca0J1NMr.mjs} +8 -8
  43. package/dist/shared/{interval2d-8IBZnUOq.mjs.map → interval2d-ca0J1NMr.mjs.map} +1 -1
  44. package/dist/shared/{quadratic-CamozcFc.mjs → quadratic-DyeMtvET.mjs} +20 -2
  45. package/dist/shared/quadratic-DyeMtvET.mjs.map +1 -0
  46. package/dist/shared/{rationalCubic2d-Bys2Uory.mjs → rationalCubic2d-D658ltUM.mjs} +17 -17
  47. package/dist/shared/{rationalCubic2d-Bys2Uory.mjs.map → rationalCubic2d-D658ltUM.mjs.map} +1 -1
  48. package/dist/shared/{rationalCubic2d-BEgUGSFf.mjs → rationalCubic2d-Vw4qGPZj.mjs} +9 -9
  49. package/dist/shared/{rationalCubic2d-BEgUGSFf.mjs.map → rationalCubic2d-Vw4qGPZj.mjs.map} +1 -1
  50. package/dist/shared/{solution-CrtLfqEq.mjs → solution-3TDATEMn.mjs} +28 -2
  51. package/dist/shared/solution-3TDATEMn.mjs.map +1 -0
  52. package/dist/shared/{vector2-CL1HDdPr.mjs → vector2-CCuJx1rX.mjs} +6 -6
  53. package/dist/shared/{vector2-CL1HDdPr.mjs.map → vector2-CCuJx1rX.mjs.map} +1 -1
  54. package/dist/shared/{vector3-D-tv_aKL.mjs → vector3-C-qgKAjR.mjs} +2 -2
  55. package/dist/shared/{vector3-D-tv_aKL.mjs.map → vector3-C-qgKAjR.mjs.map} +1 -1
  56. package/dist/shared/{vector4-5KbjoHVj.mjs → vector4-BhOKDhD5.mjs} +2 -2
  57. package/dist/shared/{vector4-5KbjoHVj.mjs.map → vector4-BhOKDhD5.mjs.map} +1 -1
  58. package/dist/solution/index.d.ts +3 -0
  59. package/dist/solution/index.mjs +1 -1
  60. package/dist/{shared/solution-sNQ-ZVhN.d.mts → solution/solution.d.ts} +81 -68
  61. package/dist/splines/basis2d.d.ts +122 -0
  62. package/dist/splines/bezier2d.d.ts +202 -0
  63. package/dist/splines/cardinal2d.d.ts +273 -0
  64. package/dist/splines/hermite2d.d.ts +117 -0
  65. package/dist/splines/index.d.ts +15 -0
  66. package/dist/splines/index.mjs +193 -35
  67. package/dist/splines/index.mjs.map +1 -1
  68. package/dist/splines/rationalBezier2d.d.ts +148 -0
  69. package/dist/splines/util.d.ts +5 -0
  70. package/dist/utils.d.ts +73 -0
  71. package/dist/vector/index.d.ts +9 -0
  72. package/dist/vector/index.mjs +3 -3
  73. package/dist/vector/vector2.d.ts +446 -0
  74. package/dist/vector/vector3.d.ts +449 -0
  75. package/dist/vector/vector4.d.ts +253 -0
  76. package/package.json +13 -13
  77. package/dist/curve/index.d.mts +0 -2
  78. package/dist/interval/index.d.mts +0 -3
  79. package/dist/matrix/index.d.mts +0 -2
  80. package/dist/number.d.mts +0 -280
  81. package/dist/path/index.d.mts +0 -261
  82. package/dist/polynomial/index.d.mts +0 -2
  83. package/dist/shared/cubic-BajUY0JT.d.mts +0 -1100
  84. package/dist/shared/cubic-CpHAx8cC.mjs.map +0 -1
  85. package/dist/shared/interval-Dy-RMEE3.d.mts +0 -533
  86. package/dist/shared/interval2d-C2id9u31.d.mts +0 -172
  87. package/dist/shared/matrix4x4-Dm_tSiH1.d.mts +0 -1183
  88. package/dist/shared/quadratic-CamozcFc.mjs.map +0 -1
  89. package/dist/shared/rationalCubic2d-B6g97ryJ.d.mts +0 -308
  90. package/dist/shared/rationalCubic2d-DlQfBURs.d.mts +0 -818
  91. package/dist/shared/solution-CrtLfqEq.mjs.map +0 -1
  92. package/dist/shared/utils-MCckigYk.d.mts +0 -76
  93. package/dist/shared/vector2-DPUY3_eA.d.mts +0 -470
  94. package/dist/shared/vector3-DqeOZtOB.d.mts +0 -703
  95. package/dist/solution/index.d.mts +0 -2
  96. package/dist/splines/index.d.mts +0 -701
  97. package/dist/utils.d.mts +0 -2
  98. package/dist/vector/index.d.mts +0 -3
@@ -0,0 +1,227 @@
1
+ import type { Interval2d } from '../interval/interval2d';
2
+ import type { TwoDimensional } from '../dimensions';
3
+ import type { Closed, Interval } from '../interval/interval';
4
+ import type { Pipeable } from '../utils';
5
+ import type { QuadraticPolynomial } from '../polynomial/quadratic';
6
+ import type { Decreasing, Increasing, Monotonic } from '../polynomial/traits';
7
+ import type * as Solution from '../solution/solution';
8
+ import type { Vector2 } from '../vector/vector2';
9
+ import type { LinearCurve2d } from './linear2d';
10
+
11
+ declare const QuadraticCurve2dTypeId: unique symbol;
12
+ type QuadraticCurve2dTypeId = typeof QuadraticCurve2dTypeId;
13
+
14
+
15
+ export type { Monotonic, Increasing, Decreasing } from '../polynomial/traits';
16
+ /**
17
+ * A quadratic curve in 2D space.
18
+ *
19
+ * All fields are readonly and immutable, and all operations create new instances.
20
+ *
21
+ * The two type parameters carry the trait sets of the curve's per-axis
22
+ * polynomials. Refiners check monotonicity over the unit interval `[0, 1]` —
23
+ * the curve's natural parameter domain.
24
+ *
25
+ * @since 1.0.0
26
+ */
27
+ export interface QuadraticCurve2d<out XTraits = unknown, out YTraits = unknown> extends Pipeable, TwoDimensional<QuadraticPolynomial<XTraits>, QuadraticPolynomial<YTraits>> {
28
+ readonly [QuadraticCurve2dTypeId]: QuadraticCurve2dTypeId;
29
+ }
30
+ /**
31
+ * Creates a new `QuadraticCurve2d` instance from polynomial parameters.
32
+ *
33
+ * @param c0 - The x polynomial.
34
+ * @param c1 - The y polynomial.
35
+ * @returns A new `QuadraticCurve2d` instance.
36
+ * @since 1.0.0
37
+ */
38
+ export declare const fromPolynomials: (c0: QuadraticPolynomial, c1: QuadraticPolynomial) => QuadraticCurve2d;
39
+ /**
40
+ * Creates a new `QuadraticCurve2d` instance from monomial coefficient vectors.
41
+ *
42
+ * Each argument bundles the per-axis coefficient at the given power: `c0`
43
+ * holds the x⁰ term, `c1` holds the x¹ term, and so on. The resulting curve
44
+ * evaluates to `c0 + c1·t + c2·t²` per axis.
45
+ *
46
+ * @param c0 - The x⁰ coefficients (x and y).
47
+ * @param c1 - The x¹ coefficients (x and y).
48
+ * @param c2 - The x² coefficients (x and y).
49
+ * @returns A new `QuadraticCurve2d` instance.
50
+ * @since 2.0.0
51
+ */
52
+ export declare const fromCoefficients: (c0: Vector2, c1: Vector2, c2: Vector2) => QuadraticCurve2d;
53
+ /**
54
+ * Creates a new `QuadraticCurve2d` instance from quadratic Bézier control
55
+ * points.
56
+ *
57
+ * The three arguments are the Bernstein-basis control points: `p0` and `p2`
58
+ * are the curve's endpoints and `p1` is the off-curve control handle. The
59
+ * implementation converts to the curve's internal monomial form in closed
60
+ * form.
61
+ *
62
+ * @param p0 - The first control point (curve start).
63
+ * @param p1 - The second control point (control handle).
64
+ * @param p2 - The third control point (curve end).
65
+ * @returns A new `QuadraticCurve2d` instance whose curve matches the given Bézier.
66
+ * @since 2.0.0
67
+ */
68
+ export declare const fromBezierPoints: (p0: Vector2, p1: Vector2, p2: Vector2) => QuadraticCurve2d;
69
+ /**
70
+ * Checks if a value is a `QuadraticCurve2d`.
71
+ *
72
+ * @param c - The value to check.
73
+ * @returns `true` if the value is a `QuadraticCurve2d`, `false` otherwise.
74
+ * @since 1.0.0
75
+ */
76
+ export declare const isQuadraticCurve2d: (c: unknown) => c is QuadraticCurve2d;
77
+ export declare const solve: {
78
+ /**
79
+ * Solves the quadratic curve for a given parameter t.
80
+ *
81
+ * @param t - The parameter value.
82
+ * @returns A function that takes a quadratic curve and returns the point on the curve at parameter t.
83
+ * @since 1.0.0
84
+ */
85
+ (t: number): (c: QuadraticCurve2d) => Vector2;
86
+ /**
87
+ * Solves the quadratic curve for a given parameter t.
88
+ *
89
+ * @param c - The quadratic curve to solve.
90
+ * @param t - The parameter value.
91
+ * @returns The point on the curve at parameter t.
92
+ * @since 1.0.0
93
+ */
94
+ (c: QuadraticCurve2d, t: number): Vector2;
95
+ };
96
+ export declare const length: {
97
+ /**
98
+ * Computes the length of the quadratic curve over a given interval.
99
+ *
100
+ * @param c - The quadratic curve to compute the length of.
101
+ * @param i - The interval over which to compute the length.
102
+ * @returns The length of the quadratic curve over the interval.
103
+ * @since 1.0.0
104
+ */
105
+ (c: QuadraticCurve2d, i: Interval): number;
106
+ /**
107
+ * Computes the length of the quadratic curve over a given interval.
108
+ *
109
+ * @param i - The interval over which to compute the length.
110
+ * @returns A function that takes a quadratic curve and returns the length of the curve over the interval.
111
+ * @since 1.0.0
112
+ */
113
+ (i: Interval): (c: QuadraticCurve2d) => number;
114
+ };
115
+ export declare const solveAtX: {
116
+ /**
117
+ * Evaluates the curve's y values at a given x. Because the x polynomial is
118
+ * `Monotonic`, the inverse has at most one solution — at most one y value.
119
+ *
120
+ * @param c - The quadratic curve.
121
+ * @param x - The x coordinate.
122
+ * @returns Zero or one y values, in t-ascending order.
123
+ * @since 2.0.0
124
+ */
125
+ <XT extends Monotonic, YT>(c: QuadraticCurve2d<XT, YT>, x: number): Solution.AtMostOne<number>;
126
+ /**
127
+ * Evaluates the curve's y values at a given x. The result is the y values
128
+ * the curve passes through where x(t) = the given x — up to two solutions
129
+ * for a quadratic curve.
130
+ *
131
+ * @param c - The quadratic curve.
132
+ * @param x - The x coordinate.
133
+ * @returns The y values at x, in t-ascending order.
134
+ * @since 2.0.0
135
+ */
136
+ <XT, YT>(c: QuadraticCurve2d<XT, YT>, x: number): Solution.AtMostTwo<number>;
137
+ /** @since 2.0.0 */
138
+ (x: number): {
139
+ <XT extends Monotonic, YT>(c: QuadraticCurve2d<XT, YT>): Solution.AtMostOne<number>;
140
+ <XT, YT>(c: QuadraticCurve2d<XT, YT>): Solution.AtMostTwo<number>;
141
+ };
142
+ };
143
+ export declare const solveAtY: {
144
+ /**
145
+ * Evaluates the curve's x values at a given y. Because the y polynomial is
146
+ * `Monotonic`, the inverse has at most one solution.
147
+ *
148
+ * @param c - The quadratic curve.
149
+ * @param y - The y coordinate.
150
+ * @returns Zero or one x values, in t-ascending order.
151
+ * @since 2.0.0
152
+ */
153
+ <XT, YT extends Monotonic>(c: QuadraticCurve2d<XT, YT>, y: number): Solution.AtMostOne<number>;
154
+ /**
155
+ * Evaluates the curve's x values at a given y. The result is the x values
156
+ * the curve passes through where y(t) = the given y — up to two solutions
157
+ * for a quadratic curve.
158
+ *
159
+ * @param c - The quadratic curve.
160
+ * @param y - The y coordinate.
161
+ * @returns The x values at y, in t-ascending order.
162
+ * @since 2.0.0
163
+ */
164
+ <XT, YT>(c: QuadraticCurve2d<XT, YT>, y: number): Solution.AtMostTwo<number>;
165
+ /** @since 2.0.0 */
166
+ (y: number): {
167
+ <XT, YT extends Monotonic>(c: QuadraticCurve2d<XT, YT>): Solution.AtMostOne<number>;
168
+ <XT, YT>(c: QuadraticCurve2d<XT, YT>): Solution.AtMostTwo<number>;
169
+ };
170
+ };
171
+ /**
172
+ * Computes the derivative of a quadratic curve.
173
+ *
174
+ * @param c - The quadratic curve to compute the derivative of.
175
+ * @returns The derivative of the quadratic curve as a linear curve.
176
+ * @since 1.0.0
177
+ */
178
+ export declare const derivative: (c: QuadraticCurve2d) => LinearCurve2d;
179
+ export declare const curvature: {
180
+ /**
181
+ * Computes the curvature of the quadratic curve at a given parameter t.
182
+ *
183
+ * @param c - The quadratic curve to compute the curvature for.
184
+ * @param t - The parameter value.
185
+ * @returns The curvature of the quadratic curve at parameter t.
186
+ * @since 1.0.0
187
+ */
188
+ (c: QuadraticCurve2d, t: number): number;
189
+ /**
190
+ * Computes the curvature of the quadratic curve at a given parameter t.
191
+ *
192
+ * @param t - The parameter value.
193
+ * @returns A function that takes a quadratic curve and returns the curvature of the curve at parameter t.
194
+ * @since 1.0.0
195
+ */
196
+ (t: number): (c: QuadraticCurve2d) => number;
197
+ };
198
+ /**
199
+ * Computes the axis-aligned bounding box of the curve over its parameter
200
+ * domain `[0, 1]`. Accounts for interior extrema, so the box is tight against
201
+ * the curve and not just the control polygon.
202
+ *
203
+ * @param c - The quadratic curve.
204
+ * @returns A closed `Box2d` enclosing the curve.
205
+ * @since 2.0.0
206
+ */
207
+ export declare const boundingBox: (c: QuadraticCurve2d) => Interval2d<Closed, Closed>;
208
+ /**
209
+ * Type-narrowing predicate: refines both axes' traits to include `Monotonic`
210
+ * when both x and y polynomials are monotonic over the unit interval `[0, 1]`.
211
+ *
212
+ * For checking only one axis, call the polynomial-level refiner directly:
213
+ * `QuadraticPolynomial.isMonotonic(curve.x, Interval.unit)`.
214
+ *
215
+ * @since 2.0.0
216
+ */
217
+ export declare const isMonotonic: <XT, YT>(c: QuadraticCurve2d<XT, YT>) => c is QuadraticCurve2d<XT & Monotonic, YT & Monotonic>;
218
+ /** @since 2.0.0 */
219
+ export declare const isIncreasing: <XT, YT>(c: QuadraticCurve2d<XT, YT>) => c is QuadraticCurve2d<XT & Increasing, YT & Increasing>;
220
+ /** @since 2.0.0 */
221
+ export declare const isDecreasing: <XT, YT>(c: QuadraticCurve2d<XT, YT>) => c is QuadraticCurve2d<XT & Decreasing, YT & Decreasing>;
222
+ /** @since 2.0.0 */
223
+ export declare const asMonotonic: <XT, YT>(c: QuadraticCurve2d<XT, YT>) => QuadraticCurve2d<XT & Monotonic, YT & Monotonic>;
224
+ /** @since 2.0.0 */
225
+ export declare const asIncreasing: <XT, YT>(c: QuadraticCurve2d<XT, YT>) => QuadraticCurve2d<XT & Increasing, YT & Increasing>;
226
+ /** @since 2.0.0 */
227
+ export declare const asDecreasing: <XT, YT>(c: QuadraticCurve2d<XT, YT>) => QuadraticCurve2d<XT & Decreasing, YT & Decreasing>;
@@ -0,0 +1,200 @@
1
+ import type { Pipeable } from '../utils';
2
+ import type { CubicPolynomial } from '../polynomial/cubic';
3
+ import type { Increasing, Monotonic } from '../polynomial/traits';
4
+ import type * as Solution from '../solution/solution';
5
+ import type { Vector2, Weighted } from '../vector/vector2';
6
+ import type { CubicCurve2d } from './cubic2d';
7
+
8
+ declare const RationalCubicCurve2dTypeId: unique symbol;
9
+ type RationalCubicCurve2dTypeId = typeof RationalCubicCurve2dTypeId;
10
+ declare const RationalCurveTraits: unique symbol;
11
+ type RationalCurveTraits = typeof RationalCurveTraits;
12
+
13
+
14
+ export type { Decreasing, Increasing, Monotonic } from '../polynomial/traits';
15
+ export { RationalCurveTraits } from './rationalCubic2d.internal';
16
+ /**
17
+ * A rational cubic curve in 2D space.
18
+ *
19
+ * Represented as three cubic polynomials in the parameter `t`: per-axis
20
+ * numerators `x`, `y`, and a shared denominator `w`. Evaluation is
21
+ * `(x(t)/w(t), y(t)/w(t))` — the projection from homogeneous coordinates
22
+ * back to the plane. With all weights equal at the source (e.g. produced
23
+ * from a non-rational Bézier with unit weights), `w` is constant and the
24
+ * curve coincides with a polynomial cubic.
25
+ *
26
+ * The two type parameters carry per-axis monotonicity trait brands attached
27
+ * to the rational functions `x(t)/w(t)` and `y(t)/w(t)`. Unlike
28
+ * `CubicCurve2d`, traits do not flow through to the underlying polynomials —
29
+ * monotonicity of a ratio of cubics is not the same property as monotonicity
30
+ * of either cubic alone, so the brand lives on the curve itself. Constructors
31
+ * with construction-time monotonicity guarantees (e.g. {@link makeMonotonicEasing})
32
+ * return curves with `Increasing` brands attached, narrowing downstream
33
+ * operations like {@link solveAtX} to single-solution returns.
34
+ *
35
+ * All fields are readonly and immutable, and all operations create new instances.
36
+ *
37
+ * @since 2.0.0
38
+ */
39
+ export interface RationalCubicCurve2d<out XTraits = unknown, out YTraits = unknown> extends Pipeable {
40
+ readonly [RationalCubicCurve2dTypeId]: RationalCubicCurve2dTypeId;
41
+ readonly [RationalCurveTraits]: [XTraits, YTraits];
42
+ readonly x: CubicPolynomial;
43
+ readonly y: CubicPolynomial;
44
+ readonly w: CubicPolynomial;
45
+ }
46
+ /**
47
+ * Checks if a value is a `RationalCubicCurve2d`.
48
+ *
49
+ * @param c - The value to check.
50
+ * @returns `true` if the value is a `RationalCubicCurve2d`, `false` otherwise.
51
+ * @since 2.0.0
52
+ */
53
+ export declare const isRationalCubicCurve2d: (c: unknown) => c is RationalCubicCurve2d;
54
+ /**
55
+ * Creates a new `RationalCubicCurve2d` from per-axis numerator polynomials
56
+ * and a shared denominator polynomial.
57
+ *
58
+ * @param x - The x numerator polynomial.
59
+ * @param y - The y numerator polynomial.
60
+ * @param w - The shared denominator polynomial (must be non-zero on `[0, 1]`).
61
+ * @returns A new `RationalCubicCurve2d` instance.
62
+ * @since 2.0.0
63
+ */
64
+ export declare const fromPolynomials: (x: CubicPolynomial, y: CubicPolynomial, w: CubicPolynomial) => RationalCubicCurve2d;
65
+ /**
66
+ * Creates a new `RationalCubicCurve2d` from four weighted cubic Bézier
67
+ * control points. The four control points are lifted to homogeneous form
68
+ * `(w·x, w·y, w)` and the cubic Bernstein basis is expanded into per-channel
69
+ * monomial coefficients, yielding the curve's `x`, `y`, and `w` polynomials.
70
+ *
71
+ * @param p0 - The first weighted control point (curve start).
72
+ * @param p1 - The second weighted control point (start handle).
73
+ * @param p2 - The third weighted control point (end handle).
74
+ * @param p3 - The fourth weighted control point (curve end).
75
+ * @returns A new `RationalCubicCurve2d` instance.
76
+ * @since 2.0.0
77
+ */
78
+ export declare const fromBezierPoints: (p0: Weighted, p1: Weighted, p2: Weighted, p3: Weighted) => RationalCubicCurve2d;
79
+ /**
80
+ * Creates a guaranteed-monotonic rational cubic easing curve via Gregory-
81
+ * Delbourgo style construction. The result interpolates `(0, 0)` and
82
+ * `(1, 1)` with the given endpoint slopes, with `x(t) = t` pinned linearly
83
+ * and a rational cubic numerator for `y(t)`. Monotonicity of `y(t)` is
84
+ * verified rigorously at construction (degree-3 polynomial sign analysis);
85
+ * the returned curve is branded `<Increasing, Increasing>` so that
86
+ * {@link solveAtX} returns `Solution.AtMostOne<number>` without further
87
+ * trait refinement.
88
+ *
89
+ * For input slope combinations that the default Gregory-Delbourgo
90
+ * construction cannot accommodate (typically when one slope is large while
91
+ * the other is small), construction throws. Useful operating range is
92
+ * roughly `m₀, m₁ ∈ [0, 2]` with `m₀ + m₁ ≲ 3`; smoothstep (`0, 0`) and
93
+ * linear (`1, 1`) fall out as special cases.
94
+ *
95
+ * @param startSlope - The easing function's slope at the start (`dy/dx` at `x = 0`); must be finite and non-negative.
96
+ * @param endSlope - The easing function's slope at the end (`dy/dx` at `x = 1`); must be finite and non-negative.
97
+ * @returns A monotone-by-construction rational cubic easing curve.
98
+ * @throws When slopes are negative, non-finite, or produce a non-monotonic curve under the default construction.
99
+ * @since 2.0.0
100
+ */
101
+ export declare const makeMonotonicEasing: (startSlope: number, endSlope: number) => RationalCubicCurve2d<Increasing, Increasing>;
102
+ export declare const solve: {
103
+ /**
104
+ * Evaluates the rational cubic curve at parameter `t`. Returns
105
+ * `(x(t)/w(t), y(t)/w(t))` — three Horner evaluations and two divisions.
106
+ *
107
+ * @param c - The curve to evaluate.
108
+ * @param t - The parameter value.
109
+ * @returns The point on the curve at parameter `t`.
110
+ * @since 2.0.0
111
+ */
112
+ (c: RationalCubicCurve2d, t: number): Vector2;
113
+ /**
114
+ * Evaluates the rational cubic curve at parameter `t`.
115
+ *
116
+ * @param t - The parameter value.
117
+ * @returns A function that takes a curve and returns the point at `t`.
118
+ * @since 2.0.0
119
+ */
120
+ (t: number): (c: RationalCubicCurve2d) => Vector2;
121
+ };
122
+ export declare const solveAtX: {
123
+ /**
124
+ * Evaluates the curve's y values at a given x. Because the curve's x axis
125
+ * carries the `Monotonic` brand, the inverse has at most one solution.
126
+ *
127
+ * @param c - The rational cubic curve with monotonic x.
128
+ * @param x - The x coordinate.
129
+ * @returns Zero or one y values.
130
+ * @since 2.0.0
131
+ */
132
+ <XT extends Monotonic, YT>(c: RationalCubicCurve2d<XT, YT>, x: number): Solution.AtMostOne<number>;
133
+ /**
134
+ * Evaluates the curve's y values at a given x. Up to three solutions —
135
+ * `(X(t) - x·W(t))` is a cubic polynomial in `t`.
136
+ *
137
+ * @param c - The rational cubic curve.
138
+ * @param x - The x coordinate.
139
+ * @returns The y values at x, in t-ascending order.
140
+ * @since 2.0.0
141
+ */
142
+ <XT, YT>(c: RationalCubicCurve2d<XT, YT>, x: number): Solution.AtMostThree<number>;
143
+ /** @since 2.0.0 */
144
+ (x: number): {
145
+ <XT extends Monotonic, YT>(c: RationalCubicCurve2d<XT, YT>): Solution.AtMostOne<number>;
146
+ <XT, YT>(c: RationalCubicCurve2d<XT, YT>): Solution.AtMostThree<number>;
147
+ };
148
+ };
149
+ export declare const solveAtY: {
150
+ /**
151
+ * Evaluates the curve's x values at a given y. Because the curve's y axis
152
+ * carries the `Monotonic` brand, the inverse has at most one solution.
153
+ *
154
+ * @param c - The rational cubic curve with monotonic y.
155
+ * @param y - The y coordinate.
156
+ * @returns Zero or one x values.
157
+ * @since 2.0.0
158
+ */
159
+ <XT, YT extends Monotonic>(c: RationalCubicCurve2d<XT, YT>, y: number): Solution.AtMostOne<number>;
160
+ /**
161
+ * Evaluates the curve's x values at a given y. Up to three solutions.
162
+ *
163
+ * @param c - The rational cubic curve.
164
+ * @param y - The y coordinate.
165
+ * @returns The x values at y, in t-ascending order.
166
+ * @since 2.0.0
167
+ */
168
+ <XT, YT>(c: RationalCubicCurve2d<XT, YT>, y: number): Solution.AtMostThree<number>;
169
+ /** @since 2.0.0 */
170
+ (y: number): {
171
+ <XT, YT extends Monotonic>(c: RationalCubicCurve2d<XT, YT>): Solution.AtMostOne<number>;
172
+ <XT, YT>(c: RationalCubicCurve2d<XT, YT>): Solution.AtMostThree<number>;
173
+ };
174
+ };
175
+ export declare const approximateAsCubicCurves: {
176
+ /**
177
+ * Approximates the rational cubic as a sequence of polynomial cubic curves
178
+ * via recursive subdivision. At each level a candidate polynomial cubic is
179
+ * built by projecting the segment's homogeneous Bézier control points to
180
+ * 2D; if the candidate's midpoint deviates from the true rational midpoint
181
+ * by more than `tolerance`, the segment is split at `t = 0.5` and the
182
+ * procedure recurses on each half. Returns a non-empty array; for a curve
183
+ * that is already polynomial (uniform weights) the result is a single
184
+ * exact segment.
185
+ *
186
+ * @param c - The rational cubic curve to approximate.
187
+ * @param tolerance - Maximum allowed midpoint deviation; must be positive.
188
+ * @returns A sequence of polynomial cubic curves covering the input.
189
+ * @since 2.0.0
190
+ */
191
+ (c: RationalCubicCurve2d, tolerance: number): ReadonlyArray<CubicCurve2d>;
192
+ /**
193
+ * Approximates the rational cubic as a sequence of polynomial cubic curves.
194
+ *
195
+ * @param tolerance - Maximum allowed midpoint deviation; must be positive.
196
+ * @returns A function that takes a curve and returns its polynomial approximation.
197
+ * @since 2.0.0
198
+ */
199
+ (tolerance: number): (c: RationalCubicCurve2d) => ReadonlyArray<CubicCurve2d>;
200
+ };
@@ -0,0 +1,23 @@
1
+ export type TwoDimensionalIndex = 0 | 1;
2
+ export type TwoDimensionalComponent = 'x' | 'y';
3
+ export interface TwoDimensional<out T1, out T2 = T1> {
4
+ readonly x: T1;
5
+ readonly y: T2;
6
+ readonly 0: T1;
7
+ readonly 1: T2;
8
+ }
9
+ export type ThreeDimensionalIndex = TwoDimensionalIndex | 2;
10
+ export type ThreeDimensionalComponent = TwoDimensionalComponent | 'z';
11
+ export interface ThreeDimensional<out T1, out T2 = T1, out T3 = T2> extends TwoDimensional<T1, T2> {
12
+ readonly z: T3;
13
+ readonly 2: T3;
14
+ }
15
+ export type FourDimensionalIndex = ThreeDimensionalIndex | 3;
16
+ export type FourDimensionalComponent = ThreeDimensionalComponent | 'w';
17
+ export interface FourDimensional<out T1, out T2 = T1, out T3 = T2, out T4 = T3> extends ThreeDimensional<T1, T2, T3> {
18
+ readonly w: T4;
19
+ readonly 3: T4;
20
+ }
21
+ export declare const toTwoDimensionalIndex: (input: TwoDimensionalIndex | TwoDimensionalComponent) => TwoDimensionalIndex;
22
+ export declare const toThreeDimensionalIndex: (input: ThreeDimensionalIndex | ThreeDimensionalComponent) => ThreeDimensionalIndex;
23
+ export declare const toFourDimensionalIndex: (input: FourDimensionalIndex | FourDimensionalComponent) => FourDimensionalIndex;
@@ -0,0 +1,6 @@
1
+ import * as IntervalNs from './interval';
2
+ import * as Interval2dNs from './interval2d';
3
+ export { IntervalNs as Interval };
4
+ export type Interval = IntervalNs.Interval;
5
+ export { Interval2dNs as Interval2d };
6
+ export type Interval2d = Interval2dNs.Interval2d;
@@ -1,3 +1,3 @@
1
- import { s as interval_exports } from "../shared/interval-05CR6eBf.mjs";
2
- import { t as interval2d_exports } from "../shared/interval2d-8IBZnUOq.mjs";
1
+ import { s as interval_exports } from "../shared/interval-X1EYuf-T.mjs";
2
+ import { t as interval2d_exports } from "../shared/interval2d-ca0J1NMr.mjs";
3
3
  export { interval_exports as Interval, interval2d_exports as Interval2d };