curvy 1.0.9 → 2.0.0-alpha.2

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 (173) hide show
  1. package/dist/characteristic/index.d.mts +88 -0
  2. package/dist/characteristic/index.mjs +2 -0
  3. package/dist/curve/index.d.mts +2 -0
  4. package/dist/curve/index.mjs +2 -0
  5. package/dist/interval/index.d.mts +3 -0
  6. package/dist/interval/index.mjs +3 -0
  7. package/dist/matrix/index.d.mts +2 -0
  8. package/dist/matrix/index.mjs +267 -0
  9. package/dist/matrix/index.mjs.map +1 -0
  10. package/dist/number.d.mts +280 -0
  11. package/dist/number.mjs +140 -0
  12. package/dist/number.mjs.map +1 -0
  13. package/dist/path/index.d.mts +261 -0
  14. package/dist/path/index.mjs +325 -0
  15. package/dist/path/index.mjs.map +1 -0
  16. package/dist/polynomial/index.d.mts +2 -0
  17. package/dist/polynomial/index.mjs +3 -0
  18. package/dist/shared/characteristic-B9nCh_cx.mjs +104 -0
  19. package/dist/shared/characteristic-B9nCh_cx.mjs.map +1 -0
  20. package/dist/shared/chunk-25Hzd3z8.mjs +13 -0
  21. package/dist/shared/cubic-BajUY0JT.d.mts +1100 -0
  22. package/dist/shared/cubic-CpHAx8cC.mjs +479 -0
  23. package/dist/shared/cubic-CpHAx8cC.mjs.map +1 -0
  24. package/dist/shared/interval-05CR6eBf.mjs +421 -0
  25. package/dist/shared/interval-05CR6eBf.mjs.map +1 -0
  26. package/dist/shared/interval-Dy-RMEE3.d.mts +533 -0
  27. package/dist/shared/interval2d-8IBZnUOq.mjs +108 -0
  28. package/dist/shared/interval2d-8IBZnUOq.mjs.map +1 -0
  29. package/dist/shared/interval2d-C2id9u31.d.mts +172 -0
  30. package/dist/shared/matrix4x4-Ck2WROK-.mjs +440 -0
  31. package/dist/shared/matrix4x4-Ck2WROK-.mjs.map +1 -0
  32. package/dist/shared/matrix4x4-Dm_tSiH1.d.mts +1183 -0
  33. package/dist/shared/quadratic-CamozcFc.mjs +330 -0
  34. package/dist/shared/quadratic-CamozcFc.mjs.map +1 -0
  35. package/dist/shared/rationalCubic2d-B6g97ryJ.d.mts +308 -0
  36. package/dist/shared/rationalCubic2d-BEgUGSFf.mjs +295 -0
  37. package/dist/shared/rationalCubic2d-BEgUGSFf.mjs.map +1 -0
  38. package/dist/shared/rationalCubic2d-Bys2Uory.mjs +695 -0
  39. package/dist/shared/rationalCubic2d-Bys2Uory.mjs.map +1 -0
  40. package/dist/shared/rationalCubic2d-DlQfBURs.d.mts +818 -0
  41. package/dist/shared/solution-CrtLfqEq.mjs +306 -0
  42. package/dist/shared/solution-CrtLfqEq.mjs.map +1 -0
  43. package/dist/shared/solution-sNQ-ZVhN.d.mts +251 -0
  44. package/dist/{pipe.d.mts → shared/utils-MCckigYk.d.mts} +44 -26
  45. package/dist/shared/vector2-CL1HDdPr.mjs +187 -0
  46. package/dist/shared/vector2-CL1HDdPr.mjs.map +1 -0
  47. package/dist/shared/vector2-DPUY3_eA.d.mts +470 -0
  48. package/dist/shared/vector2.internal-DU_E808S.mjs +97 -0
  49. package/dist/shared/vector2.internal-DU_E808S.mjs.map +1 -0
  50. package/dist/shared/vector3-D-tv_aKL.mjs +204 -0
  51. package/dist/shared/vector3-D-tv_aKL.mjs.map +1 -0
  52. package/dist/shared/vector3-DqeOZtOB.d.mts +703 -0
  53. package/dist/shared/vector4-5KbjoHVj.mjs +109 -0
  54. package/dist/shared/vector4-5KbjoHVj.mjs.map +1 -0
  55. package/dist/shared/vector4.internal-5XcaX12X.mjs +163 -0
  56. package/dist/shared/vector4.internal-5XcaX12X.mjs.map +1 -0
  57. package/dist/solution/index.d.mts +2 -0
  58. package/dist/solution/index.mjs +2 -0
  59. package/dist/splines/index.d.mts +701 -0
  60. package/dist/splines/index.mjs +734 -0
  61. package/dist/splines/index.mjs.map +1 -0
  62. package/dist/utils.d.mts +2 -205
  63. package/dist/utils.mjs +88 -52
  64. package/dist/utils.mjs.map +1 -1
  65. package/dist/vector/index.d.mts +3 -0
  66. package/dist/vector/index.mjs +4 -0
  67. package/package.json +49 -92
  68. package/dist/curve/cubic2d.d.mts +0 -109
  69. package/dist/curve/cubic2d.d.ts +0 -109
  70. package/dist/curve/cubic2d.mjs +0 -80
  71. package/dist/curve/cubic2d.mjs.map +0 -1
  72. package/dist/curve/linear2d.d.mts +0 -94
  73. package/dist/curve/linear2d.d.ts +0 -94
  74. package/dist/curve/linear2d.mjs +0 -46
  75. package/dist/curve/linear2d.mjs.map +0 -1
  76. package/dist/curve/quadratic2d.d.mts +0 -117
  77. package/dist/curve/quadratic2d.d.ts +0 -117
  78. package/dist/curve/quadratic2d.mjs +0 -82
  79. package/dist/curve/quadratic2d.mjs.map +0 -1
  80. package/dist/interval.d.mts +0 -251
  81. package/dist/interval.d.ts +0 -251
  82. package/dist/interval.mjs +0 -86
  83. package/dist/interval.mjs.map +0 -1
  84. package/dist/matrix/matrix2x2.d.mts +0 -320
  85. package/dist/matrix/matrix2x2.d.ts +0 -320
  86. package/dist/matrix/matrix2x2.mjs +0 -25
  87. package/dist/matrix/matrix2x2.mjs.map +0 -1
  88. package/dist/matrix/matrix3x3.d.mts +0 -370
  89. package/dist/matrix/matrix3x3.d.ts +0 -370
  90. package/dist/matrix/matrix3x3.mjs +0 -28
  91. package/dist/matrix/matrix3x3.mjs.map +0 -1
  92. package/dist/matrix/matrix4x4.d.mts +0 -381
  93. package/dist/matrix/matrix4x4.d.ts +0 -381
  94. package/dist/matrix/matrix4x4.mjs +0 -178
  95. package/dist/matrix/matrix4x4.mjs.map +0 -1
  96. package/dist/path/cubic2d.d.mts +0 -95
  97. package/dist/path/cubic2d.d.ts +0 -95
  98. package/dist/path/cubic2d.mjs +0 -60
  99. package/dist/path/cubic2d.mjs.map +0 -1
  100. package/dist/path/linear2d.d.mts +0 -95
  101. package/dist/path/linear2d.d.ts +0 -95
  102. package/dist/path/linear2d.mjs +0 -53
  103. package/dist/path/linear2d.mjs.map +0 -1
  104. package/dist/path/quadratic2d.d.mts +0 -95
  105. package/dist/path/quadratic2d.d.ts +0 -95
  106. package/dist/path/quadratic2d.mjs +0 -57
  107. package/dist/path/quadratic2d.mjs.map +0 -1
  108. package/dist/pipe.d.ts +0 -58
  109. package/dist/pipe.mjs +0 -92
  110. package/dist/pipe.mjs.map +0 -1
  111. package/dist/polynomial/cubic.d.mts +0 -7
  112. package/dist/polynomial/cubic.d.ts +0 -7
  113. package/dist/polynomial/cubic.mjs +0 -133
  114. package/dist/polynomial/cubic.mjs.map +0 -1
  115. package/dist/polynomial/linear.d.mts +0 -7
  116. package/dist/polynomial/linear.d.ts +0 -7
  117. package/dist/polynomial/linear.mjs +0 -24
  118. package/dist/polynomial/linear.mjs.map +0 -1
  119. package/dist/polynomial/quadratic.d.mts +0 -7
  120. package/dist/polynomial/quadratic.d.ts +0 -7
  121. package/dist/polynomial/quadratic.mjs +0 -27
  122. package/dist/polynomial/quadratic.mjs.map +0 -1
  123. package/dist/shared/curvy.Bf5TIk31.d.mts +0 -22
  124. package/dist/shared/curvy.Bf5TIk31.d.ts +0 -22
  125. package/dist/shared/curvy.BkkW8Tx9.mjs +0 -102
  126. package/dist/shared/curvy.BkkW8Tx9.mjs.map +0 -1
  127. package/dist/shared/curvy.BxdGW9he.mjs +0 -116
  128. package/dist/shared/curvy.BxdGW9he.mjs.map +0 -1
  129. package/dist/shared/curvy.C_sCeg9J.mjs +0 -66
  130. package/dist/shared/curvy.C_sCeg9J.mjs.map +0 -1
  131. package/dist/shared/curvy.Cg8lZVUz.d.ts +0 -688
  132. package/dist/shared/curvy.DCt1gGII.mjs +0 -147
  133. package/dist/shared/curvy.DCt1gGII.mjs.map +0 -1
  134. package/dist/shared/curvy.DJ4xO0al.mjs +0 -63
  135. package/dist/shared/curvy.DJ4xO0al.mjs.map +0 -1
  136. package/dist/shared/curvy.DmVFTi0N.mjs +0 -35
  137. package/dist/shared/curvy.DmVFTi0N.mjs.map +0 -1
  138. package/dist/shared/curvy.FDaj5rlj.d.mts +0 -688
  139. package/dist/shared/curvy.lktriTpx.mjs +0 -101
  140. package/dist/shared/curvy.lktriTpx.mjs.map +0 -1
  141. package/dist/shared/curvy.mLFprrGm.mjs +0 -85
  142. package/dist/shared/curvy.mLFprrGm.mjs.map +0 -1
  143. package/dist/shared/curvy.r6f1j287.mjs +0 -76
  144. package/dist/shared/curvy.r6f1j287.mjs.map +0 -1
  145. package/dist/splines/basis2d.d.mts +0 -130
  146. package/dist/splines/basis2d.d.ts +0 -130
  147. package/dist/splines/basis2d.mjs +0 -90
  148. package/dist/splines/basis2d.mjs.map +0 -1
  149. package/dist/splines/bezier2d.d.mts +0 -182
  150. package/dist/splines/bezier2d.d.ts +0 -182
  151. package/dist/splines/bezier2d.mjs +0 -23
  152. package/dist/splines/bezier2d.mjs.map +0 -1
  153. package/dist/splines/cardinal2d.d.mts +0 -178
  154. package/dist/splines/cardinal2d.d.ts +0 -178
  155. package/dist/splines/cardinal2d.mjs +0 -114
  156. package/dist/splines/cardinal2d.mjs.map +0 -1
  157. package/dist/splines/hermite2d.d.mts +0 -124
  158. package/dist/splines/hermite2d.d.ts +0 -124
  159. package/dist/splines/hermite2d.mjs +0 -63
  160. package/dist/splines/hermite2d.mjs.map +0 -1
  161. package/dist/utils.d.ts +0 -205
  162. package/dist/vector/vector2.d.mts +0 -324
  163. package/dist/vector/vector2.d.ts +0 -324
  164. package/dist/vector/vector2.mjs +0 -30
  165. package/dist/vector/vector2.mjs.map +0 -1
  166. package/dist/vector/vector3.d.mts +0 -417
  167. package/dist/vector/vector3.d.ts +0 -417
  168. package/dist/vector/vector3.mjs +0 -38
  169. package/dist/vector/vector3.mjs.map +0 -1
  170. package/dist/vector/vector4.d.mts +0 -205
  171. package/dist/vector/vector4.d.ts +0 -205
  172. package/dist/vector/vector4.mjs +0 -20
  173. package/dist/vector/vector4.mjs.map +0 -1
@@ -0,0 +1,695 @@
1
+ import { t as __exportAll } from "./chunk-25Hzd3z8.mjs";
2
+ import { Pipeable, dual, invariant } from "../utils.mjs";
3
+ import { i as make, n as cross, r as magnitude } from "./vector2-CL1HDdPr.mjs";
4
+ import { n as transpose } from "./vector4-5KbjoHVj.mjs";
5
+ import { l as scaleShift, m as unitOpen, p as unit, t as biunit, u as size } from "./interval-05CR6eBf.mjs";
6
+ import { a as match, i as map, o as none, s as one, t as clip } from "./solution-CrtLfqEq.mjs";
7
+ import { A as GL32_X1, B as GL32_X5, C as GL32_W4, D as GL32_W8, E as GL32_W7, F as GL32_X14, H as GL32_X7, I as GL32_X15, L as GL32_X2, M as GL32_X11, N as GL32_X12, O as GL32_W9, P as GL32_X13, R as GL32_X3, S as GL32_W3, T as GL32_W6, U as GL32_X8, V as GL32_X6, W as GL32_X9, _ as GL32_W12, a as isIncreasing$6, b as GL32_W15, c as range, d as solveInverse, f as subdivide, g as GL32_W11, h as GL32_W10, i as isDecreasing$6, j as GL32_X10, k as GL32_X0, l as roots, m as GL32_W1, n as derivative$5, o as isMonotonic$6, p as GL32_W0, s as make$1, u as solve$8, v as GL32_W13, w as GL32_W5, x as GL32_W2, y as GL32_W14, z as GL32_X4 } from "./cubic-CpHAx8cC.mjs";
8
+ import { _ as solveInverse$1, a as make$3, c as solve$10, d as isIncreasing$7, f as isMonotonic$7, g as solve$9, h as range$1, i as isMonotonic$8, l as solveInverse$2, m as make$2, n as isDecreasing$8, r as isIncreasing$8, s as range$2, t as derivative$6, u as isDecreasing$7 } from "./quadratic-CamozcFc.mjs";
9
+ import { n as make$4 } from "./interval2d-8IBZnUOq.mjs";
10
+ import { i as cubicBezier, t as apply } from "./characteristic-B9nCh_cx.mjs";
11
+ //#region src/curve/linear2d.internal.ts
12
+ const LinearCurve2dTypeId = Symbol("curvy/curve/linear2d");
13
+ var LinearCurve2dImpl = class extends Pipeable {
14
+ [LinearCurve2dTypeId] = LinearCurve2dTypeId;
15
+ x;
16
+ y;
17
+ constructor(c0, c1) {
18
+ super();
19
+ this.x = c0;
20
+ this.y = c1;
21
+ }
22
+ get [0]() {
23
+ return this.x;
24
+ }
25
+ get [1]() {
26
+ return this.y;
27
+ }
28
+ };
29
+ const fromPolynomials$7 = (c0, c1) => new LinearCurve2dImpl(c0, c1);
30
+ const fromCoefficients$5 = (c0, c1) => new LinearCurve2dImpl(make$2(c0.x, c1.x), make$2(c0.y, c1.y));
31
+ const fromBezierPoints$7 = (p0, p1) => new LinearCurve2dImpl(make$2(p0.x, p1.x - p0.x), make$2(p0.y, p1.y - p0.y));
32
+ const isLinearCurve2d$1 = (c) => typeof c === "object" && c !== null && LinearCurve2dTypeId in c;
33
+ const derivative$4 = (c) => make(c.x.c1, c.y.c1);
34
+ const solve$7 = dual(2, (c, t) => make(solve$9(c.x, t), solve$9(c.y, t)));
35
+ const solveAtX$7 = dual(2, (c, x) => match(solveInverse$1(c.x, x), {
36
+ onNone: () => none,
37
+ onSome: ({ value: t }) => t < 0 || t > 1 ? none : one(solve$9(c.y, t))
38
+ }));
39
+ const solveAtY$7 = dual(2, (c, y) => match(solveInverse$1(c.y, y), {
40
+ onNone: () => none,
41
+ onSome: ({ value: t }) => t < 0 || t > 1 ? none : one(solve$9(c.x, t))
42
+ }));
43
+ const length$5 = dual(2, (c, i) => Math.sqrt(c.x.c1 ** 2 + c.y.c1 ** 2) * Math.abs(i.end - i.start));
44
+ const boundingBox$5 = (c) => make$4(range$1(c.x, unit), range$1(c.y, unit));
45
+ const isMonotonic$5 = (c) => isMonotonic$7(c.x) && isMonotonic$7(c.y);
46
+ const isIncreasing$5 = (c) => isIncreasing$7(c.x) && isIncreasing$7(c.y);
47
+ const isDecreasing$5 = (c) => isDecreasing$7(c.x) && isDecreasing$7(c.y);
48
+ const fail$2 = (m) => {
49
+ throw new Error(m);
50
+ };
51
+ const asMonotonic$5 = (c) => isMonotonic$5(c) ? c : fail$2("linear curve is not monotonic in both axes");
52
+ const asIncreasing$5 = (c) => isIncreasing$5(c) ? c : fail$2("linear curve is not increasing in both axes");
53
+ const asDecreasing$5 = (c) => isDecreasing$5(c) ? c : fail$2("linear curve is not decreasing in both axes");
54
+ //#endregion
55
+ //#region src/curve/linear2d.ts
56
+ var linear2d_exports = /* @__PURE__ */ __exportAll({
57
+ asDecreasing: () => asDecreasing$4,
58
+ asIncreasing: () => asIncreasing$4,
59
+ asMonotonic: () => asMonotonic$4,
60
+ boundingBox: () => boundingBox$4,
61
+ derivative: () => derivative$3,
62
+ fromBezierPoints: () => fromBezierPoints$6,
63
+ fromCoefficients: () => fromCoefficients$4,
64
+ fromPolynomials: () => fromPolynomials$6,
65
+ isDecreasing: () => isDecreasing$4,
66
+ isIncreasing: () => isIncreasing$4,
67
+ isLinearCurve2d: () => isLinearCurve2d,
68
+ isMonotonic: () => isMonotonic$4,
69
+ length: () => length$4,
70
+ solve: () => solve$6,
71
+ solveAtX: () => solveAtX$6,
72
+ solveAtY: () => solveAtY$6
73
+ });
74
+ /**
75
+ * Creates a new `LinearCurve2d` instance from polynomial parameters.
76
+ *
77
+ * @param x - The x polynomial.
78
+ * @param y - The y polynomial.
79
+ * @returns A new `LinearCurve2d` instance.
80
+ * @since 1.0.0
81
+ */
82
+ const fromPolynomials$6 = fromPolynomials$7;
83
+ /**
84
+ * Creates a new `LinearCurve2d` instance from monomial coefficient vectors.
85
+ *
86
+ * Each argument bundles the per-axis coefficient at the given power: `c0`
87
+ * holds the x⁰ term, `c1` holds the x¹ term. The resulting curve evaluates to
88
+ * `c0 + c1·t` per axis.
89
+ *
90
+ * @param c0 - The x⁰ coefficients (x and y).
91
+ * @param c1 - The x¹ coefficients (x and y).
92
+ * @returns A new `LinearCurve2d` instance.
93
+ * @since 2.0.0
94
+ */
95
+ const fromCoefficients$4 = fromCoefficients$5;
96
+ /**
97
+ * Creates a new `LinearCurve2d` instance from a pair of endpoints.
98
+ *
99
+ * `p0` is the curve at `t = 0`, `p1` is the curve at `t = 1`. The
100
+ * implementation converts to the curve's internal monomial form (slope-form
101
+ * polynomial in `t`) in closed form.
102
+ *
103
+ * @param p0 - The curve's start point.
104
+ * @param p1 - The curve's end point.
105
+ * @returns A new `LinearCurve2d` instance whose curve matches the line from `p0` to `p1`.
106
+ * @since 2.0.0
107
+ */
108
+ const fromBezierPoints$6 = fromBezierPoints$7;
109
+ /**
110
+ * Checks if a value is a `LinearCurve2d`.
111
+ *
112
+ * @param c - The value to check.
113
+ * @returns `true` if the value is a `LinearCurve2d`, `false` otherwise.
114
+ * @since 1.0.0
115
+ */
116
+ const isLinearCurve2d = isLinearCurve2d$1;
117
+ /**
118
+ * Gets the derivative of a linear curve as a vector
119
+ *
120
+ * @param c - The linear curve to get the derivative of.
121
+ * @returns The derivative of the linear curve as a vector.
122
+ * @since 1.0.0
123
+ */
124
+ const derivative$3 = derivative$4;
125
+ const solve$6 = solve$7;
126
+ const length$4 = length$5;
127
+ /**
128
+ * Computes the axis-aligned bounding box of the curve over its parameter
129
+ * domain `[0, 1]`. For a linear curve this is the closed box enclosing the
130
+ * two endpoints.
131
+ *
132
+ * @param c - The linear curve.
133
+ * @returns A closed `Box2d` enclosing the curve.
134
+ * @since 2.1.0
135
+ */
136
+ const boundingBox$4 = boundingBox$5;
137
+ const solveAtX$6 = solveAtX$7;
138
+ const solveAtY$6 = solveAtY$7;
139
+ /**
140
+ * Type-narrowing predicate: refines both axes' traits to include `Monotonic`
141
+ * when both the x and y polynomials are strictly monotonic. When both axes
142
+ * are monotonic, the curve is invertible in either direction.
143
+ *
144
+ * For checking only one axis, call the polynomial-level refiner directly:
145
+ * `LinearPolynomial.isMonotonic(curve.x)`.
146
+ *
147
+ * @since 2.0.0
148
+ */
149
+ const isMonotonic$4 = isMonotonic$5;
150
+ /**
151
+ * Type-narrowing predicate: refines both axes' traits to include `Increasing`.
152
+ *
153
+ * @since 2.0.0
154
+ */
155
+ const isIncreasing$4 = isIncreasing$5;
156
+ /**
157
+ * Type-narrowing predicate: refines both axes' traits to include `Decreasing`.
158
+ *
159
+ * @since 2.0.0
160
+ */
161
+ const isDecreasing$4 = isDecreasing$5;
162
+ /**
163
+ * Asserts monotonicity in both axes, throwing on failure.
164
+ *
165
+ * @since 2.0.0
166
+ */
167
+ const asMonotonic$4 = asMonotonic$5;
168
+ /**
169
+ * Asserts that both axes are strictly increasing, throwing on failure.
170
+ *
171
+ * @since 2.0.0
172
+ */
173
+ const asIncreasing$4 = asIncreasing$5;
174
+ /**
175
+ * Asserts that both axes are strictly decreasing, throwing on failure.
176
+ *
177
+ * @since 2.0.0
178
+ */
179
+ const asDecreasing$4 = asDecreasing$5;
180
+ //#endregion
181
+ //#region src/curve/quadratic2d.internal.ts
182
+ const QuadraticCurve2dTypeId = Symbol("curvy/curve/quadratic2d");
183
+ var QuadraticCurve2dImpl = class extends Pipeable {
184
+ [QuadraticCurve2dTypeId] = QuadraticCurve2dTypeId;
185
+ x;
186
+ y;
187
+ constructor(c0, c1) {
188
+ super();
189
+ this.x = c0;
190
+ this.y = c1;
191
+ }
192
+ get [0]() {
193
+ return this.x;
194
+ }
195
+ get [1]() {
196
+ return this.y;
197
+ }
198
+ };
199
+ const fromPolynomials$5 = (c0, c1) => new QuadraticCurve2dImpl(c0, c1);
200
+ const fromCoefficients$3 = (c0, c1, c2) => new QuadraticCurve2dImpl(make$3(c0.x, c1.x, c2.x), make$3(c0.y, c1.y, c2.y));
201
+ const fromBezierPoints$5 = (p0, p1, p2) => new QuadraticCurve2dImpl(make$3(p0.x, -2 * p0.x + 2 * p1.x, p0.x - 2 * p1.x + p2.x), make$3(p0.y, -2 * p0.y + 2 * p1.y, p0.y - 2 * p1.y + p2.y));
202
+ const isQuadraticCurve2d$1 = (c) => typeof c === "object" && c !== null && QuadraticCurve2dTypeId in c;
203
+ const solve$5 = dual(2, (c, t) => make(solve$10(c.x, t), solve$10(c.y, t)));
204
+ const solveAtX$5 = dual(2, (c, x) => {
205
+ return map(clip(solveInverse$2(c.x, x), unit), (t) => solve$10(c.y, t));
206
+ });
207
+ const solveAtY$5 = dual(2, (c, y) => {
208
+ return map(clip(solveInverse$2(c.y, y), unit), (t) => solve$10(c.x, t));
209
+ });
210
+ const derivative$2 = (c) => fromPolynomials$6(derivative$6(c.x), derivative$6(c.y));
211
+ const length$3 = dual(2, (c, i) => {
212
+ if (size(i) === 0) return 0;
213
+ if (c.x.c2 === 0 && c.y.c2 === 0) return length$4(fromPolynomials$6(make$2(c.x.c0, c.x.c1), make$2(c.y.c0, c.y.c1)), i);
214
+ const d = derivative$2(c);
215
+ const { scale, shift } = scaleShift(biunit, i);
216
+ return (GL32_W0 * magnitude(solve$6(d, shift + scale * -GL32_X0)) + GL32_W0 * magnitude(solve$6(d, shift + scale * GL32_X0)) + GL32_W1 * magnitude(solve$6(d, shift + scale * -GL32_X1)) + GL32_W1 * magnitude(solve$6(d, shift + scale * GL32_X1)) + GL32_W2 * magnitude(solve$6(d, shift + scale * -GL32_X2)) + GL32_W2 * magnitude(solve$6(d, shift + scale * GL32_X2)) + GL32_W3 * magnitude(solve$6(d, shift + scale * -GL32_X3)) + GL32_W3 * magnitude(solve$6(d, shift + scale * GL32_X3)) + GL32_W4 * magnitude(solve$6(d, shift + scale * -GL32_X4)) + GL32_W4 * magnitude(solve$6(d, shift + scale * GL32_X4)) + GL32_W5 * magnitude(solve$6(d, shift + scale * -GL32_X5)) + GL32_W5 * magnitude(solve$6(d, shift + scale * GL32_X5)) + GL32_W6 * magnitude(solve$6(d, shift + scale * -GL32_X6)) + GL32_W6 * magnitude(solve$6(d, shift + scale * GL32_X6)) + GL32_W7 * magnitude(solve$6(d, shift + scale * -GL32_X7)) + GL32_W7 * magnitude(solve$6(d, shift + scale * GL32_X7)) + GL32_W8 * magnitude(solve$6(d, shift + scale * -GL32_X8)) + GL32_W8 * magnitude(solve$6(d, shift + scale * GL32_X8)) + GL32_W9 * magnitude(solve$6(d, shift + scale * -GL32_X9)) + GL32_W9 * magnitude(solve$6(d, shift + scale * GL32_X9)) + GL32_W10 * magnitude(solve$6(d, shift + scale * -GL32_X10)) + GL32_W10 * magnitude(solve$6(d, shift + scale * GL32_X10)) + GL32_W11 * magnitude(solve$6(d, shift + scale * -GL32_X11)) + GL32_W11 * magnitude(solve$6(d, shift + scale * GL32_X11)) + GL32_W12 * magnitude(solve$6(d, shift + scale * -GL32_X12)) + GL32_W12 * magnitude(solve$6(d, shift + scale * GL32_X12)) + GL32_W13 * magnitude(solve$6(d, shift + scale * -GL32_X13)) + GL32_W13 * magnitude(solve$6(d, shift + scale * GL32_X13)) + GL32_W14 * magnitude(solve$6(d, shift + scale * -GL32_X14)) + GL32_W14 * magnitude(solve$6(d, shift + scale * GL32_X14)) + GL32_W15 * magnitude(solve$6(d, shift + scale * -GL32_X15)) + GL32_W15 * magnitude(solve$6(d, shift + scale * GL32_X15))) * scale;
217
+ });
218
+ const curvature$3 = dual(2, (c, t) => {
219
+ const d = derivative$2(c);
220
+ const v = solve$6(d, t);
221
+ const a = derivative$3(d);
222
+ const vMag = magnitude(v);
223
+ if (vMag === 0) return 0;
224
+ return Math.abs(cross(v, a)) / vMag ** 3;
225
+ });
226
+ const boundingBox$3 = (c) => make$4(range$2(c.x, unit), range$2(c.y, unit));
227
+ const isMonotonic$3 = (c) => isMonotonic$8(c.x, unit) && isMonotonic$8(c.y, unit);
228
+ const isIncreasing$3 = (c) => isIncreasing$8(c.x, unit) && isIncreasing$8(c.y, unit);
229
+ const isDecreasing$3 = (c) => isDecreasing$8(c.x, unit) && isDecreasing$8(c.y, unit);
230
+ const fail$1 = (m) => {
231
+ throw new Error(m);
232
+ };
233
+ const asMonotonic$3 = (c) => isMonotonic$3(c) ? c : fail$1("quadratic curve is not monotonic in both axes");
234
+ const asIncreasing$3 = (c) => isIncreasing$3(c) ? c : fail$1("quadratic curve is not increasing in both axes");
235
+ const asDecreasing$3 = (c) => isDecreasing$3(c) ? c : fail$1("quadratic curve is not decreasing in both axes");
236
+ //#endregion
237
+ //#region src/curve/quadratic2d.ts
238
+ var quadratic2d_exports = /* @__PURE__ */ __exportAll({
239
+ asDecreasing: () => asDecreasing$2,
240
+ asIncreasing: () => asIncreasing$2,
241
+ asMonotonic: () => asMonotonic$2,
242
+ boundingBox: () => boundingBox$2,
243
+ curvature: () => curvature$2,
244
+ derivative: () => derivative$1,
245
+ fromBezierPoints: () => fromBezierPoints$4,
246
+ fromCoefficients: () => fromCoefficients$2,
247
+ fromPolynomials: () => fromPolynomials$4,
248
+ isDecreasing: () => isDecreasing$2,
249
+ isIncreasing: () => isIncreasing$2,
250
+ isMonotonic: () => isMonotonic$2,
251
+ isQuadraticCurve2d: () => isQuadraticCurve2d,
252
+ length: () => length$2,
253
+ solve: () => solve$4,
254
+ solveAtX: () => solveAtX$4,
255
+ solveAtY: () => solveAtY$4
256
+ });
257
+ /**
258
+ * Creates a new `QuadraticCurve2d` instance from polynomial parameters.
259
+ *
260
+ * @param c0 - The x polynomial.
261
+ * @param c1 - The y polynomial.
262
+ * @returns A new `QuadraticCurve2d` instance.
263
+ * @since 1.0.0
264
+ */
265
+ const fromPolynomials$4 = fromPolynomials$5;
266
+ /**
267
+ * Creates a new `QuadraticCurve2d` instance from monomial coefficient vectors.
268
+ *
269
+ * Each argument bundles the per-axis coefficient at the given power: `c0`
270
+ * holds the x⁰ term, `c1` holds the x¹ term, and so on. The resulting curve
271
+ * evaluates to `c0 + c1·t + c2·t²` per axis.
272
+ *
273
+ * @param c0 - The x⁰ coefficients (x and y).
274
+ * @param c1 - The x¹ coefficients (x and y).
275
+ * @param c2 - The x² coefficients (x and y).
276
+ * @returns A new `QuadraticCurve2d` instance.
277
+ * @since 2.0.0
278
+ */
279
+ const fromCoefficients$2 = fromCoefficients$3;
280
+ /**
281
+ * Creates a new `QuadraticCurve2d` instance from quadratic Bézier control
282
+ * points.
283
+ *
284
+ * The three arguments are the Bernstein-basis control points: `p0` and `p2`
285
+ * are the curve's endpoints and `p1` is the off-curve control handle. The
286
+ * implementation converts to the curve's internal monomial form in closed
287
+ * form.
288
+ *
289
+ * @param p0 - The first control point (curve start).
290
+ * @param p1 - The second control point (control handle).
291
+ * @param p2 - The third control point (curve end).
292
+ * @returns A new `QuadraticCurve2d` instance whose curve matches the given Bézier.
293
+ * @since 2.0.0
294
+ */
295
+ const fromBezierPoints$4 = fromBezierPoints$5;
296
+ /**
297
+ * Checks if a value is a `QuadraticCurve2d`.
298
+ *
299
+ * @param c - The value to check.
300
+ * @returns `true` if the value is a `QuadraticCurve2d`, `false` otherwise.
301
+ * @since 1.0.0
302
+ */
303
+ const isQuadraticCurve2d = isQuadraticCurve2d$1;
304
+ const solve$4 = solve$5;
305
+ const length$2 = length$3;
306
+ const solveAtX$4 = solveAtX$5;
307
+ const solveAtY$4 = solveAtY$5;
308
+ /**
309
+ * Computes the derivative of a quadratic curve.
310
+ *
311
+ * @param c - The quadratic curve to compute the derivative of.
312
+ * @returns The derivative of the quadratic curve as a linear curve.
313
+ * @since 1.0.0
314
+ */
315
+ const derivative$1 = derivative$2;
316
+ const curvature$2 = curvature$3;
317
+ /**
318
+ * Computes the axis-aligned bounding box of the curve over its parameter
319
+ * domain `[0, 1]`. Accounts for interior extrema, so the box is tight against
320
+ * the curve and not just the control polygon.
321
+ *
322
+ * @param c - The quadratic curve.
323
+ * @returns A closed `Box2d` enclosing the curve.
324
+ * @since 2.1.0
325
+ */
326
+ const boundingBox$2 = boundingBox$3;
327
+ /**
328
+ * Type-narrowing predicate: refines both axes' traits to include `Monotonic`
329
+ * when both x and y polynomials are monotonic over the unit interval `[0, 1]`.
330
+ *
331
+ * For checking only one axis, call the polynomial-level refiner directly:
332
+ * `QuadraticPolynomial.isMonotonic(curve.x, Interval.unit)`.
333
+ *
334
+ * @since 2.0.0
335
+ */
336
+ const isMonotonic$2 = isMonotonic$3;
337
+ /** @since 2.0.0 */
338
+ const isIncreasing$2 = isIncreasing$3;
339
+ /** @since 2.0.0 */
340
+ const isDecreasing$2 = isDecreasing$3;
341
+ /** @since 2.0.0 */
342
+ const asMonotonic$2 = asMonotonic$3;
343
+ /** @since 2.0.0 */
344
+ const asIncreasing$2 = asIncreasing$3;
345
+ /** @since 2.0.0 */
346
+ const asDecreasing$2 = asDecreasing$3;
347
+ //#endregion
348
+ //#region src/curve/cubic2d.internal.ts
349
+ const CubicCurve2dTypeId = Symbol("curvy/curve/cubic2d");
350
+ var CubicCurve2dImpl = class extends Pipeable {
351
+ [CubicCurve2dTypeId] = CubicCurve2dTypeId;
352
+ x;
353
+ y;
354
+ constructor(c0, c1) {
355
+ super();
356
+ this.x = c0;
357
+ this.y = c1;
358
+ }
359
+ get [0]() {
360
+ return this.x;
361
+ }
362
+ get [1]() {
363
+ return this.y;
364
+ }
365
+ };
366
+ const fromPolynomials$3 = (c0, c1) => new CubicCurve2dImpl(c0, c1);
367
+ const fromCoefficients$1 = (c0, c1, c2, c3) => new CubicCurve2dImpl(make$1(c0.x, c1.x, c2.x, c3.x), make$1(c0.y, c1.y, c2.y, c3.y));
368
+ const fromBezierPoints$3 = (p0, p1, p2, p3) => {
369
+ return new CubicCurve2dImpl(...apply(cubicBezier, ...transpose([
370
+ p0,
371
+ p1,
372
+ p2,
373
+ p3
374
+ ], (p) => [p.x, p.y])));
375
+ };
376
+ const isCubicCurve2d$1 = (c) => typeof c === "object" && c !== null && CubicCurve2dTypeId in c;
377
+ const solve$3 = dual(2, (c, t) => make(solve$8(c.x, t), solve$8(c.y, t)));
378
+ const solveAtX$3 = dual(2, (c, x) => {
379
+ return map(clip(solveInverse(c.x, x), unit), (t) => solve$8(c.y, t));
380
+ });
381
+ const solveAtY$3 = dual(2, (c, y) => {
382
+ return map(clip(solveInverse(c.y, y), unit), (t) => solve$8(c.x, t));
383
+ });
384
+ const derivative = (c) => fromPolynomials$4(derivative$5(c.x), derivative$5(c.y));
385
+ const length$1 = dual(2, (c, i) => {
386
+ if (size(i) === 0) return 0;
387
+ if (c.x.c3 === 0 && c.y.c3 === 0) return length$2(fromPolynomials$4(make$3(c.x.c0, c.x.c1, c.x.c2), make$3(c.y.c0, c.y.c1, c.y.c2)), i);
388
+ const d = derivative(c);
389
+ const { scale, shift } = scaleShift(biunit, i);
390
+ return (GL32_W0 * magnitude(solve$4(d, shift + scale * -GL32_X0)) + GL32_W0 * magnitude(solve$4(d, shift + scale * GL32_X0)) + GL32_W1 * magnitude(solve$4(d, shift + scale * -GL32_X1)) + GL32_W1 * magnitude(solve$4(d, shift + scale * GL32_X1)) + GL32_W2 * magnitude(solve$4(d, shift + scale * -GL32_X2)) + GL32_W2 * magnitude(solve$4(d, shift + scale * GL32_X2)) + GL32_W3 * magnitude(solve$4(d, shift + scale * -GL32_X3)) + GL32_W3 * magnitude(solve$4(d, shift + scale * GL32_X3)) + GL32_W4 * magnitude(solve$4(d, shift + scale * -GL32_X4)) + GL32_W4 * magnitude(solve$4(d, shift + scale * GL32_X4)) + GL32_W5 * magnitude(solve$4(d, shift + scale * -GL32_X5)) + GL32_W5 * magnitude(solve$4(d, shift + scale * GL32_X5)) + GL32_W6 * magnitude(solve$4(d, shift + scale * -GL32_X6)) + GL32_W6 * magnitude(solve$4(d, shift + scale * GL32_X6)) + GL32_W7 * magnitude(solve$4(d, shift + scale * -GL32_X7)) + GL32_W7 * magnitude(solve$4(d, shift + scale * GL32_X7)) + GL32_W8 * magnitude(solve$4(d, shift + scale * -GL32_X8)) + GL32_W8 * magnitude(solve$4(d, shift + scale * GL32_X8)) + GL32_W9 * magnitude(solve$4(d, shift + scale * -GL32_X9)) + GL32_W9 * magnitude(solve$4(d, shift + scale * GL32_X9)) + GL32_W10 * magnitude(solve$4(d, shift + scale * -GL32_X10)) + GL32_W10 * magnitude(solve$4(d, shift + scale * GL32_X10)) + GL32_W11 * magnitude(solve$4(d, shift + scale * -GL32_X11)) + GL32_W11 * magnitude(solve$4(d, shift + scale * GL32_X11)) + GL32_W12 * magnitude(solve$4(d, shift + scale * -GL32_X12)) + GL32_W12 * magnitude(solve$4(d, shift + scale * GL32_X12)) + GL32_W13 * magnitude(solve$4(d, shift + scale * -GL32_X13)) + GL32_W13 * magnitude(solve$4(d, shift + scale * GL32_X13)) + GL32_W14 * magnitude(solve$4(d, shift + scale * -GL32_X14)) + GL32_W14 * magnitude(solve$4(d, shift + scale * GL32_X14)) + GL32_W15 * magnitude(solve$4(d, shift + scale * -GL32_X15)) + GL32_W15 * magnitude(solve$4(d, shift + scale * GL32_X15))) * scale;
391
+ });
392
+ const curvature$1 = dual(2, (c, t) => {
393
+ const d = derivative(c);
394
+ const v = solve$4(d, t);
395
+ const a = solve$6(derivative$1(d), t);
396
+ const vMag = magnitude(v);
397
+ if (vMag === 0) return 0;
398
+ return Math.abs(cross(v, a)) / vMag ** 3;
399
+ });
400
+ const boundingBox$1 = (c) => make$4(range(c.x, unit), range(c.y, unit));
401
+ const isMonotonic$1 = (c) => isMonotonic$6(c.x, unit) && isMonotonic$6(c.y, unit);
402
+ const isIncreasing$1 = (c) => isIncreasing$6(c.x, unit) && isIncreasing$6(c.y, unit);
403
+ const isDecreasing$1 = (c) => isDecreasing$6(c.x, unit) && isDecreasing$6(c.y, unit);
404
+ const fail = (m) => {
405
+ throw new Error(m);
406
+ };
407
+ const asMonotonic$1 = (c) => isMonotonic$1(c) ? c : fail("cubic curve is not monotonic in both axes");
408
+ const asIncreasing$1 = (c) => isIncreasing$1(c) ? c : fail("cubic curve is not increasing in both axes");
409
+ const asDecreasing$1 = (c) => isDecreasing$1(c) ? c : fail("cubic curve is not decreasing in both axes");
410
+ //#endregion
411
+ //#region src/curve/cubic2d.ts
412
+ var cubic2d_exports = /* @__PURE__ */ __exportAll({
413
+ asDecreasing: () => asDecreasing,
414
+ asIncreasing: () => asIncreasing,
415
+ asMonotonic: () => asMonotonic,
416
+ boundingBox: () => boundingBox,
417
+ curvature: () => curvature,
418
+ fromBezierPoints: () => fromBezierPoints$2,
419
+ fromCoefficients: () => fromCoefficients,
420
+ fromPolynomials: () => fromPolynomials$2,
421
+ isCubicCurve2d: () => isCubicCurve2d,
422
+ isDecreasing: () => isDecreasing,
423
+ isIncreasing: () => isIncreasing,
424
+ isMonotonic: () => isMonotonic,
425
+ length: () => length,
426
+ solve: () => solve$2,
427
+ solveAtX: () => solveAtX$2,
428
+ solveAtY: () => solveAtY$2
429
+ });
430
+ /**
431
+ * Creates a new `CubicCurve2d` instance from polynomial parameters.
432
+ *
433
+ * @param x - The x polynomial.
434
+ * @param y - The y polynomial.
435
+ * @returns A new `CubicCurve2d` instance.
436
+ * @since 1.0.0
437
+ */
438
+ const fromPolynomials$2 = fromPolynomials$3;
439
+ /**
440
+ * Creates a new `CubicCurve2d` instance from monomial coefficient vectors.
441
+ *
442
+ * Each argument bundles the per-axis coefficient at the given power: `c0`
443
+ * holds the x⁰ term, `c1` holds the x¹ term, and so on. The resulting curve
444
+ * evaluates to `c0 + c1·t + c2·t² + c3·t³` per axis.
445
+ *
446
+ * @param c0 - The x⁰ coefficients (x and y).
447
+ * @param c1 - The x¹ coefficients (x and y).
448
+ * @param c2 - The x² coefficients (x and y).
449
+ * @param c3 - The x³ coefficients (x and y).
450
+ * @returns A new `CubicCurve2d` instance.
451
+ * @since 2.0.0
452
+ */
453
+ const fromCoefficients = fromCoefficients$1;
454
+ /**
455
+ * Creates a new `CubicCurve2d` instance from cubic Bézier control points.
456
+ *
457
+ * The four arguments are the Bernstein-basis control points: `p0` and `p3` are
458
+ * the curve's endpoints and `p1` and `p2` are the off-curve control handles.
459
+ * The implementation converts to the curve's internal monomial form in closed
460
+ * form.
461
+ *
462
+ * @param p0 - The first control point (curve start).
463
+ * @param p1 - The second control point (start handle).
464
+ * @param p2 - The third control point (end handle).
465
+ * @param p3 - The fourth control point (curve end).
466
+ * @returns A new `CubicCurve2d` instance whose curve matches the given Bézier.
467
+ * @since 2.0.0
468
+ */
469
+ const fromBezierPoints$2 = fromBezierPoints$3;
470
+ /**
471
+ * Checks if a value is a `CubicCurve2d`.
472
+ *
473
+ * @param c - The value to check.
474
+ * @returns `true` if the value is a `CubicCurve2d`, `false` otherwise.
475
+ * @since 1.0.0
476
+ */
477
+ const isCubicCurve2d = isCubicCurve2d$1;
478
+ const solve$2 = solve$3;
479
+ const length = length$1;
480
+ const solveAtX$2 = solveAtX$3;
481
+ const solveAtY$2 = solveAtY$3;
482
+ const curvature = curvature$1;
483
+ /**
484
+ * Computes the axis-aligned bounding box of the curve over its parameter
485
+ * domain `[0, 1]`. Accounts for up to two interior extrema per axis, so the
486
+ * box is tight against the curve and not just the control polygon.
487
+ *
488
+ * @param c - The cubic curve.
489
+ * @returns A closed `Box2d` enclosing the curve.
490
+ * @since 2.1.0
491
+ */
492
+ const boundingBox = boundingBox$1;
493
+ /**
494
+ * Type-narrowing predicate: refines both axes' traits to include `Monotonic`
495
+ * when both x and y polynomials are monotonic over the unit interval `[0, 1]`.
496
+ *
497
+ * For checking only one axis, call the polynomial-level refiner directly:
498
+ * `CubicPolynomial.isMonotonic(curve.x, Interval.unit)`.
499
+ *
500
+ * @since 2.0.0
501
+ */
502
+ const isMonotonic = isMonotonic$1;
503
+ /** @since 2.0.0 */
504
+ const isIncreasing = isIncreasing$1;
505
+ /** @since 2.0.0 */
506
+ const isDecreasing = isDecreasing$1;
507
+ /** @since 2.0.0 */
508
+ const asMonotonic = asMonotonic$1;
509
+ /** @since 2.0.0 */
510
+ const asIncreasing = asIncreasing$1;
511
+ /** @since 2.0.0 */
512
+ const asDecreasing = asDecreasing$1;
513
+ //#endregion
514
+ //#region src/curve/rationalCubic2d.internal.ts
515
+ const RationalCubicCurve2dTypeId = Symbol("curvy/curve/rationalCubic2d");
516
+ const RationalCurveTraits = Symbol.for("curvy/curve/rationalCubic2d/traits");
517
+ var RationalCubicCurve2dImpl = class extends Pipeable {
518
+ [RationalCubicCurve2dTypeId] = RationalCubicCurve2dTypeId;
519
+ x;
520
+ y;
521
+ w;
522
+ constructor(x, y, w) {
523
+ super();
524
+ this.x = x;
525
+ this.y = y;
526
+ this.w = w;
527
+ }
528
+ };
529
+ const isRationalCubicCurve2d$1 = (c) => typeof c === "object" && c !== null && RationalCubicCurve2dTypeId in c;
530
+ const fromPolynomials$1 = (x, y, w) => new RationalCubicCurve2dImpl(x, y, w);
531
+ const fromBezierPoints$1 = (p0, p1, p2, p3) => new RationalCubicCurve2dImpl(...apply(cubicBezier, ...transpose([
532
+ p0,
533
+ p1,
534
+ p2,
535
+ p3
536
+ ], (p) => [
537
+ p.x * p.weight,
538
+ p.y * p.weight,
539
+ p.weight
540
+ ])));
541
+ const makeMonotonicEasing$1 = (startSlope, endSlope) => {
542
+ invariant(Number.isFinite(startSlope) && startSlope >= 0, "makeMonotonicEasing: startSlope must be finite and ≥ 0");
543
+ invariant(Number.isFinite(endSlope) && endSlope >= 0, "makeMonotonicEasing: endSlope must be finite and ≥ 0");
544
+ const m0 = startSlope;
545
+ const m1 = endSlope;
546
+ const alpha = m0 + 1;
547
+ const beta = m1 + 1;
548
+ const pC0 = 0;
549
+ const pC1 = m0 * alpha;
550
+ const pC2 = beta * (2 - m1) + alpha * (1 - 2 * m0);
551
+ const pC3 = beta * (m1 - 1) + alpha * (m0 - 1);
552
+ const qC0 = alpha;
553
+ const qC1 = beta - alpha;
554
+ const xPoly = make$1(0, alpha, beta - alpha, 0);
555
+ const yPoly = make$1(pC0, pC1, pC2, pC3);
556
+ const wPoly = make$1(qC0, qC1, 0, 0);
557
+ const monoQ = make$1(m0 * alpha * alpha, 2 * alpha * pC2, 3 * alpha * pC3 + pC2 * (beta - alpha), 2 * pC3 * (beta - alpha));
558
+ const interiorRoots = monoQ.pipe(roots, clip(unitOpen));
559
+ for (const t of interiorRoots) {
560
+ const epsilon = 1e-6;
561
+ const lo = Math.max(0, t - epsilon);
562
+ const hi = Math.min(1, t + epsilon);
563
+ invariant(Math.sign(solve$8(monoQ, lo)) * Math.sign(solve$8(monoQ, hi)) >= 0, `makeMonotonicEasing: slopes (${m0}, ${m1}) produce a non-monotonic curve with the default Gregory-Delbourgo construction. Try smaller slopes or use a different easing form.`);
564
+ }
565
+ return new RationalCubicCurve2dImpl(xPoly, yPoly, wPoly);
566
+ };
567
+ const solve$1 = dual(2, (c, t) => {
568
+ const w = solve$8(c.w, t);
569
+ return make(solve$8(c.x, t) / w, solve$8(c.y, t) / w);
570
+ });
571
+ const solveAtX$1 = dual(2, (c, x) => make$1(c.x.c0 - x * c.w.c0, c.x.c1 - x * c.w.c1, c.x.c2 - x * c.w.c2, c.x.c3 - x * c.w.c3).pipe(roots, clip(unit), map((t) => solve$8(c.y, t) / solve$8(c.w, t))));
572
+ const solveAtY$1 = dual(2, (c, y) => make$1(c.y.c0 - y * c.w.c0, c.y.c1 - y * c.w.c1, c.y.c2 - y * c.w.c2, c.y.c3 - y * c.w.c3).pipe(roots, clip(unit), map((t) => solve$8(c.x, t) / solve$8(c.w, t))));
573
+ const MAX_APPROX_DEPTH = 20;
574
+ const buildCubicCandidate = (c) => {
575
+ const x0 = c.x.c0;
576
+ const x1 = c.x.c0 + c.x.c1 / 3;
577
+ const x2 = c.x.c0 + 2 * c.x.c1 / 3 + c.x.c2 / 3;
578
+ const x3 = c.x.c0 + c.x.c1 + c.x.c2 + c.x.c3;
579
+ const y0 = c.y.c0;
580
+ const y1 = c.y.c0 + c.y.c1 / 3;
581
+ const y2 = c.y.c0 + 2 * c.y.c1 / 3 + c.y.c2 / 3;
582
+ const y3 = c.y.c0 + c.y.c1 + c.y.c2 + c.y.c3;
583
+ const w0 = c.w.c0;
584
+ const w1 = c.w.c0 + c.w.c1 / 3;
585
+ const w2 = c.w.c0 + 2 * c.w.c1 / 3 + c.w.c2 / 3;
586
+ const w3 = c.w.c0 + c.w.c1 + c.w.c2 + c.w.c3;
587
+ return fromBezierPoints$2(make(x0 / w0, y0 / w0), make(x1 / w1, y1 / w1), make(x2 / w2, y2 / w2), make(x3 / w3, y3 / w3));
588
+ };
589
+ const splitAtHalf = (c) => {
590
+ const [leftX, rightX] = subdivide(c.x, .5);
591
+ const [leftY, rightY] = subdivide(c.y, .5);
592
+ const [leftW, rightW] = subdivide(c.w, .5);
593
+ return [new RationalCubicCurve2dImpl(leftX, leftY, leftW), new RationalCubicCurve2dImpl(rightX, rightY, rightW)];
594
+ };
595
+ const midpointError = (c, candidate) => {
596
+ const w = solve$8(c.w, .5);
597
+ const trueX = solve$8(c.x, .5) / w;
598
+ const trueY = solve$8(c.y, .5) / w;
599
+ const candX = solve$8(candidate.x, .5);
600
+ const candY = solve$8(candidate.y, .5);
601
+ return Math.hypot(trueX - candX, trueY - candY);
602
+ };
603
+ const approximateAsCubicCurves$1 = dual(2, (c, tolerance) => {
604
+ invariant(Number.isFinite(tolerance) && tolerance > 0, "approximateAsCubicCurves: tolerance must be finite and > 0");
605
+ const out = [];
606
+ const recurse = (curr, depth) => {
607
+ const candidate = buildCubicCandidate(curr);
608
+ if (depth >= MAX_APPROX_DEPTH || midpointError(curr, candidate) <= tolerance) {
609
+ out.push(candidate);
610
+ return;
611
+ }
612
+ const [left, right] = splitAtHalf(curr);
613
+ recurse(left, depth + 1);
614
+ recurse(right, depth + 1);
615
+ };
616
+ recurse(c, 0);
617
+ return out;
618
+ });
619
+ //#endregion
620
+ //#region src/curve/rationalCubic2d.ts
621
+ var rationalCubic2d_exports = /* @__PURE__ */ __exportAll({
622
+ RationalCurveTraits: () => RationalCurveTraits,
623
+ approximateAsCubicCurves: () => approximateAsCubicCurves,
624
+ fromBezierPoints: () => fromBezierPoints,
625
+ fromPolynomials: () => fromPolynomials,
626
+ isRationalCubicCurve2d: () => isRationalCubicCurve2d,
627
+ makeMonotonicEasing: () => makeMonotonicEasing,
628
+ solve: () => solve,
629
+ solveAtX: () => solveAtX,
630
+ solveAtY: () => solveAtY
631
+ });
632
+ /**
633
+ * Checks if a value is a `RationalCubicCurve2d`.
634
+ *
635
+ * @param c - The value to check.
636
+ * @returns `true` if the value is a `RationalCubicCurve2d`, `false` otherwise.
637
+ * @since 2.1.0
638
+ */
639
+ const isRationalCubicCurve2d = isRationalCubicCurve2d$1;
640
+ /**
641
+ * Creates a new `RationalCubicCurve2d` from per-axis numerator polynomials
642
+ * and a shared denominator polynomial.
643
+ *
644
+ * @param x - The x numerator polynomial.
645
+ * @param y - The y numerator polynomial.
646
+ * @param w - The shared denominator polynomial (must be non-zero on `[0, 1]`).
647
+ * @returns A new `RationalCubicCurve2d` instance.
648
+ * @since 2.1.0
649
+ */
650
+ const fromPolynomials = fromPolynomials$1;
651
+ /**
652
+ * Creates a new `RationalCubicCurve2d` from four weighted cubic Bézier
653
+ * control points. The four control points are lifted to homogeneous form
654
+ * `(w·x, w·y, w)` and the cubic Bernstein basis is expanded into per-channel
655
+ * monomial coefficients, yielding the curve's `x`, `y`, and `w` polynomials.
656
+ *
657
+ * @param p0 - The first weighted control point (curve start).
658
+ * @param p1 - The second weighted control point (start handle).
659
+ * @param p2 - The third weighted control point (end handle).
660
+ * @param p3 - The fourth weighted control point (curve end).
661
+ * @returns A new `RationalCubicCurve2d` instance.
662
+ * @since 2.1.0
663
+ */
664
+ const fromBezierPoints = fromBezierPoints$1;
665
+ /**
666
+ * Creates a guaranteed-monotonic rational cubic easing curve via Gregory-
667
+ * Delbourgo style construction. The result interpolates `(0, 0)` and
668
+ * `(1, 1)` with the given endpoint slopes, with `x(t) = t` pinned linearly
669
+ * and a rational cubic numerator for `y(t)`. Monotonicity of `y(t)` is
670
+ * verified rigorously at construction (degree-3 polynomial sign analysis);
671
+ * the returned curve is branded `<Increasing, Increasing>` so that
672
+ * {@link solveAtX} returns `Solution.AtMostOne<number>` without further
673
+ * trait refinement.
674
+ *
675
+ * For input slope combinations that the default Gregory-Delbourgo
676
+ * construction cannot accommodate (typically when one slope is large while
677
+ * the other is small), construction throws. Useful operating range is
678
+ * roughly `m₀, m₁ ∈ [0, 2]` with `m₀ + m₁ ≲ 3`; smoothstep (`0, 0`) and
679
+ * linear (`1, 1`) fall out as special cases.
680
+ *
681
+ * @param startSlope - The easing function's slope at the start (`dy/dx` at `x = 0`); must be finite and non-negative.
682
+ * @param endSlope - The easing function's slope at the end (`dy/dx` at `x = 1`); must be finite and non-negative.
683
+ * @returns A monotone-by-construction rational cubic easing curve.
684
+ * @throws When slopes are negative, non-finite, or produce a non-monotonic curve under the default construction.
685
+ * @since 2.1.0
686
+ */
687
+ const makeMonotonicEasing = makeMonotonicEasing$1;
688
+ const solve = solve$1;
689
+ const solveAtX = solveAtX$1;
690
+ const solveAtY = solveAtY$1;
691
+ const approximateAsCubicCurves = approximateAsCubicCurves$1;
692
+ //#endregion
693
+ export { linear2d_exports as _, boundingBox as a, length as c, boundingBox$2 as d, length$2 as f, length$4 as g, boundingBox$4 as h, solve as i, solve$2 as l, solve$4 as m, fromBezierPoints as n, cubic2d_exports as o, quadratic2d_exports as p, rationalCubic2d_exports as r, fromPolynomials$2 as s, approximateAsCubicCurves as t, derivative as u, solve$6 as v };
694
+
695
+ //# sourceMappingURL=rationalCubic2d-Bys2Uory.mjs.map