curvy 2.0.0-alpha.6 → 2.0.0-alpha.8
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.d.mts → characteristic.d.ts} +9 -17
- package/dist/characteristic/index.d.ts +1 -0
- package/dist/characteristic/index.mjs +1 -1
- package/dist/curve/cubic2d.d.ts +215 -0
- package/dist/curve/cubic2d.internal.d.ts +2 -0
- package/dist/curve/index.d.ts +12 -0
- package/dist/curve/index.mjs +1 -1
- package/dist/curve/linear2d.d.ts +195 -0
- package/dist/curve/linear2d.internal.d.ts +2 -0
- package/dist/curve/quadratic2d.d.ts +223 -0
- 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 +2 -2
- 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 +1 -1
- package/dist/matrix/index.mjs.map +1 -1
- package/dist/matrix/matrix2x2.d.ts +335 -0
- package/dist/matrix/matrix2x2.internal.d.ts +2 -0
- package/dist/matrix/matrix3x3.d.ts +396 -0
- package/dist/matrix/matrix3x3.internal.d.ts +4 -0
- package/dist/matrix/matrix4x4.d.ts +439 -0
- package/dist/matrix/matrix4x4.internal.d.ts +2 -0
- package/dist/number.d.ts +276 -0
- package/dist/number.mjs.map +1 -1
- package/dist/path/cubic2d.d.ts +262 -0
- package/dist/path/cubic2d.internal.d.ts +2 -0
- package/dist/path/index.d.ts +12 -0
- package/dist/path/index.mjs +413 -4
- package/dist/path/index.mjs.map +1 -1
- package/dist/path/linear2d.d.ts +245 -0
- package/dist/path/linear2d.internal.d.ts +2 -0
- package/dist/path/quadratic2d.d.ts +234 -0
- 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 -0
- 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 +2 -2
- package/dist/polynomial/linear.d.ts +317 -0
- package/dist/polynomial/linear.internal.d.ts +2 -0
- package/dist/polynomial/monotonicity.d.ts +3 -0
- package/dist/polynomial/quadratic.d.ts +371 -0
- 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-DLlhja-I.mjs → characteristic-D9yZWCym.mjs} +3 -3
- package/dist/shared/characteristic-D9yZWCym.mjs.map +1 -0
- package/dist/shared/{cubic-CMonq6bg.mjs → cubic-BK8xjSkd.mjs} +79 -4
- package/dist/shared/cubic-BK8xjSkd.mjs.map +1 -0
- package/dist/shared/{interval-X1EYuf-T.mjs → interval-CqC3ZIqj.mjs} +40 -1
- package/dist/shared/interval-CqC3ZIqj.mjs.map +1 -0
- package/dist/shared/{interval2d-ca0J1NMr.mjs → interval2d-BMDmeL1M.mjs} +45 -4
- package/dist/shared/interval2d-BMDmeL1M.mjs.map +1 -0
- package/dist/shared/{matrix4x4-Ck2WROK-.mjs → matrix4x4-qyRufxfs.mjs} +62 -3
- package/dist/shared/matrix4x4-qyRufxfs.mjs.map +1 -0
- package/dist/shared/{quadratic-DyeMtvET.mjs → quadratic-CWXIRh42.mjs} +2 -2
- package/dist/shared/quadratic-CWXIRh42.mjs.map +1 -0
- package/dist/shared/{rationalCubic2d-Vw4qGPZj.mjs → rationalCubic2d-BZvT9s5N.mjs} +218 -5
- package/dist/shared/rationalCubic2d-BZvT9s5N.mjs.map +1 -0
- package/dist/shared/{rationalCubic2d-D658ltUM.mjs → rationalCubic2d-DaFTrUXw.mjs} +250 -36
- package/dist/shared/rationalCubic2d-DaFTrUXw.mjs.map +1 -0
- package/dist/shared/{solution-3TDATEMn.mjs → solution-UKGK826h.mjs} +22 -2
- package/dist/shared/solution-UKGK826h.mjs.map +1 -0
- package/dist/shared/{vector2-CCuJx1rX.mjs → vector2-CWU3cPB2.mjs} +12 -2
- package/dist/shared/vector2-CWU3cPB2.mjs.map +1 -0
- package/dist/shared/{vector2.internal-DU_E808S.mjs → vector2.internal-BL8hFl1c.mjs} +31 -2
- package/dist/shared/vector2.internal-BL8hFl1c.mjs.map +1 -0
- package/dist/shared/{vector3-C-qgKAjR.mjs → vector3-DmMm6pX8.mjs} +12 -2
- package/dist/shared/vector3-DmMm6pX8.mjs.map +1 -0
- package/dist/shared/{vector4-BhOKDhD5.mjs → vector4-oqPPp45j.mjs} +12 -2
- package/dist/shared/vector4-oqPPp45j.mjs.map +1 -0
- package/dist/shared/{vector4.internal-5XcaX12X.mjs → vector4.internal-BnnTjVIr.mjs} +45 -2
- package/dist/shared/vector4.internal-BnnTjVIr.mjs.map +1 -0
- package/dist/solution/index.d.ts +1 -0
- package/dist/solution/index.mjs +1 -1
- package/dist/{shared/solution-Cf_zoKFU.d.mts → solution/solution.d.ts} +64 -71
- package/dist/solution/solution.internal.d.ts +2 -0
- package/dist/splines/basis2d.d.ts +118 -0
- package/dist/splines/basis2d.internal.d.ts +2 -0
- package/dist/splines/bezier2d.d.ts +198 -0
- package/dist/splines/bezier2d.internal.d.ts +2 -0
- package/dist/splines/cardinal2d.d.ts +269 -0
- package/dist/splines/cardinal2d.internal.d.ts +2 -0
- package/dist/splines/hermite2d.d.ts +113 -0
- package/dist/splines/hermite2d.internal.d.ts +2 -0
- package/dist/splines/index.d.ts +15 -0
- package/dist/splines/index.mjs +62 -8
- package/dist/splines/index.mjs.map +1 -1
- 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 +73 -0
- package/dist/vector/index.d.ts +9 -0
- package/dist/vector/index.mjs +3 -3
- package/dist/vector/vector2.d.ts +449 -0
- package/dist/vector/vector2.internal.d.ts +4 -0
- package/dist/vector/vector3.d.ts +454 -0
- package/dist/vector/vector3.internal.d.ts +2 -0
- package/dist/vector/vector4.d.ts +258 -0
- package/dist/vector/vector4.internal.d.ts +2 -0
- package/package.json +13 -13
- package/dist/curve/index.d.mts +0 -2
- package/dist/interval/index.d.mts +0 -3
- package/dist/matrix/index.d.mts +0 -2
- package/dist/number.d.mts +0 -280
- package/dist/path/index.d.mts +0 -261
- package/dist/polynomial/index.d.mts +0 -2
- package/dist/shared/characteristic-DLlhja-I.mjs.map +0 -1
- package/dist/shared/cubic-C3ZMAoGj.d.mts +0 -1124
- package/dist/shared/cubic-CMonq6bg.mjs.map +0 -1
- package/dist/shared/interval-CSntLeSX.d.mts +0 -533
- package/dist/shared/interval-X1EYuf-T.mjs.map +0 -1
- package/dist/shared/interval2d-D42_0ka1.d.mts +0 -172
- package/dist/shared/interval2d-ca0J1NMr.mjs.map +0 -1
- package/dist/shared/matrix4x4-Ck2WROK-.mjs.map +0 -1
- package/dist/shared/matrix4x4-gy9ejrX2.d.mts +0 -1183
- package/dist/shared/quadratic-DyeMtvET.mjs.map +0 -1
- package/dist/shared/rationalCubic2d-C1RBShBF.d.mts +0 -818
- package/dist/shared/rationalCubic2d-D658ltUM.mjs.map +0 -1
- package/dist/shared/rationalCubic2d-DFFvp5S1.d.mts +0 -308
- package/dist/shared/rationalCubic2d-Vw4qGPZj.mjs.map +0 -1
- package/dist/shared/solution-3TDATEMn.mjs.map +0 -1
- package/dist/shared/utils-MCckigYk.d.mts +0 -76
- package/dist/shared/vector2-5GyA0jBj.d.mts +0 -470
- package/dist/shared/vector2-CCuJx1rX.mjs.map +0 -1
- package/dist/shared/vector2.internal-DU_E808S.mjs.map +0 -1
- package/dist/shared/vector3-BfOPFZEn.d.mts +0 -703
- package/dist/shared/vector3-C-qgKAjR.mjs.map +0 -1
- package/dist/shared/vector4-BhOKDhD5.mjs.map +0 -1
- package/dist/shared/vector4.internal-5XcaX12X.mjs.map +0 -1
- package/dist/solution/index.d.mts +0 -2
- package/dist/splines/index.d.mts +0 -858
- package/dist/utils.d.mts +0 -2
- package/dist/vector/index.d.mts +0 -3
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
//#region src/characteristic/characteristic.d.ts
|
|
6
|
-
declare namespace characteristic_d_exports {
|
|
7
|
-
export { apply, cubicBasisSpline, cubicBezier, cubicCardinal, cubicCatmullRom, cubicHermite };
|
|
8
|
-
}
|
|
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';
|
|
9
4
|
/**
|
|
10
5
|
* The cubic Bézier characteristic matrix.
|
|
11
6
|
*
|
|
@@ -16,7 +11,7 @@ declare namespace characteristic_d_exports {
|
|
|
16
11
|
*
|
|
17
12
|
* @since 2.0.0
|
|
18
13
|
*/
|
|
19
|
-
declare const cubicBezier: Matrix4x4;
|
|
14
|
+
export declare const cubicBezier: Matrix4x4.Matrix4x4;
|
|
20
15
|
/**
|
|
21
16
|
* The cubic Hermite characteristic matrix.
|
|
22
17
|
*
|
|
@@ -25,7 +20,7 @@ declare const cubicBezier: Matrix4x4;
|
|
|
25
20
|
*
|
|
26
21
|
* @since 2.0.0
|
|
27
22
|
*/
|
|
28
|
-
declare const cubicHermite: Matrix4x4;
|
|
23
|
+
export declare const cubicHermite: Matrix4x4.Matrix4x4;
|
|
29
24
|
/**
|
|
30
25
|
* The uniform cubic B-spline (basis spline) characteristic matrix.
|
|
31
26
|
*
|
|
@@ -36,7 +31,7 @@ declare const cubicHermite: Matrix4x4;
|
|
|
36
31
|
*
|
|
37
32
|
* @since 2.0.0
|
|
38
33
|
*/
|
|
39
|
-
declare const cubicBasisSpline: Matrix4x4;
|
|
34
|
+
export declare const cubicBasisSpline: Matrix4x4.Matrix4x4;
|
|
40
35
|
/**
|
|
41
36
|
* The cubic Cardinal spline characteristic matrix, parameterized by tension.
|
|
42
37
|
*
|
|
@@ -54,7 +49,7 @@ declare const cubicBasisSpline: Matrix4x4;
|
|
|
54
49
|
* @returns The characteristic matrix for that tension.
|
|
55
50
|
* @since 2.0.0
|
|
56
51
|
*/
|
|
57
|
-
declare const cubicCardinal: (tension: number) => Matrix4x4;
|
|
52
|
+
export declare const cubicCardinal: (tension: number) => Matrix4x4.Matrix4x4;
|
|
58
53
|
/**
|
|
59
54
|
* The cubic Catmull-Rom characteristic matrix — Cardinal with tension `0.5`.
|
|
60
55
|
* The most common Cardinal-family variant; reused widely enough to deserve
|
|
@@ -62,7 +57,7 @@ declare const cubicCardinal: (tension: number) => Matrix4x4;
|
|
|
62
57
|
*
|
|
63
58
|
* @since 2.0.0
|
|
64
59
|
*/
|
|
65
|
-
declare const cubicCatmullRom: Matrix4x4;
|
|
60
|
+
export declare const cubicCatmullRom: Matrix4x4.Matrix4x4;
|
|
66
61
|
/**
|
|
67
62
|
* Applies a characteristic matrix to N channels of control values, producing
|
|
68
63
|
* N cubic polynomials in monomial form.
|
|
@@ -82,7 +77,4 @@ declare const cubicCatmullRom: Matrix4x4;
|
|
|
82
77
|
* @returns A tuple of cubic polynomials, one per input channel.
|
|
83
78
|
* @since 2.0.0
|
|
84
79
|
*/
|
|
85
|
-
declare const apply: <const Channels extends ReadonlyArray<Vector4>>(matrix: Matrix4x4, ...channels: Channels) => { readonly [K in keyof Channels]: CubicPolynomial };
|
|
86
|
-
//#endregion
|
|
87
|
-
export { characteristic_d_exports as Characteristic };
|
|
88
|
-
//# sourceMappingURL=index.d.mts.map
|
|
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';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as characteristic_exports } from "../shared/characteristic-
|
|
1
|
+
import { n as characteristic_exports } from "../shared/characteristic-D9yZWCym.mjs";
|
|
2
2
|
export { characteristic_exports as Characteristic };
|
|
@@ -0,0 +1,215 @@
|
|
|
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';
|
|
11
|
+
/**
|
|
12
|
+
* A cubic curve in 2D space.
|
|
13
|
+
*
|
|
14
|
+
* All fields are readonly and immutable, and all operations create new instances.
|
|
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
|
+
*
|
|
20
|
+
* @since 1.0.0
|
|
21
|
+
*/
|
|
22
|
+
export interface CubicCurve2d<out XTraits = unknown, out YTraits = unknown> extends Pipeable, TwoDimensional<CubicPolynomial<XTraits>, CubicPolynomial<YTraits>> {
|
|
23
|
+
readonly [CubicCurve2dTypeId]: CubicCurve2dTypeId;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new `CubicCurve2d` instance from polynomial parameters.
|
|
27
|
+
*
|
|
28
|
+
* @param x - The x polynomial.
|
|
29
|
+
* @param y - The y polynomial.
|
|
30
|
+
* @returns A new `CubicCurve2d` instance.
|
|
31
|
+
* @since 1.0.0
|
|
32
|
+
*/
|
|
33
|
+
export declare const fromPolynomials: (x: CubicPolynomial, y: CubicPolynomial) => CubicCurve2d;
|
|
34
|
+
/**
|
|
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.
|
|
40
|
+
*
|
|
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).
|
|
45
|
+
* @returns A new `CubicCurve2d` instance.
|
|
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
|
|
63
|
+
*/
|
|
64
|
+
export declare const fromBezierPoints: (p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2) => CubicCurve2d;
|
|
65
|
+
/**
|
|
66
|
+
* Checks if a value is a `CubicCurve2d`.
|
|
67
|
+
*
|
|
68
|
+
* @param c - The value to check.
|
|
69
|
+
* @returns `true` if the value is a `CubicCurve2d`, `false` otherwise.
|
|
70
|
+
* @since 1.0.0
|
|
71
|
+
*/
|
|
72
|
+
export declare const isCubicCurve2d: (c: unknown) => c is CubicCurve2d;
|
|
73
|
+
export declare const solve: {
|
|
74
|
+
/**
|
|
75
|
+
* Solves the cubic curve for a given parameter t.
|
|
76
|
+
*
|
|
77
|
+
* @param t - The parameter value.
|
|
78
|
+
* @returns A function that takes a cubic curve and returns the point on the curve at parameter t.
|
|
79
|
+
* @since 1.0.0
|
|
80
|
+
*/
|
|
81
|
+
(t: number): (c: CubicCurve2d) => Vector2;
|
|
82
|
+
/**
|
|
83
|
+
* Solves the cubic curve for a given parameter t.
|
|
84
|
+
*
|
|
85
|
+
* @param c - The cubic curve to solve.
|
|
86
|
+
* @param t - The parameter value.
|
|
87
|
+
* @returns The point on the curve at parameter t.
|
|
88
|
+
* @since 1.0.0
|
|
89
|
+
*/
|
|
90
|
+
(c: CubicCurve2d, t: number): Vector2;
|
|
91
|
+
};
|
|
92
|
+
export declare const length: {
|
|
93
|
+
/**
|
|
94
|
+
* Calculates (approximates) the length of a cubic curve.
|
|
95
|
+
*
|
|
96
|
+
* @param c - The cubic curve to calculate the length of.
|
|
97
|
+
* @param i - The interval over which to calculate the length.
|
|
98
|
+
* @returns The length of the cubic curve.
|
|
99
|
+
* @since 1.0.0
|
|
100
|
+
*/
|
|
101
|
+
(c: CubicCurve2d, i: Interval): number;
|
|
102
|
+
/**
|
|
103
|
+
* Calculates (approximates) the length of a cubic curve.
|
|
104
|
+
*
|
|
105
|
+
* @param i - The interval over which to calculate the length.
|
|
106
|
+
* @returns A function that takes a cubic curve and returns the length of the cubic curve.
|
|
107
|
+
* @since 1.0.0
|
|
108
|
+
*/
|
|
109
|
+
(i: Interval): (c: CubicCurve2d) => number;
|
|
110
|
+
};
|
|
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: {
|
|
168
|
+
/**
|
|
169
|
+
* Calculates the curvature of a cubic curve at a given parameter.
|
|
170
|
+
*
|
|
171
|
+
* @param c - The cubic curve to calculate the curvature for.
|
|
172
|
+
* @param t - The parameter value.
|
|
173
|
+
* @returns The curvature of the cubic curve at parameter t.
|
|
174
|
+
* @since 1.0.0
|
|
175
|
+
*/
|
|
176
|
+
(c: CubicCurve2d, t: number): number;
|
|
177
|
+
/**
|
|
178
|
+
* Calculates the curvature of a cubic curve at a given parameter.
|
|
179
|
+
*
|
|
180
|
+
* @param t - The parameter value.
|
|
181
|
+
* @returns A function that takes a cubic curve and returns the curvature of the cubic curve at parameter t.
|
|
182
|
+
* @since 1.0.0
|
|
183
|
+
*/
|
|
184
|
+
(t: number): (c: CubicCurve2d) => number;
|
|
185
|
+
};
|
|
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 };
|
package/dist/curve/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { S as linear2d_exports, g as quadratic2d_exports, o as cubic2d_exports, r as rationalCubic2d_exports } from "../shared/rationalCubic2d-DaFTrUXw.mjs";
|
|
2
2
|
export { cubic2d_exports as CubicCurve2d, linear2d_exports as LinearCurve2d, quadratic2d_exports as QuadraticCurve2d, rationalCubic2d_exports as RationalCubicCurve2d };
|
|
@@ -0,0 +1,195 @@
|
|
|
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';
|
|
11
|
+
/**
|
|
12
|
+
* A linear curve in 2D space.
|
|
13
|
+
*
|
|
14
|
+
* All fields are readonly and immutable, and all operations create new instances.
|
|
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
|
+
*
|
|
20
|
+
* @since 1.0.0
|
|
21
|
+
*/
|
|
22
|
+
export interface LinearCurve2d<out XTraits = unknown, out YTraits = unknown> extends Pipeable, TwoDimensional<LinearPolynomial<XTraits>, LinearPolynomial<YTraits>> {
|
|
23
|
+
readonly [LinearCurve2dTypeId]: LinearCurve2dTypeId;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new `LinearCurve2d` instance from polynomial parameters.
|
|
27
|
+
*
|
|
28
|
+
* @param x - The x polynomial.
|
|
29
|
+
* @param y - The y polynomial.
|
|
30
|
+
* @returns A new `LinearCurve2d` instance.
|
|
31
|
+
* @since 1.0.0
|
|
32
|
+
*/
|
|
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;
|
|
47
|
+
/**
|
|
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.
|
|
53
|
+
*
|
|
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
|
|
58
|
+
*/
|
|
59
|
+
export declare const fromEndpoints: (p0: Vector2, p1: Vector2) => LinearCurve2d;
|
|
60
|
+
/**
|
|
61
|
+
* Checks if a value is a `LinearCurve2d`.
|
|
62
|
+
*
|
|
63
|
+
* @param c - The value to check.
|
|
64
|
+
* @returns `true` if the value is a `LinearCurve2d`, `false` otherwise.
|
|
65
|
+
* @since 1.0.0
|
|
66
|
+
*/
|
|
67
|
+
export declare const isLinearCurve2d: (c: unknown) => c is LinearCurve2d;
|
|
68
|
+
/**
|
|
69
|
+
* Gets the derivative of a linear curve as a vector
|
|
70
|
+
*
|
|
71
|
+
* @param c - The linear curve to get the derivative of.
|
|
72
|
+
* @returns The derivative of the linear curve as a vector.
|
|
73
|
+
* @since 1.0.0
|
|
74
|
+
*/
|
|
75
|
+
export declare const derivative: (c: LinearCurve2d) => Vector2;
|
|
76
|
+
export declare const solve: {
|
|
77
|
+
/**
|
|
78
|
+
* Solves the linear curve for a given parameter t.
|
|
79
|
+
*
|
|
80
|
+
* @param t - The parameter value.
|
|
81
|
+
* @returns A function that takes a linear curve and returns the point on the curve at parameter t.
|
|
82
|
+
* @since 1.0.0
|
|
83
|
+
*/
|
|
84
|
+
(t: number): (c: LinearCurve2d) => Vector2;
|
|
85
|
+
/**
|
|
86
|
+
* Solves the linear curve for a given parameter t.
|
|
87
|
+
*
|
|
88
|
+
* @param c - The linear curve to solve.
|
|
89
|
+
* @param t - The parameter value.
|
|
90
|
+
* @returns The point on the curve at parameter t.
|
|
91
|
+
* @since 1.0.0
|
|
92
|
+
*/
|
|
93
|
+
(c: LinearCurve2d, t: number): Vector2;
|
|
94
|
+
};
|
|
95
|
+
export declare const length: {
|
|
96
|
+
/**
|
|
97
|
+
* Calculates (approximates) the length of a linear curve.
|
|
98
|
+
*
|
|
99
|
+
* @param c - The linear curve to calculate the length of.
|
|
100
|
+
* @param i - The interval to calculate the length over.
|
|
101
|
+
* @returns The length of the linear curve over the given interval.
|
|
102
|
+
* @since 1.0.0
|
|
103
|
+
*/
|
|
104
|
+
(c: LinearCurve2d, i: Interval): number;
|
|
105
|
+
/**
|
|
106
|
+
* Calculates (approximates) the length of a linear curve.
|
|
107
|
+
*
|
|
108
|
+
* @param i - The interval to calculate the length over.
|
|
109
|
+
* @returns A function that takes a linear curve and returns the length of the linear curve over the given interval.
|
|
110
|
+
* @since 1.0.0
|
|
111
|
+
*/
|
|
112
|
+
(i: Interval): (c: LinearCurve2d) => number;
|
|
113
|
+
};
|
|
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>;
|