curvy 1.0.9 → 2.0.0-alpha.10
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/characteristic.d.ts +80 -0
- package/dist/characteristic/index.d.ts +1 -0
- package/dist/characteristic/index.mjs +2 -0
- package/dist/curve/cubic2d.d.ts +133 -27
- package/dist/curve/cubic2d.internal.d.ts +2 -0
- package/dist/curve/index.d.ts +12 -0
- package/dist/curve/index.mjs +2 -0
- package/dist/curve/linear2d.d.ts +125 -24
- package/dist/curve/linear2d.internal.d.ts +2 -0
- package/dist/curve/quadratic2d.d.ts +134 -28
- package/dist/curve/quadratic2d.internal.d.ts +2 -0
- package/dist/curve/rationalCubic2d.d.ts +241 -0
- package/dist/curve/rationalCubic2d.internal.d.ts +2 -0
- package/dist/dimensions.d.ts +23 -0
- package/dist/interval/index.d.ts +6 -0
- package/dist/interval/index.mjs +3 -0
- package/dist/interval/interval.d.ts +525 -0
- package/dist/interval/interval.internal.d.ts +1 -0
- package/dist/interval/interval2d.d.ts +204 -0
- package/dist/interval/interval2d.internal.d.ts +2 -0
- package/dist/length.d.ts +32 -0
- package/dist/matrix/index.d.ts +9 -0
- package/dist/matrix/index.mjs +267 -0
- package/dist/matrix/index.mjs.map +1 -0
- package/dist/matrix/matrix2x2.d.ts +44 -29
- package/dist/matrix/matrix2x2.internal.d.ts +2 -0
- package/dist/matrix/matrix3x3.d.ts +64 -38
- package/dist/matrix/matrix3x3.internal.d.ts +4 -0
- package/dist/matrix/matrix4x4.d.ts +92 -34
- package/dist/matrix/matrix4x4.internal.d.ts +2 -0
- package/dist/number.d.ts +276 -0
- package/dist/number.mjs +140 -0
- package/dist/number.mjs.map +1 -0
- package/dist/path/cubic2d.d.ts +192 -25
- package/dist/path/cubic2d.internal.d.ts +2 -0
- package/dist/path/index.d.ts +12 -0
- package/dist/path/index.mjs +734 -0
- package/dist/path/index.mjs.map +1 -0
- package/dist/path/linear2d.d.ts +175 -25
- package/dist/path/linear2d.internal.d.ts +2 -0
- package/dist/path/quadratic2d.d.ts +165 -26
- package/dist/path/quadratic2d.internal.d.ts +2 -0
- package/dist/path/rationalCubic2d.d.ts +116 -0
- package/dist/path/rationalCubic2d.internal.d.ts +2 -0
- package/dist/path/traits.d.ts +95 -0
- package/dist/polynomial/cubic.d.ts +377 -7
- package/dist/polynomial/cubic.internal.circular.d.ts +2 -0
- package/dist/polynomial/cubic.internal.d.ts +1 -0
- package/dist/polynomial/index.d.ts +9 -0
- package/dist/polynomial/index.mjs +3 -0
- package/dist/polynomial/linear.d.ts +317 -7
- package/dist/polynomial/linear.internal.d.ts +2 -0
- package/dist/polynomial/monotonicity.d.ts +3 -0
- package/dist/polynomial/quadratic.d.ts +371 -7
- package/dist/polynomial/quadratic.internal.circular.d.ts +2 -0
- package/dist/polynomial/quadratic.internal.d.ts +1 -0
- package/dist/polynomial/traits.d.ts +56 -0
- package/dist/shared/characteristic-B0VEB_OA.mjs +104 -0
- package/dist/shared/characteristic-B0VEB_OA.mjs.map +1 -0
- package/dist/shared/chunk-25Hzd3z8.mjs +13 -0
- package/dist/shared/cubic-NEn7E6V_.mjs +575 -0
- package/dist/shared/cubic-NEn7E6V_.mjs.map +1 -0
- package/dist/shared/interval-CqC3ZIqj.mjs +460 -0
- package/dist/shared/interval-CqC3ZIqj.mjs.map +1 -0
- package/dist/shared/interval2d-C0eduE-V.mjs +149 -0
- package/dist/shared/interval2d-C0eduE-V.mjs.map +1 -0
- package/dist/shared/matrix4x4-BWmf4lZM.mjs +499 -0
- package/dist/shared/matrix4x4-BWmf4lZM.mjs.map +1 -0
- package/dist/shared/quadratic-Dlxqo2V1.mjs +348 -0
- package/dist/shared/quadratic-Dlxqo2V1.mjs.map +1 -0
- package/dist/shared/rationalCubic2d-3S5K69Jy.mjs +909 -0
- package/dist/shared/rationalCubic2d-3S5K69Jy.mjs.map +1 -0
- package/dist/shared/rationalCubic2d-CJY-feGw.mjs +508 -0
- package/dist/shared/rationalCubic2d-CJY-feGw.mjs.map +1 -0
- package/dist/shared/solution-UKGK826h.mjs +352 -0
- package/dist/shared/solution-UKGK826h.mjs.map +1 -0
- package/dist/shared/vector2-CSkaMXvp.mjs +205 -0
- package/dist/shared/vector2-CSkaMXvp.mjs.map +1 -0
- package/dist/shared/vector2.internal-DP1nTBdS.mjs +141 -0
- package/dist/shared/vector2.internal-DP1nTBdS.mjs.map +1 -0
- package/dist/shared/vector3-CR2LPV03.mjs +226 -0
- package/dist/shared/vector3-CR2LPV03.mjs.map +1 -0
- package/dist/shared/vector4-PO_7EYd-.mjs +171 -0
- package/dist/shared/vector4-PO_7EYd-.mjs.map +1 -0
- package/dist/shared/vector4.internal-BJ1QN2Ck.mjs +246 -0
- package/dist/shared/vector4.internal-BJ1QN2Ck.mjs.map +1 -0
- package/dist/solution/index.d.ts +1 -0
- package/dist/solution/index.mjs +2 -0
- package/dist/solution/solution.d.ts +264 -0
- package/dist/solution/solution.internal.d.ts +2 -0
- package/dist/splines/basis2d.d.ts +26 -38
- package/dist/splines/basis2d.internal.d.ts +2 -0
- package/dist/splines/bezier2d.d.ts +61 -45
- package/dist/splines/bezier2d.internal.d.ts +2 -0
- package/dist/splines/cardinal2d.d.ts +179 -88
- package/dist/splines/cardinal2d.internal.d.ts +2 -0
- package/dist/splines/hermite2d.d.ts +25 -36
- package/dist/splines/hermite2d.internal.d.ts +2 -0
- package/dist/splines/index.d.ts +15 -0
- package/dist/splines/index.mjs +946 -0
- package/dist/splines/index.mjs.map +1 -0
- package/dist/splines/rationalBezier2d.d.ts +144 -0
- package/dist/splines/rationalBezier2d.internal.d.ts +2 -0
- package/dist/splines/util.d.ts +5 -0
- package/dist/utils.d.ts +54 -186
- package/dist/utils.mjs +88 -52
- package/dist/utils.mjs.map +1 -1
- package/dist/vector/index.d.ts +9 -0
- package/dist/vector/index.mjs +4 -0
- package/dist/vector/vector2.d.ts +238 -33
- package/dist/vector/vector2.internal.d.ts +4 -0
- package/dist/vector/vector3.d.ts +198 -41
- package/dist/vector/vector3.internal.d.ts +2 -0
- package/dist/vector/vector4.d.ts +260 -23
- package/dist/vector/vector4.internal.d.ts +2 -0
- package/package.json +48 -91
- package/dist/curve/cubic2d.d.mts +0 -109
- package/dist/curve/cubic2d.mjs +0 -80
- package/dist/curve/cubic2d.mjs.map +0 -1
- package/dist/curve/linear2d.d.mts +0 -94
- package/dist/curve/linear2d.mjs +0 -46
- package/dist/curve/linear2d.mjs.map +0 -1
- package/dist/curve/quadratic2d.d.mts +0 -117
- package/dist/curve/quadratic2d.mjs +0 -82
- package/dist/curve/quadratic2d.mjs.map +0 -1
- package/dist/interval.d.mts +0 -251
- package/dist/interval.d.ts +0 -251
- package/dist/interval.mjs +0 -86
- package/dist/interval.mjs.map +0 -1
- package/dist/matrix/matrix2x2.d.mts +0 -320
- package/dist/matrix/matrix2x2.mjs +0 -25
- package/dist/matrix/matrix2x2.mjs.map +0 -1
- package/dist/matrix/matrix3x3.d.mts +0 -370
- package/dist/matrix/matrix3x3.mjs +0 -28
- package/dist/matrix/matrix3x3.mjs.map +0 -1
- package/dist/matrix/matrix4x4.d.mts +0 -381
- package/dist/matrix/matrix4x4.mjs +0 -178
- package/dist/matrix/matrix4x4.mjs.map +0 -1
- package/dist/path/cubic2d.d.mts +0 -95
- package/dist/path/cubic2d.mjs +0 -60
- package/dist/path/cubic2d.mjs.map +0 -1
- package/dist/path/linear2d.d.mts +0 -95
- package/dist/path/linear2d.mjs +0 -53
- package/dist/path/linear2d.mjs.map +0 -1
- package/dist/path/quadratic2d.d.mts +0 -95
- package/dist/path/quadratic2d.mjs +0 -57
- package/dist/path/quadratic2d.mjs.map +0 -1
- package/dist/pipe.d.mts +0 -58
- package/dist/pipe.d.ts +0 -58
- package/dist/pipe.mjs +0 -92
- package/dist/pipe.mjs.map +0 -1
- package/dist/polynomial/cubic.d.mts +0 -7
- package/dist/polynomial/cubic.mjs +0 -133
- package/dist/polynomial/cubic.mjs.map +0 -1
- package/dist/polynomial/linear.d.mts +0 -7
- package/dist/polynomial/linear.mjs +0 -24
- package/dist/polynomial/linear.mjs.map +0 -1
- package/dist/polynomial/quadratic.d.mts +0 -7
- package/dist/polynomial/quadratic.mjs +0 -27
- package/dist/polynomial/quadratic.mjs.map +0 -1
- package/dist/shared/curvy.Bf5TIk31.d.mts +0 -22
- package/dist/shared/curvy.Bf5TIk31.d.ts +0 -22
- package/dist/shared/curvy.BkkW8Tx9.mjs +0 -102
- package/dist/shared/curvy.BkkW8Tx9.mjs.map +0 -1
- package/dist/shared/curvy.BxdGW9he.mjs +0 -116
- package/dist/shared/curvy.BxdGW9he.mjs.map +0 -1
- package/dist/shared/curvy.C_sCeg9J.mjs +0 -66
- package/dist/shared/curvy.C_sCeg9J.mjs.map +0 -1
- package/dist/shared/curvy.Cg8lZVUz.d.ts +0 -688
- package/dist/shared/curvy.DCt1gGII.mjs +0 -147
- package/dist/shared/curvy.DCt1gGII.mjs.map +0 -1
- package/dist/shared/curvy.DJ4xO0al.mjs +0 -63
- package/dist/shared/curvy.DJ4xO0al.mjs.map +0 -1
- package/dist/shared/curvy.DmVFTi0N.mjs +0 -35
- package/dist/shared/curvy.DmVFTi0N.mjs.map +0 -1
- package/dist/shared/curvy.FDaj5rlj.d.mts +0 -688
- package/dist/shared/curvy.lktriTpx.mjs +0 -101
- package/dist/shared/curvy.lktriTpx.mjs.map +0 -1
- package/dist/shared/curvy.mLFprrGm.mjs +0 -85
- package/dist/shared/curvy.mLFprrGm.mjs.map +0 -1
- package/dist/shared/curvy.r6f1j287.mjs +0 -76
- package/dist/shared/curvy.r6f1j287.mjs.map +0 -1
- package/dist/splines/basis2d.d.mts +0 -130
- package/dist/splines/basis2d.mjs +0 -90
- package/dist/splines/basis2d.mjs.map +0 -1
- package/dist/splines/bezier2d.d.mts +0 -182
- package/dist/splines/bezier2d.mjs +0 -23
- package/dist/splines/bezier2d.mjs.map +0 -1
- package/dist/splines/cardinal2d.d.mts +0 -178
- package/dist/splines/cardinal2d.mjs +0 -114
- package/dist/splines/cardinal2d.mjs.map +0 -1
- package/dist/splines/hermite2d.d.mts +0 -124
- package/dist/splines/hermite2d.mjs +0 -63
- package/dist/splines/hermite2d.mjs.map +0 -1
- package/dist/utils.d.mts +0 -205
- package/dist/vector/vector2.d.mts +0 -324
- package/dist/vector/vector2.mjs +0 -30
- package/dist/vector/vector2.mjs.map +0 -1
- package/dist/vector/vector3.d.mts +0 -417
- package/dist/vector/vector3.mjs +0 -38
- package/dist/vector/vector3.mjs.map +0 -1
- package/dist/vector/vector4.d.mts +0 -205
- package/dist/vector/vector4.mjs +0 -20
- package/dist/vector/vector4.mjs.map +0 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import * as Matrix4x4 from '../matrix/matrix4x4.ts';
|
|
2
|
+
import * as CubicPolynomial from '../polynomial/cubic.ts';
|
|
3
|
+
import type * as Vector4 from '../vector/vector4.ts';
|
|
4
|
+
/**
|
|
5
|
+
* The cubic Bézier characteristic matrix.
|
|
6
|
+
*
|
|
7
|
+
* Maps Bernstein-basis control points `(P₀, P₁, P₂, P₃)` to monomial cubic
|
|
8
|
+
* coefficients `(c₀, c₁, c₂, c₃)` for `c₀ + c₁·t + c₂·t² + c₃·t³`. The matrix
|
|
9
|
+
* IS the Bézier spline family — combined with control points (via {@link apply}),
|
|
10
|
+
* it produces the cubic polynomial that parameterizes the curve.
|
|
11
|
+
*
|
|
12
|
+
* @since 2.0.0
|
|
13
|
+
*/
|
|
14
|
+
export declare const cubicBezier: Matrix4x4.Matrix4x4;
|
|
15
|
+
/**
|
|
16
|
+
* The cubic Hermite characteristic matrix.
|
|
17
|
+
*
|
|
18
|
+
* Maps Hermite control data `(P₀, V₀, P₁, V₁)` — two endpoints and two
|
|
19
|
+
* tangent vectors — to monomial cubic coefficients.
|
|
20
|
+
*
|
|
21
|
+
* @since 2.0.0
|
|
22
|
+
*/
|
|
23
|
+
export declare const cubicHermite: Matrix4x4.Matrix4x4;
|
|
24
|
+
/**
|
|
25
|
+
* The uniform cubic B-spline (basis spline) characteristic matrix.
|
|
26
|
+
*
|
|
27
|
+
* Maps a window of four control points to the monomial cubic coefficients
|
|
28
|
+
* of one segment of the corresponding uniform cubic B-spline. Stride-1
|
|
29
|
+
* application produces a C² piecewise spline; the curve does not generally
|
|
30
|
+
* pass through the control points.
|
|
31
|
+
*
|
|
32
|
+
* @since 2.0.0
|
|
33
|
+
*/
|
|
34
|
+
export declare const cubicBasisSpline: Matrix4x4.Matrix4x4;
|
|
35
|
+
/**
|
|
36
|
+
* The cubic Cardinal spline characteristic matrix, parameterized by tension.
|
|
37
|
+
*
|
|
38
|
+
* Maps four control points to the monomial cubic coefficients of one
|
|
39
|
+
* Cardinal segment. The tension `s` controls how tightly the curve hugs
|
|
40
|
+
* the control points: `s = 0` produces straight-line segments between
|
|
41
|
+
* adjacent points, `s = 0.5` is the Catmull-Rom variant (see
|
|
42
|
+
* {@link cubicCatmullRom}), and higher values produce looser, more curved
|
|
43
|
+
* shapes.
|
|
44
|
+
*
|
|
45
|
+
* Cached per tension value — repeated calls with the same tension return
|
|
46
|
+
* the same matrix instance.
|
|
47
|
+
*
|
|
48
|
+
* @param tension - The tension parameter.
|
|
49
|
+
* @returns The characteristic matrix for that tension.
|
|
50
|
+
* @since 2.0.0
|
|
51
|
+
*/
|
|
52
|
+
export declare const cubicCardinal: (tension: number) => Matrix4x4.Matrix4x4;
|
|
53
|
+
/**
|
|
54
|
+
* The cubic Catmull-Rom characteristic matrix — Cardinal with tension `0.5`.
|
|
55
|
+
* The most common Cardinal-family variant; reused widely enough to deserve
|
|
56
|
+
* a constant.
|
|
57
|
+
*
|
|
58
|
+
* @since 2.0.0
|
|
59
|
+
*/
|
|
60
|
+
export declare const cubicCatmullRom: Matrix4x4.Matrix4x4;
|
|
61
|
+
/**
|
|
62
|
+
* Applies a characteristic matrix to N channels of control values, producing
|
|
63
|
+
* N cubic polynomials in monomial form.
|
|
64
|
+
*
|
|
65
|
+
* Each channel is a `Vector4` packing one axis's values across the four
|
|
66
|
+
* control points: `(v₀, v₁, v₂, v₃)`. The result tuple has the same arity
|
|
67
|
+
* as the input.
|
|
68
|
+
*
|
|
69
|
+
* The polynomial 2D spline pipeline applies this with two channels (x, y);
|
|
70
|
+
* the rational 2D pipeline uses three (x, y, w) where `w` is the projective
|
|
71
|
+
* denominator. Higher channel counts generalize to 3D, rational 3D, and
|
|
72
|
+
* beyond — the characteristic matrix doesn't care about the geometric
|
|
73
|
+
* domain, only about how to combine four samples per channel.
|
|
74
|
+
*
|
|
75
|
+
* @param matrix - The characteristic matrix of the spline family.
|
|
76
|
+
* @param channels - One `Vector4` per output polynomial, packing the four control values for that channel.
|
|
77
|
+
* @returns A tuple of cubic polynomials, one per input channel.
|
|
78
|
+
* @since 2.0.0
|
|
79
|
+
*/
|
|
80
|
+
export declare const apply: <const Channels extends ReadonlyArray<Vector4.Vector4>>(matrix: Matrix4x4.Matrix4x4, ...channels: Channels) => { readonly [K in keyof Channels]: CubicPolynomial.CubicPolynomial; };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as Characteristic from './characteristic.ts';
|
package/dist/curve/cubic2d.d.ts
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import '../
|
|
7
|
-
import '../
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
type
|
|
11
|
-
|
|
1
|
+
import type { Interval2d } from '../interval/interval2d.ts';
|
|
2
|
+
import type { TwoDimensional } from '../dimensions.ts';
|
|
3
|
+
import type { Closed, Interval } from '../interval/interval.ts';
|
|
4
|
+
import type { Pipeable } from '../utils.ts';
|
|
5
|
+
import type { CubicPolynomial } from '../polynomial/cubic.ts';
|
|
6
|
+
import type { Decreasing, Increasing, Monotonic } from '../polynomial/traits.ts';
|
|
7
|
+
import type * as Solution from '../solution/solution.ts';
|
|
8
|
+
import type { Vector2 } from '../vector/vector2.ts';
|
|
9
|
+
import type { CubicCurve2dTypeId } from './cubic2d.internal.ts';
|
|
10
|
+
export type { Monotonic, Increasing, Decreasing } from '../polynomial/traits.ts';
|
|
12
11
|
/**
|
|
13
12
|
* A cubic curve in 2D space.
|
|
14
13
|
*
|
|
15
14
|
* All fields are readonly and immutable, and all operations create new instances.
|
|
16
15
|
*
|
|
16
|
+
* The two type parameters carry the trait sets of the curve's per-axis
|
|
17
|
+
* polynomials. Refiners check monotonicity over the unit interval `[0, 1]` —
|
|
18
|
+
* the curve's natural parameter domain.
|
|
19
|
+
*
|
|
17
20
|
* @since 1.0.0
|
|
18
21
|
*/
|
|
19
|
-
interface CubicCurve2d extends Pipeable, TwoDimensional<CubicPolynomial
|
|
22
|
+
export interface CubicCurve2d<out XTraits = unknown, out YTraits = unknown> extends Pipeable, TwoDimensional<CubicPolynomial<XTraits>, CubicPolynomial<YTraits>> {
|
|
20
23
|
readonly [CubicCurve2dTypeId]: CubicCurve2dTypeId;
|
|
21
24
|
}
|
|
22
25
|
/**
|
|
@@ -27,18 +30,38 @@ interface CubicCurve2d extends Pipeable, TwoDimensional<CubicPolynomial> {
|
|
|
27
30
|
* @returns A new `CubicCurve2d` instance.
|
|
28
31
|
* @since 1.0.0
|
|
29
32
|
*/
|
|
30
|
-
declare const fromPolynomials: (x: CubicPolynomial, y: CubicPolynomial) => CubicCurve2d;
|
|
33
|
+
export declare const fromPolynomials: (x: CubicPolynomial, y: CubicPolynomial) => CubicCurve2d;
|
|
31
34
|
/**
|
|
32
|
-
* Creates a new `CubicCurve2d` instance from
|
|
35
|
+
* Creates a new `CubicCurve2d` instance from monomial coefficient vectors.
|
|
36
|
+
*
|
|
37
|
+
* Each argument bundles the per-axis coefficient at the given power: `c0`
|
|
38
|
+
* holds the x⁰ term, `c1` holds the x¹ term, and so on. The resulting curve
|
|
39
|
+
* evaluates to `c0 + c1·t + c2·t² + c3·t³` per axis.
|
|
33
40
|
*
|
|
34
|
-
* @param
|
|
35
|
-
* @param
|
|
36
|
-
* @param
|
|
37
|
-
* @param
|
|
41
|
+
* @param c0 - The x⁰ coefficients (x and y).
|
|
42
|
+
* @param c1 - The x¹ coefficients (x and y).
|
|
43
|
+
* @param c2 - The x² coefficients (x and y).
|
|
44
|
+
* @param c3 - The x³ coefficients (x and y).
|
|
38
45
|
* @returns A new `CubicCurve2d` instance.
|
|
39
|
-
* @since
|
|
46
|
+
* @since 2.0.0
|
|
47
|
+
*/
|
|
48
|
+
export declare const fromCoefficients: (c0: Vector2, c1: Vector2, c2: Vector2, c3: Vector2) => CubicCurve2d;
|
|
49
|
+
/**
|
|
50
|
+
* Creates a new `CubicCurve2d` instance from cubic Bézier control points.
|
|
51
|
+
*
|
|
52
|
+
* The four arguments are the Bernstein-basis control points: `p0` and `p3` are
|
|
53
|
+
* the curve's endpoints and `p1` and `p2` are the off-curve control handles.
|
|
54
|
+
* The implementation converts to the curve's internal monomial form in closed
|
|
55
|
+
* form.
|
|
56
|
+
*
|
|
57
|
+
* @param p0 - The first control point (curve start).
|
|
58
|
+
* @param p1 - The second control point (start handle).
|
|
59
|
+
* @param p2 - The third control point (end handle).
|
|
60
|
+
* @param p3 - The fourth control point (curve end).
|
|
61
|
+
* @returns A new `CubicCurve2d` instance whose curve matches the given Bézier.
|
|
62
|
+
* @since 2.0.0
|
|
40
63
|
*/
|
|
41
|
-
declare const
|
|
64
|
+
export declare const fromBezierPoints: (p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2) => CubicCurve2d;
|
|
42
65
|
/**
|
|
43
66
|
* Checks if a value is a `CubicCurve2d`.
|
|
44
67
|
*
|
|
@@ -46,8 +69,8 @@ declare const fromPoints: (p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2) =
|
|
|
46
69
|
* @returns `true` if the value is a `CubicCurve2d`, `false` otherwise.
|
|
47
70
|
* @since 1.0.0
|
|
48
71
|
*/
|
|
49
|
-
declare const isCubicCurve2d: (c: unknown) => c is CubicCurve2d;
|
|
50
|
-
declare const solve: {
|
|
72
|
+
export declare const isCubicCurve2d: (c: unknown) => c is CubicCurve2d;
|
|
73
|
+
export declare const solve: {
|
|
51
74
|
/**
|
|
52
75
|
* Solves the cubic curve for a given parameter t.
|
|
53
76
|
*
|
|
@@ -66,7 +89,7 @@ declare const solve: {
|
|
|
66
89
|
*/
|
|
67
90
|
(c: CubicCurve2d, t: number): Vector2;
|
|
68
91
|
};
|
|
69
|
-
declare const length: {
|
|
92
|
+
export declare const length: {
|
|
70
93
|
/**
|
|
71
94
|
* Calculates (approximates) the length of a cubic curve.
|
|
72
95
|
*
|
|
@@ -85,7 +108,63 @@ declare const length: {
|
|
|
85
108
|
*/
|
|
86
109
|
(i: Interval): (c: CubicCurve2d) => number;
|
|
87
110
|
};
|
|
88
|
-
declare const
|
|
111
|
+
export declare const solveAtX: {
|
|
112
|
+
/**
|
|
113
|
+
* Evaluates the curve's y values at a given x. Because the x polynomial is
|
|
114
|
+
* `Monotonic`, the inverse has at most one solution — at most one y value.
|
|
115
|
+
*
|
|
116
|
+
* @param c - The cubic curve.
|
|
117
|
+
* @param x - The x coordinate.
|
|
118
|
+
* @returns Zero or one y values, in t-ascending order.
|
|
119
|
+
* @since 2.0.0
|
|
120
|
+
*/
|
|
121
|
+
<XT extends Monotonic, YT>(c: CubicCurve2d<XT, YT>, x: number): Solution.AtMostOne<number>;
|
|
122
|
+
/**
|
|
123
|
+
* Evaluates the curve's y values at a given x. The result is the y values
|
|
124
|
+
* the curve passes through where x(t) = the given x — up to three solutions
|
|
125
|
+
* for a cubic curve.
|
|
126
|
+
*
|
|
127
|
+
* @param c - The cubic curve.
|
|
128
|
+
* @param x - The x coordinate.
|
|
129
|
+
* @returns The y values at x, in t-ascending order.
|
|
130
|
+
* @since 2.0.0
|
|
131
|
+
*/
|
|
132
|
+
<XT, YT>(c: CubicCurve2d<XT, YT>, x: number): Solution.AtMostThree<number>;
|
|
133
|
+
/** @since 2.0.0 */
|
|
134
|
+
(x: number): {
|
|
135
|
+
<XT extends Monotonic, YT>(c: CubicCurve2d<XT, YT>): Solution.AtMostOne<number>;
|
|
136
|
+
<XT, YT>(c: CubicCurve2d<XT, YT>): Solution.AtMostThree<number>;
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
export declare const solveAtY: {
|
|
140
|
+
/**
|
|
141
|
+
* Evaluates the curve's x values at a given y. Because the y polynomial is
|
|
142
|
+
* `Monotonic`, the inverse has at most one solution.
|
|
143
|
+
*
|
|
144
|
+
* @param c - The cubic curve.
|
|
145
|
+
* @param y - The y coordinate.
|
|
146
|
+
* @returns Zero or one x values, in t-ascending order.
|
|
147
|
+
* @since 2.0.0
|
|
148
|
+
*/
|
|
149
|
+
<XT, YT extends Monotonic>(c: CubicCurve2d<XT, YT>, y: number): Solution.AtMostOne<number>;
|
|
150
|
+
/**
|
|
151
|
+
* Evaluates the curve's x values at a given y. The result is the x values
|
|
152
|
+
* the curve passes through where y(t) = the given y — up to three solutions
|
|
153
|
+
* for a cubic curve.
|
|
154
|
+
*
|
|
155
|
+
* @param c - The cubic curve.
|
|
156
|
+
* @param y - The y coordinate.
|
|
157
|
+
* @returns The x values at y, in t-ascending order.
|
|
158
|
+
* @since 2.0.0
|
|
159
|
+
*/
|
|
160
|
+
<XT, YT>(c: CubicCurve2d<XT, YT>, y: number): Solution.AtMostThree<number>;
|
|
161
|
+
/** @since 2.0.0 */
|
|
162
|
+
(y: number): {
|
|
163
|
+
<XT, YT extends Monotonic>(c: CubicCurve2d<XT, YT>): Solution.AtMostOne<number>;
|
|
164
|
+
<XT, YT>(c: CubicCurve2d<XT, YT>): Solution.AtMostThree<number>;
|
|
165
|
+
};
|
|
166
|
+
};
|
|
167
|
+
export declare const curvature: {
|
|
89
168
|
/**
|
|
90
169
|
* Calculates the curvature of a cubic curve at a given parameter.
|
|
91
170
|
*
|
|
@@ -104,6 +183,33 @@ declare const curvature: {
|
|
|
104
183
|
*/
|
|
105
184
|
(t: number): (c: CubicCurve2d) => number;
|
|
106
185
|
};
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
186
|
+
/**
|
|
187
|
+
* Computes the axis-aligned bounding box of the curve over its parameter
|
|
188
|
+
* domain `[0, 1]`. Accounts for up to two interior extrema per axis, so the
|
|
189
|
+
* box is tight against the curve and not just the control polygon.
|
|
190
|
+
*
|
|
191
|
+
* @param c - The cubic curve.
|
|
192
|
+
* @returns A closed `Box2d` enclosing the curve.
|
|
193
|
+
* @since 2.0.0
|
|
194
|
+
*/
|
|
195
|
+
export declare const boundingBox: (c: CubicCurve2d) => Interval2d<Closed, Closed>;
|
|
196
|
+
/**
|
|
197
|
+
* Type-narrowing predicate: refines both axes' traits to include `Monotonic`
|
|
198
|
+
* when both x and y polynomials are monotonic over the unit interval `[0, 1]`.
|
|
199
|
+
*
|
|
200
|
+
* For checking only one axis, call the polynomial-level refiner directly:
|
|
201
|
+
* `CubicPolynomial.isMonotonic(curve.x, Interval.unit)`.
|
|
202
|
+
*
|
|
203
|
+
* @since 2.0.0
|
|
204
|
+
*/
|
|
205
|
+
export declare const isMonotonic: <XT, YT>(c: CubicCurve2d<XT, YT>) => c is CubicCurve2d<XT & Monotonic, YT & Monotonic>;
|
|
206
|
+
/** @since 2.0.0 */
|
|
207
|
+
export declare const isIncreasing: <XT, YT>(c: CubicCurve2d<XT, YT>) => c is CubicCurve2d<XT & Increasing, YT & Increasing>;
|
|
208
|
+
/** @since 2.0.0 */
|
|
209
|
+
export declare const isDecreasing: <XT, YT>(c: CubicCurve2d<XT, YT>) => c is CubicCurve2d<XT & Decreasing, YT & Decreasing>;
|
|
210
|
+
/** @since 2.0.0 */
|
|
211
|
+
export declare const asMonotonic: <XT, YT>(c: CubicCurve2d<XT, YT>) => CubicCurve2d<XT & Monotonic, YT & Monotonic>;
|
|
212
|
+
/** @since 2.0.0 */
|
|
213
|
+
export declare const asIncreasing: <XT, YT>(c: CubicCurve2d<XT, YT>) => CubicCurve2d<XT & Increasing, YT & Increasing>;
|
|
214
|
+
/** @since 2.0.0 */
|
|
215
|
+
export declare const asDecreasing: <XT, YT>(c: CubicCurve2d<XT, YT>) => CubicCurve2d<XT & Decreasing, YT & Decreasing>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as LinearCurve2dNs from './linear2d.ts';
|
|
2
|
+
import * as QuadraticCurve2dNs from './quadratic2d.ts';
|
|
3
|
+
import * as CubicCurve2dNs from './cubic2d.ts';
|
|
4
|
+
import * as RationalCubicCurve2dNs from './rationalCubic2d.ts';
|
|
5
|
+
export type LinearCurve2d<XTraits = unknown, YTraits = unknown> = LinearCurve2dNs.LinearCurve2d<XTraits, YTraits>;
|
|
6
|
+
export { LinearCurve2dNs as LinearCurve2d };
|
|
7
|
+
export type QuadraticCurve2d<XTraits = unknown, YTraits = unknown> = QuadraticCurve2dNs.QuadraticCurve2d<XTraits, YTraits>;
|
|
8
|
+
export { QuadraticCurve2dNs as QuadraticCurve2d };
|
|
9
|
+
export type CubicCurve2d<XTraits = unknown, YTraits = unknown> = CubicCurve2dNs.CubicCurve2d<XTraits, YTraits>;
|
|
10
|
+
export { CubicCurve2dNs as CubicCurve2d };
|
|
11
|
+
export type RationalCubicCurve2d<XTraits = unknown, YTraits = unknown> = RationalCubicCurve2dNs.RationalCubicCurve2d<XTraits, YTraits>;
|
|
12
|
+
export { RationalCubicCurve2dNs as RationalCubicCurve2d };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { S as linear2d_exports, g as quadratic2d_exports, o as cubic2d_exports, r as rationalCubic2d_exports } from "../shared/rationalCubic2d-3S5K69Jy.mjs";
|
|
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
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import '../
|
|
7
|
-
import '../
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
type
|
|
11
|
-
|
|
1
|
+
import type { Interval2d } from '../interval/interval2d.ts';
|
|
2
|
+
import type { TwoDimensional } from '../dimensions.ts';
|
|
3
|
+
import type { Closed, Interval } from '../interval/interval.ts';
|
|
4
|
+
import type { Pipeable } from '../utils.ts';
|
|
5
|
+
import type { LinearPolynomial } from '../polynomial/linear.ts';
|
|
6
|
+
import type { Decreasing, Increasing, Monotonic } from '../polynomial/traits.ts';
|
|
7
|
+
import type * as Solution from '../solution/solution.ts';
|
|
8
|
+
import type { Vector2 } from '../vector/vector2.ts';
|
|
9
|
+
import type { LinearCurve2dTypeId } from './linear2d.internal.ts';
|
|
10
|
+
export type { Monotonic, Increasing, Decreasing } from '../polynomial/traits.ts';
|
|
12
11
|
/**
|
|
13
12
|
* A linear curve in 2D space.
|
|
14
13
|
*
|
|
15
14
|
* All fields are readonly and immutable, and all operations create new instances.
|
|
16
15
|
*
|
|
16
|
+
* The two type parameters carry the trait sets of the curve's per-axis
|
|
17
|
+
* polynomials. Refiners like `isMonotonic` lift each axis's monotonicity into
|
|
18
|
+
* the curve's combined trait set.
|
|
19
|
+
*
|
|
17
20
|
* @since 1.0.0
|
|
18
21
|
*/
|
|
19
|
-
interface LinearCurve2d extends Pipeable, TwoDimensional<LinearPolynomial
|
|
22
|
+
export interface LinearCurve2d<out XTraits = unknown, out YTraits = unknown> extends Pipeable, TwoDimensional<LinearPolynomial<XTraits>, LinearPolynomial<YTraits>> {
|
|
20
23
|
readonly [LinearCurve2dTypeId]: LinearCurve2dTypeId;
|
|
21
24
|
}
|
|
22
25
|
/**
|
|
@@ -27,14 +30,33 @@ interface LinearCurve2d extends Pipeable, TwoDimensional<LinearPolynomial> {
|
|
|
27
30
|
* @returns A new `LinearCurve2d` instance.
|
|
28
31
|
* @since 1.0.0
|
|
29
32
|
*/
|
|
30
|
-
declare const fromPolynomials: (x: LinearPolynomial, y: LinearPolynomial) => LinearCurve2d;
|
|
33
|
+
export declare const fromPolynomials: (x: LinearPolynomial, y: LinearPolynomial) => LinearCurve2d;
|
|
34
|
+
/**
|
|
35
|
+
* Creates a new `LinearCurve2d` instance from monomial coefficient vectors.
|
|
36
|
+
*
|
|
37
|
+
* Each argument bundles the per-axis coefficient at the given power: `c0`
|
|
38
|
+
* holds the x⁰ term, `c1` holds the x¹ term. The resulting curve evaluates to
|
|
39
|
+
* `c0 + c1·t` per axis.
|
|
40
|
+
*
|
|
41
|
+
* @param c0 - The x⁰ coefficients (x and y).
|
|
42
|
+
* @param c1 - The x¹ coefficients (x and y).
|
|
43
|
+
* @returns A new `LinearCurve2d` instance.
|
|
44
|
+
* @since 2.0.0
|
|
45
|
+
*/
|
|
46
|
+
export declare const fromCoefficients: (c0: Vector2, c1: Vector2) => LinearCurve2d;
|
|
31
47
|
/**
|
|
32
|
-
* Creates a new `LinearCurve2d` instance from
|
|
48
|
+
* Creates a new `LinearCurve2d` instance from a pair of endpoints.
|
|
49
|
+
*
|
|
50
|
+
* `p0` is the curve at `t = 0`, `p1` is the curve at `t = 1`. The
|
|
51
|
+
* implementation converts to the curve's internal monomial form (slope-form
|
|
52
|
+
* polynomial in `t`) in closed form.
|
|
33
53
|
*
|
|
34
|
-
* @param p0 - The
|
|
35
|
-
* @param p1 - The
|
|
54
|
+
* @param p0 - The curve's start point.
|
|
55
|
+
* @param p1 - The curve's end point.
|
|
56
|
+
* @returns A new `LinearCurve2d` instance whose curve matches the line from `p0` to `p1`.
|
|
57
|
+
* @since 2.0.0
|
|
36
58
|
*/
|
|
37
|
-
declare const
|
|
59
|
+
export declare const fromEndpoints: (p0: Vector2, p1: Vector2) => LinearCurve2d;
|
|
38
60
|
/**
|
|
39
61
|
* Checks if a value is a `LinearCurve2d`.
|
|
40
62
|
*
|
|
@@ -42,7 +64,7 @@ declare const fromPoints: (p0: Vector2, p1: Vector2) => LinearCurve2d;
|
|
|
42
64
|
* @returns `true` if the value is a `LinearCurve2d`, `false` otherwise.
|
|
43
65
|
* @since 1.0.0
|
|
44
66
|
*/
|
|
45
|
-
declare const isLinearCurve2d: (c: unknown) => c is LinearCurve2d;
|
|
67
|
+
export declare const isLinearCurve2d: (c: unknown) => c is LinearCurve2d;
|
|
46
68
|
/**
|
|
47
69
|
* Gets the derivative of a linear curve as a vector
|
|
48
70
|
*
|
|
@@ -50,8 +72,8 @@ declare const isLinearCurve2d: (c: unknown) => c is LinearCurve2d;
|
|
|
50
72
|
* @returns The derivative of the linear curve as a vector.
|
|
51
73
|
* @since 1.0.0
|
|
52
74
|
*/
|
|
53
|
-
declare const derivative: (c: LinearCurve2d) => Vector2;
|
|
54
|
-
declare const solve: {
|
|
75
|
+
export declare const derivative: (c: LinearCurve2d) => Vector2;
|
|
76
|
+
export declare const solve: {
|
|
55
77
|
/**
|
|
56
78
|
* Solves the linear curve for a given parameter t.
|
|
57
79
|
*
|
|
@@ -70,7 +92,7 @@ declare const solve: {
|
|
|
70
92
|
*/
|
|
71
93
|
(c: LinearCurve2d, t: number): Vector2;
|
|
72
94
|
};
|
|
73
|
-
declare const length: {
|
|
95
|
+
export declare const length: {
|
|
74
96
|
/**
|
|
75
97
|
* Calculates (approximates) the length of a linear curve.
|
|
76
98
|
*
|
|
@@ -89,6 +111,85 @@ declare const length: {
|
|
|
89
111
|
*/
|
|
90
112
|
(i: Interval): (c: LinearCurve2d) => number;
|
|
91
113
|
};
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
114
|
+
/**
|
|
115
|
+
* Computes the axis-aligned bounding box of the curve over its parameter
|
|
116
|
+
* domain `[0, 1]`. For a linear curve this is the closed box enclosing the
|
|
117
|
+
* two endpoints.
|
|
118
|
+
*
|
|
119
|
+
* @param c - The linear curve.
|
|
120
|
+
* @returns A closed `Box2d` enclosing the curve.
|
|
121
|
+
* @since 2.0.0
|
|
122
|
+
*/
|
|
123
|
+
export declare const boundingBox: (c: LinearCurve2d) => Interval2d<Closed, Closed>;
|
|
124
|
+
export declare const solveAtX: {
|
|
125
|
+
/**
|
|
126
|
+
* Evaluates the curve's y value at a given x. A linear curve crosses any
|
|
127
|
+
* vertical line at most once (within the curve's parameter domain `[0, 1]`),
|
|
128
|
+
* so the result is at most one y. Returns the empty tuple when x is outside
|
|
129
|
+
* the curve's range or when the curve's x polynomial is constant.
|
|
130
|
+
*
|
|
131
|
+
* @param c - The linear curve.
|
|
132
|
+
* @param x - The x coordinate.
|
|
133
|
+
* @returns The y value at x, or empty when x is undefined for this curve.
|
|
134
|
+
* @since 2.0.0
|
|
135
|
+
*/
|
|
136
|
+
<XT, YT>(c: LinearCurve2d<XT, YT>, x: number): Solution.AtMostOne<number>;
|
|
137
|
+
/** @since 2.0.0 */
|
|
138
|
+
(x: number): <XT, YT>(c: LinearCurve2d<XT, YT>) => Solution.AtMostOne<number>;
|
|
139
|
+
};
|
|
140
|
+
export declare const solveAtY: {
|
|
141
|
+
/**
|
|
142
|
+
* Evaluates the curve's x value at a given y. A linear curve crosses any
|
|
143
|
+
* horizontal line at most once (within the curve's parameter domain
|
|
144
|
+
* `[0, 1]`), so the result is at most one x.
|
|
145
|
+
*
|
|
146
|
+
* @param c - The linear curve.
|
|
147
|
+
* @param y - The y coordinate.
|
|
148
|
+
* @returns The x value at y, or empty when y is undefined for this curve.
|
|
149
|
+
* @since 2.0.0
|
|
150
|
+
*/
|
|
151
|
+
<XT, YT>(c: LinearCurve2d<XT, YT>, y: number): Solution.AtMostOne<number>;
|
|
152
|
+
/** @since 2.0.0 */
|
|
153
|
+
(y: number): <XT, YT>(c: LinearCurve2d<XT, YT>) => Solution.AtMostOne<number>;
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Type-narrowing predicate: refines both axes' traits to include `Monotonic`
|
|
157
|
+
* when both the x and y polynomials are strictly monotonic. When both axes
|
|
158
|
+
* are monotonic, the curve is invertible in either direction.
|
|
159
|
+
*
|
|
160
|
+
* For checking only one axis, call the polynomial-level refiner directly:
|
|
161
|
+
* `LinearPolynomial.isMonotonic(curve.x)`.
|
|
162
|
+
*
|
|
163
|
+
* @since 2.0.0
|
|
164
|
+
*/
|
|
165
|
+
export declare const isMonotonic: <XT, YT>(c: LinearCurve2d<XT, YT>) => c is LinearCurve2d<XT & Monotonic, YT & Monotonic>;
|
|
166
|
+
/**
|
|
167
|
+
* Type-narrowing predicate: refines both axes' traits to include `Increasing`.
|
|
168
|
+
*
|
|
169
|
+
* @since 2.0.0
|
|
170
|
+
*/
|
|
171
|
+
export declare const isIncreasing: <XT, YT>(c: LinearCurve2d<XT, YT>) => c is LinearCurve2d<XT & Increasing, YT & Increasing>;
|
|
172
|
+
/**
|
|
173
|
+
* Type-narrowing predicate: refines both axes' traits to include `Decreasing`.
|
|
174
|
+
*
|
|
175
|
+
* @since 2.0.0
|
|
176
|
+
*/
|
|
177
|
+
export declare const isDecreasing: <XT, YT>(c: LinearCurve2d<XT, YT>) => c is LinearCurve2d<XT & Decreasing, YT & Decreasing>;
|
|
178
|
+
/**
|
|
179
|
+
* Asserts monotonicity in both axes, throwing on failure.
|
|
180
|
+
*
|
|
181
|
+
* @since 2.0.0
|
|
182
|
+
*/
|
|
183
|
+
export declare const asMonotonic: <XT, YT>(c: LinearCurve2d<XT, YT>) => LinearCurve2d<XT & Monotonic, YT & Monotonic>;
|
|
184
|
+
/**
|
|
185
|
+
* Asserts that both axes are strictly increasing, throwing on failure.
|
|
186
|
+
*
|
|
187
|
+
* @since 2.0.0
|
|
188
|
+
*/
|
|
189
|
+
export declare const asIncreasing: <XT, YT>(c: LinearCurve2d<XT, YT>) => LinearCurve2d<XT & Increasing, YT & Increasing>;
|
|
190
|
+
/**
|
|
191
|
+
* Asserts that both axes are strictly decreasing, throwing on failure.
|
|
192
|
+
*
|
|
193
|
+
* @since 2.0.0
|
|
194
|
+
*/
|
|
195
|
+
export declare const asDecreasing: <XT, YT>(c: LinearCurve2d<XT, YT>) => LinearCurve2d<XT & Decreasing, YT & Decreasing>;
|