curvy 2.0.0-alpha.12 → 2.0.0-alpha.13
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.
- package/dist/characteristic/index.mjs +1 -1
- package/dist/curve/index.mjs +1 -1
- package/dist/curve/rationalCubic2d.d.ts +195 -11
- package/dist/interval/index.mjs +1 -1
- package/dist/monotonicity/index.d.ts +4 -0
- package/dist/monotonicity/index.mjs +2 -0
- package/dist/monotonicity/monotonicity.d.ts +80 -0
- package/dist/path/index.mjs +5 -5
- package/dist/path/rationalCubic2d.d.ts +27 -0
- package/dist/polynomial/cubic.d.ts +2 -2
- package/dist/polynomial/index.mjs +2 -2
- package/dist/polynomial/linear.d.ts +7 -7
- package/dist/polynomial/quadratic.d.ts +2 -2
- package/dist/shared/{characteristic-Hb7F8SBw.mjs → characteristic-BkEr-rr8.mjs} +2 -2
- package/dist/shared/{characteristic-Hb7F8SBw.mjs.map → characteristic-BkEr-rr8.mjs.map} +1 -1
- package/dist/shared/{cubic-DHJrzZJN.mjs → cubic-BL6dpuHh.mjs} +18 -30
- package/dist/shared/cubic-BL6dpuHh.mjs.map +1 -0
- package/dist/shared/{interval2d-DPmvk_Qe.mjs → interval2d-AtneyI45.mjs} +1 -1
- package/dist/shared/{interval2d-DPmvk_Qe.mjs.map → interval2d-AtneyI45.mjs.map} +1 -1
- package/dist/shared/monotonicity-BdebFOtv.mjs +34 -0
- package/dist/shared/monotonicity-BdebFOtv.mjs.map +1 -0
- package/dist/shared/{quadratic-BZmfZE71.mjs → quadratic-DPrUsFCp.mjs} +9 -9
- package/dist/shared/quadratic-DPrUsFCp.mjs.map +1 -0
- package/dist/shared/{rationalCubic2d-D5g3_hTV.mjs → rationalCubic2d-CeHgpNht.mjs} +373 -79
- package/dist/shared/rationalCubic2d-CeHgpNht.mjs.map +1 -0
- package/dist/shared/{rationalCubic2d-MojACId0.mjs → rationalCubic2d-H1J2Fjyy.mjs} +25 -16
- package/dist/shared/rationalCubic2d-H1J2Fjyy.mjs.map +1 -0
- package/dist/shared/{solution-B6KY1E7M.mjs → solution-B2JdOZpe.mjs} +1 -1
- package/dist/shared/{solution-B6KY1E7M.mjs.map → solution-B2JdOZpe.mjs.map} +1 -1
- package/dist/solution/index.mjs +1 -1
- package/dist/splines/index.mjs +4 -4
- package/package.json +5 -1
- package/dist/polynomial/monotonicity.d.ts +0 -3
- package/dist/shared/cubic-DHJrzZJN.mjs.map +0 -1
- package/dist/shared/quadratic-BZmfZE71.mjs.map +0 -1
- package/dist/shared/rationalCubic2d-D5g3_hTV.mjs.map +0 -1
- package/dist/shared/rationalCubic2d-MojACId0.mjs.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as characteristic_exports } from "../shared/characteristic-
|
|
1
|
+
import { n as characteristic_exports } from "../shared/characteristic-BkEr-rr8.mjs";
|
|
2
2
|
export { characteristic_exports as Characteristic };
|
package/dist/curve/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as quadratic2d_exports, i as rationalCubic2d_exports, s as cubic2d_exports, w as linear2d_exports } from "../shared/rationalCubic2d-CeHgpNht.mjs";
|
|
2
2
|
export { cubic2d_exports as CubicCurve2d, linear2d_exports as LinearCurve2d, quadratic2d_exports as QuadraticCurve2d, rationalCubic2d_exports as RationalCubicCurve2d };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { Closed } from '../interval/interval.ts';
|
|
2
2
|
import type { Interval2d } from '../interval/interval2d.ts';
|
|
3
|
+
import type { Monotonicity } from '../monotonicity/monotonicity.ts';
|
|
3
4
|
import type { Pipeable } from '../utils.ts';
|
|
4
5
|
import type { CubicPolynomial } from '../polynomial/cubic.ts';
|
|
5
|
-
import type { Increasing, Monotonic } from '../polynomial/traits.ts';
|
|
6
|
+
import type { Decreasing, Increasing, Monotonic } from '../polynomial/traits.ts';
|
|
6
7
|
import type * as Solution from '../solution/solution.ts';
|
|
7
8
|
import type { Vector2, Weighted } from '../vector/vector2.ts';
|
|
8
9
|
import type { CubicCurve2d } from './cubic2d.ts';
|
|
@@ -191,22 +192,205 @@ export declare const subdivide: {
|
|
|
191
192
|
*/
|
|
192
193
|
(t: number): (c: RationalCubicCurve2d) => [RationalCubicCurve2d, RationalCubicCurve2d];
|
|
193
194
|
};
|
|
195
|
+
export declare const boundingBox: {
|
|
196
|
+
/**
|
|
197
|
+
* Computes a closed axis-aligned bounding box for a rational cubic curve,
|
|
198
|
+
* tight to within `tolerance` per side.
|
|
199
|
+
*
|
|
200
|
+
* Implemented as recursive subdivision: at each leaf the curve segment's
|
|
201
|
+
* loose hull AABB (cheap, always valid) is compared against the segment's
|
|
202
|
+
* endpoint AABB (which the curve provably visits). When the per-side gap
|
|
203
|
+
* between them is ≤ `tolerance`, the leaf returns its hull; otherwise the
|
|
204
|
+
* segment is split at `t = 0.5` and the procedure recurses, unioning the
|
|
205
|
+
* halves.
|
|
206
|
+
*
|
|
207
|
+
* The returned box is provably within `tolerance` of the true tight box on
|
|
208
|
+
* every side, and contains the curve since each leaf hull does. The
|
|
209
|
+
* polynomial cubic case (uniform weights) is handled by a fast path that
|
|
210
|
+
* computes the exact box from per-axis cubic extrema, with no subdivision.
|
|
211
|
+
*
|
|
212
|
+
* @param c - The rational cubic curve.
|
|
213
|
+
* @param tolerance - Maximum allowed slack per side; must be positive.
|
|
214
|
+
* @returns A closed `Interval2d` enclosing the curve, tight to within `tolerance`.
|
|
215
|
+
* @since 2.0.0
|
|
216
|
+
*/
|
|
217
|
+
(c: RationalCubicCurve2d, tolerance: number): Interval2d<Closed, Closed>;
|
|
218
|
+
/**
|
|
219
|
+
* Computes a closed axis-aligned bounding box for a rational cubic curve.
|
|
220
|
+
*
|
|
221
|
+
* @param tolerance - Maximum allowed slack per side; must be positive.
|
|
222
|
+
* @returns A function that takes a curve and returns its bounding box.
|
|
223
|
+
* @since 2.0.0
|
|
224
|
+
*/
|
|
225
|
+
(tolerance: number): (c: RationalCubicCurve2d) => Interval2d<Closed, Closed>;
|
|
226
|
+
};
|
|
227
|
+
/**
|
|
228
|
+
* Classifies the monotonicity of the curve's `x(t) = X(t)/W(t)` projection on
|
|
229
|
+
* the unit interval `[0, 1]`.
|
|
230
|
+
*
|
|
231
|
+
* Decided via Bernstein sign convexity on the derivative-numerator polynomial
|
|
232
|
+
* `q(t) = X'·W − X·W'`. Since `W² > 0` wherever the curve is well-defined,
|
|
233
|
+
* the sign of `dx/dt` equals the sign of `q`. Although `q` is a difference of
|
|
234
|
+
* degree-5 products, the leading terms cancel and `q` is in fact a quartic —
|
|
235
|
+
* its 5 Bernstein coefficients on `[0, 1]` are evaluated for uniform sign,
|
|
236
|
+
* with de Casteljau subdivision to resolve mixed-sign cases. The procedure is
|
|
237
|
+
* exact except at tangential zeros, where it conservatively reports `None`.
|
|
238
|
+
*
|
|
239
|
+
* Returning `Increasing` or `Decreasing` is the trigger for
|
|
240
|
+
* {@link asMonotonic} / {@link asIncreasing} / {@link asDecreasing}.
|
|
241
|
+
*
|
|
242
|
+
* @param c - The rational cubic curve.
|
|
243
|
+
* @returns The monotonicity of the curve's x projection on `[0, 1]`.
|
|
244
|
+
* @since 2.0.0
|
|
245
|
+
*/
|
|
246
|
+
export declare const xMonotonicity: (c: RationalCubicCurve2d) => Monotonicity;
|
|
247
|
+
/**
|
|
248
|
+
* Classifies the monotonicity of the curve's `y(t) = Y(t)/W(t)` projection on
|
|
249
|
+
* the unit interval `[0, 1]`. See {@link xMonotonicity} for the method.
|
|
250
|
+
*
|
|
251
|
+
* @param c - The rational cubic curve.
|
|
252
|
+
* @returns The monotonicity of the curve's y projection on `[0, 1]`.
|
|
253
|
+
* @since 2.0.0
|
|
254
|
+
*/
|
|
255
|
+
export declare const yMonotonicity: (c: RationalCubicCurve2d) => Monotonicity;
|
|
256
|
+
/**
|
|
257
|
+
* Type-narrowing predicate: refines the curve's x-axis trait to include
|
|
258
|
+
* `Monotonic` when `x(t)/w(t)` is strictly monotonic on `[0, 1]`. The y-axis
|
|
259
|
+
* trait is unchanged.
|
|
260
|
+
*
|
|
261
|
+
* Use this when only x-axis monotonicity is required (e.g. to make {@link solveAtX}
|
|
262
|
+
* narrow to `AtMostOne` without also asserting y-axis monotonicity).
|
|
263
|
+
*
|
|
264
|
+
* @param c - The rational cubic curve.
|
|
265
|
+
* @returns `true` when the x projection is strictly monotonic on `[0, 1]`.
|
|
266
|
+
* @since 2.0.0
|
|
267
|
+
*/
|
|
268
|
+
export declare const isMonotonicX: <XT, YT>(c: RationalCubicCurve2d<XT, YT>) => c is RationalCubicCurve2d<XT & Monotonic, YT>;
|
|
269
|
+
/**
|
|
270
|
+
* Type-narrowing predicate: refines the curve's x-axis trait to include
|
|
271
|
+
* `Increasing`.
|
|
272
|
+
*
|
|
273
|
+
* @since 2.0.0
|
|
274
|
+
*/
|
|
275
|
+
export declare const isIncreasingX: <XT, YT>(c: RationalCubicCurve2d<XT, YT>) => c is RationalCubicCurve2d<XT & Increasing, YT>;
|
|
276
|
+
/**
|
|
277
|
+
* Type-narrowing predicate: refines the curve's x-axis trait to include
|
|
278
|
+
* `Decreasing`.
|
|
279
|
+
*
|
|
280
|
+
* @since 2.0.0
|
|
281
|
+
*/
|
|
282
|
+
export declare const isDecreasingX: <XT, YT>(c: RationalCubicCurve2d<XT, YT>) => c is RationalCubicCurve2d<XT & Decreasing, YT>;
|
|
283
|
+
/**
|
|
284
|
+
* Type-narrowing predicate: refines the curve's y-axis trait to include
|
|
285
|
+
* `Monotonic`. The x-axis trait is unchanged. y analog of {@link isMonotonicX}.
|
|
286
|
+
*
|
|
287
|
+
* @since 2.0.0
|
|
288
|
+
*/
|
|
289
|
+
export declare const isMonotonicY: <XT, YT>(c: RationalCubicCurve2d<XT, YT>) => c is RationalCubicCurve2d<XT, YT & Monotonic>;
|
|
290
|
+
/**
|
|
291
|
+
* Type-narrowing predicate: refines the curve's y-axis trait to include
|
|
292
|
+
* `Increasing`.
|
|
293
|
+
*
|
|
294
|
+
* @since 2.0.0
|
|
295
|
+
*/
|
|
296
|
+
export declare const isIncreasingY: <XT, YT>(c: RationalCubicCurve2d<XT, YT>) => c is RationalCubicCurve2d<XT, YT & Increasing>;
|
|
297
|
+
/**
|
|
298
|
+
* Type-narrowing predicate: refines the curve's y-axis trait to include
|
|
299
|
+
* `Decreasing`.
|
|
300
|
+
*
|
|
301
|
+
* @since 2.0.0
|
|
302
|
+
*/
|
|
303
|
+
export declare const isDecreasingY: <XT, YT>(c: RationalCubicCurve2d<XT, YT>) => c is RationalCubicCurve2d<XT, YT & Decreasing>;
|
|
304
|
+
/**
|
|
305
|
+
* Type-narrowing predicate: refines both axes' traits to include `Monotonic`
|
|
306
|
+
* when both `x(t)/w(t)` and `y(t)/w(t)` are strictly monotonic on `[0, 1]`.
|
|
307
|
+
*
|
|
308
|
+
* The constant case is excluded — `Monotonic` is the *strict* brand.
|
|
309
|
+
*
|
|
310
|
+
* @param c - The rational cubic curve.
|
|
311
|
+
* @returns `true` when both axes are strictly monotonic on `[0, 1]`.
|
|
312
|
+
* @since 2.0.0
|
|
313
|
+
*/
|
|
314
|
+
export declare const isMonotonic: <XT, YT>(c: RationalCubicCurve2d<XT, YT>) => c is RationalCubicCurve2d<XT & Monotonic, YT & Monotonic>;
|
|
315
|
+
/**
|
|
316
|
+
* Type-narrowing predicate: refines both axes' traits to include `Increasing`
|
|
317
|
+
* when both `x(t)/w(t)` and `y(t)/w(t)` are strictly increasing on `[0, 1]`.
|
|
318
|
+
*
|
|
319
|
+
* @since 2.0.0
|
|
320
|
+
*/
|
|
321
|
+
export declare const isIncreasing: <XT, YT>(c: RationalCubicCurve2d<XT, YT>) => c is RationalCubicCurve2d<XT & Increasing, YT & Increasing>;
|
|
322
|
+
/**
|
|
323
|
+
* Type-narrowing predicate: refines both axes' traits to include `Decreasing`
|
|
324
|
+
* when both `x(t)/w(t)` and `y(t)/w(t)` are strictly decreasing on `[0, 1]`.
|
|
325
|
+
*
|
|
326
|
+
* @since 2.0.0
|
|
327
|
+
*/
|
|
328
|
+
export declare const isDecreasing: <XT, YT>(c: RationalCubicCurve2d<XT, YT>) => c is RationalCubicCurve2d<XT & Decreasing, YT & Decreasing>;
|
|
329
|
+
/**
|
|
330
|
+
* Asserts that the curve is strictly monotonic in x on `[0, 1]`, returning
|
|
331
|
+
* the same curve with the x-axis trait branded `Monotonic`.
|
|
332
|
+
*
|
|
333
|
+
* @param c - The rational cubic curve.
|
|
334
|
+
* @returns The same curve, refined with the `Monotonic` brand on x.
|
|
335
|
+
* @throws When the x projection is not strictly monotonic on `[0, 1]`.
|
|
336
|
+
* @since 2.0.0
|
|
337
|
+
*/
|
|
338
|
+
export declare const asMonotonicX: <XT, YT>(c: RationalCubicCurve2d<XT, YT>) => RationalCubicCurve2d<XT & Monotonic, YT>;
|
|
339
|
+
/**
|
|
340
|
+
* Asserts that the curve is strictly increasing in x on `[0, 1]`.
|
|
341
|
+
*
|
|
342
|
+
* @since 2.0.0
|
|
343
|
+
*/
|
|
344
|
+
export declare const asIncreasingX: <XT, YT>(c: RationalCubicCurve2d<XT, YT>) => RationalCubicCurve2d<XT & Increasing, YT>;
|
|
345
|
+
/**
|
|
346
|
+
* Asserts that the curve is strictly decreasing in x on `[0, 1]`.
|
|
347
|
+
*
|
|
348
|
+
* @since 2.0.0
|
|
349
|
+
*/
|
|
350
|
+
export declare const asDecreasingX: <XT, YT>(c: RationalCubicCurve2d<XT, YT>) => RationalCubicCurve2d<XT & Decreasing, YT>;
|
|
351
|
+
/**
|
|
352
|
+
* Asserts that the curve is strictly monotonic in y on `[0, 1]`. y analog of
|
|
353
|
+
* {@link asMonotonicX}.
|
|
354
|
+
*
|
|
355
|
+
* @since 2.0.0
|
|
356
|
+
*/
|
|
357
|
+
export declare const asMonotonicY: <XT, YT>(c: RationalCubicCurve2d<XT, YT>) => RationalCubicCurve2d<XT, YT & Monotonic>;
|
|
358
|
+
/**
|
|
359
|
+
* Asserts that the curve is strictly increasing in y on `[0, 1]`.
|
|
360
|
+
*
|
|
361
|
+
* @since 2.0.0
|
|
362
|
+
*/
|
|
363
|
+
export declare const asIncreasingY: <XT, YT>(c: RationalCubicCurve2d<XT, YT>) => RationalCubicCurve2d<XT, YT & Increasing>;
|
|
194
364
|
/**
|
|
195
|
-
*
|
|
196
|
-
* its projected control polygon. Looser than the tight extrema-based box used
|
|
197
|
-
* by `CubicCurve2d.boundingBox` — finding tight extrema of `x(t)/w(t)` and
|
|
198
|
-
* `y(t)/w(t)` requires solving degree-5 polynomials — but always valid: a
|
|
199
|
-
* positive-weight rational Bézier curve lies inside the convex hull of its
|
|
200
|
-
* projected control points, so the AABB of those points contains the curve.
|
|
365
|
+
* Asserts that the curve is strictly decreasing in y on `[0, 1]`.
|
|
201
366
|
*
|
|
202
|
-
*
|
|
203
|
-
|
|
367
|
+
* @since 2.0.0
|
|
368
|
+
*/
|
|
369
|
+
export declare const asDecreasingY: <XT, YT>(c: RationalCubicCurve2d<XT, YT>) => RationalCubicCurve2d<XT, YT & Decreasing>;
|
|
370
|
+
/**
|
|
371
|
+
* Asserts that the curve is strictly monotonic in both axes on `[0, 1]`,
|
|
372
|
+
* returning the same curve with both axes branded `Monotonic`.
|
|
204
373
|
*
|
|
205
374
|
* @param c - The rational cubic curve.
|
|
206
|
-
* @returns
|
|
375
|
+
* @returns The same curve, refined with the `Monotonic` brand on both axes.
|
|
376
|
+
* @throws When either axis is not strictly monotonic on `[0, 1]`.
|
|
377
|
+
* @since 2.0.0
|
|
378
|
+
*/
|
|
379
|
+
export declare const asMonotonic: <XT, YT>(c: RationalCubicCurve2d<XT, YT>) => RationalCubicCurve2d<XT & Monotonic, YT & Monotonic>;
|
|
380
|
+
/**
|
|
381
|
+
* Asserts that the curve is strictly increasing in both axes on `[0, 1]`,
|
|
382
|
+
* returning the same curve with both axes branded `Increasing`.
|
|
383
|
+
*
|
|
384
|
+
* @since 2.0.0
|
|
385
|
+
*/
|
|
386
|
+
export declare const asIncreasing: <XT, YT>(c: RationalCubicCurve2d<XT, YT>) => RationalCubicCurve2d<XT & Increasing, YT & Increasing>;
|
|
387
|
+
/**
|
|
388
|
+
* Asserts that the curve is strictly decreasing in both axes on `[0, 1]`,
|
|
389
|
+
* returning the same curve with both axes branded `Decreasing`.
|
|
390
|
+
*
|
|
207
391
|
* @since 2.0.0
|
|
208
392
|
*/
|
|
209
|
-
export declare const
|
|
393
|
+
export declare const asDecreasing: <XT, YT>(c: RationalCubicCurve2d<XT, YT>) => RationalCubicCurve2d<XT & Decreasing, YT & Decreasing>;
|
|
210
394
|
export declare const approximateAsCubicCurves: {
|
|
211
395
|
/**
|
|
212
396
|
* Approximates the rational cubic as a sequence of polynomial cubic curves
|
package/dist/interval/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { s as interval_exports } from "../shared/interval-Dm35Xhy4.mjs";
|
|
2
|
-
import { n as interval2d_exports } from "../shared/interval2d-
|
|
2
|
+
import { n as interval2d_exports } from "../shared/interval2d-AtneyI45.mjs";
|
|
3
3
|
export { interval_exports as Interval, interval2d_exports as Interval2d };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Classification of a function's monotonicity on an interval.
|
|
3
|
+
*
|
|
4
|
+
* Encoded as a 2-bit sign-coverage bitmask of the function's derivative:
|
|
5
|
+
* - bit 0 (`Increasing`) — derivative takes positive values
|
|
6
|
+
* - bit 1 (`Decreasing`) — derivative takes negative values
|
|
7
|
+
*
|
|
8
|
+
* The four states fall out of the encoding:
|
|
9
|
+
*
|
|
10
|
+
* | value | name | derivative on the interval |
|
|
11
|
+
* |-------|--------------|-----------------------------------|
|
|
12
|
+
* | `0` | `Constant` | ≡ 0 |
|
|
13
|
+
* | `1` | `Increasing` | ≥ 0, with at least one `> 0` |
|
|
14
|
+
* | `2` | `Decreasing` | ≤ 0, with at least one `< 0` |
|
|
15
|
+
* | `3` | `None` | crosses zero |
|
|
16
|
+
*
|
|
17
|
+
* The numeric encoding is principled, not arbitrary: the bitwise OR of two
|
|
18
|
+
* adjacent subintervals' classifications gives the classification of their
|
|
19
|
+
* union, which lets monotonicity be computed by recursive subdivision
|
|
20
|
+
* without any custom combine logic.
|
|
21
|
+
*
|
|
22
|
+
* @since 2.0.0
|
|
23
|
+
*/
|
|
24
|
+
export type Monotonicity = 0 | 1 | 2 | 3;
|
|
25
|
+
/**
|
|
26
|
+
* Subset of {@link Monotonicity} excluding the indeterminate `None` state.
|
|
27
|
+
* Returned by classifiers operating on functions whose derivative cannot
|
|
28
|
+
* change sign on the interval (e.g. linear polynomials, whose derivative is
|
|
29
|
+
* constant).
|
|
30
|
+
*
|
|
31
|
+
* @since 2.0.0
|
|
32
|
+
*/
|
|
33
|
+
export type GuaranteedMonotonicity = 0 | 1 | 2;
|
|
34
|
+
/**
|
|
35
|
+
* Derivative is identically zero on the interval. The function is constant.
|
|
36
|
+
*
|
|
37
|
+
* @since 2.0.0
|
|
38
|
+
*/
|
|
39
|
+
export declare const Constant: 0;
|
|
40
|
+
/**
|
|
41
|
+
* Derivative is non-negative on the interval with at least one strictly
|
|
42
|
+
* positive sample. The function is strictly increasing.
|
|
43
|
+
*
|
|
44
|
+
* @since 2.0.0
|
|
45
|
+
*/
|
|
46
|
+
export declare const Increasing: 1;
|
|
47
|
+
/**
|
|
48
|
+
* Derivative is non-positive on the interval with at least one strictly
|
|
49
|
+
* negative sample. The function is strictly decreasing.
|
|
50
|
+
*
|
|
51
|
+
* @since 2.0.0
|
|
52
|
+
*/
|
|
53
|
+
export declare const Decreasing: 2;
|
|
54
|
+
/**
|
|
55
|
+
* Derivative crosses zero on the interval. The function has at least one
|
|
56
|
+
* interior extremum and is not monotonic in either direction.
|
|
57
|
+
*
|
|
58
|
+
* @since 2.0.0
|
|
59
|
+
*/
|
|
60
|
+
export declare const None: 3;
|
|
61
|
+
/**
|
|
62
|
+
* Type-narrowing predicate: refines a `Monotonicity` to `Increasing |
|
|
63
|
+
* Decreasing` — the strict cases that admit a unique inverse.
|
|
64
|
+
*
|
|
65
|
+
* @param m - The monotonicity classification.
|
|
66
|
+
* @returns `true` when `m` is `Increasing` or `Decreasing`.
|
|
67
|
+
* @since 2.0.0
|
|
68
|
+
*/
|
|
69
|
+
export declare const isStrict: (m: Monotonicity) => m is 1 | 2;
|
|
70
|
+
/**
|
|
71
|
+
* Classifies the monotonicity of a function given its values at two interval
|
|
72
|
+
* endpoints, when the function is known a priori to be monotonic on the
|
|
73
|
+
* spanning interval (e.g. a linear polynomial).
|
|
74
|
+
*
|
|
75
|
+
* @param s0 - The function value at the start of the interval.
|
|
76
|
+
* @param s1 - The function value at the end of the interval.
|
|
77
|
+
* @returns The classification — `Increasing`, `Decreasing`, or `Constant`.
|
|
78
|
+
* @since 2.0.0
|
|
79
|
+
*/
|
|
80
|
+
export declare const fromComparison: (s0: number, s1: number) => GuaranteedMonotonicity;
|
package/dist/path/index.mjs
CHANGED
|
@@ -2,11 +2,11 @@ import { t as __exportAll } from "../shared/chunk-25Hzd3z8.mjs";
|
|
|
2
2
|
import { Pipeable, dual, invariant } from "../utils.mjs";
|
|
3
3
|
import { epsEquals } from "../number.mjs";
|
|
4
4
|
import { p as unit } from "../shared/interval-Dm35Xhy4.mjs";
|
|
5
|
-
import { o as none, r as isNone, s as one } from "../shared/solution-
|
|
6
|
-
import { n as isDecreasing, r as isIncreasing } from "../shared/quadratic-
|
|
7
|
-
import { a as union } from "../shared/interval2d-
|
|
8
|
-
import {
|
|
9
|
-
import { n as rationalCubic2d_exports, o as linear2d_exports, r as cubic2d_exports } from "../shared/rationalCubic2d-
|
|
5
|
+
import { o as none, r as isNone, s as one } from "../shared/solution-B2JdOZpe.mjs";
|
|
6
|
+
import { n as isDecreasing, r as isIncreasing } from "../shared/quadratic-DPrUsFCp.mjs";
|
|
7
|
+
import { a as union } from "../shared/interval2d-AtneyI45.mjs";
|
|
8
|
+
import { b as solveAtY$2, g as length$2, h as boundingBox$2, v as solve$2, y as solveAtX$2 } from "../shared/rationalCubic2d-CeHgpNht.mjs";
|
|
9
|
+
import { n as rationalCubic2d_exports, o as linear2d_exports, r as cubic2d_exports } from "../shared/rationalCubic2d-H1J2Fjyy.mjs";
|
|
10
10
|
//#region src/path/quadratic2d.internal.ts
|
|
11
11
|
const QuadraticPath2dTypeId = Symbol("curvy/path/quadratic2d");
|
|
12
12
|
/** @internal */
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { RationalCubicCurve2d } from '../curve/rationalCubic2d.ts';
|
|
2
|
+
import type { Closed } from '../interval/interval.ts';
|
|
3
|
+
import type { Interval2d } from '../interval/interval2d.ts';
|
|
2
4
|
import type { Pipeable } from '../utils.ts';
|
|
3
5
|
import type { Vector2 } from '../vector/vector2.ts';
|
|
4
6
|
import type { CubicPath2d } from './cubic2d.ts';
|
|
@@ -88,6 +90,31 @@ export declare const solve: {
|
|
|
88
90
|
*/
|
|
89
91
|
(u: number): (p: RationalCubicPath2d) => Vector2;
|
|
90
92
|
};
|
|
93
|
+
export declare const boundingBox: {
|
|
94
|
+
/**
|
|
95
|
+
* Computes a closed axis-aligned bounding box for a rational cubic path,
|
|
96
|
+
* tight to within `tolerance` per side.
|
|
97
|
+
*
|
|
98
|
+
* Per-segment delegates to `RationalCubicCurve2d.boundingBox(c, tolerance)`
|
|
99
|
+
* — recursive subdivision producing a hull-AABB union tight to within
|
|
100
|
+
* `tolerance` per side. The path box is the union of segment boxes; since
|
|
101
|
+
* each segment box has slack ≤ tolerance per side, so does the union.
|
|
102
|
+
*
|
|
103
|
+
* @param p - The rational cubic path.
|
|
104
|
+
* @param tolerance - Maximum allowed slack per side; must be positive.
|
|
105
|
+
* @returns A closed `Interval2d` enclosing the path, tight to within `tolerance`.
|
|
106
|
+
* @since 2.0.0
|
|
107
|
+
*/
|
|
108
|
+
(p: RationalCubicPath2d, tolerance: number): Interval2d<Closed, Closed>;
|
|
109
|
+
/**
|
|
110
|
+
* Computes a closed axis-aligned bounding box for a rational cubic path.
|
|
111
|
+
*
|
|
112
|
+
* @param tolerance - Maximum allowed slack per side; must be positive.
|
|
113
|
+
* @returns A function that takes a path and returns its bounding box.
|
|
114
|
+
* @since 2.0.0
|
|
115
|
+
*/
|
|
116
|
+
(tolerance: number): (p: RationalCubicPath2d) => Interval2d<Closed, Closed>;
|
|
117
|
+
};
|
|
91
118
|
export declare const approximateAsCubicPath: {
|
|
92
119
|
/**
|
|
93
120
|
* Approximates the rational cubic path as a `CubicPath2d` via per-segment
|
|
@@ -4,7 +4,7 @@ import type * as Solution from '../solution/solution.ts';
|
|
|
4
4
|
import type { Vector2 } from '../vector/vector2.ts';
|
|
5
5
|
import type { Vector4 } from '../vector/vector4.ts';
|
|
6
6
|
import type { CubicPolynomialTypeId } from './cubic.internal.circular.ts';
|
|
7
|
-
import type { Monotonicity } from '
|
|
7
|
+
import type { Monotonicity } from '../monotonicity/monotonicity.ts';
|
|
8
8
|
import type { QuadraticPolynomial } from './quadratic.ts';
|
|
9
9
|
import type { Decreasing, Increasing, Monotonic, PolynomialTraits } from './traits.ts';
|
|
10
10
|
export type { Monotonic, Increasing, Decreasing } from './traits.ts';
|
|
@@ -252,7 +252,7 @@ export declare const monotonicity: {
|
|
|
252
252
|
*
|
|
253
253
|
* @param p - The cubic polynomial to check.
|
|
254
254
|
* @param i - Optional interval over which to check monotonicity.
|
|
255
|
-
* @returns `true` when monotonicity is `
|
|
255
|
+
* @returns `true` when monotonicity is `Increasing` or `Decreasing`.
|
|
256
256
|
* @since 2.0.0
|
|
257
257
|
*/
|
|
258
258
|
export declare const isMonotonic: {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as cubic_exports } from "../shared/cubic-
|
|
2
|
-
import { o as quadratic_exports, p as linear_exports } from "../shared/quadratic-
|
|
1
|
+
import { t as cubic_exports } from "../shared/cubic-BL6dpuHh.mjs";
|
|
2
|
+
import { o as quadratic_exports, p as linear_exports } from "../shared/quadratic-DPrUsFCp.mjs";
|
|
3
3
|
export { cubic_exports as CubicPolynomial, linear_exports as LinearPolynomial, quadratic_exports as QuadraticPolynomial };
|
|
@@ -3,7 +3,7 @@ import type { Pipeable } from '../utils.ts';
|
|
|
3
3
|
import type * as Solution from '../solution/solution.ts';
|
|
4
4
|
import type { Vector2 } from '../vector/vector2.ts';
|
|
5
5
|
import type { LinearPolynomialTypeId } from './linear.internal.ts';
|
|
6
|
-
import type { GuaranteedMonotonicity } from '
|
|
6
|
+
import type { GuaranteedMonotonicity } from '../monotonicity/monotonicity.ts';
|
|
7
7
|
import type { QuadraticPolynomial } from './quadratic.ts';
|
|
8
8
|
import type { Decreasing, Increasing, Monotonic, PolynomialTraits } from './traits.ts';
|
|
9
9
|
export type { Monotonic, Increasing, Decreasing } from './traits.ts';
|
|
@@ -176,7 +176,7 @@ export declare const monotonicity: (p: LinearPolynomial) => GuaranteedMonotonici
|
|
|
176
176
|
* `LinearPolynomial<T & Monotonic>` when the polynomial is strictly monotonic.
|
|
177
177
|
*
|
|
178
178
|
* @param p - The linear polynomial to check.
|
|
179
|
-
* @returns `true` when `monotonicity(p)` is `
|
|
179
|
+
* @returns `true` when `monotonicity(p)` is `Increasing` or `Decreasing`.
|
|
180
180
|
* @since 2.0.0
|
|
181
181
|
*/
|
|
182
182
|
export declare const isMonotonic: <T>(p: LinearPolynomial<T>) => p is LinearPolynomial<T & Monotonic>;
|
|
@@ -184,7 +184,7 @@ export declare const isMonotonic: <T>(p: LinearPolynomial<T>) => p is LinearPoly
|
|
|
184
184
|
* Type-narrowing predicate: refines to `LinearPolynomial<T & Increasing>`.
|
|
185
185
|
*
|
|
186
186
|
* @param p - The linear polynomial to check.
|
|
187
|
-
* @returns `true` when `monotonicity(p)` is `
|
|
187
|
+
* @returns `true` when `monotonicity(p)` is `Increasing`.
|
|
188
188
|
* @since 2.0.0
|
|
189
189
|
*/
|
|
190
190
|
export declare const isIncreasing: <T>(p: LinearPolynomial<T>) => p is LinearPolynomial<T & Increasing>;
|
|
@@ -192,7 +192,7 @@ export declare const isIncreasing: <T>(p: LinearPolynomial<T>) => p is LinearPol
|
|
|
192
192
|
* Type-narrowing predicate: refines to `LinearPolynomial<T & Decreasing>`.
|
|
193
193
|
*
|
|
194
194
|
* @param p - The linear polynomial to check.
|
|
195
|
-
* @returns `true` when `monotonicity(p)` is `
|
|
195
|
+
* @returns `true` when `monotonicity(p)` is `Decreasing`.
|
|
196
196
|
* @since 2.0.0
|
|
197
197
|
*/
|
|
198
198
|
export declare const isDecreasing: <T>(p: LinearPolynomial<T>) => p is LinearPolynomial<T & Decreasing>;
|
|
@@ -201,7 +201,7 @@ export declare const isDecreasing: <T>(p: LinearPolynomial<T>) => p is LinearPol
|
|
|
201
201
|
*
|
|
202
202
|
* @param p - The linear polynomial to assert against.
|
|
203
203
|
* @returns The same polynomial, typed with the `Monotonic` brand.
|
|
204
|
-
* @throws When `monotonicity(p)` is `
|
|
204
|
+
* @throws When `monotonicity(p)` is `Constant`.
|
|
205
205
|
* @since 2.0.0
|
|
206
206
|
*/
|
|
207
207
|
export declare const asMonotonic: <T>(p: LinearPolynomial<T>) => LinearPolynomial<T & Monotonic>;
|
|
@@ -210,7 +210,7 @@ export declare const asMonotonic: <T>(p: LinearPolynomial<T>) => LinearPolynomia
|
|
|
210
210
|
*
|
|
211
211
|
* @param p - The linear polynomial to assert against.
|
|
212
212
|
* @returns The same polynomial, typed with the `Increasing` brand.
|
|
213
|
-
* @throws When `monotonicity(p)` is not `
|
|
213
|
+
* @throws When `monotonicity(p)` is not `Increasing`.
|
|
214
214
|
* @since 2.0.0
|
|
215
215
|
*/
|
|
216
216
|
export declare const asIncreasing: <T>(p: LinearPolynomial<T>) => LinearPolynomial<T & Increasing>;
|
|
@@ -219,7 +219,7 @@ export declare const asIncreasing: <T>(p: LinearPolynomial<T>) => LinearPolynomi
|
|
|
219
219
|
*
|
|
220
220
|
* @param p - The linear polynomial to assert against.
|
|
221
221
|
* @returns The same polynomial, typed with the `Decreasing` brand.
|
|
222
|
-
* @throws When `monotonicity(p)` is not `
|
|
222
|
+
* @throws When `monotonicity(p)` is not `Decreasing`.
|
|
223
223
|
* @since 2.0.0
|
|
224
224
|
*/
|
|
225
225
|
export declare const asDecreasing: <T>(p: LinearPolynomial<T>) => LinearPolynomial<T & Decreasing>;
|
|
@@ -5,7 +5,7 @@ import type { Vector2 } from '../vector/vector2.ts';
|
|
|
5
5
|
import type { Vector3 } from '../vector/vector3.ts';
|
|
6
6
|
import type { CubicPolynomial } from './cubic.ts';
|
|
7
7
|
import type { LinearPolynomial } from './linear.ts';
|
|
8
|
-
import type { Monotonicity } from '
|
|
8
|
+
import type { Monotonicity } from '../monotonicity/monotonicity.ts';
|
|
9
9
|
import type { QuadraticPolynomialTypeId } from './quadratic.internal.circular.ts';
|
|
10
10
|
import type { Decreasing, Increasing, Monotonic, PolynomialTraits } from './traits.ts';
|
|
11
11
|
export type { Monotonic, Increasing, Decreasing } from './traits.ts';
|
|
@@ -227,7 +227,7 @@ export declare const monotonicity: {
|
|
|
227
227
|
*
|
|
228
228
|
* @param p - The quadratic polynomial to check.
|
|
229
229
|
* @param i - Optional interval over which to check monotonicity.
|
|
230
|
-
* @returns `true` when monotonicity is `
|
|
230
|
+
* @returns `true` when monotonicity is `Increasing` or `Decreasing`.
|
|
231
231
|
* @since 2.0.0
|
|
232
232
|
*/
|
|
233
233
|
export declare const isMonotonic: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as __exportAll } from "./chunk-25Hzd3z8.mjs";
|
|
2
2
|
import { roundDown } from "../number.mjs";
|
|
3
3
|
import { a as vectorProductLeft, n as make } from "./matrix4x4-BWmf4lZM.mjs";
|
|
4
|
-
import { r as fromVector } from "./cubic-
|
|
4
|
+
import { r as fromVector } from "./cubic-BL6dpuHh.mjs";
|
|
5
5
|
//#region src/characteristic/characteristic.ts
|
|
6
6
|
var characteristic_exports = /* @__PURE__ */ __exportAll({
|
|
7
7
|
apply: () => apply,
|
|
@@ -101,4 +101,4 @@ const apply = (matrix, ...channels) => {
|
|
|
101
101
|
//#endregion
|
|
102
102
|
export { cubicHermite as a, cubicBezier as i, characteristic_exports as n, cubicBasisSpline as r, apply as t };
|
|
103
103
|
|
|
104
|
-
//# sourceMappingURL=characteristic-
|
|
104
|
+
//# sourceMappingURL=characteristic-BkEr-rr8.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"characteristic-
|
|
1
|
+
{"version":3,"file":"characteristic-BkEr-rr8.mjs","names":["Matrix4x4.make","CubicPolynomial.fromVector","Matrix4x4.vectorProductLeft"],"sources":["../../src/characteristic/characteristic.ts"],"sourcesContent":["import * as Matrix4x4 from '../matrix/matrix4x4.ts'\nimport * as CubicPolynomial from '../polynomial/cubic.ts'\nimport { roundDown } from '../number.ts'\nimport type * as Vector4 from '../vector/vector4.ts'\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.0.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.0.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.0.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.0.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.0.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.0.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"}
|