curvy 1.0.9 → 2.0.0-alpha.0

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 (169) 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 +2 -0
  6. package/dist/interval/index.mjs +2 -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 +241 -0
  14. package/dist/path/index.mjs +292 -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-BGRxcxUH.mjs +104 -0
  19. package/dist/shared/characteristic-BGRxcxUH.mjs.map +1 -0
  20. package/dist/shared/chunk-25Hzd3z8.mjs +13 -0
  21. package/dist/shared/cubic-CYYEUHNm.mjs +479 -0
  22. package/dist/shared/cubic-CYYEUHNm.mjs.map +1 -0
  23. package/dist/shared/cubic-Dfn6DB02.d.mts +1099 -0
  24. package/dist/shared/interval-CCEqzPgA.mjs +376 -0
  25. package/dist/shared/interval-CCEqzPgA.mjs.map +1 -0
  26. package/dist/shared/interval-hQDiKqj0.d.mts +494 -0
  27. package/dist/shared/matrix4x4-Bt_DBlP0.d.mts +1182 -0
  28. package/dist/shared/matrix4x4-Ck2WROK-.mjs +440 -0
  29. package/dist/shared/matrix4x4-Ck2WROK-.mjs.map +1 -0
  30. package/dist/shared/quadratic-DEhuAKuE.mjs +330 -0
  31. package/dist/shared/quadratic-DEhuAKuE.mjs.map +1 -0
  32. package/dist/shared/rationalCubic2d-BPLohNuI.d.mts +787 -0
  33. package/dist/shared/rationalCubic2d-CP4oGpnk.mjs +658 -0
  34. package/dist/shared/rationalCubic2d-CP4oGpnk.mjs.map +1 -0
  35. package/dist/shared/rationalCubic2d-CXa7Yren.mjs +278 -0
  36. package/dist/shared/rationalCubic2d-CXa7Yren.mjs.map +1 -0
  37. package/dist/shared/rationalCubic2d-D_-XWxcm.d.mts +297 -0
  38. package/dist/shared/solution-BjoW7ov4.d.mts +251 -0
  39. package/dist/shared/solution-CbSWzXCn.mjs +306 -0
  40. package/dist/shared/solution-CbSWzXCn.mjs.map +1 -0
  41. package/dist/{pipe.d.mts → shared/utils-DqTGyXrP.d.mts} +44 -26
  42. package/dist/shared/vector2-CL1HDdPr.mjs +187 -0
  43. package/dist/shared/vector2-CL1HDdPr.mjs.map +1 -0
  44. package/dist/shared/vector2-TV0UnlxY.d.mts +1168 -0
  45. package/dist/shared/vector2.internal-DU_E808S.mjs +97 -0
  46. package/dist/shared/vector2.internal-DU_E808S.mjs.map +1 -0
  47. package/dist/shared/vector3-D-tv_aKL.mjs +204 -0
  48. package/dist/shared/vector3-D-tv_aKL.mjs.map +1 -0
  49. package/dist/shared/vector4-5KbjoHVj.mjs +109 -0
  50. package/dist/shared/vector4-5KbjoHVj.mjs.map +1 -0
  51. package/dist/shared/vector4.internal-5XcaX12X.mjs +163 -0
  52. package/dist/shared/vector4.internal-5XcaX12X.mjs.map +1 -0
  53. package/dist/solution/index.d.mts +2 -0
  54. package/dist/solution/index.mjs +2 -0
  55. package/dist/splines/index.d.mts +701 -0
  56. package/dist/splines/index.mjs +734 -0
  57. package/dist/splines/index.mjs.map +1 -0
  58. package/dist/utils.d.mts +2 -205
  59. package/dist/utils.mjs +88 -52
  60. package/dist/utils.mjs.map +1 -1
  61. package/dist/vector/index.d.mts +2 -0
  62. package/dist/vector/index.mjs +4 -0
  63. package/package.json +49 -92
  64. package/dist/curve/cubic2d.d.mts +0 -109
  65. package/dist/curve/cubic2d.d.ts +0 -109
  66. package/dist/curve/cubic2d.mjs +0 -80
  67. package/dist/curve/cubic2d.mjs.map +0 -1
  68. package/dist/curve/linear2d.d.mts +0 -94
  69. package/dist/curve/linear2d.d.ts +0 -94
  70. package/dist/curve/linear2d.mjs +0 -46
  71. package/dist/curve/linear2d.mjs.map +0 -1
  72. package/dist/curve/quadratic2d.d.mts +0 -117
  73. package/dist/curve/quadratic2d.d.ts +0 -117
  74. package/dist/curve/quadratic2d.mjs +0 -82
  75. package/dist/curve/quadratic2d.mjs.map +0 -1
  76. package/dist/interval.d.mts +0 -251
  77. package/dist/interval.d.ts +0 -251
  78. package/dist/interval.mjs +0 -86
  79. package/dist/interval.mjs.map +0 -1
  80. package/dist/matrix/matrix2x2.d.mts +0 -320
  81. package/dist/matrix/matrix2x2.d.ts +0 -320
  82. package/dist/matrix/matrix2x2.mjs +0 -25
  83. package/dist/matrix/matrix2x2.mjs.map +0 -1
  84. package/dist/matrix/matrix3x3.d.mts +0 -370
  85. package/dist/matrix/matrix3x3.d.ts +0 -370
  86. package/dist/matrix/matrix3x3.mjs +0 -28
  87. package/dist/matrix/matrix3x3.mjs.map +0 -1
  88. package/dist/matrix/matrix4x4.d.mts +0 -381
  89. package/dist/matrix/matrix4x4.d.ts +0 -381
  90. package/dist/matrix/matrix4x4.mjs +0 -178
  91. package/dist/matrix/matrix4x4.mjs.map +0 -1
  92. package/dist/path/cubic2d.d.mts +0 -95
  93. package/dist/path/cubic2d.d.ts +0 -95
  94. package/dist/path/cubic2d.mjs +0 -60
  95. package/dist/path/cubic2d.mjs.map +0 -1
  96. package/dist/path/linear2d.d.mts +0 -95
  97. package/dist/path/linear2d.d.ts +0 -95
  98. package/dist/path/linear2d.mjs +0 -53
  99. package/dist/path/linear2d.mjs.map +0 -1
  100. package/dist/path/quadratic2d.d.mts +0 -95
  101. package/dist/path/quadratic2d.d.ts +0 -95
  102. package/dist/path/quadratic2d.mjs +0 -57
  103. package/dist/path/quadratic2d.mjs.map +0 -1
  104. package/dist/pipe.d.ts +0 -58
  105. package/dist/pipe.mjs +0 -92
  106. package/dist/pipe.mjs.map +0 -1
  107. package/dist/polynomial/cubic.d.mts +0 -7
  108. package/dist/polynomial/cubic.d.ts +0 -7
  109. package/dist/polynomial/cubic.mjs +0 -133
  110. package/dist/polynomial/cubic.mjs.map +0 -1
  111. package/dist/polynomial/linear.d.mts +0 -7
  112. package/dist/polynomial/linear.d.ts +0 -7
  113. package/dist/polynomial/linear.mjs +0 -24
  114. package/dist/polynomial/linear.mjs.map +0 -1
  115. package/dist/polynomial/quadratic.d.mts +0 -7
  116. package/dist/polynomial/quadratic.d.ts +0 -7
  117. package/dist/polynomial/quadratic.mjs +0 -27
  118. package/dist/polynomial/quadratic.mjs.map +0 -1
  119. package/dist/shared/curvy.Bf5TIk31.d.mts +0 -22
  120. package/dist/shared/curvy.Bf5TIk31.d.ts +0 -22
  121. package/dist/shared/curvy.BkkW8Tx9.mjs +0 -102
  122. package/dist/shared/curvy.BkkW8Tx9.mjs.map +0 -1
  123. package/dist/shared/curvy.BxdGW9he.mjs +0 -116
  124. package/dist/shared/curvy.BxdGW9he.mjs.map +0 -1
  125. package/dist/shared/curvy.C_sCeg9J.mjs +0 -66
  126. package/dist/shared/curvy.C_sCeg9J.mjs.map +0 -1
  127. package/dist/shared/curvy.Cg8lZVUz.d.ts +0 -688
  128. package/dist/shared/curvy.DCt1gGII.mjs +0 -147
  129. package/dist/shared/curvy.DCt1gGII.mjs.map +0 -1
  130. package/dist/shared/curvy.DJ4xO0al.mjs +0 -63
  131. package/dist/shared/curvy.DJ4xO0al.mjs.map +0 -1
  132. package/dist/shared/curvy.DmVFTi0N.mjs +0 -35
  133. package/dist/shared/curvy.DmVFTi0N.mjs.map +0 -1
  134. package/dist/shared/curvy.FDaj5rlj.d.mts +0 -688
  135. package/dist/shared/curvy.lktriTpx.mjs +0 -101
  136. package/dist/shared/curvy.lktriTpx.mjs.map +0 -1
  137. package/dist/shared/curvy.mLFprrGm.mjs +0 -85
  138. package/dist/shared/curvy.mLFprrGm.mjs.map +0 -1
  139. package/dist/shared/curvy.r6f1j287.mjs +0 -76
  140. package/dist/shared/curvy.r6f1j287.mjs.map +0 -1
  141. package/dist/splines/basis2d.d.mts +0 -130
  142. package/dist/splines/basis2d.d.ts +0 -130
  143. package/dist/splines/basis2d.mjs +0 -90
  144. package/dist/splines/basis2d.mjs.map +0 -1
  145. package/dist/splines/bezier2d.d.mts +0 -182
  146. package/dist/splines/bezier2d.d.ts +0 -182
  147. package/dist/splines/bezier2d.mjs +0 -23
  148. package/dist/splines/bezier2d.mjs.map +0 -1
  149. package/dist/splines/cardinal2d.d.mts +0 -178
  150. package/dist/splines/cardinal2d.d.ts +0 -178
  151. package/dist/splines/cardinal2d.mjs +0 -114
  152. package/dist/splines/cardinal2d.mjs.map +0 -1
  153. package/dist/splines/hermite2d.d.mts +0 -124
  154. package/dist/splines/hermite2d.d.ts +0 -124
  155. package/dist/splines/hermite2d.mjs +0 -63
  156. package/dist/splines/hermite2d.mjs.map +0 -1
  157. package/dist/utils.d.ts +0 -205
  158. package/dist/vector/vector2.d.mts +0 -324
  159. package/dist/vector/vector2.d.ts +0 -324
  160. package/dist/vector/vector2.mjs +0 -30
  161. package/dist/vector/vector2.mjs.map +0 -1
  162. package/dist/vector/vector3.d.mts +0 -417
  163. package/dist/vector/vector3.d.ts +0 -417
  164. package/dist/vector/vector3.mjs +0 -38
  165. package/dist/vector/vector3.mjs.map +0 -1
  166. package/dist/vector/vector4.d.mts +0 -205
  167. package/dist/vector/vector4.d.ts +0 -205
  168. package/dist/vector/vector4.mjs +0 -20
  169. package/dist/vector/vector4.mjs.map +0 -1
@@ -0,0 +1,292 @@
1
+ import { t as __exportAll } from "../shared/chunk-25Hzd3z8.mjs";
2
+ import { Pipeable, dual, invariant } from "../utils.mjs";
3
+ import { epsEquals } from "../number.mjs";
4
+ import { u as unit } from "../shared/interval-CCEqzPgA.mjs";
5
+ import { f as solve$5, h as solve$4, p as length$4, u as length$5 } from "../shared/rationalCubic2d-CP4oGpnk.mjs";
6
+ import { n as rationalCubic2d_exports, r as cubic2d_exports } from "../shared/rationalCubic2d-CXa7Yren.mjs";
7
+ //#region src/path/linear2d.internal.ts
8
+ const LinearPath2dTypeId = Symbol("curvy/path/linear2d");
9
+ var LinearPath2dImpl = class extends Pipeable {
10
+ [LinearPath2dTypeId] = LinearPath2dTypeId;
11
+ curves;
12
+ constructor(curves) {
13
+ super();
14
+ this.curves = curves;
15
+ }
16
+ [Symbol.iterator]() {
17
+ return this.curves[Symbol.iterator]();
18
+ }
19
+ };
20
+ const isLinearPath2d$1 = (p) => typeof p === "object" && p !== null && LinearPath2dTypeId in p;
21
+ const make$3 = (...curves) => new LinearPath2dImpl(curves);
22
+ const fromArray$3 = (curves) => new LinearPath2dImpl(curves);
23
+ const append$3 = dual(2, (p, c) => fromArray$3([...p, c]));
24
+ const length$3 = (p) => {
25
+ let total = 0;
26
+ for (const curve of p) total += length$4(curve, unit);
27
+ return total;
28
+ };
29
+ const solve$3 = dual(2, (p, u) => {
30
+ const curves = p instanceof LinearPath2dImpl ? p.curves : [...p];
31
+ if (u === 1) return solve$4(curves.at(-1), 1);
32
+ const t = u * curves.length;
33
+ const i = Math.floor(t);
34
+ const curve = curves[i];
35
+ return solve$4(curve, t - i);
36
+ });
37
+ const toPathData$3 = (p) => {
38
+ let result = "";
39
+ let prevEndX = NaN;
40
+ let prevEndY = NaN;
41
+ for (const curve of p) {
42
+ const startX = curve.x.c0;
43
+ const startY = curve.y.c0;
44
+ const endX = curve.x.c0 + curve.x.c1;
45
+ const endY = curve.y.c0 + curve.y.c1;
46
+ if (!epsEquals(startX, prevEndX) || !epsEquals(startY, prevEndY)) result += ` M ${startX},${startY}`;
47
+ result += ` L ${endX},${endY}`;
48
+ prevEndX = endX;
49
+ prevEndY = endY;
50
+ }
51
+ return result.slice(1);
52
+ };
53
+ const isContinuous$3 = (p) => {
54
+ let prevEndX = NaN;
55
+ let prevEndY = NaN;
56
+ let first = true;
57
+ for (const curve of p) {
58
+ const startX = curve.x.c0;
59
+ const startY = curve.y.c0;
60
+ if (!first && (!epsEquals(startX, prevEndX) || !epsEquals(startY, prevEndY))) return false;
61
+ prevEndX = curve.x.c0 + curve.x.c1;
62
+ prevEndY = curve.y.c0 + curve.y.c1;
63
+ first = false;
64
+ }
65
+ return true;
66
+ };
67
+ const asContinuous$3 = (p) => {
68
+ invariant(isContinuous$3(p), "linear path is not continuous");
69
+ return p;
70
+ };
71
+ //#endregion
72
+ //#region src/path/linear2d.ts
73
+ var linear2d_exports = /* @__PURE__ */ __exportAll({
74
+ append: () => append$2,
75
+ asContinuous: () => asContinuous$2,
76
+ fromArray: () => fromArray$2,
77
+ isContinuous: () => isContinuous$2,
78
+ isLinearPath2d: () => isLinearPath2d,
79
+ length: () => length$2,
80
+ make: () => make$2,
81
+ solve: () => solve$2,
82
+ toPathData: () => toPathData$2
83
+ });
84
+ /**
85
+ * Creates a new `LinearPath2d` instance from a sequence of curves.
86
+ *
87
+ * @param curves - The curves to create the path from.
88
+ * @returns A new `LinearPath2d` instance.
89
+ * @since 2.0.0
90
+ */
91
+ const make$2 = make$3;
92
+ /**
93
+ * Creates a new `LinearPath2d` instance from an array of curves.
94
+ *
95
+ * @param curves - The curves to create the path from.
96
+ * @returns A new `LinearPath2d` instance.
97
+ * @since 2.0.0
98
+ */
99
+ const fromArray$2 = fromArray$3;
100
+ /**
101
+ * Checks if a value is a `LinearPath2d`.
102
+ *
103
+ * @param p - The value to check.
104
+ * @returns `true` if the value is a `LinearPath2d`, `false` otherwise.
105
+ * @since 1.0.0
106
+ */
107
+ const isLinearPath2d = isLinearPath2d$1;
108
+ const append$2 = append$3;
109
+ /**
110
+ * Calculates the length of a linear path.
111
+ *
112
+ * @param p - The linear path to calculate the length of.
113
+ * @returns The length of the linear path.
114
+ * @since 1.0.0
115
+ */
116
+ const length$2 = length$3;
117
+ const solve$2 = solve$3;
118
+ /**
119
+ * Serializes a linear path as an SVG path data string (the value of a `<path>`
120
+ * element's `d` attribute), using `M` and `L` commands. Discontinuities between
121
+ * curves emit a fresh `M` command.
122
+ *
123
+ * @param p - The linear path to serialize.
124
+ * @returns The SVG path data string.
125
+ * @since 2.0.0
126
+ */
127
+ const toPathData$2 = toPathData$3;
128
+ /**
129
+ * Type-narrowing predicate: refines `LinearPath2d<T>` to
130
+ * `LinearPath2d<T & Continuous>` when adjacent curves connect at their join
131
+ * points.
132
+ *
133
+ * @param p - The linear path to check.
134
+ * @returns `true` when the path is continuous (G⁰).
135
+ * @since 2.0.0
136
+ */
137
+ const isContinuous$2 = isContinuous$3;
138
+ /**
139
+ * Asserts that the linear path is continuous, throwing on failure.
140
+ *
141
+ * @param p - The linear path to assert against.
142
+ * @returns The same path, typed with the `Continuous` brand.
143
+ * @throws When the path has a discontinuity between adjacent curves.
144
+ * @since 2.0.0
145
+ */
146
+ const asContinuous$2 = asContinuous$3;
147
+ //#endregion
148
+ //#region src/path/quadratic2d.internal.ts
149
+ const QuadraticPath2dTypeId = Symbol("curvy/path/quadratic2d");
150
+ var QuadraticPath2dImpl = class extends Pipeable {
151
+ [QuadraticPath2dTypeId] = QuadraticPath2dTypeId;
152
+ curves;
153
+ constructor(curves) {
154
+ super();
155
+ this.curves = curves;
156
+ }
157
+ [Symbol.iterator]() {
158
+ return this.curves[Symbol.iterator]();
159
+ }
160
+ };
161
+ const isQuadraticPath2d$1 = (p) => typeof p === "object" && p !== null && QuadraticPath2dTypeId in p;
162
+ const make$1 = (...curves) => new QuadraticPath2dImpl(curves);
163
+ const fromArray$1 = (curves) => new QuadraticPath2dImpl(curves);
164
+ const append$1 = dual(2, (p, c) => fromArray$1([...p, c]));
165
+ const length$1 = (p) => {
166
+ let total = 0;
167
+ for (const curve of p) total += length$5(curve, unit);
168
+ return total;
169
+ };
170
+ const solve$1 = dual(2, (p, u) => {
171
+ const curves = p instanceof QuadraticPath2dImpl ? p.curves : [...p];
172
+ if (u === 1) return solve$5(curves.at(-1), 1);
173
+ const t = u * curves.length;
174
+ const i = Math.floor(t);
175
+ const curve = curves[i];
176
+ return solve$5(curve, t - i);
177
+ });
178
+ const toPathData$1 = (p) => {
179
+ let result = "";
180
+ let prevEndX = NaN;
181
+ let prevEndY = NaN;
182
+ for (const curve of p) {
183
+ const c0x = curve.x.c0;
184
+ const c0y = curve.y.c0;
185
+ const c1x = curve.x.c1;
186
+ const c1y = curve.y.c1;
187
+ const c2x = curve.x.c2;
188
+ const c2y = curve.y.c2;
189
+ const startX = c0x;
190
+ const startY = c0y;
191
+ const ctrlX = c0x + c1x / 2;
192
+ const ctrlY = c0y + c1y / 2;
193
+ const endX = c0x + c1x + c2x;
194
+ const endY = c0y + c1y + c2y;
195
+ if (!epsEquals(startX, prevEndX) || !epsEquals(startY, prevEndY)) result += ` M ${startX},${startY}`;
196
+ result += ` Q ${ctrlX},${ctrlY} ${endX},${endY}`;
197
+ prevEndX = endX;
198
+ prevEndY = endY;
199
+ }
200
+ return result.slice(1);
201
+ };
202
+ const isContinuous$1 = (p) => {
203
+ let prevEndX = NaN;
204
+ let prevEndY = NaN;
205
+ let first = true;
206
+ for (const curve of p) {
207
+ const startX = curve.x.c0;
208
+ const startY = curve.y.c0;
209
+ if (!first && (!epsEquals(startX, prevEndX) || !epsEquals(startY, prevEndY))) return false;
210
+ prevEndX = curve.x.c0 + curve.x.c1 + curve.x.c2;
211
+ prevEndY = curve.y.c0 + curve.y.c1 + curve.y.c2;
212
+ first = false;
213
+ }
214
+ return true;
215
+ };
216
+ const asContinuous$1 = (p) => {
217
+ invariant(isContinuous$1(p), "quadratic path is not continuous");
218
+ return p;
219
+ };
220
+ //#endregion
221
+ //#region src/path/quadratic2d.ts
222
+ var quadratic2d_exports = /* @__PURE__ */ __exportAll({
223
+ append: () => append,
224
+ asContinuous: () => asContinuous,
225
+ fromArray: () => fromArray,
226
+ isContinuous: () => isContinuous,
227
+ isQuadraticPath2d: () => isQuadraticPath2d,
228
+ length: () => length,
229
+ make: () => make,
230
+ solve: () => solve,
231
+ toPathData: () => toPathData
232
+ });
233
+ /**
234
+ * Creates a new `QuadraticPath2d` instance from a sequence of curves.
235
+ *
236
+ * @param curves - The curves to create the path from.
237
+ * @returns A new `QuadraticPath2d` instance.
238
+ * @since 2.0.0
239
+ */
240
+ const make = make$1;
241
+ /**
242
+ * Creates a new `QuadraticPath2d` instance from an array of curves.
243
+ *
244
+ * @param curves - The curves to create the path from.
245
+ * @returns A new `QuadraticPath2d` instance.
246
+ * @since 2.0.0
247
+ */
248
+ const fromArray = fromArray$1;
249
+ /**
250
+ * Checks if a value is a `QuadraticPath2d`.
251
+ *
252
+ * @param p - The value to check.
253
+ * @returns `true` if the value is a `QuadraticPath2d`, `false` otherwise.
254
+ * @since 1.0.0
255
+ */
256
+ const isQuadraticPath2d = isQuadraticPath2d$1;
257
+ const append = append$1;
258
+ /**
259
+ * Calculates the length of a quadratic path.
260
+ *
261
+ * @param p - The quadratic path to calculate the length of.
262
+ * @returns The length of the path.
263
+ */
264
+ const length = length$1;
265
+ const solve = solve$1;
266
+ /**
267
+ * Serializes a quadratic path as an SVG path data string (the value of a
268
+ * `<path>` element's `d` attribute), using `M` and `Q` commands. Discontinuities
269
+ * between curves emit a fresh `M` command.
270
+ *
271
+ * @param p - The quadratic path to serialize.
272
+ * @returns The SVG path data string.
273
+ * @since 2.0.0
274
+ */
275
+ const toPathData = toPathData$1;
276
+ /**
277
+ * Type-narrowing predicate: refines `QuadraticPath2d<T>` to
278
+ * `QuadraticPath2d<T & Continuous>` when adjacent curves connect.
279
+ *
280
+ * @since 2.0.0
281
+ */
282
+ const isContinuous = isContinuous$1;
283
+ /**
284
+ * Asserts that the quadratic path is continuous, throwing on failure.
285
+ *
286
+ * @since 2.0.0
287
+ */
288
+ const asContinuous = asContinuous$1;
289
+ //#endregion
290
+ export { cubic2d_exports as CubicPath2d, linear2d_exports as LinearPath2d, quadratic2d_exports as QuadraticPath2d, rationalCubic2d_exports as RationalCubicPath2d };
291
+
292
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["isLinearPath2d","make","fromArray","append","length","LinearCurve2d.length","Interval.unit","solve","LinearCurve2d.solve","toPathData","isContinuous","asContinuous","make","internal.make","fromArray","internal.fromArray","internal.isLinearPath2d","append","internal.append","length","internal.length","solve","internal.solve","toPathData","internal.toPathData","isContinuous","internal.isContinuous","asContinuous","internal.asContinuous","isQuadraticPath2d","make","fromArray","append","length","QuadraticCurve2d.length","Interval.unit","solve","QuadraticCurve2d.solve","toPathData","isContinuous","asContinuous","internal.make","internal.fromArray","internal.isQuadraticPath2d","internal.append","internal.length","internal.solve","internal.toPathData","internal.isContinuous","internal.asContinuous"],"sources":["../../src/path/linear2d.internal.ts","../../src/path/linear2d.ts","../../src/path/quadratic2d.internal.ts","../../src/path/quadratic2d.ts"],"sourcesContent":["import * as LinearCurve2d from '../curve/linear2d'\nimport * as Interval from '../interval/interval'\nimport { dual, Pipeable } from '../utils'\nimport { invariant } from '../utils'\nimport { epsEquals } from '../number'\nimport type { Vector2 } from '../vector/vector2'\nimport type { LinearPath2d } from './linear2d'\nimport { PathTraits, type Continuous } from './traits'\n\nexport const LinearPath2dTypeId: unique symbol = Symbol('curvy/path/linear2d')\nexport type LinearPath2dTypeId = typeof LinearPath2dTypeId\n\nexport class LinearPath2dImpl extends Pipeable implements LinearPath2d<unknown> {\n readonly [LinearPath2dTypeId]: LinearPath2dTypeId = LinearPath2dTypeId\n declare readonly [PathTraits]: unknown\n\n readonly curves: ReadonlyArray<LinearCurve2d.LinearCurve2d>\n\n constructor(curves: ReadonlyArray<LinearCurve2d.LinearCurve2d>) {\n super()\n this.curves = curves\n }\n\n [Symbol.iterator](): Iterator<LinearCurve2d.LinearCurve2d> {\n return this.curves[Symbol.iterator]()\n }\n}\n\nexport const isLinearPath2d = (p: unknown): p is LinearPath2d =>\n typeof p === 'object' && p !== null && LinearPath2dTypeId in p\n\nexport const make = (...curves: ReadonlyArray<LinearCurve2d.LinearCurve2d>): LinearPath2d =>\n new LinearPath2dImpl(curves)\n\nexport const fromArray = (curves: ReadonlyArray<LinearCurve2d.LinearCurve2d>) =>\n new LinearPath2dImpl(curves)\n\nexport const append = dual<\n (c: LinearCurve2d.LinearCurve2d) => (p: LinearPath2d) => LinearPath2d,\n (p: LinearPath2d, c: LinearCurve2d.LinearCurve2d) => LinearPath2d\n>(2, (p: LinearPath2d, c: LinearCurve2d.LinearCurve2d) => fromArray([...p, c]))\n\nexport const length = (p: LinearPath2d) => {\n let total = 0\n for (const curve of p) {\n total += LinearCurve2d.length(curve, Interval.unit)\n }\n\n return total\n}\n\nexport const solve = dual<\n (u: number) => (p: LinearPath2d) => Vector2,\n (p: LinearPath2d, u: number) => Vector2\n>(2, (p: LinearPath2d, u: number) => {\n const curves = p instanceof LinearPath2dImpl ? p.curves : [...p]\n\n if (u === 1) {\n const last = curves.at(-1) as LinearCurve2d.LinearCurve2d\n return LinearCurve2d.solve(last, 1)\n }\n\n const t = u * curves.length\n const i = Math.floor(t)\n const curve = curves[i] as LinearCurve2d.LinearCurve2d\n return LinearCurve2d.solve(curve, t - i)\n})\n\nexport const toPathData = (p: LinearPath2d): string => {\n let result = ''\n let prevEndX = Number.NaN\n let prevEndY = Number.NaN\n\n for (const curve of p) {\n const startX = curve.x.c0\n const startY = curve.y.c0\n const endX = curve.x.c0 + curve.x.c1\n const endY = curve.y.c0 + curve.y.c1\n\n if (!epsEquals(startX, prevEndX) || !epsEquals(startY, prevEndY)) {\n result += ` M ${startX},${startY}`\n }\n result += ` L ${endX},${endY}`\n\n prevEndX = endX\n prevEndY = endY\n }\n\n return result.slice(1)\n}\n\nexport const isContinuous = <T>(p: LinearPath2d<T>): p is LinearPath2d<T & Continuous> => {\n let prevEndX = Number.NaN\n let prevEndY = Number.NaN\n let first = true\n\n for (const curve of p) {\n const startX = curve.x.c0\n const startY = curve.y.c0\n if (!first && (!epsEquals(startX, prevEndX) || !epsEquals(startY, prevEndY))) {\n return false\n }\n prevEndX = curve.x.c0 + curve.x.c1\n prevEndY = curve.y.c0 + curve.y.c1\n first = false\n }\n return true\n}\n\nexport const asContinuous = <T>(p: LinearPath2d<T>): LinearPath2d<T & Continuous> => {\n invariant(isContinuous(p), 'linear path is not continuous')\n return p\n}\n","import type { LinearCurve2d } from '../curve/linear2d'\nimport type { Pipeable } from '../utils'\nimport type { Vector2 } from '../vector/vector2'\nimport type { LinearPath2dTypeId } from './linear2d.internal'\nimport * as internal from './linear2d.internal'\nimport type { Continuous, PathTraits } from './traits'\n\nexport type { Continuous } from './traits'\n\n/**\n * A linear path in 2D space.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * The `Trait` type parameter accumulates trait brands as the path is refined\n * via `isContinuous` / `asContinuous`. A `Continuous` path's `toPathData`\n * skips the per-segment discontinuity check.\n *\n * @since 1.0.0\n */\nexport interface LinearPath2d<out Trait = unknown> extends Pipeable, Iterable<LinearCurve2d> {\n readonly [LinearPath2dTypeId]: LinearPath2dTypeId\n readonly [PathTraits]: Trait\n}\n\n/**\n * Creates a new `LinearPath2d` instance from a sequence of curves.\n *\n * @param curves - The curves to create the path from.\n * @returns A new `LinearPath2d` instance.\n * @since 2.0.0\n */\nexport const make: (...curves: ReadonlyArray<LinearCurve2d>) => LinearPath2d = internal.make\n\n/**\n * Creates a new `LinearPath2d` instance from an array of curves.\n *\n * @param curves - The curves to create the path from.\n * @returns A new `LinearPath2d` instance.\n * @since 2.0.0\n */\nexport const fromArray: (curves: ReadonlyArray<LinearCurve2d>) => LinearPath2d = internal.fromArray\n\n/**\n * Checks if a value is a `LinearPath2d`.\n *\n * @param p - The value to check.\n * @returns `true` if the value is a `LinearPath2d`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isLinearPath2d: (p: unknown) => p is LinearPath2d = internal.isLinearPath2d\n\nexport const append: {\n /**\n * Appends a linear curve to a linear path.\n *\n * @param c - The linear curve to append.\n * @returns A function that takes a linear path and returns a new linear path.\n * @since 1.0.0\n */\n (c: LinearCurve2d): (p: LinearPath2d) => LinearPath2d\n /**\n * Appends a linear curve to a linear path.\n *\n * @param p - The linear path to append to.\n * @param c - The linear curve to append.\n * @returns A new `LinearPath2d` instance with the appended curve.\n * @since 1.0.0\n */\n (p: LinearPath2d, c: LinearCurve2d): LinearPath2d\n} = internal.append\n\n/**\n * Calculates the length of a linear path.\n *\n * @param p - The linear path to calculate the length of.\n * @returns The length of the linear path.\n * @since 1.0.0\n */\nexport const length: (p: LinearPath2d) => number = internal.length\n\nexport const solve: {\n /**\n * Solves a linear path for a given parameter.\n *\n * @param u - The parameter to solve for.\n * @returns A function that takes a linear path and returns the solved point.\n * @since 1.0.0\n */\n (u: number): (p: LinearPath2d) => Vector2\n /**\n * Solves a linear path for a given parameter.\n *\n * @param p - The linear path to solve.\n * @param u - The parameter to solve for.\n * @returns The solved point on the linear path.\n * @since 1.0.0\n */\n (p: LinearPath2d, u: number): Vector2\n} = internal.solve\n\n/**\n * Serializes a linear path as an SVG path data string (the value of a `<path>`\n * element's `d` attribute), using `M` and `L` commands. Discontinuities between\n * curves emit a fresh `M` command.\n *\n * @param p - The linear path to serialize.\n * @returns The SVG path data string.\n * @since 2.0.0\n */\nexport const toPathData: (p: LinearPath2d) => string = internal.toPathData\n\n/**\n * Type-narrowing predicate: refines `LinearPath2d<T>` to\n * `LinearPath2d<T & Continuous>` when adjacent curves connect at their join\n * points.\n *\n * @param p - The linear path to check.\n * @returns `true` when the path is continuous (G⁰).\n * @since 2.0.0\n */\nexport const isContinuous: <T>(p: LinearPath2d<T>) => p is LinearPath2d<T & Continuous> =\n internal.isContinuous\n\n/**\n * Asserts that the linear path is continuous, throwing on failure.\n *\n * @param p - The linear path to assert against.\n * @returns The same path, typed with the `Continuous` brand.\n * @throws When the path has a discontinuity between adjacent curves.\n * @since 2.0.0\n */\nexport const asContinuous: <T>(p: LinearPath2d<T>) => LinearPath2d<T & Continuous> =\n internal.asContinuous\n","import * as QuadraticCurve2d from '../curve/quadratic2d'\nimport * as Interval from '../interval/interval'\nimport { dual, Pipeable } from '../utils'\nimport { invariant } from '../utils'\nimport { epsEquals } from '../number'\nimport type { Vector2 } from '../vector/vector2'\nimport type { QuadraticPath2d } from './quadratic2d'\nimport { PathTraits, type Continuous } from './traits'\n\nexport const QuadraticPath2dTypeId: unique symbol = Symbol('curvy/path/quadratic2d')\nexport type QuadraticPath2dTypeId = typeof QuadraticPath2dTypeId\n\nexport class QuadraticPath2dImpl extends Pipeable implements QuadraticPath2d<unknown> {\n readonly [QuadraticPath2dTypeId]: QuadraticPath2dTypeId = QuadraticPath2dTypeId\n declare readonly [PathTraits]: unknown\n\n readonly curves: ReadonlyArray<QuadraticCurve2d.QuadraticCurve2d>\n\n constructor(curves: ReadonlyArray<QuadraticCurve2d.QuadraticCurve2d>) {\n super()\n this.curves = curves\n }\n\n [Symbol.iterator](): Iterator<QuadraticCurve2d.QuadraticCurve2d> {\n return this.curves[Symbol.iterator]()\n }\n}\n\nexport const isQuadraticPath2d = (p: unknown): p is QuadraticPath2d =>\n typeof p === 'object' && p !== null && QuadraticPath2dTypeId in p\n\nexport const make = (\n ...curves: ReadonlyArray<QuadraticCurve2d.QuadraticCurve2d>\n): QuadraticPath2d => new QuadraticPath2dImpl(curves)\n\nexport const fromArray = (\n curves: ReadonlyArray<QuadraticCurve2d.QuadraticCurve2d>,\n): QuadraticPath2d => new QuadraticPath2dImpl(curves)\n\nexport const append = dual<\n (c: QuadraticCurve2d.QuadraticCurve2d) => (p: QuadraticPath2d) => QuadraticPath2d,\n (p: QuadraticPath2d, c: QuadraticCurve2d.QuadraticCurve2d) => QuadraticPath2d\n>(2, (p: QuadraticPath2d, c: QuadraticCurve2d.QuadraticCurve2d) => fromArray([...p, c]))\n\nexport const length = (p: QuadraticPath2d) => {\n let total = 0\n for (const curve of p) {\n total += QuadraticCurve2d.length(curve, Interval.unit)\n }\n\n return total\n}\n\nexport const solve = dual<\n (u: number) => (p: QuadraticPath2d) => Vector2,\n (p: QuadraticPath2d, u: number) => Vector2\n>(2, (p: QuadraticPath2d, u: number) => {\n const curves = p instanceof QuadraticPath2dImpl ? p.curves : [...p]\n\n if (u === 1) {\n const last = curves.at(-1) as QuadraticCurve2d.QuadraticCurve2d\n return QuadraticCurve2d.solve(last, 1)\n }\n\n const t = u * curves.length\n const i = Math.floor(t)\n const curve = curves[i] as QuadraticCurve2d.QuadraticCurve2d\n return QuadraticCurve2d.solve(curve, t - i)\n})\n\n// Quadratic Bernstein basis: P(t) = (1-t)²·p0 + 2(1-t)t·p1 + t²·p2\n// expanded gives c0 = p0, c1 = -2p0 + 2p1, c2 = p0 - 2p1 + p2, so:\n// p0 = c0, p1 = c0 + c1/2, p2 = c0 + c1 + c2.\nexport const toPathData = (p: QuadraticPath2d): string => {\n let result = ''\n let prevEndX = Number.NaN\n let prevEndY = Number.NaN\n\n for (const curve of p) {\n const c0x = curve.x.c0\n const c0y = curve.y.c0\n const c1x = curve.x.c1\n const c1y = curve.y.c1\n const c2x = curve.x.c2\n const c2y = curve.y.c2\n\n const startX = c0x\n const startY = c0y\n const ctrlX = c0x + c1x / 2\n const ctrlY = c0y + c1y / 2\n const endX = c0x + c1x + c2x\n const endY = c0y + c1y + c2y\n\n if (!epsEquals(startX, prevEndX) || !epsEquals(startY, prevEndY)) {\n result += ` M ${startX},${startY}`\n }\n result += ` Q ${ctrlX},${ctrlY} ${endX},${endY}`\n\n prevEndX = endX\n prevEndY = endY\n }\n\n return result.slice(1)\n}\n\nexport const isContinuous = <T>(p: QuadraticPath2d<T>): p is QuadraticPath2d<T & Continuous> => {\n let prevEndX = Number.NaN\n let prevEndY = Number.NaN\n let first = true\n\n for (const curve of p) {\n const startX = curve.x.c0\n const startY = curve.y.c0\n if (!first && (!epsEquals(startX, prevEndX) || !epsEquals(startY, prevEndY))) {\n return false\n }\n prevEndX = curve.x.c0 + curve.x.c1 + curve.x.c2\n prevEndY = curve.y.c0 + curve.y.c1 + curve.y.c2\n first = false\n }\n return true\n}\n\nexport const asContinuous = <T>(p: QuadraticPath2d<T>): QuadraticPath2d<T & Continuous> => {\n invariant(isContinuous(p), 'quadratic path is not continuous')\n return p\n}\n","import type { QuadraticCurve2d } from '../curve/quadratic2d'\nimport type { Pipeable } from '../utils'\nimport type { Vector2 } from '../vector/vector2'\nimport type { QuadraticPath2dTypeId } from './quadratic2d.internal'\nimport * as internal from './quadratic2d.internal'\nimport type { Continuous, PathTraits } from './traits'\n\nexport type { Continuous } from './traits'\n\n/**\n * A quadratic path in 2D space.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * The `Trait` type parameter accumulates trait brands as the path is refined\n * via `isContinuous` / `asContinuous`.\n *\n * @since 1.0.0\n */\nexport interface QuadraticPath2d<out Trait = unknown> extends Pipeable, Iterable<QuadraticCurve2d> {\n readonly [QuadraticPath2dTypeId]: QuadraticPath2dTypeId\n readonly [PathTraits]: Trait\n}\n\n/**\n * Creates a new `QuadraticPath2d` instance from a sequence of curves.\n *\n * @param curves - The curves to create the path from.\n * @returns A new `QuadraticPath2d` instance.\n * @since 2.0.0\n */\nexport const make: (...curves: ReadonlyArray<QuadraticCurve2d>) => QuadraticPath2d = internal.make\n\n/**\n * Creates a new `QuadraticPath2d` instance from an array of curves.\n *\n * @param curves - The curves to create the path from.\n * @returns A new `QuadraticPath2d` instance.\n * @since 2.0.0\n */\nexport const fromArray: (curves: ReadonlyArray<QuadraticCurve2d>) => QuadraticPath2d =\n internal.fromArray\n\n/**\n * Checks if a value is a `QuadraticPath2d`.\n *\n * @param p - The value to check.\n * @returns `true` if the value is a `QuadraticPath2d`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isQuadraticPath2d: (p: unknown) => p is QuadraticPath2d = internal.isQuadraticPath2d\n\nexport const append: {\n /**\n * Appends a quadratic curve to a quadratic path.\n *\n * @param c - The quadratic curve to append.\n * @returns A function that takes a quadratic path and returns a new quadratic path.\n * @since 1.0.0\n */\n (c: QuadraticCurve2d): (p: QuadraticPath2d) => QuadraticPath2d\n /**\n * Appends a quadratic curve to a quadratic path.\n *\n * @param p - The quadratic path to append to.\n * @param c - The quadratic curve to append.\n * @returns A new `QuadraticPath2d` instance with the appended curve.\n * @since 1.0.0\n */\n (p: QuadraticPath2d, c: QuadraticCurve2d): QuadraticPath2d\n} = internal.append\n\n/**\n * Calculates the length of a quadratic path.\n *\n * @param p - The quadratic path to calculate the length of.\n * @returns The length of the path.\n */\nexport const length: (p: QuadraticPath2d) => number = internal.length\n\nexport const solve: {\n /**\n * Solves a quadratic path at a given parameter.\n *\n * @param u - The parameter to solve for.\n * @returns A function that takes a quadratic path and returns the solved point.\n * @since 1.0.0\n */\n (u: number): (p: QuadraticPath2d) => Vector2\n /**\n * Solves a quadratic path at a given parameter.\n *\n * @param p - The quadratic path to solve.\n * @param u - The parameter to solve for.\n * @returns The solved point.\n * @since 1.0.0\n */\n (p: QuadraticPath2d, u: number): Vector2\n} = internal.solve\n\n/**\n * Serializes a quadratic path as an SVG path data string (the value of a\n * `<path>` element's `d` attribute), using `M` and `Q` commands. Discontinuities\n * between curves emit a fresh `M` command.\n *\n * @param p - The quadratic path to serialize.\n * @returns The SVG path data string.\n * @since 2.0.0\n */\nexport const toPathData: (p: QuadraticPath2d) => string = internal.toPathData\n\n/**\n * Type-narrowing predicate: refines `QuadraticPath2d<T>` to\n * `QuadraticPath2d<T & Continuous>` when adjacent curves connect.\n *\n * @since 2.0.0\n */\nexport const isContinuous: <T>(p: QuadraticPath2d<T>) => p is QuadraticPath2d<T & Continuous> =\n internal.isContinuous\n\n/**\n * Asserts that the quadratic path is continuous, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asContinuous: <T>(p: QuadraticPath2d<T>) => QuadraticPath2d<T & Continuous> =\n internal.asContinuous\n"],"mappings":";;;;;;;AASA,MAAa,qBAAoC,OAAO,sBAAsB;AAG9E,IAAa,mBAAb,cAAsC,SAA0C;CAC9E,CAAU,sBAA0C;CAGpD;CAEA,YAAY,QAAoD;EAC9D,OAAO;EACP,KAAK,SAAS;;CAGhB,CAAC,OAAO,YAAmD;EACzD,OAAO,KAAK,OAAO,OAAO,WAA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,QAAQ,SAAS,GACzE,OAAO;EAET,WAAW,MAAM,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,EAAE;EAC7C,WAAW,MAAM,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,EAAE;EAC7C,QAAQ;;CAEV,OAAO;;AAGT,MAAaC,kBAAmB,MAA2D;CACzF,UAAUD,eAAa,EAAE,EAAE,mCAAmC;CAC9D,OAAO;;;;;;;;;;;;;;;;;;;;;;AC9FT,MAAa,OAAwEE;;;;;;;;AASrF,MAAa,YACXC;;;;;;;;AASF,MAAa,oBAA0DC;AAEvE,MAAa,SAkBTC;;;;;;;AAQJ,MAAa,SAAyCC;AAEtD,MAAa,QAkBTC;;;;;;;;;;AAWJ,MAAa,aAA6CC;;;;;;;AAQ1D,MAAa,eACXC;;;;;;AAOF,MAAa,eACXC"}
@@ -0,0 +1,2 @@
1
+ import { i as quadratic_d_exports, n as cubic_d_exports, o as linear_d_exports } from "../shared/cubic-Dfn6DB02.mjs";
2
+ export { cubic_d_exports as CubicPolynomial, linear_d_exports as LinearPolynomial, quadratic_d_exports as QuadraticPolynomial };
@@ -0,0 +1,3 @@
1
+ import { t as cubic_exports } from "../shared/cubic-CYYEUHNm.mjs";
2
+ import { f as linear_exports, o as quadratic_exports } from "../shared/quadratic-DEhuAKuE.mjs";
3
+ export { cubic_exports as CubicPolynomial, linear_exports as LinearPolynomial, quadratic_exports as QuadraticPolynomial };
@@ -0,0 +1,104 @@
1
+ import { t as __exportAll } from "./chunk-25Hzd3z8.mjs";
2
+ import { roundDown } from "../number.mjs";
3
+ import { a as vectorProductLeft, n as make } from "./matrix4x4-Ck2WROK-.mjs";
4
+ import { r as fromVector } from "./cubic-CYYEUHNm.mjs";
5
+ //#region src/characteristic/characteristic.ts
6
+ var characteristic_exports = /* @__PURE__ */ __exportAll({
7
+ apply: () => apply,
8
+ cubicBasisSpline: () => cubicBasisSpline,
9
+ cubicBezier: () => cubicBezier,
10
+ cubicCardinal: () => cubicCardinal,
11
+ cubicCatmullRom: () => cubicCatmullRom,
12
+ cubicHermite: () => cubicHermite
13
+ });
14
+ /**
15
+ * The cubic Bézier characteristic matrix.
16
+ *
17
+ * Maps Bernstein-basis control points `(P₀, P₁, P₂, P₃)` to monomial cubic
18
+ * coefficients `(c₀, c₁, c₂, c₃)` for `c₀ + c₁·t + c₂·t² + c₃·t³`. The matrix
19
+ * IS the Bézier spline family — combined with control points (via {@link apply}),
20
+ * it produces the cubic polynomial that parameterizes the curve.
21
+ *
22
+ * @since 2.1.0
23
+ */
24
+ const cubicBezier = make(1, 0, 0, 0, -3, 3, 0, 0, 3, -6, 3, 0, -1, 3, -3, 1);
25
+ /**
26
+ * The cubic Hermite characteristic matrix.
27
+ *
28
+ * Maps Hermite control data `(P₀, V₀, P₁, V₁)` — two endpoints and two
29
+ * tangent vectors — to monomial cubic coefficients.
30
+ *
31
+ * @since 2.1.0
32
+ */
33
+ const cubicHermite = make(1, 0, 0, 0, 0, 1, 0, 0, -3, -2, 3, -1, 2, 1, -2, 1);
34
+ /**
35
+ * The uniform cubic B-spline (basis spline) characteristic matrix.
36
+ *
37
+ * Maps a window of four control points to the monomial cubic coefficients
38
+ * of one segment of the corresponding uniform cubic B-spline. Stride-1
39
+ * application produces a C² piecewise spline; the curve does not generally
40
+ * pass through the control points.
41
+ *
42
+ * @since 2.1.0
43
+ */
44
+ const cubicBasisSpline = make(1 / 6, 4 / 6, roundDown(1 / 6), 0, -.5, 0, .5, 0, .5, -1, .5, 0, -1 / 6, .5, -.5, 1 / 6);
45
+ const cardinalCache = /* @__PURE__ */ new Map();
46
+ /**
47
+ * The cubic Cardinal spline characteristic matrix, parameterized by tension.
48
+ *
49
+ * Maps four control points to the monomial cubic coefficients of one
50
+ * Cardinal segment. The tension `s` controls how tightly the curve hugs
51
+ * the control points: `s = 0` produces straight-line segments between
52
+ * adjacent points, `s = 0.5` is the Catmull-Rom variant (see
53
+ * {@link cubicCatmullRom}), and higher values produce looser, more curved
54
+ * shapes.
55
+ *
56
+ * Cached per tension value — repeated calls with the same tension return
57
+ * the same matrix instance.
58
+ *
59
+ * @param tension - The tension parameter.
60
+ * @returns The characteristic matrix for that tension.
61
+ * @since 2.1.0
62
+ */
63
+ const cubicCardinal = (tension) => {
64
+ let m = cardinalCache.get(tension);
65
+ if (m === void 0) {
66
+ m = make(0, 1, 0, 0, -tension, 0, tension, 0, 2 * tension, tension - 3, 3 - 2 * tension, -tension, -tension, 2 - tension, tension - 2, tension);
67
+ cardinalCache.set(tension, m);
68
+ }
69
+ return m;
70
+ };
71
+ /**
72
+ * The cubic Catmull-Rom characteristic matrix — Cardinal with tension `0.5`.
73
+ * The most common Cardinal-family variant; reused widely enough to deserve
74
+ * a constant.
75
+ *
76
+ * @since 2.1.0
77
+ */
78
+ const cubicCatmullRom = cubicCardinal(.5);
79
+ /**
80
+ * Applies a characteristic matrix to N channels of control values, producing
81
+ * N cubic polynomials in monomial form.
82
+ *
83
+ * Each channel is a `Vector4` packing one axis's values across the four
84
+ * control points: `(v₀, v₁, v₂, v₃)`. The result tuple has the same arity
85
+ * as the input.
86
+ *
87
+ * The polynomial 2D spline pipeline applies this with two channels (x, y);
88
+ * the rational 2D pipeline uses three (x, y, w) where `w` is the projective
89
+ * denominator. Higher channel counts generalize to 3D, rational 3D, and
90
+ * beyond — the characteristic matrix doesn't care about the geometric
91
+ * domain, only about how to combine four samples per channel.
92
+ *
93
+ * @param matrix - The characteristic matrix of the spline family.
94
+ * @param channels - One `Vector4` per output polynomial, packing the four control values for that channel.
95
+ * @returns A tuple of cubic polynomials, one per input channel.
96
+ * @since 2.1.0
97
+ */
98
+ const apply = (matrix, ...channels) => {
99
+ return channels.map((c) => fromVector(vectorProductLeft(matrix, c)));
100
+ };
101
+ //#endregion
102
+ export { cubicCardinal as a, cubicBezier as i, characteristic_exports as n, cubicHermite as o, cubicBasisSpline as r, apply as t };
103
+
104
+ //# sourceMappingURL=characteristic-BGRxcxUH.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"characteristic-BGRxcxUH.mjs","names":["Matrix4x4.make","CubicPolynomial.fromVector","Matrix4x4.vectorProductLeft"],"sources":["../../src/characteristic/characteristic.ts"],"sourcesContent":["import * as Matrix4x4 from '../matrix/matrix4x4'\nimport * as CubicPolynomial from '../polynomial/cubic'\nimport { roundDown } from '../number'\nimport type * as Vector4 from '../vector/vector4'\n\n/**\n * The cubic Bézier characteristic matrix.\n *\n * Maps Bernstein-basis control points `(P₀, P₁, P₂, P₃)` to monomial cubic\n * coefficients `(c₀, c₁, c₂, c₃)` for `c₀ + c₁·t + c₂·t² + c₃·t³`. The matrix\n * IS the Bézier spline family — combined with control points (via {@link apply}),\n * it produces the cubic polynomial that parameterizes the curve.\n *\n * @since 2.1.0\n */\nexport const cubicBezier: Matrix4x4.Matrix4x4 = Matrix4x4.make(\n 1,\n 0,\n 0,\n 0,\n -3,\n 3,\n 0,\n 0,\n 3,\n -6,\n 3,\n 0,\n -1,\n 3,\n -3,\n 1,\n)\n\n/**\n * The cubic Hermite characteristic matrix.\n *\n * Maps Hermite control data `(P₀, V₀, P₁, V₁)` — two endpoints and two\n * tangent vectors — to monomial cubic coefficients.\n *\n * @since 2.1.0\n */\nexport const cubicHermite: Matrix4x4.Matrix4x4 = Matrix4x4.make(\n 1,\n 0,\n 0,\n 0,\n 0,\n 1,\n 0,\n 0,\n -3,\n -2,\n 3,\n -1,\n 2,\n 1,\n -2,\n 1,\n)\n\n/**\n * The uniform cubic B-spline (basis spline) characteristic matrix.\n *\n * Maps a window of four control points to the monomial cubic coefficients\n * of one segment of the corresponding uniform cubic B-spline. Stride-1\n * application produces a C² piecewise spline; the curve does not generally\n * pass through the control points.\n *\n * @since 2.1.0\n */\nexport const cubicBasisSpline: Matrix4x4.Matrix4x4 = Matrix4x4.make(\n 1 / 6,\n 4 / 6,\n roundDown(1 / 6),\n 0,\n -0.5,\n 0,\n 0.5,\n 0,\n 0.5,\n -1,\n 0.5,\n 0,\n -1 / 6,\n 0.5,\n -0.5,\n 1 / 6,\n)\n\nconst cardinalCache = new Map<number, Matrix4x4.Matrix4x4>()\n\n/**\n * The cubic Cardinal spline characteristic matrix, parameterized by tension.\n *\n * Maps four control points to the monomial cubic coefficients of one\n * Cardinal segment. The tension `s` controls how tightly the curve hugs\n * the control points: `s = 0` produces straight-line segments between\n * adjacent points, `s = 0.5` is the Catmull-Rom variant (see\n * {@link cubicCatmullRom}), and higher values produce looser, more curved\n * shapes.\n *\n * Cached per tension value — repeated calls with the same tension return\n * the same matrix instance.\n *\n * @param tension - The tension parameter.\n * @returns The characteristic matrix for that tension.\n * @since 2.1.0\n */\nexport const cubicCardinal = (tension: number): Matrix4x4.Matrix4x4 => {\n let m = cardinalCache.get(tension)\n if (m === undefined) {\n m = Matrix4x4.make(\n 0,\n 1,\n 0,\n 0,\n -tension,\n 0,\n tension,\n 0,\n 2 * tension,\n tension - 3,\n 3 - 2 * tension,\n -tension,\n -tension,\n 2 - tension,\n tension - 2,\n tension,\n )\n cardinalCache.set(tension, m)\n }\n return m\n}\n\n/**\n * The cubic Catmull-Rom characteristic matrix — Cardinal with tension `0.5`.\n * The most common Cardinal-family variant; reused widely enough to deserve\n * a constant.\n *\n * @since 2.1.0\n */\nexport const cubicCatmullRom: Matrix4x4.Matrix4x4 = cubicCardinal(0.5)\n\n/**\n * Applies a characteristic matrix to N channels of control values, producing\n * N cubic polynomials in monomial form.\n *\n * Each channel is a `Vector4` packing one axis's values across the four\n * control points: `(v₀, v₁, v₂, v₃)`. The result tuple has the same arity\n * as the input.\n *\n * The polynomial 2D spline pipeline applies this with two channels (x, y);\n * the rational 2D pipeline uses three (x, y, w) where `w` is the projective\n * denominator. Higher channel counts generalize to 3D, rational 3D, and\n * beyond — the characteristic matrix doesn't care about the geometric\n * domain, only about how to combine four samples per channel.\n *\n * @param matrix - The characteristic matrix of the spline family.\n * @param channels - One `Vector4` per output polynomial, packing the four control values for that channel.\n * @returns A tuple of cubic polynomials, one per input channel.\n * @since 2.1.0\n */\nexport const apply = <const Channels extends ReadonlyArray<Vector4.Vector4>>(\n matrix: Matrix4x4.Matrix4x4,\n ...channels: Channels\n): { readonly [K in keyof Channels]: CubicPolynomial.CubicPolynomial } => {\n const result = channels.map((c) =>\n CubicPolynomial.fromVector(Matrix4x4.vectorProductLeft(matrix, c)),\n )\n return result as { readonly [K in keyof Channels]: CubicPolynomial.CubicPolynomial }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAeA,MAAa,cAAmCA,KAC9C,GACA,GACA,GACA,GACA,IACA,GACA,GACA,GACA,GACA,IACA,GACA,GACA,IACA,GACA,IACA,EACD;;;;;;;;;AAUD,MAAa,eAAoCA,KAC/C,GACA,GACA,GACA,GACA,GACA,GACA,GACA,GACA,IACA,IACA,GACA,IACA,GACA,GACA,IACA,EACD;;;;;;;;;;;AAYD,MAAa,mBAAwCA,KACnD,IAAI,GACJ,IAAI,GACJ,UAAU,IAAI,EAAE,EAChB,GACA,KACA,GACA,IACA,GACA,IACA,IACA,IACA,GACA,KAAK,GACL,IACA,KACA,IAAI,EACL;AAED,MAAM,gCAAgB,IAAI,KAAkC;;;;;;;;;;;;;;;;;;AAmB5D,MAAa,iBAAiB,YAAyC;CACrE,IAAI,IAAI,cAAc,IAAI,QAAQ;CAClC,IAAI,MAAM,KAAA,GAAW;EACnB,IAAIA,KACF,GACA,GACA,GACA,GACA,CAAC,SACD,GACA,SACA,GACA,IAAI,SACJ,UAAU,GACV,IAAI,IAAI,SACR,CAAC,SACD,CAAC,SACD,IAAI,SACJ,UAAU,GACV,QACD;EACD,cAAc,IAAI,SAAS,EAAE;;CAE/B,OAAO;;;;;;;;;AAUT,MAAa,kBAAuC,cAAc,GAAI;;;;;;;;;;;;;;;;;;;;AAqBtE,MAAa,SACX,QACA,GAAG,aACqE;CAIxE,OAHe,SAAS,KAAK,MAC3BC,WAA2BC,kBAA4B,QAAQ,EAAE,CAAC,CAEvD"}
@@ -0,0 +1,13 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, no_symbols) => {
4
+ let target = {};
5
+ for (var name in all) __defProp(target, name, {
6
+ get: all[name],
7
+ enumerable: true
8
+ });
9
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
10
+ return target;
11
+ };
12
+ //#endregion
13
+ export { __exportAll as t };