curvy 2.0.0-alpha.6 → 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.
Files changed (145) hide show
  1. package/dist/characteristic/{index.d.mts → characteristic.d.ts} +9 -17
  2. package/dist/characteristic/index.d.ts +1 -0
  3. package/dist/characteristic/index.mjs +1 -1
  4. package/dist/curve/cubic2d.d.ts +215 -0
  5. package/dist/curve/cubic2d.internal.d.ts +2 -0
  6. package/dist/curve/index.d.ts +12 -0
  7. package/dist/curve/index.mjs +1 -1
  8. package/dist/curve/linear2d.d.ts +195 -0
  9. package/dist/curve/linear2d.internal.d.ts +2 -0
  10. package/dist/curve/quadratic2d.d.ts +223 -0
  11. package/dist/curve/quadratic2d.internal.d.ts +2 -0
  12. package/dist/curve/rationalCubic2d.d.ts +241 -0
  13. package/dist/curve/rationalCubic2d.internal.d.ts +2 -0
  14. package/dist/dimensions.d.ts +23 -0
  15. package/dist/interval/index.d.ts +6 -0
  16. package/dist/interval/index.mjs +2 -2
  17. package/dist/interval/interval.d.ts +525 -0
  18. package/dist/interval/interval.internal.d.ts +1 -0
  19. package/dist/interval/interval2d.d.ts +204 -0
  20. package/dist/interval/interval2d.internal.d.ts +2 -0
  21. package/dist/length.d.ts +32 -0
  22. package/dist/matrix/index.d.ts +9 -0
  23. package/dist/matrix/index.mjs +1 -1
  24. package/dist/matrix/index.mjs.map +1 -1
  25. package/dist/matrix/matrix2x2.d.ts +335 -0
  26. package/dist/matrix/matrix2x2.internal.d.ts +2 -0
  27. package/dist/matrix/matrix3x3.d.ts +396 -0
  28. package/dist/matrix/matrix3x3.internal.d.ts +4 -0
  29. package/dist/matrix/matrix4x4.d.ts +439 -0
  30. package/dist/matrix/matrix4x4.internal.d.ts +2 -0
  31. package/dist/number.d.ts +276 -0
  32. package/dist/number.mjs.map +1 -1
  33. package/dist/path/cubic2d.d.ts +262 -0
  34. package/dist/path/cubic2d.internal.d.ts +2 -0
  35. package/dist/path/index.d.ts +12 -0
  36. package/dist/path/index.mjs +413 -4
  37. package/dist/path/index.mjs.map +1 -1
  38. package/dist/path/linear2d.d.ts +245 -0
  39. package/dist/path/linear2d.internal.d.ts +2 -0
  40. package/dist/path/quadratic2d.d.ts +234 -0
  41. package/dist/path/quadratic2d.internal.d.ts +2 -0
  42. package/dist/path/rationalCubic2d.d.ts +116 -0
  43. package/dist/path/rationalCubic2d.internal.d.ts +2 -0
  44. package/dist/path/traits.d.ts +95 -0
  45. package/dist/polynomial/cubic.d.ts +377 -0
  46. package/dist/polynomial/cubic.internal.circular.d.ts +2 -0
  47. package/dist/polynomial/cubic.internal.d.ts +1 -0
  48. package/dist/polynomial/index.d.ts +9 -0
  49. package/dist/polynomial/index.mjs +2 -2
  50. package/dist/polynomial/linear.d.ts +317 -0
  51. package/dist/polynomial/linear.internal.d.ts +2 -0
  52. package/dist/polynomial/monotonicity.d.ts +3 -0
  53. package/dist/polynomial/quadratic.d.ts +371 -0
  54. package/dist/polynomial/quadratic.internal.circular.d.ts +2 -0
  55. package/dist/polynomial/quadratic.internal.d.ts +1 -0
  56. package/dist/polynomial/traits.d.ts +56 -0
  57. package/dist/shared/{characteristic-DLlhja-I.mjs → characteristic-D9yZWCym.mjs} +3 -3
  58. package/dist/shared/characteristic-D9yZWCym.mjs.map +1 -0
  59. package/dist/shared/{cubic-CMonq6bg.mjs → cubic-BK8xjSkd.mjs} +79 -4
  60. package/dist/shared/cubic-BK8xjSkd.mjs.map +1 -0
  61. package/dist/shared/{interval-X1EYuf-T.mjs → interval-CqC3ZIqj.mjs} +40 -1
  62. package/dist/shared/interval-CqC3ZIqj.mjs.map +1 -0
  63. package/dist/shared/{interval2d-ca0J1NMr.mjs → interval2d-BMDmeL1M.mjs} +45 -4
  64. package/dist/shared/interval2d-BMDmeL1M.mjs.map +1 -0
  65. package/dist/shared/{matrix4x4-Ck2WROK-.mjs → matrix4x4-qyRufxfs.mjs} +62 -3
  66. package/dist/shared/matrix4x4-qyRufxfs.mjs.map +1 -0
  67. package/dist/shared/{quadratic-DyeMtvET.mjs → quadratic-CWXIRh42.mjs} +2 -2
  68. package/dist/shared/quadratic-CWXIRh42.mjs.map +1 -0
  69. package/dist/shared/{rationalCubic2d-Vw4qGPZj.mjs → rationalCubic2d-BZvT9s5N.mjs} +218 -5
  70. package/dist/shared/rationalCubic2d-BZvT9s5N.mjs.map +1 -0
  71. package/dist/shared/{rationalCubic2d-D658ltUM.mjs → rationalCubic2d-DaFTrUXw.mjs} +250 -36
  72. package/dist/shared/rationalCubic2d-DaFTrUXw.mjs.map +1 -0
  73. package/dist/shared/{solution-3TDATEMn.mjs → solution-UKGK826h.mjs} +22 -2
  74. package/dist/shared/solution-UKGK826h.mjs.map +1 -0
  75. package/dist/shared/{vector2-CCuJx1rX.mjs → vector2-CWU3cPB2.mjs} +12 -2
  76. package/dist/shared/vector2-CWU3cPB2.mjs.map +1 -0
  77. package/dist/shared/{vector2.internal-DU_E808S.mjs → vector2.internal-BL8hFl1c.mjs} +31 -2
  78. package/dist/shared/vector2.internal-BL8hFl1c.mjs.map +1 -0
  79. package/dist/shared/{vector3-C-qgKAjR.mjs → vector3-DmMm6pX8.mjs} +12 -2
  80. package/dist/shared/vector3-DmMm6pX8.mjs.map +1 -0
  81. package/dist/shared/{vector4-BhOKDhD5.mjs → vector4-oqPPp45j.mjs} +12 -2
  82. package/dist/shared/vector4-oqPPp45j.mjs.map +1 -0
  83. package/dist/shared/{vector4.internal-5XcaX12X.mjs → vector4.internal-BnnTjVIr.mjs} +45 -2
  84. package/dist/shared/vector4.internal-BnnTjVIr.mjs.map +1 -0
  85. package/dist/solution/index.d.ts +1 -0
  86. package/dist/solution/index.mjs +1 -1
  87. package/dist/{shared/solution-Cf_zoKFU.d.mts → solution/solution.d.ts} +64 -71
  88. package/dist/solution/solution.internal.d.ts +2 -0
  89. package/dist/splines/basis2d.d.ts +118 -0
  90. package/dist/splines/basis2d.internal.d.ts +2 -0
  91. package/dist/splines/bezier2d.d.ts +198 -0
  92. package/dist/splines/bezier2d.internal.d.ts +2 -0
  93. package/dist/splines/cardinal2d.d.ts +269 -0
  94. package/dist/splines/cardinal2d.internal.d.ts +2 -0
  95. package/dist/splines/hermite2d.d.ts +113 -0
  96. package/dist/splines/hermite2d.internal.d.ts +2 -0
  97. package/dist/splines/index.d.ts +15 -0
  98. package/dist/splines/index.mjs +62 -8
  99. package/dist/splines/index.mjs.map +1 -1
  100. package/dist/splines/rationalBezier2d.d.ts +144 -0
  101. package/dist/splines/rationalBezier2d.internal.d.ts +2 -0
  102. package/dist/splines/util.d.ts +5 -0
  103. package/dist/utils.d.ts +73 -0
  104. package/dist/vector/index.d.ts +9 -0
  105. package/dist/vector/index.mjs +3 -3
  106. package/dist/vector/vector2.d.ts +449 -0
  107. package/dist/vector/vector2.internal.d.ts +4 -0
  108. package/dist/vector/vector3.d.ts +454 -0
  109. package/dist/vector/vector3.internal.d.ts +2 -0
  110. package/dist/vector/vector4.d.ts +258 -0
  111. package/dist/vector/vector4.internal.d.ts +2 -0
  112. package/package.json +13 -13
  113. package/dist/curve/index.d.mts +0 -2
  114. package/dist/interval/index.d.mts +0 -3
  115. package/dist/matrix/index.d.mts +0 -2
  116. package/dist/number.d.mts +0 -280
  117. package/dist/path/index.d.mts +0 -261
  118. package/dist/polynomial/index.d.mts +0 -2
  119. package/dist/shared/characteristic-DLlhja-I.mjs.map +0 -1
  120. package/dist/shared/cubic-C3ZMAoGj.d.mts +0 -1124
  121. package/dist/shared/cubic-CMonq6bg.mjs.map +0 -1
  122. package/dist/shared/interval-CSntLeSX.d.mts +0 -533
  123. package/dist/shared/interval-X1EYuf-T.mjs.map +0 -1
  124. package/dist/shared/interval2d-D42_0ka1.d.mts +0 -172
  125. package/dist/shared/interval2d-ca0J1NMr.mjs.map +0 -1
  126. package/dist/shared/matrix4x4-Ck2WROK-.mjs.map +0 -1
  127. package/dist/shared/matrix4x4-gy9ejrX2.d.mts +0 -1183
  128. package/dist/shared/quadratic-DyeMtvET.mjs.map +0 -1
  129. package/dist/shared/rationalCubic2d-C1RBShBF.d.mts +0 -818
  130. package/dist/shared/rationalCubic2d-D658ltUM.mjs.map +0 -1
  131. package/dist/shared/rationalCubic2d-DFFvp5S1.d.mts +0 -308
  132. package/dist/shared/rationalCubic2d-Vw4qGPZj.mjs.map +0 -1
  133. package/dist/shared/solution-3TDATEMn.mjs.map +0 -1
  134. package/dist/shared/utils-MCckigYk.d.mts +0 -76
  135. package/dist/shared/vector2-5GyA0jBj.d.mts +0 -470
  136. package/dist/shared/vector2-CCuJx1rX.mjs.map +0 -1
  137. package/dist/shared/vector2.internal-DU_E808S.mjs.map +0 -1
  138. package/dist/shared/vector3-BfOPFZEn.d.mts +0 -703
  139. package/dist/shared/vector3-C-qgKAjR.mjs.map +0 -1
  140. package/dist/shared/vector4-BhOKDhD5.mjs.map +0 -1
  141. package/dist/shared/vector4.internal-5XcaX12X.mjs.map +0 -1
  142. package/dist/solution/index.d.mts +0 -2
  143. package/dist/splines/index.d.mts +0 -858
  144. package/dist/utils.d.mts +0 -2
  145. package/dist/vector/index.d.mts +0 -3
@@ -0,0 +1,223 @@
1
+ import type { Interval2d } from '../interval/interval2d.ts';
2
+ import type { TwoDimensional } from '../dimensions.ts';
3
+ import type { Closed, Interval } from '../interval/interval.ts';
4
+ import type { Pipeable } from '../utils.ts';
5
+ import type { QuadraticPolynomial } from '../polynomial/quadratic.ts';
6
+ import type { Decreasing, Increasing, Monotonic } from '../polynomial/traits.ts';
7
+ import type * as Solution from '../solution/solution.ts';
8
+ import type { Vector2 } from '../vector/vector2.ts';
9
+ import type { LinearCurve2d } from './linear2d.ts';
10
+ import type { QuadraticCurve2dTypeId } from './quadratic2d.internal.ts';
11
+ export type { Monotonic, Increasing, Decreasing } from '../polynomial/traits.ts';
12
+ /**
13
+ * A quadratic curve in 2D space.
14
+ *
15
+ * All fields are readonly and immutable, and all operations create new instances.
16
+ *
17
+ * The two type parameters carry the trait sets of the curve's per-axis
18
+ * polynomials. Refiners check monotonicity over the unit interval `[0, 1]` —
19
+ * the curve's natural parameter domain.
20
+ *
21
+ * @since 1.0.0
22
+ */
23
+ export interface QuadraticCurve2d<out XTraits = unknown, out YTraits = unknown> extends Pipeable, TwoDimensional<QuadraticPolynomial<XTraits>, QuadraticPolynomial<YTraits>> {
24
+ readonly [QuadraticCurve2dTypeId]: QuadraticCurve2dTypeId;
25
+ }
26
+ /**
27
+ * Creates a new `QuadraticCurve2d` instance from polynomial parameters.
28
+ *
29
+ * @param c0 - The x polynomial.
30
+ * @param c1 - The y polynomial.
31
+ * @returns A new `QuadraticCurve2d` instance.
32
+ * @since 1.0.0
33
+ */
34
+ export declare const fromPolynomials: (c0: QuadraticPolynomial, c1: QuadraticPolynomial) => QuadraticCurve2d;
35
+ /**
36
+ * Creates a new `QuadraticCurve2d` instance from monomial coefficient vectors.
37
+ *
38
+ * Each argument bundles the per-axis coefficient at the given power: `c0`
39
+ * holds the x⁰ term, `c1` holds the x¹ term, and so on. The resulting curve
40
+ * evaluates to `c0 + c1·t + c2·t²` per axis.
41
+ *
42
+ * @param c0 - The x⁰ coefficients (x and y).
43
+ * @param c1 - The x¹ coefficients (x and y).
44
+ * @param c2 - The x² coefficients (x and y).
45
+ * @returns A new `QuadraticCurve2d` instance.
46
+ * @since 2.0.0
47
+ */
48
+ export declare const fromCoefficients: (c0: Vector2, c1: Vector2, c2: Vector2) => QuadraticCurve2d;
49
+ /**
50
+ * Creates a new `QuadraticCurve2d` instance from quadratic Bézier control
51
+ * points.
52
+ *
53
+ * The three arguments are the Bernstein-basis control points: `p0` and `p2`
54
+ * are the curve's endpoints and `p1` is the off-curve control handle. The
55
+ * implementation converts to the curve's internal monomial form in closed
56
+ * form.
57
+ *
58
+ * @param p0 - The first control point (curve start).
59
+ * @param p1 - The second control point (control handle).
60
+ * @param p2 - The third control point (curve end).
61
+ * @returns A new `QuadraticCurve2d` instance whose curve matches the given Bézier.
62
+ * @since 2.0.0
63
+ */
64
+ export declare const fromBezierPoints: (p0: Vector2, p1: Vector2, p2: Vector2) => QuadraticCurve2d;
65
+ /**
66
+ * Checks if a value is a `QuadraticCurve2d`.
67
+ *
68
+ * @param c - The value to check.
69
+ * @returns `true` if the value is a `QuadraticCurve2d`, `false` otherwise.
70
+ * @since 1.0.0
71
+ */
72
+ export declare const isQuadraticCurve2d: (c: unknown) => c is QuadraticCurve2d;
73
+ export declare const solve: {
74
+ /**
75
+ * Solves the quadratic curve for a given parameter t.
76
+ *
77
+ * @param t - The parameter value.
78
+ * @returns A function that takes a quadratic curve and returns the point on the curve at parameter t.
79
+ * @since 1.0.0
80
+ */
81
+ (t: number): (c: QuadraticCurve2d) => Vector2;
82
+ /**
83
+ * Solves the quadratic curve for a given parameter t.
84
+ *
85
+ * @param c - The quadratic curve to solve.
86
+ * @param t - The parameter value.
87
+ * @returns The point on the curve at parameter t.
88
+ * @since 1.0.0
89
+ */
90
+ (c: QuadraticCurve2d, t: number): Vector2;
91
+ };
92
+ export declare const length: {
93
+ /**
94
+ * Computes the length of the quadratic curve over a given interval.
95
+ *
96
+ * @param c - The quadratic curve to compute the length of.
97
+ * @param i - The interval over which to compute the length.
98
+ * @returns The length of the quadratic curve over the interval.
99
+ * @since 1.0.0
100
+ */
101
+ (c: QuadraticCurve2d, i: Interval): number;
102
+ /**
103
+ * Computes the length of the quadratic curve over a given interval.
104
+ *
105
+ * @param i - The interval over which to compute the length.
106
+ * @returns A function that takes a quadratic curve and returns the length of the curve over the interval.
107
+ * @since 1.0.0
108
+ */
109
+ (i: Interval): (c: QuadraticCurve2d) => number;
110
+ };
111
+ export declare const solveAtX: {
112
+ /**
113
+ * Evaluates the curve's y values at a given x. Because the x polynomial is
114
+ * `Monotonic`, the inverse has at most one solution — at most one y value.
115
+ *
116
+ * @param c - The quadratic curve.
117
+ * @param x - The x coordinate.
118
+ * @returns Zero or one y values, in t-ascending order.
119
+ * @since 2.0.0
120
+ */
121
+ <XT extends Monotonic, YT>(c: QuadraticCurve2d<XT, YT>, x: number): Solution.AtMostOne<number>;
122
+ /**
123
+ * Evaluates the curve's y values at a given x. The result is the y values
124
+ * the curve passes through where x(t) = the given x — up to two solutions
125
+ * for a quadratic curve.
126
+ *
127
+ * @param c - The quadratic curve.
128
+ * @param x - The x coordinate.
129
+ * @returns The y values at x, in t-ascending order.
130
+ * @since 2.0.0
131
+ */
132
+ <XT, YT>(c: QuadraticCurve2d<XT, YT>, x: number): Solution.AtMostTwo<number>;
133
+ /** @since 2.0.0 */
134
+ (x: number): {
135
+ <XT extends Monotonic, YT>(c: QuadraticCurve2d<XT, YT>): Solution.AtMostOne<number>;
136
+ <XT, YT>(c: QuadraticCurve2d<XT, YT>): Solution.AtMostTwo<number>;
137
+ };
138
+ };
139
+ export declare const solveAtY: {
140
+ /**
141
+ * Evaluates the curve's x values at a given y. Because the y polynomial is
142
+ * `Monotonic`, the inverse has at most one solution.
143
+ *
144
+ * @param c - The quadratic curve.
145
+ * @param y - The y coordinate.
146
+ * @returns Zero or one x values, in t-ascending order.
147
+ * @since 2.0.0
148
+ */
149
+ <XT, YT extends Monotonic>(c: QuadraticCurve2d<XT, YT>, y: number): Solution.AtMostOne<number>;
150
+ /**
151
+ * Evaluates the curve's x values at a given y. The result is the x values
152
+ * the curve passes through where y(t) = the given y — up to two solutions
153
+ * for a quadratic curve.
154
+ *
155
+ * @param c - The quadratic curve.
156
+ * @param y - The y coordinate.
157
+ * @returns The x values at y, in t-ascending order.
158
+ * @since 2.0.0
159
+ */
160
+ <XT, YT>(c: QuadraticCurve2d<XT, YT>, y: number): Solution.AtMostTwo<number>;
161
+ /** @since 2.0.0 */
162
+ (y: number): {
163
+ <XT, YT extends Monotonic>(c: QuadraticCurve2d<XT, YT>): Solution.AtMostOne<number>;
164
+ <XT, YT>(c: QuadraticCurve2d<XT, YT>): Solution.AtMostTwo<number>;
165
+ };
166
+ };
167
+ /**
168
+ * Computes the derivative of a quadratic curve.
169
+ *
170
+ * @param c - The quadratic curve to compute the derivative of.
171
+ * @returns The derivative of the quadratic curve as a linear curve.
172
+ * @since 1.0.0
173
+ */
174
+ export declare const derivative: (c: QuadraticCurve2d) => LinearCurve2d;
175
+ export declare const curvature: {
176
+ /**
177
+ * Computes the curvature of the quadratic curve at a given parameter t.
178
+ *
179
+ * @param c - The quadratic curve to compute the curvature for.
180
+ * @param t - The parameter value.
181
+ * @returns The curvature of the quadratic curve at parameter t.
182
+ * @since 1.0.0
183
+ */
184
+ (c: QuadraticCurve2d, t: number): number;
185
+ /**
186
+ * Computes the curvature of the quadratic curve at a given parameter t.
187
+ *
188
+ * @param t - The parameter value.
189
+ * @returns A function that takes a quadratic curve and returns the curvature of the curve at parameter t.
190
+ * @since 1.0.0
191
+ */
192
+ (t: number): (c: QuadraticCurve2d) => number;
193
+ };
194
+ /**
195
+ * Computes the axis-aligned bounding box of the curve over its parameter
196
+ * domain `[0, 1]`. Accounts for interior extrema, so the box is tight against
197
+ * the curve and not just the control polygon.
198
+ *
199
+ * @param c - The quadratic curve.
200
+ * @returns A closed `Box2d` enclosing the curve.
201
+ * @since 2.0.0
202
+ */
203
+ export declare const boundingBox: (c: QuadraticCurve2d) => Interval2d<Closed, Closed>;
204
+ /**
205
+ * Type-narrowing predicate: refines both axes' traits to include `Monotonic`
206
+ * when both x and y polynomials are monotonic over the unit interval `[0, 1]`.
207
+ *
208
+ * For checking only one axis, call the polynomial-level refiner directly:
209
+ * `QuadraticPolynomial.isMonotonic(curve.x, Interval.unit)`.
210
+ *
211
+ * @since 2.0.0
212
+ */
213
+ export declare const isMonotonic: <XT, YT>(c: QuadraticCurve2d<XT, YT>) => c is QuadraticCurve2d<XT & Monotonic, YT & Monotonic>;
214
+ /** @since 2.0.0 */
215
+ export declare const isIncreasing: <XT, YT>(c: QuadraticCurve2d<XT, YT>) => c is QuadraticCurve2d<XT & Increasing, YT & Increasing>;
216
+ /** @since 2.0.0 */
217
+ export declare const isDecreasing: <XT, YT>(c: QuadraticCurve2d<XT, YT>) => c is QuadraticCurve2d<XT & Decreasing, YT & Decreasing>;
218
+ /** @since 2.0.0 */
219
+ export declare const asMonotonic: <XT, YT>(c: QuadraticCurve2d<XT, YT>) => QuadraticCurve2d<XT & Monotonic, YT & Monotonic>;
220
+ /** @since 2.0.0 */
221
+ export declare const asIncreasing: <XT, YT>(c: QuadraticCurve2d<XT, YT>) => QuadraticCurve2d<XT & Increasing, YT & Increasing>;
222
+ /** @since 2.0.0 */
223
+ export declare const asDecreasing: <XT, YT>(c: QuadraticCurve2d<XT, YT>) => QuadraticCurve2d<XT & Decreasing, YT & Decreasing>;
@@ -0,0 +1,2 @@
1
+ export declare const QuadraticCurve2dTypeId: unique symbol;
2
+ export type QuadraticCurve2dTypeId = typeof QuadraticCurve2dTypeId;
@@ -0,0 +1,241 @@
1
+ import type { Closed } from '../interval/interval.ts';
2
+ import type { Interval2d } from '../interval/interval2d.ts';
3
+ import type { Pipeable } from '../utils.ts';
4
+ import type { CubicPolynomial } from '../polynomial/cubic.ts';
5
+ import type { Increasing, Monotonic } from '../polynomial/traits.ts';
6
+ import type * as Solution from '../solution/solution.ts';
7
+ import type { Vector2, Weighted } from '../vector/vector2.ts';
8
+ import type { CubicCurve2d } from './cubic2d.ts';
9
+ import type { RationalCubicCurve2dTypeId, RationalCurveTraits } from './rationalCubic2d.internal.ts';
10
+ export type { Decreasing, Increasing, Monotonic } from '../polynomial/traits.ts';
11
+ export { RationalCurveTraits } from './rationalCubic2d.internal.ts';
12
+ /**
13
+ * A rational cubic curve in 2D space.
14
+ *
15
+ * Represented as three cubic polynomials in the parameter `t`: per-axis
16
+ * numerators `x`, `y`, and a shared denominator `w`. Evaluation is
17
+ * `(x(t)/w(t), y(t)/w(t))` — the projection from homogeneous coordinates
18
+ * back to the plane. With all weights equal at the source (e.g. produced
19
+ * from a non-rational Bézier with unit weights), `w` is constant and the
20
+ * curve coincides with a polynomial cubic.
21
+ *
22
+ * The two type parameters carry per-axis monotonicity trait brands attached
23
+ * to the rational functions `x(t)/w(t)` and `y(t)/w(t)`. Unlike
24
+ * `CubicCurve2d`, traits do not flow through to the underlying polynomials —
25
+ * monotonicity of a ratio of cubics is not the same property as monotonicity
26
+ * of either cubic alone, so the brand lives on the curve itself. Constructors
27
+ * with construction-time monotonicity guarantees (e.g. {@link makeMonotonicEasing})
28
+ * return curves with `Increasing` brands attached, narrowing downstream
29
+ * operations like {@link solveAtX} to single-solution returns.
30
+ *
31
+ * All fields are readonly and immutable, and all operations create new instances.
32
+ *
33
+ * @since 2.0.0
34
+ */
35
+ export interface RationalCubicCurve2d<out XTraits = unknown, out YTraits = unknown> extends Pipeable {
36
+ readonly [RationalCubicCurve2dTypeId]: RationalCubicCurve2dTypeId;
37
+ readonly [RationalCurveTraits]: [XTraits, YTraits];
38
+ readonly x: CubicPolynomial;
39
+ readonly y: CubicPolynomial;
40
+ readonly w: CubicPolynomial;
41
+ }
42
+ /**
43
+ * Checks if a value is a `RationalCubicCurve2d`.
44
+ *
45
+ * @param c - The value to check.
46
+ * @returns `true` if the value is a `RationalCubicCurve2d`, `false` otherwise.
47
+ * @since 2.0.0
48
+ */
49
+ export declare const isRationalCubicCurve2d: (c: unknown) => c is RationalCubicCurve2d;
50
+ /**
51
+ * Creates a new `RationalCubicCurve2d` from per-axis numerator polynomials
52
+ * and a shared denominator polynomial.
53
+ *
54
+ * @param x - The x numerator polynomial.
55
+ * @param y - The y numerator polynomial.
56
+ * @param w - The shared denominator polynomial (must be non-zero on `[0, 1]`).
57
+ * @returns A new `RationalCubicCurve2d` instance.
58
+ * @since 2.0.0
59
+ */
60
+ export declare const fromPolynomials: (x: CubicPolynomial, y: CubicPolynomial, w: CubicPolynomial) => RationalCubicCurve2d;
61
+ /**
62
+ * Creates a new `RationalCubicCurve2d` from four weighted cubic Bézier
63
+ * control points. The four control points are lifted to homogeneous form
64
+ * `(w·x, w·y, w)` and the cubic Bernstein basis is expanded into per-channel
65
+ * monomial coefficients, yielding the curve's `x`, `y`, and `w` polynomials.
66
+ *
67
+ * @param p0 - The first weighted control point (curve start).
68
+ * @param p1 - The second weighted control point (start handle).
69
+ * @param p2 - The third weighted control point (end handle).
70
+ * @param p3 - The fourth weighted control point (curve end).
71
+ * @returns A new `RationalCubicCurve2d` instance.
72
+ * @since 2.0.0
73
+ */
74
+ export declare const fromBezierPoints: (p0: Weighted, p1: Weighted, p2: Weighted, p3: Weighted) => RationalCubicCurve2d;
75
+ /**
76
+ * Creates a guaranteed-monotonic rational cubic easing curve via Gregory-
77
+ * Delbourgo style construction. The result interpolates `(0, 0)` and
78
+ * `(1, 1)` with the given endpoint slopes, with `x(t) = t` pinned linearly
79
+ * and a rational cubic numerator for `y(t)`. Monotonicity of `y(t)` is
80
+ * verified rigorously at construction (degree-3 polynomial sign analysis);
81
+ * the returned curve is branded `<Increasing, Increasing>` so that
82
+ * {@link solveAtX} returns `Solution.AtMostOne<number>` without further
83
+ * trait refinement.
84
+ *
85
+ * For input slope combinations that the default Gregory-Delbourgo
86
+ * construction cannot accommodate (typically when one slope is large while
87
+ * the other is small), construction throws. Useful operating range is
88
+ * roughly `m₀, m₁ ∈ [0, 2]` with `m₀ + m₁ ≲ 3`; smoothstep (`0, 0`) and
89
+ * linear (`1, 1`) fall out as special cases.
90
+ *
91
+ * @param startSlope - The easing function's slope at the start (`dy/dx` at `x = 0`); must be finite and non-negative.
92
+ * @param endSlope - The easing function's slope at the end (`dy/dx` at `x = 1`); must be finite and non-negative.
93
+ * @returns A monotone-by-construction rational cubic easing curve.
94
+ * @throws When slopes are negative, non-finite, or produce a non-monotonic curve under the default construction.
95
+ * @since 2.0.0
96
+ */
97
+ export declare const makeMonotonicEasing: (startSlope: number, endSlope: number) => RationalCubicCurve2d<Increasing, Increasing>;
98
+ export declare const solve: {
99
+ /**
100
+ * Evaluates the rational cubic curve at parameter `t`. Returns
101
+ * `(x(t)/w(t), y(t)/w(t))` — three Horner evaluations and two divisions.
102
+ *
103
+ * @param c - The curve to evaluate.
104
+ * @param t - The parameter value.
105
+ * @returns The point on the curve at parameter `t`.
106
+ * @since 2.0.0
107
+ */
108
+ (c: RationalCubicCurve2d, t: number): Vector2;
109
+ /**
110
+ * Evaluates the rational cubic curve at parameter `t`.
111
+ *
112
+ * @param t - The parameter value.
113
+ * @returns A function that takes a curve and returns the point at `t`.
114
+ * @since 2.0.0
115
+ */
116
+ (t: number): (c: RationalCubicCurve2d) => Vector2;
117
+ };
118
+ export declare const solveAtX: {
119
+ /**
120
+ * Evaluates the curve's y values at a given x. Because the curve's x axis
121
+ * carries the `Monotonic` brand, the inverse has at most one solution.
122
+ *
123
+ * @param c - The rational cubic curve with monotonic x.
124
+ * @param x - The x coordinate.
125
+ * @returns Zero or one y values.
126
+ * @since 2.0.0
127
+ */
128
+ <XT extends Monotonic, YT>(c: RationalCubicCurve2d<XT, YT>, x: number): Solution.AtMostOne<number>;
129
+ /**
130
+ * Evaluates the curve's y values at a given x. Up to three solutions —
131
+ * `(X(t) - x·W(t))` is a cubic polynomial in `t`.
132
+ *
133
+ * @param c - The rational cubic curve.
134
+ * @param x - The x coordinate.
135
+ * @returns The y values at x, in t-ascending order.
136
+ * @since 2.0.0
137
+ */
138
+ <XT, YT>(c: RationalCubicCurve2d<XT, YT>, x: number): Solution.AtMostThree<number>;
139
+ /** @since 2.0.0 */
140
+ (x: number): {
141
+ <XT extends Monotonic, YT>(c: RationalCubicCurve2d<XT, YT>): Solution.AtMostOne<number>;
142
+ <XT, YT>(c: RationalCubicCurve2d<XT, YT>): Solution.AtMostThree<number>;
143
+ };
144
+ };
145
+ export declare const solveAtY: {
146
+ /**
147
+ * Evaluates the curve's x values at a given y. Because the curve's y axis
148
+ * carries the `Monotonic` brand, the inverse has at most one solution.
149
+ *
150
+ * @param c - The rational cubic curve with monotonic y.
151
+ * @param y - The y coordinate.
152
+ * @returns Zero or one x values.
153
+ * @since 2.0.0
154
+ */
155
+ <XT, YT extends Monotonic>(c: RationalCubicCurve2d<XT, YT>, y: number): Solution.AtMostOne<number>;
156
+ /**
157
+ * Evaluates the curve's x values at a given y. Up to three solutions.
158
+ *
159
+ * @param c - The rational cubic 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: RationalCubicCurve2d<XT, YT>, y: number): Solution.AtMostThree<number>;
165
+ /** @since 2.0.0 */
166
+ (y: number): {
167
+ <XT, YT extends Monotonic>(c: RationalCubicCurve2d<XT, YT>): Solution.AtMostOne<number>;
168
+ <XT, YT>(c: RationalCubicCurve2d<XT, YT>): Solution.AtMostThree<number>;
169
+ };
170
+ };
171
+ export declare const subdivide: {
172
+ /**
173
+ * Subdivides a rational cubic curve at parameter `t ∈ (0, 1)` into two new
174
+ * rational cubic curves. The first curve's evaluation on `[0, 1]` matches
175
+ * the original's on `[0, t]`; the second matches the original's on `[t, 1]`.
176
+ * Equivalent to de Casteljau subdivision on the homogeneous control polygon,
177
+ * but performed directly on the per-axis monomial polynomials.
178
+ *
179
+ * @param c - The rational cubic curve to subdivide.
180
+ * @param t - The split parameter; must be in the open interval `(0, 1)`.
181
+ * @returns A `[left, right]` tuple of rational cubic curves.
182
+ * @since 2.0.0
183
+ */
184
+ (c: RationalCubicCurve2d, t: number): [RationalCubicCurve2d, RationalCubicCurve2d];
185
+ /**
186
+ * Subdivides a rational cubic curve at parameter `t ∈ (0, 1)`.
187
+ *
188
+ * @param t - The split parameter; must be in the open interval `(0, 1)`.
189
+ * @returns A function that takes a curve and returns its `[left, right]` halves.
190
+ * @since 2.0.0
191
+ */
192
+ (t: number): (c: RationalCubicCurve2d) => [RationalCubicCurve2d, RationalCubicCurve2d];
193
+ };
194
+ /**
195
+ * Computes a closed axis-aligned bounding box for a rational cubic curve from
196
+ * its projected control polygon. Looser than the tight extrema-based box used
197
+ * by `CubicCurve2d.boundingBox` — finding tight extrema of `x(t)/w(t)` and
198
+ * `y(t)/w(t)` requires solving degree-5 polynomials — but always valid: a
199
+ * positive-weight rational Bézier curve lies inside the convex hull of its
200
+ * projected control points, so the AABB of those points contains the curve.
201
+ *
202
+ * Suitable for subdivision-based geometric queries, where bound looseness is
203
+ * compensated by recursion depth.
204
+ *
205
+ * @param c - The rational cubic curve.
206
+ * @returns A closed `Interval2d` enclosing the curve.
207
+ * @since 2.0.0
208
+ */
209
+ export declare const boundingBox: (c: RationalCubicCurve2d) => Interval2d<Closed, Closed>;
210
+ export declare const approximateAsCubicCurves: {
211
+ /**
212
+ * Approximates the rational cubic as a sequence of polynomial cubic curves
213
+ * via recursive subdivision. At each level a candidate polynomial cubic is
214
+ * built by projecting the segment's homogeneous Bézier control points to
215
+ * 2D; if the symmetric Hausdorff distance between the rational segment and
216
+ * its candidate exceeds `tolerance` (verified via a certified subdivision
217
+ * bound, not a single-point sample), the segment is split at `t = 0.5` and
218
+ * the procedure recurses on each half. Returns a non-empty array; for a
219
+ * curve that is already polynomial (uniform weights) the result is a
220
+ * single exact segment.
221
+ *
222
+ * The Hausdorff guarantee means: every point on the rational lies within
223
+ * `tolerance` of some output segment, and every point on the output lies
224
+ * within `tolerance` of the rational — a true two-sided bound on geometric
225
+ * deviation, not just a parametric error at one sample.
226
+ *
227
+ * @param c - The rational cubic curve to approximate.
228
+ * @param tolerance - Maximum allowed Hausdorff distance; must be positive.
229
+ * @returns A sequence of polynomial cubic curves covering the input.
230
+ * @since 2.0.0
231
+ */
232
+ (c: RationalCubicCurve2d, tolerance: number): ReadonlyArray<CubicCurve2d>;
233
+ /**
234
+ * Approximates the rational cubic as a sequence of polynomial cubic curves.
235
+ *
236
+ * @param tolerance - Maximum allowed Hausdorff distance; must be positive.
237
+ * @returns A function that takes a curve and returns its polynomial approximation.
238
+ * @since 2.0.0
239
+ */
240
+ (tolerance: number): (c: RationalCubicCurve2d) => ReadonlyArray<CubicCurve2d>;
241
+ };
@@ -0,0 +1,2 @@
1
+ export declare const RationalCubicCurve2dTypeId: unique symbol;
2
+ export type RationalCubicCurve2dTypeId = typeof RationalCubicCurve2dTypeId;
@@ -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.ts';
2
+ import * as Interval2dNs from './interval2d.ts';
3
+ export type Interval = IntervalNs.Interval;
4
+ export { IntervalNs as Interval };
5
+ export type Interval2d<X extends IntervalNs.Interval = IntervalNs.Interval, Y extends IntervalNs.Interval = IntervalNs.Interval> = Interval2dNs.Interval2d<X, Y>;
6
+ export { Interval2dNs as Interval2d };
@@ -1,3 +1,3 @@
1
- import { s as interval_exports } from "../shared/interval-X1EYuf-T.mjs";
2
- import { t as interval2d_exports } from "../shared/interval2d-ca0J1NMr.mjs";
1
+ import { s as interval_exports } from "../shared/interval-CqC3ZIqj.mjs";
2
+ import { n as interval2d_exports } from "../shared/interval2d-BMDmeL1M.mjs";
3
3
  export { interval_exports as Interval, interval2d_exports as Interval2d };