curvy 2.0.0-alpha.13 → 2.0.0-alpha.14
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/cubic2d.d.ts +102 -3
- package/dist/curve/curve2d.d.ts +81 -0
- package/dist/curve/index.mjs +1 -1
- package/dist/curve/linear2d.d.ts +122 -3
- package/dist/curve/quadratic2d.d.ts +103 -3
- package/dist/curve/rationalCubic2d.d.ts +100 -38
- package/dist/interval/index.mjs +2 -2
- package/dist/matrix/index.mjs +47 -1
- package/dist/matrix/index.mjs.map +1 -1
- package/dist/matrix/matrix3x3.d.ts +87 -1
- package/dist/matrix/matrix4x4.d.ts +57 -6
- package/dist/matrix/traits.d.ts +34 -0
- package/dist/monotonicity/index.mjs +1 -1
- package/dist/monotonicity/monotonicity.d.ts +25 -0
- package/dist/number.d.ts +53 -0
- package/dist/number.mjs +56 -1
- package/dist/number.mjs.map +1 -1
- package/dist/path/cubic2d.d.ts +22 -0
- package/dist/path/index.mjs +25 -149
- package/dist/path/index.mjs.map +1 -1
- package/dist/path/linear2d.d.ts +24 -0
- package/dist/path/path2d.d.ts +54 -0
- package/dist/path/quadratic2d.d.ts +22 -0
- package/dist/path/rationalCubic2d.d.ts +21 -0
- package/dist/polynomial/index.mjs +2 -2
- package/dist/shared/affine2d-Dvna84gc.mjs +332 -0
- package/dist/shared/affine2d-Dvna84gc.mjs.map +1 -0
- package/dist/shared/{characteristic-BkEr-rr8.mjs → characteristic--7nC4Q_a.mjs} +4 -5
- package/dist/shared/characteristic--7nC4Q_a.mjs.map +1 -0
- package/dist/shared/{cubic-BL6dpuHh.mjs → cubic-BiGuAnZ0.mjs} +56 -27
- package/dist/shared/cubic-BiGuAnZ0.mjs.map +1 -0
- package/dist/shared/{interval-Dm35Xhy4.mjs → interval-Dcqpo73t.mjs} +5 -5
- package/dist/shared/interval-Dcqpo73t.mjs.map +1 -0
- package/dist/shared/{interval2d-AtneyI45.mjs → interval2d-C2Pk66-2.mjs} +3 -3
- package/dist/shared/{interval2d-AtneyI45.mjs.map → interval2d-C2Pk66-2.mjs.map} +1 -1
- package/dist/shared/matrix3x3.internal-Cod-r7H3.mjs +233 -0
- package/dist/shared/matrix3x3.internal-Cod-r7H3.mjs.map +1 -0
- package/dist/shared/{matrix4x4-BWmf4lZM.mjs → matrix4x4-BrqgYZCD.mjs} +72 -223
- package/dist/shared/matrix4x4-BrqgYZCD.mjs.map +1 -0
- package/dist/shared/monotonicity-DNxBoC7F.mjs +64 -0
- package/dist/shared/monotonicity-DNxBoC7F.mjs.map +1 -0
- package/dist/shared/{quadratic-DPrUsFCp.mjs → quadratic-BmMqkvxx.mjs} +2 -2
- package/dist/shared/{quadratic-DPrUsFCp.mjs.map → quadratic-BmMqkvxx.mjs.map} +1 -1
- package/dist/shared/{rationalCubic2d-CeHgpNht.mjs → rationalCubic2d-CZSwwKtS.mjs} +591 -125
- package/dist/shared/rationalCubic2d-CZSwwKtS.mjs.map +1 -0
- package/dist/shared/{rationalCubic2d-H1J2Fjyy.mjs → rationalCubic2d-bveuGqBZ.mjs} +282 -326
- package/dist/shared/rationalCubic2d-bveuGqBZ.mjs.map +1 -0
- package/dist/shared/{solution-B2JdOZpe.mjs → solution-BW0BBMXI.mjs} +22 -6
- package/dist/shared/solution-BW0BBMXI.mjs.map +1 -0
- package/dist/shared/{vector2-CSkaMXvp.mjs → vector2-DuA3EmfL.mjs} +5 -3
- package/dist/shared/vector2-DuA3EmfL.mjs.map +1 -0
- package/dist/shared/{vector2.internal-DP1nTBdS.mjs → vector2.internal-rPnW0RCx.mjs} +10 -5
- package/dist/shared/vector2.internal-rPnW0RCx.mjs.map +1 -0
- package/dist/shared/{vector3-CR2LPV03.mjs → vector3-oxtggkDp.mjs} +2 -2
- package/dist/shared/{vector3-CR2LPV03.mjs.map → vector3-oxtggkDp.mjs.map} +1 -1
- package/dist/shared/vector3.internal-CfWHl9SG.mjs +135 -0
- package/dist/shared/vector3.internal-CfWHl9SG.mjs.map +1 -0
- package/dist/shared/{vector4-PO_7EYd-.mjs → vector4-DGHuCvTV.mjs} +2 -2
- package/dist/shared/{vector4-PO_7EYd-.mjs.map → vector4-DGHuCvTV.mjs.map} +1 -1
- package/dist/shared/vector4.internal-DH5DzNYO.mjs +116 -0
- package/dist/shared/vector4.internal-DH5DzNYO.mjs.map +1 -0
- package/dist/solution/index.mjs +1 -1
- package/dist/solution/solution.d.ts +16 -0
- package/dist/splines/basis2d.d.ts +64 -0
- package/dist/splines/bezier2d.d.ts +72 -0
- package/dist/splines/cardinal2d.d.ts +78 -0
- package/dist/splines/hermite2d.d.ts +76 -0
- package/dist/splines/index.mjs +109 -15
- package/dist/splines/index.mjs.map +1 -1
- package/dist/splines/linear2d.d.ts +65 -0
- package/dist/splines/rationalBezier2d.d.ts +76 -0
- package/dist/transform/affine2d.d.ts +339 -0
- package/dist/transform/affine2d.internal.d.ts +2 -0
- package/dist/transform/index.d.ts +3 -0
- package/dist/transform/index.mjs +2 -0
- package/dist/transform/traits.d.ts +19 -0
- package/dist/vector/index.mjs +3 -3
- package/dist/vector/vector2.d.ts +49 -0
- package/package.json +5 -1
- package/dist/shared/characteristic-BkEr-rr8.mjs.map +0 -1
- package/dist/shared/cubic-BL6dpuHh.mjs.map +0 -1
- package/dist/shared/interval-Dm35Xhy4.mjs.map +0 -1
- package/dist/shared/matrix4x4-BWmf4lZM.mjs.map +0 -1
- package/dist/shared/monotonicity-BdebFOtv.mjs +0 -34
- package/dist/shared/monotonicity-BdebFOtv.mjs.map +0 -1
- package/dist/shared/rationalCubic2d-CeHgpNht.mjs.map +0 -1
- package/dist/shared/rationalCubic2d-H1J2Fjyy.mjs.map +0 -1
- package/dist/shared/solution-B2JdOZpe.mjs.map +0 -1
- package/dist/shared/vector2-CSkaMXvp.mjs.map +0 -1
- package/dist/shared/vector2.internal-DP1nTBdS.mjs.map +0 -1
- package/dist/shared/vector4.internal-BJ1QN2Ck.mjs +0 -246
- package/dist/shared/vector4.internal-BJ1QN2Ck.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--7nC4Q_a.mjs";
|
|
2
2
|
export { characteristic_exports as Characteristic };
|
package/dist/curve/cubic2d.d.ts
CHANGED
|
@@ -5,8 +5,10 @@ import type { Pipeable } from '../utils.ts';
|
|
|
5
5
|
import type { CubicPolynomial } from '../polynomial/cubic.ts';
|
|
6
6
|
import type { Decreasing, Increasing, Monotonic } from '../polynomial/traits.ts';
|
|
7
7
|
import type * as Solution from '../solution/solution.ts';
|
|
8
|
+
import type { Affine2d } from '../transform/affine2d.ts';
|
|
8
9
|
import type { Vector2 } from '../vector/vector2.ts';
|
|
9
10
|
import type { CubicCurve2dTypeId } from './cubic2d.internal.ts';
|
|
11
|
+
import type { Curve2dOps } from './curve2d.ts';
|
|
10
12
|
export type { Monotonic, Increasing, Decreasing } from '../polynomial/traits.ts';
|
|
11
13
|
/**
|
|
12
14
|
* A cubic curve in 2D space.
|
|
@@ -193,13 +195,79 @@ export declare const curvature: {
|
|
|
193
195
|
* @since 2.0.0
|
|
194
196
|
*/
|
|
195
197
|
export declare const boundingBox: (c: CubicCurve2d) => Interval2d<Closed, Closed>;
|
|
198
|
+
/**
|
|
199
|
+
* Evaluates the curve at `t = 0` in closed form — `(c.x.c0, c.y.c0)`.
|
|
200
|
+
*
|
|
201
|
+
* @param c - The cubic curve.
|
|
202
|
+
* @returns The point at the start of the curve's parameter domain.
|
|
203
|
+
* @since 2.0.0
|
|
204
|
+
*/
|
|
205
|
+
export declare const startPoint: (c: CubicCurve2d) => Vector2;
|
|
206
|
+
/**
|
|
207
|
+
* Evaluates the curve at `t = 1` in closed form — the sum of the per-axis
|
|
208
|
+
* monomial coefficients.
|
|
209
|
+
*
|
|
210
|
+
* @param c - The cubic curve.
|
|
211
|
+
* @returns The point at the end of the curve's parameter domain.
|
|
212
|
+
* @since 2.0.0
|
|
213
|
+
*/
|
|
214
|
+
export declare const endPoint: (c: CubicCurve2d) => Vector2;
|
|
215
|
+
/**
|
|
216
|
+
* The tight `[min, max]` range of x over the curve's parameter domain `[0, 1]`,
|
|
217
|
+
* accounting for up to two interior extrema.
|
|
218
|
+
*
|
|
219
|
+
* @param c - The cubic curve.
|
|
220
|
+
* @returns The closed range of x over `[0, 1]`.
|
|
221
|
+
* @since 2.0.0
|
|
222
|
+
*/
|
|
223
|
+
export declare const xRange: (c: CubicCurve2d) => Closed;
|
|
224
|
+
/**
|
|
225
|
+
* The tight `[min, max]` range of y over the curve's parameter domain `[0, 1]`,
|
|
226
|
+
* accounting for up to two interior extrema.
|
|
227
|
+
*
|
|
228
|
+
* @param c - The cubic curve.
|
|
229
|
+
* @returns The closed range of y over `[0, 1]`.
|
|
230
|
+
* @since 2.0.0
|
|
231
|
+
*/
|
|
232
|
+
export declare const yRange: (c: CubicCurve2d) => Closed;
|
|
233
|
+
/**
|
|
234
|
+
* Renders the curve as a single SVG path-data drawing command — for a cubic
|
|
235
|
+
* curve, `C ctrl1X,ctrl1Y ctrl2X,ctrl2Y endX,endY`. Bernstein control points
|
|
236
|
+
* are recovered from the monomial coefficients in closed form. Does not
|
|
237
|
+
* include a leading `M`.
|
|
238
|
+
*
|
|
239
|
+
* @param c - The cubic curve.
|
|
240
|
+
* @returns The SVG drawing command for this segment, without a leading `M`.
|
|
241
|
+
* @since 2.0.0
|
|
242
|
+
*/
|
|
243
|
+
export declare const toPathDataSegment: (c: CubicCurve2d) => string;
|
|
244
|
+
/**
|
|
245
|
+
* Type-narrowing predicate: refines the curve's x-axis trait to include
|
|
246
|
+
* `Monotonic` when the x polynomial is strictly monotonic on the unit
|
|
247
|
+
* interval `[0, 1]`. The y-axis trait is unchanged.
|
|
248
|
+
*
|
|
249
|
+
* @since 2.0.0
|
|
250
|
+
*/
|
|
251
|
+
export declare const isMonotonicX: <XT, YT>(c: CubicCurve2d<XT, YT>) => c is CubicCurve2d<XT & Monotonic, YT>;
|
|
252
|
+
/** @since 2.0.0 */
|
|
253
|
+
export declare const isIncreasingX: <XT, YT>(c: CubicCurve2d<XT, YT>) => c is CubicCurve2d<XT & Increasing, YT>;
|
|
254
|
+
/** @since 2.0.0 */
|
|
255
|
+
export declare const isDecreasingX: <XT, YT>(c: CubicCurve2d<XT, YT>) => c is CubicCurve2d<XT & Decreasing, YT>;
|
|
256
|
+
/**
|
|
257
|
+
* Type-narrowing predicate: refines the curve's y-axis trait to include
|
|
258
|
+
* `Monotonic`. The x-axis trait is unchanged.
|
|
259
|
+
*
|
|
260
|
+
* @since 2.0.0
|
|
261
|
+
*/
|
|
262
|
+
export declare const isMonotonicY: <XT, YT>(c: CubicCurve2d<XT, YT>) => c is CubicCurve2d<XT, YT & Monotonic>;
|
|
263
|
+
/** @since 2.0.0 */
|
|
264
|
+
export declare const isIncreasingY: <XT, YT>(c: CubicCurve2d<XT, YT>) => c is CubicCurve2d<XT, YT & Increasing>;
|
|
265
|
+
/** @since 2.0.0 */
|
|
266
|
+
export declare const isDecreasingY: <XT, YT>(c: CubicCurve2d<XT, YT>) => c is CubicCurve2d<XT, YT & Decreasing>;
|
|
196
267
|
/**
|
|
197
268
|
* Type-narrowing predicate: refines both axes' traits to include `Monotonic`
|
|
198
269
|
* when both x and y polynomials are monotonic over the unit interval `[0, 1]`.
|
|
199
270
|
*
|
|
200
|
-
* For checking only one axis, call the polynomial-level refiner directly:
|
|
201
|
-
* `CubicPolynomial.isMonotonic(curve.x, Interval.unit)`.
|
|
202
|
-
*
|
|
203
271
|
* @since 2.0.0
|
|
204
272
|
*/
|
|
205
273
|
export declare const isMonotonic: <XT, YT>(c: CubicCurve2d<XT, YT>) => c is CubicCurve2d<XT & Monotonic, YT & Monotonic>;
|
|
@@ -213,3 +281,34 @@ export declare const asMonotonic: <XT, YT>(c: CubicCurve2d<XT, YT>) => CubicCurv
|
|
|
213
281
|
export declare const asIncreasing: <XT, YT>(c: CubicCurve2d<XT, YT>) => CubicCurve2d<XT & Increasing, YT & Increasing>;
|
|
214
282
|
/** @since 2.0.0 */
|
|
215
283
|
export declare const asDecreasing: <XT, YT>(c: CubicCurve2d<XT, YT>) => CubicCurve2d<XT & Decreasing, YT & Decreasing>;
|
|
284
|
+
export declare const transform: {
|
|
285
|
+
/**
|
|
286
|
+
* Applies an `Affine2d` transform to a `CubicCurve2d`, returning a new
|
|
287
|
+
* curve whose image is the affine image of the original. Internally the
|
|
288
|
+
* transformation works directly on monomial coefficients — `c0` receives
|
|
289
|
+
* the full affine, `c1`/`c2`/`c3` receive only the linear part.
|
|
290
|
+
*
|
|
291
|
+
* @param c - The cubic curve.
|
|
292
|
+
* @param a - The affine transform.
|
|
293
|
+
* @returns The transformed cubic curve.
|
|
294
|
+
* @since 2.0.0
|
|
295
|
+
*/
|
|
296
|
+
(c: CubicCurve2d, a: Affine2d): CubicCurve2d;
|
|
297
|
+
/**
|
|
298
|
+
* Applies an `Affine2d` transform to a `CubicCurve2d`.
|
|
299
|
+
*
|
|
300
|
+
* @param a - The affine transform.
|
|
301
|
+
* @returns A function that takes a `CubicCurve2d` and returns the transformed curve.
|
|
302
|
+
* @since 2.0.0
|
|
303
|
+
*/
|
|
304
|
+
(a: Affine2d): (c: CubicCurve2d) => CubicCurve2d;
|
|
305
|
+
};
|
|
306
|
+
/**
|
|
307
|
+
* The {@link Curve2dOps} bundle for `CubicCurve2d`. Used by `CubicPath2d`
|
|
308
|
+
* to wire up the path-level operation surface. The `solveAtX` / `solveAtY`
|
|
309
|
+
* entries narrow the curve's potentially-3-element result to `AtMostOne` —
|
|
310
|
+
* path callers enforce that via the path's `MonotonicX`/`MonotonicY` brand.
|
|
311
|
+
*
|
|
312
|
+
* @since 2.0.0
|
|
313
|
+
*/
|
|
314
|
+
export declare const Ops: Curve2dOps<CubicCurve2d>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { Closed, Interval } from '../interval/interval.ts';
|
|
2
|
+
import type { Interval2d } from '../interval/interval2d.ts';
|
|
3
|
+
import type * as Solution from '../solution/solution.ts';
|
|
4
|
+
import type { Affine2d } from '../transform/affine2d.ts';
|
|
5
|
+
import type { Vector2 } from '../vector/vector2.ts';
|
|
6
|
+
/**
|
|
7
|
+
* The minimal operation bundle a curve module must provide for the generic
|
|
8
|
+
* `Path2d` to be built over it. Each polynomial curve module
|
|
9
|
+
* (`LinearCurve2d`, `QuadraticCurve2d`, `CubicCurve2d`) exports an `Ops`
|
|
10
|
+
* instance which the corresponding path module passes to
|
|
11
|
+
* `Path2d.make(ops)` to derive its operation surface.
|
|
12
|
+
*
|
|
13
|
+
* The interface is intentionally small — anything that isn't shared
|
|
14
|
+
* structurally across curve degrees stays on the per-degree module.
|
|
15
|
+
*
|
|
16
|
+
* @since 2.0.0
|
|
17
|
+
*/
|
|
18
|
+
export interface Curve2dOps<C> {
|
|
19
|
+
/**
|
|
20
|
+
* Evaluate the curve at parameter `t ∈ [0, 1]`.
|
|
21
|
+
*/
|
|
22
|
+
solve(c: C, t: number): Vector2;
|
|
23
|
+
/**
|
|
24
|
+
* Closed-form value at `t = 0`.
|
|
25
|
+
*/
|
|
26
|
+
startPoint(c: C): Vector2;
|
|
27
|
+
/**
|
|
28
|
+
* Closed-form value at `t = 1`.
|
|
29
|
+
*/
|
|
30
|
+
endPoint(c: C): Vector2;
|
|
31
|
+
/**
|
|
32
|
+
* Arc length over an interval of the curve's domain.
|
|
33
|
+
*/
|
|
34
|
+
length(c: C, interval: Interval): number;
|
|
35
|
+
/**
|
|
36
|
+
* Axis-aligned bounding box over the unit interval `[0, 1]`.
|
|
37
|
+
*/
|
|
38
|
+
boundingBox(c: C): Interval2d<Closed, Closed>;
|
|
39
|
+
/**
|
|
40
|
+
* Inverse solve for x. Path-level callers enforce single-valuedness via
|
|
41
|
+
* the path's `MonotonicX` brand, so the result is narrowed to `AtMostOne`.
|
|
42
|
+
*/
|
|
43
|
+
solveAtX(c: C, x: number): Solution.AtMostOne<number>;
|
|
44
|
+
/**
|
|
45
|
+
* y-axis analog of {@link solveAtX}.
|
|
46
|
+
*/
|
|
47
|
+
solveAtY(c: C, y: number): Solution.AtMostOne<number>;
|
|
48
|
+
/**
|
|
49
|
+
* SVG path-data drawing command for one segment (`L …`, `Q …`, `C …`),
|
|
50
|
+
* without a leading `M`. Move-insertion is decided by the path-level
|
|
51
|
+
* `toPathData` based on continuity with the previous segment.
|
|
52
|
+
*/
|
|
53
|
+
toPathDataSegment(c: C): string;
|
|
54
|
+
/**
|
|
55
|
+
* Whether the curve's x is strictly increasing on `[0, 1]`.
|
|
56
|
+
*/
|
|
57
|
+
isIncreasingX(c: C): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Whether the curve's x is strictly decreasing on `[0, 1]`.
|
|
60
|
+
*/
|
|
61
|
+
isDecreasingX(c: C): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Whether the curve's y is strictly increasing on `[0, 1]`.
|
|
64
|
+
*/
|
|
65
|
+
isIncreasingY(c: C): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Whether the curve's y is strictly decreasing on `[0, 1]`.
|
|
68
|
+
*/
|
|
69
|
+
isDecreasingY(c: C): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Apply an affine transform to the curve, returning a new curve whose
|
|
72
|
+
* geometric image is the affine image of the original.
|
|
73
|
+
*
|
|
74
|
+
* For non-rational coefficient-form curves this is per-coefficient: the
|
|
75
|
+
* constant coefficient receives the full affine, and all higher-degree
|
|
76
|
+
* coefficients receive only the linear part. For rational curves the
|
|
77
|
+
* translation is folded into the numerator polynomials weighted by the
|
|
78
|
+
* denominator. Path-level callers route through this op per curve.
|
|
79
|
+
*/
|
|
80
|
+
transform(c: C, a: Affine2d): C;
|
|
81
|
+
}
|
package/dist/curve/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as cubic2d_exports, h as quadratic2d_exports, i as rationalCubic2d_exports, y as linear2d_exports } from "../shared/rationalCubic2d-CZSwwKtS.mjs";
|
|
2
2
|
export { cubic2d_exports as CubicCurve2d, linear2d_exports as LinearCurve2d, quadratic2d_exports as QuadraticCurve2d, rationalCubic2d_exports as RationalCubicCurve2d };
|
package/dist/curve/linear2d.d.ts
CHANGED
|
@@ -5,7 +5,9 @@ import type { Pipeable } from '../utils.ts';
|
|
|
5
5
|
import type { LinearPolynomial } from '../polynomial/linear.ts';
|
|
6
6
|
import type { Decreasing, Increasing, Monotonic } from '../polynomial/traits.ts';
|
|
7
7
|
import type * as Solution from '../solution/solution.ts';
|
|
8
|
+
import type { Affine2d } from '../transform/affine2d.ts';
|
|
8
9
|
import type { Vector2 } from '../vector/vector2.ts';
|
|
10
|
+
import type { Curve2dOps } from './curve2d.ts';
|
|
9
11
|
import type { LinearCurve2dTypeId } from './linear2d.internal.ts';
|
|
10
12
|
export type { Monotonic, Increasing, Decreasing } from '../polynomial/traits.ts';
|
|
11
13
|
/**
|
|
@@ -121,6 +123,53 @@ export declare const length: {
|
|
|
121
123
|
* @since 2.0.0
|
|
122
124
|
*/
|
|
123
125
|
export declare const boundingBox: (c: LinearCurve2d) => Interval2d<Closed, Closed>;
|
|
126
|
+
/**
|
|
127
|
+
* Evaluates the curve at `t = 0` in closed form — `(c.x.c0, c.y.c0)`.
|
|
128
|
+
*
|
|
129
|
+
* @param c - The linear curve.
|
|
130
|
+
* @returns The point at the start of the curve's parameter domain.
|
|
131
|
+
* @since 2.0.0
|
|
132
|
+
*/
|
|
133
|
+
export declare const startPoint: (c: LinearCurve2d) => Vector2;
|
|
134
|
+
/**
|
|
135
|
+
* Evaluates the curve at `t = 1` in closed form — `(c.x.c0 + c.x.c1, c.y.c0 + c.y.c1)`.
|
|
136
|
+
*
|
|
137
|
+
* @param c - The linear curve.
|
|
138
|
+
* @returns The point at the end of the curve's parameter domain.
|
|
139
|
+
* @since 2.0.0
|
|
140
|
+
*/
|
|
141
|
+
export declare const endPoint: (c: LinearCurve2d) => Vector2;
|
|
142
|
+
/**
|
|
143
|
+
* The tight `[min, max]` range of x over the curve's parameter domain `[0, 1]`.
|
|
144
|
+
* For a linear curve this is the closed interval bounded by the two endpoints'
|
|
145
|
+
* x coordinates.
|
|
146
|
+
*
|
|
147
|
+
* @param c - The linear curve.
|
|
148
|
+
* @returns The closed range of x over `[0, 1]`.
|
|
149
|
+
* @since 2.0.0
|
|
150
|
+
*/
|
|
151
|
+
export declare const xRange: (c: LinearCurve2d) => Closed;
|
|
152
|
+
/**
|
|
153
|
+
* The tight `[min, max]` range of y over the curve's parameter domain `[0, 1]`.
|
|
154
|
+
* For a linear curve this is the closed interval bounded by the two endpoints'
|
|
155
|
+
* y coordinates.
|
|
156
|
+
*
|
|
157
|
+
* @param c - The linear curve.
|
|
158
|
+
* @returns The closed range of y over `[0, 1]`.
|
|
159
|
+
* @since 2.0.0
|
|
160
|
+
*/
|
|
161
|
+
export declare const yRange: (c: LinearCurve2d) => Closed;
|
|
162
|
+
/**
|
|
163
|
+
* Renders the curve as a single SVG path-data drawing command — for a linear
|
|
164
|
+
* curve, `L endX,endY`. Does not include a leading `M`; callers (typically a
|
|
165
|
+
* path-level `toPathData`) decide whether to emit a move based on continuity
|
|
166
|
+
* with the previous segment.
|
|
167
|
+
*
|
|
168
|
+
* @param c - The linear curve.
|
|
169
|
+
* @returns The SVG drawing command for this segment, without a leading `M`.
|
|
170
|
+
* @since 2.0.0
|
|
171
|
+
*/
|
|
172
|
+
export declare const toPathDataSegment: (c: LinearCurve2d) => string;
|
|
124
173
|
export declare const solveAtX: {
|
|
125
174
|
/**
|
|
126
175
|
* Evaluates the curve's y value at a given x. A linear curve crosses any
|
|
@@ -152,14 +201,54 @@ export declare const solveAtY: {
|
|
|
152
201
|
/** @since 2.0.0 */
|
|
153
202
|
(y: number): <XT, YT>(c: LinearCurve2d<XT, YT>) => Solution.AtMostOne<number>;
|
|
154
203
|
};
|
|
204
|
+
/**
|
|
205
|
+
* Type-narrowing predicate: refines the curve's x-axis trait to include
|
|
206
|
+
* `Monotonic` when the x polynomial is strictly monotonic. The y-axis trait
|
|
207
|
+
* is unchanged.
|
|
208
|
+
*
|
|
209
|
+
* @since 2.0.0
|
|
210
|
+
*/
|
|
211
|
+
export declare const isMonotonicX: <XT, YT>(c: LinearCurve2d<XT, YT>) => c is LinearCurve2d<XT & Monotonic, YT>;
|
|
212
|
+
/**
|
|
213
|
+
* Type-narrowing predicate: refines the curve's x-axis trait to include
|
|
214
|
+
* `Increasing`.
|
|
215
|
+
*
|
|
216
|
+
* @since 2.0.0
|
|
217
|
+
*/
|
|
218
|
+
export declare const isIncreasingX: <XT, YT>(c: LinearCurve2d<XT, YT>) => c is LinearCurve2d<XT & Increasing, YT>;
|
|
219
|
+
/**
|
|
220
|
+
* Type-narrowing predicate: refines the curve's x-axis trait to include
|
|
221
|
+
* `Decreasing`.
|
|
222
|
+
*
|
|
223
|
+
* @since 2.0.0
|
|
224
|
+
*/
|
|
225
|
+
export declare const isDecreasingX: <XT, YT>(c: LinearCurve2d<XT, YT>) => c is LinearCurve2d<XT & Decreasing, YT>;
|
|
226
|
+
/**
|
|
227
|
+
* Type-narrowing predicate: refines the curve's y-axis trait to include
|
|
228
|
+
* `Monotonic`. The x-axis trait is unchanged.
|
|
229
|
+
*
|
|
230
|
+
* @since 2.0.0
|
|
231
|
+
*/
|
|
232
|
+
export declare const isMonotonicY: <XT, YT>(c: LinearCurve2d<XT, YT>) => c is LinearCurve2d<XT, YT & Monotonic>;
|
|
233
|
+
/**
|
|
234
|
+
* Type-narrowing predicate: refines the curve's y-axis trait to include
|
|
235
|
+
* `Increasing`.
|
|
236
|
+
*
|
|
237
|
+
* @since 2.0.0
|
|
238
|
+
*/
|
|
239
|
+
export declare const isIncreasingY: <XT, YT>(c: LinearCurve2d<XT, YT>) => c is LinearCurve2d<XT, YT & Increasing>;
|
|
240
|
+
/**
|
|
241
|
+
* Type-narrowing predicate: refines the curve's y-axis trait to include
|
|
242
|
+
* `Decreasing`.
|
|
243
|
+
*
|
|
244
|
+
* @since 2.0.0
|
|
245
|
+
*/
|
|
246
|
+
export declare const isDecreasingY: <XT, YT>(c: LinearCurve2d<XT, YT>) => c is LinearCurve2d<XT, YT & Decreasing>;
|
|
155
247
|
/**
|
|
156
248
|
* Type-narrowing predicate: refines both axes' traits to include `Monotonic`
|
|
157
249
|
* when both the x and y polynomials are strictly monotonic. When both axes
|
|
158
250
|
* are monotonic, the curve is invertible in either direction.
|
|
159
251
|
*
|
|
160
|
-
* For checking only one axis, call the polynomial-level refiner directly:
|
|
161
|
-
* `LinearPolynomial.isMonotonic(curve.x)`.
|
|
162
|
-
*
|
|
163
252
|
* @since 2.0.0
|
|
164
253
|
*/
|
|
165
254
|
export declare const isMonotonic: <XT, YT>(c: LinearCurve2d<XT, YT>) => c is LinearCurve2d<XT & Monotonic, YT & Monotonic>;
|
|
@@ -193,3 +282,33 @@ export declare const asIncreasing: <XT, YT>(c: LinearCurve2d<XT, YT>) => LinearC
|
|
|
193
282
|
* @since 2.0.0
|
|
194
283
|
*/
|
|
195
284
|
export declare const asDecreasing: <XT, YT>(c: LinearCurve2d<XT, YT>) => LinearCurve2d<XT & Decreasing, YT & Decreasing>;
|
|
285
|
+
export declare const transform: {
|
|
286
|
+
/**
|
|
287
|
+
* Applies an `Affine2d` transform to a `LinearCurve2d`, returning a new
|
|
288
|
+
* curve whose image is the affine image of the original. The transformation
|
|
289
|
+
* is exact: linear curves are degree-1 in every basis, and affine maps
|
|
290
|
+
* commute with the basis.
|
|
291
|
+
*
|
|
292
|
+
* @param c - The linear curve.
|
|
293
|
+
* @param a - The affine transform.
|
|
294
|
+
* @returns The transformed linear curve.
|
|
295
|
+
* @since 2.0.0
|
|
296
|
+
*/
|
|
297
|
+
(c: LinearCurve2d, a: Affine2d): LinearCurve2d;
|
|
298
|
+
/**
|
|
299
|
+
* Applies an `Affine2d` transform to a `LinearCurve2d`.
|
|
300
|
+
*
|
|
301
|
+
* @param a - The affine transform.
|
|
302
|
+
* @returns A function that takes a `LinearCurve2d` and returns the transformed curve.
|
|
303
|
+
* @since 2.0.0
|
|
304
|
+
*/
|
|
305
|
+
(a: Affine2d): (c: LinearCurve2d) => LinearCurve2d;
|
|
306
|
+
};
|
|
307
|
+
/**
|
|
308
|
+
* The {@link Curve2dOps} bundle for `LinearCurve2d`. Used by
|
|
309
|
+
* `LinearPath2d` (and any user code building a generic `Path2d` over linear
|
|
310
|
+
* curves) to wire up the path-level operation surface.
|
|
311
|
+
*
|
|
312
|
+
* @since 2.0.0
|
|
313
|
+
*/
|
|
314
|
+
export declare const Ops: Curve2dOps<LinearCurve2d>;
|
|
@@ -5,7 +5,9 @@ import type { Pipeable } from '../utils.ts';
|
|
|
5
5
|
import type { QuadraticPolynomial } from '../polynomial/quadratic.ts';
|
|
6
6
|
import type { Decreasing, Increasing, Monotonic } from '../polynomial/traits.ts';
|
|
7
7
|
import type * as Solution from '../solution/solution.ts';
|
|
8
|
+
import type { Affine2d } from '../transform/affine2d.ts';
|
|
8
9
|
import type { Vector2 } from '../vector/vector2.ts';
|
|
10
|
+
import type { Curve2dOps } from './curve2d.ts';
|
|
9
11
|
import type { LinearCurve2d } from './linear2d.ts';
|
|
10
12
|
import type { QuadraticCurve2dTypeId } from './quadratic2d.internal.ts';
|
|
11
13
|
export type { Monotonic, Increasing, Decreasing } from '../polynomial/traits.ts';
|
|
@@ -201,13 +203,79 @@ export declare const curvature: {
|
|
|
201
203
|
* @since 2.0.0
|
|
202
204
|
*/
|
|
203
205
|
export declare const boundingBox: (c: QuadraticCurve2d) => Interval2d<Closed, Closed>;
|
|
206
|
+
/**
|
|
207
|
+
* Evaluates the curve at `t = 0` in closed form — `(c.x.c0, c.y.c0)`.
|
|
208
|
+
*
|
|
209
|
+
* @param c - The quadratic curve.
|
|
210
|
+
* @returns The point at the start of the curve's parameter domain.
|
|
211
|
+
* @since 2.0.0
|
|
212
|
+
*/
|
|
213
|
+
export declare const startPoint: (c: QuadraticCurve2d) => Vector2;
|
|
214
|
+
/**
|
|
215
|
+
* Evaluates the curve at `t = 1` in closed form — the sum of the per-axis
|
|
216
|
+
* monomial coefficients.
|
|
217
|
+
*
|
|
218
|
+
* @param c - The quadratic curve.
|
|
219
|
+
* @returns The point at the end of the curve's parameter domain.
|
|
220
|
+
* @since 2.0.0
|
|
221
|
+
*/
|
|
222
|
+
export declare const endPoint: (c: QuadraticCurve2d) => Vector2;
|
|
223
|
+
/**
|
|
224
|
+
* The tight `[min, max]` range of x over the curve's parameter domain `[0, 1]`,
|
|
225
|
+
* accounting for an interior extremum if one exists.
|
|
226
|
+
*
|
|
227
|
+
* @param c - The quadratic curve.
|
|
228
|
+
* @returns The closed range of x over `[0, 1]`.
|
|
229
|
+
* @since 2.0.0
|
|
230
|
+
*/
|
|
231
|
+
export declare const xRange: (c: QuadraticCurve2d) => Closed;
|
|
232
|
+
/**
|
|
233
|
+
* The tight `[min, max]` range of y over the curve's parameter domain `[0, 1]`,
|
|
234
|
+
* accounting for an interior extremum if one exists.
|
|
235
|
+
*
|
|
236
|
+
* @param c - The quadratic curve.
|
|
237
|
+
* @returns The closed range of y over `[0, 1]`.
|
|
238
|
+
* @since 2.0.0
|
|
239
|
+
*/
|
|
240
|
+
export declare const yRange: (c: QuadraticCurve2d) => Closed;
|
|
241
|
+
/**
|
|
242
|
+
* Renders the curve as a single SVG path-data drawing command — for a
|
|
243
|
+
* quadratic curve, `Q ctrlX,ctrlY endX,endY`, where the control point is
|
|
244
|
+
* recovered from the monomial coefficients via the inverse Bernstein
|
|
245
|
+
* expansion. Does not include a leading `M`.
|
|
246
|
+
*
|
|
247
|
+
* @param c - The quadratic curve.
|
|
248
|
+
* @returns The SVG drawing command for this segment, without a leading `M`.
|
|
249
|
+
* @since 2.0.0
|
|
250
|
+
*/
|
|
251
|
+
export declare const toPathDataSegment: (c: QuadraticCurve2d) => string;
|
|
252
|
+
/**
|
|
253
|
+
* Type-narrowing predicate: refines the curve's x-axis trait to include
|
|
254
|
+
* `Monotonic` when the x polynomial is strictly monotonic on the unit
|
|
255
|
+
* interval `[0, 1]`. The y-axis trait is unchanged.
|
|
256
|
+
*
|
|
257
|
+
* @since 2.0.0
|
|
258
|
+
*/
|
|
259
|
+
export declare const isMonotonicX: <XT, YT>(c: QuadraticCurve2d<XT, YT>) => c is QuadraticCurve2d<XT & Monotonic, YT>;
|
|
260
|
+
/** @since 2.0.0 */
|
|
261
|
+
export declare const isIncreasingX: <XT, YT>(c: QuadraticCurve2d<XT, YT>) => c is QuadraticCurve2d<XT & Increasing, YT>;
|
|
262
|
+
/** @since 2.0.0 */
|
|
263
|
+
export declare const isDecreasingX: <XT, YT>(c: QuadraticCurve2d<XT, YT>) => c is QuadraticCurve2d<XT & Decreasing, YT>;
|
|
264
|
+
/**
|
|
265
|
+
* Type-narrowing predicate: refines the curve's y-axis trait to include
|
|
266
|
+
* `Monotonic`. The x-axis trait is unchanged.
|
|
267
|
+
*
|
|
268
|
+
* @since 2.0.0
|
|
269
|
+
*/
|
|
270
|
+
export declare const isMonotonicY: <XT, YT>(c: QuadraticCurve2d<XT, YT>) => c is QuadraticCurve2d<XT, YT & Monotonic>;
|
|
271
|
+
/** @since 2.0.0 */
|
|
272
|
+
export declare const isIncreasingY: <XT, YT>(c: QuadraticCurve2d<XT, YT>) => c is QuadraticCurve2d<XT, YT & Increasing>;
|
|
273
|
+
/** @since 2.0.0 */
|
|
274
|
+
export declare const isDecreasingY: <XT, YT>(c: QuadraticCurve2d<XT, YT>) => c is QuadraticCurve2d<XT, YT & Decreasing>;
|
|
204
275
|
/**
|
|
205
276
|
* Type-narrowing predicate: refines both axes' traits to include `Monotonic`
|
|
206
277
|
* when both x and y polynomials are monotonic over the unit interval `[0, 1]`.
|
|
207
278
|
*
|
|
208
|
-
* For checking only one axis, call the polynomial-level refiner directly:
|
|
209
|
-
* `QuadraticPolynomial.isMonotonic(curve.x, Interval.unit)`.
|
|
210
|
-
*
|
|
211
279
|
* @since 2.0.0
|
|
212
280
|
*/
|
|
213
281
|
export declare const isMonotonic: <XT, YT>(c: QuadraticCurve2d<XT, YT>) => c is QuadraticCurve2d<XT & Monotonic, YT & Monotonic>;
|
|
@@ -221,3 +289,35 @@ export declare const asMonotonic: <XT, YT>(c: QuadraticCurve2d<XT, YT>) => Quadr
|
|
|
221
289
|
export declare const asIncreasing: <XT, YT>(c: QuadraticCurve2d<XT, YT>) => QuadraticCurve2d<XT & Increasing, YT & Increasing>;
|
|
222
290
|
/** @since 2.0.0 */
|
|
223
291
|
export declare const asDecreasing: <XT, YT>(c: QuadraticCurve2d<XT, YT>) => QuadraticCurve2d<XT & Decreasing, YT & Decreasing>;
|
|
292
|
+
export declare const transform: {
|
|
293
|
+
/**
|
|
294
|
+
* Applies an `Affine2d` transform to a `QuadraticCurve2d`, returning a new
|
|
295
|
+
* curve whose image is the affine image of the original. Internally the
|
|
296
|
+
* transformation works directly on the curve's monomial coefficients —
|
|
297
|
+
* `c0` receives the full affine, `c1` and `c2` receive only the linear part.
|
|
298
|
+
*
|
|
299
|
+
* @param c - The quadratic curve.
|
|
300
|
+
* @param a - The affine transform.
|
|
301
|
+
* @returns The transformed quadratic curve.
|
|
302
|
+
* @since 2.0.0
|
|
303
|
+
*/
|
|
304
|
+
(c: QuadraticCurve2d, a: Affine2d): QuadraticCurve2d;
|
|
305
|
+
/**
|
|
306
|
+
* Applies an `Affine2d` transform to a `QuadraticCurve2d`.
|
|
307
|
+
*
|
|
308
|
+
* @param a - The affine transform.
|
|
309
|
+
* @returns A function that takes a `QuadraticCurve2d` and returns the transformed curve.
|
|
310
|
+
* @since 2.0.0
|
|
311
|
+
*/
|
|
312
|
+
(a: Affine2d): (c: QuadraticCurve2d) => QuadraticCurve2d;
|
|
313
|
+
};
|
|
314
|
+
/**
|
|
315
|
+
* The {@link Curve2dOps} bundle for `QuadraticCurve2d`. Used by
|
|
316
|
+
* `QuadraticPath2d` to wire up the path-level operation surface. The
|
|
317
|
+
* `solveAtX` / `solveAtY` entries narrow the curve's potentially-2-element
|
|
318
|
+
* result to `AtMostOne` — path callers enforce that via the path's
|
|
319
|
+
* `MonotonicX`/`MonotonicY` brand.
|
|
320
|
+
*
|
|
321
|
+
* @since 2.0.0
|
|
322
|
+
*/
|
|
323
|
+
export declare const Ops: Curve2dOps<QuadraticCurve2d>;
|