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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/dist/characteristic/{index.d.mts → characteristic.d.ts} +15 -23
  2. package/dist/characteristic/index.d.ts +1 -0
  3. package/dist/characteristic/index.mjs +1 -1
  4. package/dist/curve/cubic2d.d.ts +219 -0
  5. package/dist/curve/index.d.ts +12 -0
  6. package/dist/curve/index.mjs +1 -1
  7. package/dist/curve/linear2d.d.ts +199 -0
  8. package/dist/curve/quadratic2d.d.ts +227 -0
  9. package/dist/curve/rationalCubic2d.d.ts +200 -0
  10. package/dist/dimensions.d.ts +23 -0
  11. package/dist/interval/index.d.ts +6 -0
  12. package/dist/interval/index.mjs +2 -2
  13. package/dist/interval/interval.d.ts +525 -0
  14. package/dist/interval/interval2d.d.ts +167 -0
  15. package/dist/length.d.ts +32 -0
  16. package/dist/matrix/index.d.ts +9 -0
  17. package/dist/matrix/matrix2x2.d.ts +339 -0
  18. package/dist/matrix/matrix3x3.d.ts +400 -0
  19. package/dist/matrix/matrix4x4.d.ts +443 -0
  20. package/dist/number.d.ts +276 -0
  21. package/dist/path/cubic2d.d.ts +155 -0
  22. package/dist/path/index.d.ts +12 -0
  23. package/dist/path/index.mjs +6 -6
  24. package/dist/path/index.mjs.map +1 -1
  25. package/dist/path/linear2d.d.ts +135 -0
  26. package/dist/path/quadratic2d.d.ts +127 -0
  27. package/dist/path/rationalCubic2d.d.ts +120 -0
  28. package/dist/path/traits.d.ts +31 -0
  29. package/dist/polynomial/cubic.d.ts +381 -0
  30. package/dist/polynomial/index.d.ts +9 -0
  31. package/dist/polynomial/index.mjs +2 -2
  32. package/dist/polynomial/linear.d.ts +321 -0
  33. package/dist/polynomial/monotonicity.d.ts +3 -0
  34. package/dist/polynomial/quadratic.d.ts +375 -0
  35. package/dist/polynomial/traits.d.ts +56 -0
  36. package/dist/shared/{characteristic-B9nCh_cx.mjs → characteristic-DLlhja-I.mjs} +9 -9
  37. package/dist/shared/{characteristic-B9nCh_cx.mjs.map → characteristic-DLlhja-I.mjs.map} +1 -1
  38. package/dist/shared/{cubic-CpHAx8cC.mjs → cubic-CMonq6bg.mjs} +26 -5
  39. package/dist/shared/cubic-CMonq6bg.mjs.map +1 -0
  40. package/dist/shared/{interval-05CR6eBf.mjs → interval-X1EYuf-T.mjs} +2 -2
  41. package/dist/shared/{interval-05CR6eBf.mjs.map → interval-X1EYuf-T.mjs.map} +1 -1
  42. package/dist/shared/{interval2d-8IBZnUOq.mjs → interval2d-ca0J1NMr.mjs} +8 -8
  43. package/dist/shared/{interval2d-8IBZnUOq.mjs.map → interval2d-ca0J1NMr.mjs.map} +1 -1
  44. package/dist/shared/{quadratic-CamozcFc.mjs → quadratic-DyeMtvET.mjs} +20 -2
  45. package/dist/shared/quadratic-DyeMtvET.mjs.map +1 -0
  46. package/dist/shared/{rationalCubic2d-Bys2Uory.mjs → rationalCubic2d-D658ltUM.mjs} +17 -17
  47. package/dist/shared/{rationalCubic2d-Bys2Uory.mjs.map → rationalCubic2d-D658ltUM.mjs.map} +1 -1
  48. package/dist/shared/{rationalCubic2d-BEgUGSFf.mjs → rationalCubic2d-Vw4qGPZj.mjs} +9 -9
  49. package/dist/shared/{rationalCubic2d-BEgUGSFf.mjs.map → rationalCubic2d-Vw4qGPZj.mjs.map} +1 -1
  50. package/dist/shared/{solution-CrtLfqEq.mjs → solution-3TDATEMn.mjs} +28 -2
  51. package/dist/shared/solution-3TDATEMn.mjs.map +1 -0
  52. package/dist/shared/{vector2-CL1HDdPr.mjs → vector2-CCuJx1rX.mjs} +6 -6
  53. package/dist/shared/{vector2-CL1HDdPr.mjs.map → vector2-CCuJx1rX.mjs.map} +1 -1
  54. package/dist/shared/{vector3-D-tv_aKL.mjs → vector3-C-qgKAjR.mjs} +2 -2
  55. package/dist/shared/{vector3-D-tv_aKL.mjs.map → vector3-C-qgKAjR.mjs.map} +1 -1
  56. package/dist/shared/{vector4-5KbjoHVj.mjs → vector4-BhOKDhD5.mjs} +2 -2
  57. package/dist/shared/{vector4-5KbjoHVj.mjs.map → vector4-BhOKDhD5.mjs.map} +1 -1
  58. package/dist/solution/index.d.ts +3 -0
  59. package/dist/solution/index.mjs +1 -1
  60. package/dist/{shared/solution-sNQ-ZVhN.d.mts → solution/solution.d.ts} +81 -68
  61. package/dist/splines/basis2d.d.ts +122 -0
  62. package/dist/splines/bezier2d.d.ts +202 -0
  63. package/dist/splines/cardinal2d.d.ts +273 -0
  64. package/dist/splines/hermite2d.d.ts +117 -0
  65. package/dist/splines/index.d.ts +15 -0
  66. package/dist/splines/index.mjs +193 -35
  67. package/dist/splines/index.mjs.map +1 -1
  68. package/dist/splines/rationalBezier2d.d.ts +148 -0
  69. package/dist/splines/util.d.ts +5 -0
  70. package/dist/utils.d.ts +73 -0
  71. package/dist/vector/index.d.ts +9 -0
  72. package/dist/vector/index.mjs +3 -3
  73. package/dist/vector/vector2.d.ts +446 -0
  74. package/dist/vector/vector3.d.ts +449 -0
  75. package/dist/vector/vector4.d.ts +253 -0
  76. package/package.json +13 -13
  77. package/dist/curve/index.d.mts +0 -2
  78. package/dist/interval/index.d.mts +0 -3
  79. package/dist/matrix/index.d.mts +0 -2
  80. package/dist/number.d.mts +0 -280
  81. package/dist/path/index.d.mts +0 -261
  82. package/dist/polynomial/index.d.mts +0 -2
  83. package/dist/shared/cubic-BajUY0JT.d.mts +0 -1100
  84. package/dist/shared/cubic-CpHAx8cC.mjs.map +0 -1
  85. package/dist/shared/interval-Dy-RMEE3.d.mts +0 -533
  86. package/dist/shared/interval2d-C2id9u31.d.mts +0 -172
  87. package/dist/shared/matrix4x4-Dm_tSiH1.d.mts +0 -1183
  88. package/dist/shared/quadratic-CamozcFc.mjs.map +0 -1
  89. package/dist/shared/rationalCubic2d-B6g97ryJ.d.mts +0 -308
  90. package/dist/shared/rationalCubic2d-DlQfBURs.d.mts +0 -818
  91. package/dist/shared/solution-CrtLfqEq.mjs.map +0 -1
  92. package/dist/shared/utils-MCckigYk.d.mts +0 -76
  93. package/dist/shared/vector2-DPUY3_eA.d.mts +0 -470
  94. package/dist/shared/vector3-DqeOZtOB.d.mts +0 -703
  95. package/dist/solution/index.d.mts +0 -2
  96. package/dist/splines/index.d.mts +0 -701
  97. package/dist/utils.d.mts +0 -2
  98. package/dist/vector/index.d.mts +0 -3
@@ -0,0 +1,525 @@
1
+ import type { Pipeable } from '../utils';
2
+ /**
3
+ * The structural minimum: any value with numeric `start` and `end` fields.
4
+ *
5
+ * Operations that don't read endpoint inclusivity (e.g. `lerp`, `normalize`,
6
+ * `remap`, `size`) accept `Bounds` so the signature itself documents what
7
+ * the operation depends on.
8
+ *
9
+ * @since 2.0.0
10
+ */
11
+ export interface Bounds {
12
+ readonly start: number;
13
+ readonly end: number;
14
+ }
15
+ /**
16
+ * A mathematical interval. Discriminated union of four variants by endpoint
17
+ * inclusivity: `Closed`, `OpenStart`, `OpenEnd`, `Open`. Operations that
18
+ * depend on inclusivity (e.g. `contains`, `filter`, `equals`) dispatch on
19
+ * the `kind` field; operations that don't accept the broader `Bounds` type.
20
+ *
21
+ * All fields are readonly and immutable, and all operations create new instances.
22
+ *
23
+ * @since 1.0.0
24
+ */
25
+ export type Interval = Closed | OpenStart | OpenEnd | Open;
26
+ /**
27
+ * `[start, end]` — both endpoints included.
28
+ *
29
+ * @since 2.0.0
30
+ */
31
+ export interface Closed extends Pipeable, Bounds {
32
+ readonly kind: 'closed';
33
+ }
34
+ /**
35
+ * `(start, end]` — start excluded, end included.
36
+ *
37
+ * @since 2.0.0
38
+ */
39
+ export interface OpenStart extends Pipeable, Bounds {
40
+ readonly kind: 'open-start';
41
+ }
42
+ /**
43
+ * `[start, end)` — start included, end excluded.
44
+ *
45
+ * @since 2.0.0
46
+ */
47
+ export interface OpenEnd extends Pipeable, Bounds {
48
+ readonly kind: 'open-end';
49
+ }
50
+ /**
51
+ * `(start, end)` — both endpoints excluded.
52
+ *
53
+ * @since 2.0.0
54
+ */
55
+ export interface Open extends Pipeable, Bounds {
56
+ readonly kind: 'open';
57
+ }
58
+ /**
59
+ * Checks if a value is an `Interval`.
60
+ *
61
+ * @param v - The value to check.
62
+ * @returns `true` if the value is an `Interval`, `false` otherwise.
63
+ * @since 1.0.0
64
+ */
65
+ export declare const isInterval: (v: unknown) => v is Interval;
66
+ export declare const equals: {
67
+ /**
68
+ * Checks if two `Interval` instances are approximately equal within the
69
+ * default absolute tolerance ({@link EPSILON}).
70
+ *
71
+ * Both endpoints AND the kind must match — a `Closed` and an `OpenStart` with
72
+ * the same numeric endpoints are not equal. Use `aligned` for the looser
73
+ * "same numeric range" check.
74
+ *
75
+ * @param a - The first interval.
76
+ * @param b - The second interval.
77
+ * @returns `true` when both intervals share a kind and both endpoints are within tolerance.
78
+ * @since 1.1.0
79
+ */
80
+ (a: Interval, b: Interval): boolean;
81
+ /**
82
+ * Checks if two `Interval` instances are approximately equal within the
83
+ * default absolute tolerance ({@link EPSILON}).
84
+ *
85
+ * @param b - The second interval.
86
+ * @returns A function that takes the first interval and returns the comparison result.
87
+ * @since 1.1.0
88
+ */
89
+ (b: Interval): (a: Interval) => boolean;
90
+ };
91
+ export declare const aligned: {
92
+ /**
93
+ * Checks if two values share the same numeric range, ignoring endpoint
94
+ * inclusivity. Accepts any `Bounds`-shaped value.
95
+ *
96
+ * @param a - The first bounds.
97
+ * @param b - The second bounds.
98
+ * @returns `true` when both endpoints are within the default tolerance ({@link EPSILON}).
99
+ * @since 2.0.0
100
+ */
101
+ (a: Bounds, b: Bounds): boolean;
102
+ /**
103
+ * @param b - The second bounds.
104
+ * @returns A function that takes the first bounds and returns the comparison result.
105
+ * @since 2.0.0
106
+ */
107
+ (b: Bounds): (a: Bounds) => boolean;
108
+ };
109
+ export declare const make: {
110
+ /**
111
+ * Creates a new closed `Interval` instance.
112
+ *
113
+ * @param point - The point of the interval.
114
+ * @returns A new `Closed` interval `[point, point]`.
115
+ * @since 1.0.0
116
+ */
117
+ (point: number): Closed;
118
+ /**
119
+ * Creates a new closed `Interval` instance.
120
+ *
121
+ * @param start - The start of the interval.
122
+ * @param end - The end of the interval.
123
+ * @returns A new `Closed` interval `[start, end]`.
124
+ * @since 1.0.0
125
+ */
126
+ (start: number, end: number): Closed;
127
+ };
128
+ export declare const makeOpenStart: {
129
+ /**
130
+ * Creates a new left-open `Interval` instance.
131
+ *
132
+ * @param point - The point of the interval.
133
+ * @returns A new `OpenStart` interval `(point, point]` (degenerate, empty).
134
+ * @since 2.0.0
135
+ */
136
+ (point: number): OpenStart;
137
+ /**
138
+ * Creates a new left-open `Interval` instance.
139
+ *
140
+ * @param start - The start of the interval (excluded).
141
+ * @param end - The end of the interval (included).
142
+ * @returns A new `OpenStart` interval `(start, end]`.
143
+ * @since 2.0.0
144
+ */
145
+ (start: number, end: number): OpenStart;
146
+ };
147
+ export declare const makeOpenEnd: {
148
+ /**
149
+ * Creates a new right-open `Interval` instance.
150
+ *
151
+ * @param point - The point of the interval.
152
+ * @returns A new `OpenEnd` interval `[point, point)` (degenerate, empty).
153
+ * @since 2.0.0
154
+ */
155
+ (point: number): OpenEnd;
156
+ /**
157
+ * Creates a new right-open `Interval` instance.
158
+ *
159
+ * @param start - The start of the interval (included).
160
+ * @param end - The end of the interval (excluded).
161
+ * @returns A new `OpenEnd` interval `[start, end)`.
162
+ * @since 2.0.0
163
+ */
164
+ (start: number, end: number): OpenEnd;
165
+ };
166
+ export declare const makeOpen: {
167
+ /**
168
+ * Creates a new fully open `Interval` instance.
169
+ *
170
+ * @param point - The point of the interval.
171
+ * @returns A new `Open` interval `(point, point)` (degenerate, empty).
172
+ * @since 2.0.0
173
+ */
174
+ (point: number): Open;
175
+ /**
176
+ * Creates a new fully open `Interval` instance.
177
+ *
178
+ * @param start - The start of the interval (excluded).
179
+ * @param end - The end of the interval (excluded).
180
+ * @returns A new `Open` interval `(start, end)`.
181
+ * @since 2.0.0
182
+ */
183
+ (start: number, end: number): Open;
184
+ };
185
+ export declare const fromSize: {
186
+ /**
187
+ * Creates a new closed `Interval` instance from a size.
188
+ *
189
+ * @param size - The size of the interval.
190
+ * @returns A new `Closed` interval `[0, size]`.
191
+ * @since 1.0.0
192
+ */
193
+ (size: number): Closed;
194
+ /**
195
+ * Creates a new closed `Interval` instance from a size.
196
+ *
197
+ * @param start - The start of the interval.
198
+ * @param size - The size of the interval.
199
+ * @returns A new `Closed` interval `[start, start + size]`.
200
+ * @since 1.0.0
201
+ */
202
+ (start: number, size: number): Closed;
203
+ };
204
+ /**
205
+ * Creates a new closed `Interval` from a minimum and maximum value, in any order.
206
+ *
207
+ * @param values - The values to take the min and max of.
208
+ * @returns A new `Closed` interval `[min(values), max(values)]`.
209
+ * @since 1.0.0
210
+ */
211
+ export declare const fromMinMax: (...values: ReadonlyArray<number>) => Closed;
212
+ /**
213
+ * Calculates the size of an interval.
214
+ *
215
+ * Kind-agnostic — `size` of `[0, 1]` and `(0, 1)` are both `1`.
216
+ *
217
+ * @param i - The bounds to calculate the size of.
218
+ * @returns The size of the bounds.
219
+ * @since 1.0.0
220
+ */
221
+ export declare const size: (i: Bounds) => number;
222
+ export declare const contains: {
223
+ /**
224
+ * Checks if a value is contained within an interval. Endpoint inclusivity
225
+ * follows the interval's `kind`.
226
+ *
227
+ * @param interval - The interval to check.
228
+ * @param value - The value to check.
229
+ * @returns `true` if the value is contained within the interval, `false` otherwise.
230
+ * @since 1.0.0
231
+ */
232
+ (interval: Interval, value: number): boolean;
233
+ /**
234
+ * Checks if a value is contained within an interval. Endpoint inclusivity
235
+ * follows the interval's `kind`.
236
+ *
237
+ * @param value - The value to check.
238
+ * @returns A function that takes an interval and returns `true` if the value is contained within the interval, `false` otherwise.
239
+ * @since 1.0.0
240
+ */
241
+ (value: number): (interval: Interval) => boolean;
242
+ };
243
+ export declare const containsInterval: {
244
+ /**
245
+ * Checks if `inner` is a subset of `outer` — every point of `inner` is also
246
+ * in `outer`. Respects endpoint inclusivity on both sides: a closed inner
247
+ * endpoint must be inside (or on a closed boundary of) the outer, while an
248
+ * open inner endpoint can sit exactly on an open outer boundary.
249
+ *
250
+ * @param outer - The enclosing interval.
251
+ * @param inner - The candidate inner interval.
252
+ * @returns `true` when `inner` is a subset of `outer`.
253
+ * @since 2.0.0
254
+ */
255
+ (outer: Interval, inner: Interval): boolean;
256
+ /**
257
+ * @param inner - The candidate inner interval.
258
+ * @returns A function that takes the outer interval and returns the containment result.
259
+ * @since 2.0.0
260
+ */
261
+ (inner: Interval): (outer: Interval) => boolean;
262
+ };
263
+ export declare const union: {
264
+ /**
265
+ * Returns the smallest interval enclosing both inputs. Each endpoint's
266
+ * inclusivity follows the input that contributed it; when both endpoints
267
+ * tie, the result is closed at that point if either input includes it.
268
+ *
269
+ * @param a - The first interval.
270
+ * @param b - The second interval.
271
+ * @returns A new interval enclosing both inputs.
272
+ * @since 2.0.0
273
+ */
274
+ (a: Interval, b: Interval): Interval;
275
+ /**
276
+ * @param b - The second interval.
277
+ * @returns A function that takes the first interval and returns the union.
278
+ * @since 2.0.0
279
+ */
280
+ (b: Interval): (a: Interval) => Interval;
281
+ };
282
+ export declare const filter: {
283
+ /**
284
+ * Filters an array of values to those contained within an interval.
285
+ * Endpoint inclusivity follows the interval's `kind`.
286
+ *
287
+ * @param interval - The interval to filter the values to.
288
+ * @param value - The values to filter.
289
+ * @returns The filtered values.
290
+ * @since 1.0.0
291
+ */
292
+ <V extends ReadonlyArray<number>>(interval: Interval, value: V): V;
293
+ /**
294
+ * Filters an array of values to those contained within an interval.
295
+ *
296
+ * @param value - The values to filter.
297
+ * @returns A function that takes an interval and returns the filtered values.
298
+ * @since 1.0.0
299
+ */
300
+ <V extends ReadonlyArray<number>>(value: V): (interval: Interval) => V;
301
+ };
302
+ export declare const clamp: {
303
+ /**
304
+ * Clamps a value to be within bounds. Kind-agnostic — clamps to the numeric
305
+ * range regardless of endpoint inclusivity.
306
+ *
307
+ * @param interval - The bounds to clamp the value to.
308
+ * @param value - The value to clamp.
309
+ * @returns The clamped value.
310
+ * @since 1.0.0
311
+ */
312
+ (interval: Bounds, value: number): number;
313
+ /**
314
+ * Clamps a value to be within bounds. Kind-agnostic.
315
+ *
316
+ * @param value - The value to clamp.
317
+ * @returns A function that takes bounds and returns the clamped value.
318
+ * @since 1.0.0
319
+ */
320
+ (value: number): (interval: Bounds) => number;
321
+ /**
322
+ * Clamps an array of values to be within bounds. Kind-agnostic.
323
+ *
324
+ * @param interval - The bounds to clamp the values to.
325
+ * @param value - The values to clamp.
326
+ * @returns The clamped values.
327
+ * @since 1.0.0
328
+ */
329
+ (interval: Bounds, value: ReadonlyArray<number>): ReadonlyArray<number>;
330
+ /**
331
+ * Clamps an array of values to be within bounds. Kind-agnostic.
332
+ *
333
+ * @param value - The values to clamp.
334
+ * @returns A function that takes bounds and returns the clamped values.
335
+ * @since 1.0.0
336
+ */
337
+ (value: ReadonlyArray<number>): (interval: Bounds) => ReadonlyArray<number>;
338
+ };
339
+ /**
340
+ * Returns an interval with the start endpoint open. Preserves the end endpoint's inclusivity.
341
+ *
342
+ * @since 2.0.0
343
+ */
344
+ export declare const toStartOpen: {
345
+ (i: Closed | OpenStart): OpenStart;
346
+ (i: OpenEnd | Open): Open;
347
+ };
348
+ /**
349
+ * Returns an interval with the start endpoint closed. Preserves the end endpoint's inclusivity.
350
+ *
351
+ * @since 2.0.0
352
+ */
353
+ export declare const toStartClosed: {
354
+ (i: Closed | OpenEnd): Closed;
355
+ (i: OpenStart | Open): OpenEnd;
356
+ };
357
+ /**
358
+ * Returns an interval with the end endpoint open. Preserves the start endpoint's inclusivity.
359
+ *
360
+ * @since 2.0.0
361
+ */
362
+ export declare const toEndOpen: {
363
+ (i: Closed | OpenEnd): OpenEnd;
364
+ (i: OpenStart | Open): Open;
365
+ };
366
+ /**
367
+ * Returns an interval with the end endpoint closed. Preserves the start endpoint's inclusivity.
368
+ *
369
+ * @since 2.0.0
370
+ */
371
+ export declare const toEndClosed: {
372
+ (i: Closed | OpenEnd): Closed;
373
+ (i: OpenStart | Open): OpenStart;
374
+ };
375
+ /**
376
+ * Returns a closed interval over the same numeric range.
377
+ *
378
+ * @since 2.0.0
379
+ */
380
+ export declare const toClosed: (i: Interval) => Closed;
381
+ /**
382
+ * Returns a fully open interval over the same numeric range.
383
+ *
384
+ * @since 2.0.0
385
+ */
386
+ export declare const toOpen: (i: Interval) => Open;
387
+ /**
388
+ * Type-narrowing predicate: refines `Interval` to `Closed`.
389
+ *
390
+ * @since 2.0.0
391
+ */
392
+ export declare const isClosed: (i: Interval) => i is Closed;
393
+ /**
394
+ * Type-narrowing predicate: refines `Interval` to `Open`.
395
+ *
396
+ * @since 2.0.0
397
+ */
398
+ export declare const isOpen: (i: Interval) => i is Open;
399
+ /**
400
+ * Type-narrowing predicate: refines `Interval` to `OpenStart`.
401
+ *
402
+ * @since 2.0.0
403
+ */
404
+ export declare const isOpenStart: (i: Interval) => i is OpenStart;
405
+ /**
406
+ * Type-narrowing predicate: refines `Interval` to `OpenEnd`.
407
+ *
408
+ * @since 2.0.0
409
+ */
410
+ export declare const isOpenEnd: (i: Interval) => i is OpenEnd;
411
+ /**
412
+ * Type-narrowing predicate: refines `Interval` to those with an open start endpoint.
413
+ *
414
+ * @since 2.0.0
415
+ */
416
+ export declare const isOpenAtStart: (i: Interval) => i is OpenStart | Open;
417
+ /**
418
+ * Type-narrowing predicate: refines `Interval` to those with an open end endpoint.
419
+ *
420
+ * @since 2.0.0
421
+ */
422
+ export declare const isOpenAtEnd: (i: Interval) => i is OpenEnd | Open;
423
+ /**
424
+ * Type-narrowing predicate: refines `Interval` to those with a closed start endpoint.
425
+ *
426
+ * @since 2.0.0
427
+ */
428
+ export declare const isClosedAtStart: (i: Interval) => i is Closed | OpenEnd;
429
+ /**
430
+ * Type-narrowing predicate: refines `Interval` to those with a closed end endpoint.
431
+ *
432
+ * @since 2.0.0
433
+ */
434
+ export declare const isClosedAtEnd: (i: Interval) => i is Closed | OpenStart;
435
+ /**
436
+ * The unit interval, `[0, 1]`.
437
+ *
438
+ * @since 1.0.0
439
+ */
440
+ export declare const unit: Closed;
441
+ /**
442
+ * The open unit interval, `(0, 1)`. The symmetric open analog of {@link unit};
443
+ * convenient for "strict interior" use cases such as filtering roots that
444
+ * must lie strictly inside the unit parameter range.
445
+ *
446
+ * @since 2.0.0
447
+ */
448
+ export declare const unitOpen: Open;
449
+ /**
450
+ * The biunit interval, `[-1, 1]`.
451
+ *
452
+ * @since 1.0.0
453
+ */
454
+ export declare const biunit: Closed;
455
+ /**
456
+ * Linearly interpolates a value within bounds.
457
+ *
458
+ * @param interval - The bounds to interpolate within.
459
+ * @param t - The interpolation factor, typically between 0 and 1.
460
+ * @returns The interpolated value.
461
+ * @since 1.0.0
462
+ */
463
+ export declare const lerp: (interval: Bounds, t: number) => number;
464
+ /**
465
+ * Creates a linear interpolation function for given bounds.
466
+ *
467
+ * @param interval - The bounds to create the interpolation function for.
468
+ * @returns A function that takes a factor `t` and returns the interpolated value.
469
+ * @since 1.0.0
470
+ */
471
+ export declare const toLerpFn: (interval: Bounds) => (t: number) => number;
472
+ /**
473
+ * Normalizes a value within bounds.
474
+ *
475
+ * @param interval - The bounds to normalize within.
476
+ * @param x - The value to normalize.
477
+ * @returns The normalized value.
478
+ * @since 1.0.0
479
+ */
480
+ export declare const normalize: (interval: Bounds, x: number) => number;
481
+ /**
482
+ * Creates a normalization function for given bounds.
483
+ *
484
+ * @param interval - The bounds to create the normalization function for.
485
+ * @returns A function that takes a value `x` and returns the normalized value.
486
+ * @since 1.0.0
487
+ */
488
+ export declare const toNormalizeFn: (interval: Bounds) => (x: number) => number;
489
+ /**
490
+ * Remaps a value from one bounds to another.
491
+ *
492
+ * @param source - The source bounds.
493
+ * @param target - The target bounds.
494
+ * @param x - The value to remap.
495
+ * @returns The remapped value.
496
+ * @since 1.0.0
497
+ */
498
+ export declare const remap: (source: Bounds, target: Bounds, x: number) => number;
499
+ /**
500
+ * Creates a remapping function for given bounds.
501
+ *
502
+ * @param source - The source bounds.
503
+ * @param target - The target bounds.
504
+ * @returns A function that takes a value `x` and returns the remapped value.
505
+ * @since 1.0.0
506
+ */
507
+ export declare const toRemapFn: (source: Bounds, target: Bounds) => (x: number) => number;
508
+ /**
509
+ * Calculates the scale and shift needed to map a source bounds to a target bounds.
510
+ *
511
+ * @param source - The source bounds.
512
+ * @param target - The target bounds.
513
+ * @returns An object containing the scale and shift values.
514
+ * @since 1.0.0
515
+ */
516
+ export declare const scaleShift: (source: Bounds, target: Bounds) => ScaleShift;
517
+ /**
518
+ * The scale and shift needed to map a source bounds to a target bounds.
519
+ *
520
+ * @since 1.0.0
521
+ */
522
+ export interface ScaleShift {
523
+ readonly scale: number;
524
+ readonly shift: number;
525
+ }
@@ -0,0 +1,167 @@
1
+ import type { Pipeable } from '../utils';
2
+ import type { Vector2 } from '../vector/vector2';
3
+ import type { Bounds, Closed, Interval } from './interval';
4
+
5
+ declare const Interval2dTypeId: unique symbol;
6
+ type Interval2dTypeId = typeof Interval2dTypeId;
7
+
8
+
9
+ /**
10
+ * An axis-aligned 2D interval — the Cartesian product of two 1D intervals.
11
+ * Used as a bounding box for curves and paths, and as a region for
12
+ * containment tests.
13
+ *
14
+ * The two type parameters carry the per-axis interval subtype so that a value
15
+ * built from closed intervals stays `Interval2d<Closed, Closed>` and a value
16
+ * with mixed openness preserves that information at the type level.
17
+ *
18
+ * All fields are readonly and immutable, and all operations create new instances.
19
+ *
20
+ * @since 2.0.0
21
+ */
22
+ export interface Interval2d<X extends Interval = Interval, Y extends Interval = Interval> extends Pipeable {
23
+ readonly [Interval2dTypeId]: Interval2dTypeId;
24
+ readonly x: X;
25
+ readonly y: Y;
26
+ }
27
+ /**
28
+ * The structural minimum: any value with `x` and `y` fields shaped like
29
+ * {@link Bounds}. Operations that don't read endpoint inclusivity (e.g.
30
+ * {@link size}) accept `Bounds2d` so the signature itself documents what the
31
+ * operation depends on. Mirrors the {@link Bounds}/{@link Interval} split in 1D.
32
+ *
33
+ * @since 2.0.0
34
+ */
35
+ export interface Bounds2d {
36
+ readonly x: Bounds;
37
+ readonly y: Bounds;
38
+ }
39
+ /**
40
+ * Checks if a value is an `Interval2d`.
41
+ *
42
+ * @param v - The value to check.
43
+ * @returns `true` if the value is an `Interval2d`, `false` otherwise.
44
+ * @since 2.0.0
45
+ */
46
+ export declare const isInterval2d: (v: unknown) => v is Interval2d;
47
+ /**
48
+ * Creates a new `Interval2d` from two intervals — one for the x axis, one
49
+ * for the y axis. Preserves both interval subtypes at the type level.
50
+ *
51
+ * @param x - The x-axis interval.
52
+ * @param y - The y-axis interval.
53
+ * @returns A new `Interval2d` instance.
54
+ * @since 2.0.0
55
+ */
56
+ export declare const make: <X extends Interval, Y extends Interval>(x: X, y: Y) => Interval2d<X, Y>;
57
+ /**
58
+ * Creates a closed `Interval2d` from two corner points. The corners can be in
59
+ * any order — each axis is built from the min and max of the coordinate.
60
+ *
61
+ * @param p0 - The first corner.
62
+ * @param p1 - The second corner.
63
+ * @returns A new `Interval2d<Closed, Closed>` enclosing both corners.
64
+ * @since 2.0.0
65
+ */
66
+ export declare const fromCorners: (p0: Vector2, p1: Vector2) => Interval2d<Closed, Closed>;
67
+ /**
68
+ * Creates the smallest closed `Interval2d` enclosing the given points. Useful
69
+ * for computing a bounding box from sampled points.
70
+ *
71
+ * @param points - One or more points to enclose.
72
+ * @returns A new `Interval2d<Closed, Closed>` enclosing all input points.
73
+ * @throws When called with zero points.
74
+ * @since 2.0.0
75
+ */
76
+ export declare const fromVectors: (...points: ReadonlyArray<Vector2>) => Interval2d<Closed, Closed>;
77
+ export declare const containsVector: {
78
+ /**
79
+ * Checks if a vector lies within the 2D interval. Per-axis endpoint
80
+ * inclusivity follows each axis interval's `kind`.
81
+ *
82
+ * @param box - The 2D interval to test against.
83
+ * @param v - The vector to test.
84
+ * @returns `true` when the vector lies within the box on both axes.
85
+ * @since 2.0.0
86
+ */
87
+ (box: Interval2d, v: Vector2): boolean;
88
+ /**
89
+ * @param v - The vector to test.
90
+ * @returns A function that takes a 2D interval and returns the containment result.
91
+ * @since 2.0.0
92
+ */
93
+ (v: Vector2): (box: Interval2d) => boolean;
94
+ };
95
+ export declare const containsInterval2d: {
96
+ /**
97
+ * Checks if `inner` is a subset of `outer`. The check is per-axis interval
98
+ * containment — for each axis, every point of the inner interval must also
99
+ * be in the outer interval, respecting endpoint inclusivity on both sides.
100
+ *
101
+ * @param outer - The enclosing 2D interval.
102
+ * @param inner - The candidate inner 2D interval.
103
+ * @returns `true` when every point of `inner` is also in `outer`.
104
+ * @since 2.0.0
105
+ */
106
+ (outer: Interval2d, inner: Interval2d): boolean;
107
+ /**
108
+ * @param inner - The candidate inner 2D interval.
109
+ * @returns A function that takes the outer 2D interval and returns the containment result.
110
+ * @since 2.0.0
111
+ */
112
+ (inner: Interval2d): (outer: Interval2d) => boolean;
113
+ };
114
+ /**
115
+ * Returns the size as a vector `(width, height)`. Accepts the broader
116
+ * {@link Bounds2d} type because size does not depend on endpoint inclusivity.
117
+ *
118
+ * @param box - The 2D interval (or bounds-shaped value) to measure.
119
+ * @returns The size as a `Vector2`.
120
+ * @since 2.0.0
121
+ */
122
+ export declare const size: (box: Bounds2d) => Vector2;
123
+ export declare const union: {
124
+ /**
125
+ * Returns the smallest 2D interval enclosing both inputs.
126
+ *
127
+ * The per-axis return kind is determined by which input's endpoint wins on
128
+ * each side, with the contributor's openness preserved (or unioned to
129
+ * "closed" when endpoints are numerically equal and either is closed at
130
+ * that point).
131
+ *
132
+ * When both inputs share the same kind on an axis, the result collapses
133
+ * back to that kind. Otherwise the axis falls back to the open
134
+ * {@link Interval} type since the runtime kind depends on the values.
135
+ *
136
+ * @param a - The first 2D interval.
137
+ * @param b - The second 2D interval.
138
+ * @returns A new `Interval2d` enclosing both inputs.
139
+ * @since 2.0.0
140
+ */
141
+ <AX extends Interval, AY extends Interval, BX extends Interval, BY extends Interval>(a: Interval2d<AX, AY>, b: Interval2d<BX, BY>): Interval2d<AX extends BX ? (BX extends AX ? AX : Interval) : Interval, AY extends BY ? (BY extends AY ? AY : Interval) : Interval>;
142
+ /**
143
+ * @param b - The second 2D interval.
144
+ * @returns A function that takes the first 2D interval and returns the union.
145
+ * @since 2.0.0
146
+ */
147
+ <BX extends Interval, BY extends Interval>(b: Interval2d<BX, BY>): <AX extends Interval, AY extends Interval>(a: Interval2d<AX, AY>) => Interval2d<AX extends BX ? (BX extends AX ? AX : Interval) : Interval, AY extends BY ? (BY extends AY ? AY : Interval) : Interval>;
148
+ };
149
+ export declare const equals: {
150
+ /**
151
+ * Checks if two `Interval2d` values are approximately equal within the
152
+ * default absolute tolerance ({@link EPSILON}). Both the numeric endpoints
153
+ * AND the per-axis kinds must match.
154
+ *
155
+ * @param a - The first 2D interval.
156
+ * @param b - The second 2D interval.
157
+ * @returns `true` when both axes are equal.
158
+ * @since 2.0.0
159
+ */
160
+ (a: Interval2d, b: Interval2d): boolean;
161
+ /**
162
+ * @param b - The second 2D interval.
163
+ * @returns A function that takes the first 2D interval and returns the comparison result.
164
+ * @since 2.0.0
165
+ */
166
+ (b: Interval2d): (a: Interval2d) => boolean;
167
+ };