curvy 1.0.1 → 1.0.3
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/curve/cubic2d.d.mts +1 -1
- package/dist/curve/cubic2d.d.ts +1 -1
- package/dist/curve/cubic2d.mjs +4 -4
- package/dist/curve/linear2d.d.mts +1 -1
- package/dist/curve/linear2d.d.ts +1 -1
- package/dist/curve/linear2d.mjs +3 -3
- package/dist/curve/quadratic2d.d.mts +1 -1
- package/dist/curve/quadratic2d.d.ts +1 -1
- package/dist/curve/quadratic2d.mjs +4 -4
- package/dist/interval.mjs +1 -1
- package/dist/matrix/matrix2x2.d.mts +1 -1
- package/dist/matrix/matrix2x2.d.ts +1 -1
- package/dist/matrix/matrix2x2.mjs +3 -3
- package/dist/matrix/matrix3x3.d.mts +1 -1
- package/dist/matrix/matrix3x3.d.ts +1 -1
- package/dist/matrix/matrix3x3.mjs +5 -5
- package/dist/matrix/matrix4x4.d.mts +1 -1
- package/dist/matrix/matrix4x4.d.ts +1 -1
- package/dist/matrix/matrix4x4.mjs +6 -6
- package/dist/path/cubic2d.d.mts +1 -1
- package/dist/path/cubic2d.d.ts +1 -1
- package/dist/path/cubic2d.mjs +5 -4
- package/dist/path/linear2d.d.mts +1 -1
- package/dist/path/linear2d.d.ts +1 -1
- package/dist/path/linear2d.mjs +3 -3
- package/dist/path/quadratic2d.d.mts +1 -1
- package/dist/path/quadratic2d.d.ts +1 -1
- package/dist/path/quadratic2d.mjs +4 -4
- package/dist/polynomial/cubic.d.mts +1 -1
- package/dist/polynomial/cubic.d.ts +1 -1
- package/dist/polynomial/cubic.mjs +3 -3
- package/dist/polynomial/linear.d.mts +1 -1
- package/dist/polynomial/linear.d.ts +1 -1
- package/dist/polynomial/linear.mjs +2 -2
- package/dist/polynomial/quadratic.d.mts +1 -1
- package/dist/polynomial/quadratic.d.ts +1 -1
- package/dist/polynomial/quadratic.mjs +3 -3
- package/dist/shared/{curvy.Cty3LrOR.mjs → curvy.B1zfBfvf.mjs} +6 -2
- package/dist/shared/{curvy.DOSsf40r.mjs → curvy.BPOevbwG.mjs} +7 -8
- package/dist/shared/curvy.BZXFCKQe.mjs +180 -0
- package/dist/shared/{curvy.CT38g_II.d.mts → curvy.Bf5TIk31.d.mts} +1 -1
- package/dist/shared/{curvy.CT38g_II.d.ts → curvy.Bf5TIk31.d.ts} +1 -1
- package/dist/shared/{curvy.DM6AiKbn.mjs → curvy.BrrC9QVB.mjs} +2 -2
- package/dist/shared/{curvy.ChkqgKuv.mjs → curvy.DLOeble8.mjs} +9 -1
- package/dist/shared/{curvy.bvP77ZZm.mjs → curvy.DTco5vku.mjs} +3 -3
- package/dist/shared/{curvy.D7bhnwZy.mjs → curvy.DV4S13Cq.mjs} +3 -2
- package/dist/shared/{curvy.DB7nQmVs.mjs → curvy.O57gIOmy.mjs} +1 -1
- package/dist/shared/{curvy.D7MEXd5g.mjs → curvy.ZjG-q57I.mjs} +2 -2
- package/dist/splines/basis2d.d.mts +38 -0
- package/dist/splines/basis2d.d.ts +38 -0
- package/dist/splines/basis2d.mjs +88 -0
- package/dist/splines/bezier2d.d.mts +9 -4
- package/dist/splines/bezier2d.d.ts +9 -4
- package/dist/splines/bezier2d.mjs +15 -142
- package/dist/splines/cardinal2d.d.mts +49 -0
- package/dist/splines/cardinal2d.d.ts +49 -0
- package/dist/splines/cardinal2d.mjs +122 -0
- package/dist/splines/hermite2d.d.mts +33 -0
- package/dist/splines/hermite2d.d.ts +33 -0
- package/dist/splines/hermite2d.mjs +76 -0
- package/dist/vector/vector2.d.mts +6 -2
- package/dist/vector/vector2.d.ts +6 -2
- package/dist/vector/vector2.mjs +4 -3
- package/dist/vector/vector3.d.mts +6 -2
- package/dist/vector/vector3.d.ts +6 -2
- package/dist/vector/vector3.mjs +4 -3
- package/dist/vector/vector4.d.mts +6 -2
- package/dist/vector/vector4.d.ts +6 -2
- package/dist/vector/vector4.mjs +4 -3
- package/package.json +13 -1
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { d as dual, P as Pipeable, i as invariant } from './curvy.DLOeble8.mjs';
|
|
2
|
+
import { vectorProductLeft, make as make$3, solveSystem } from '../matrix/matrix4x4.mjs';
|
|
3
|
+
import { fromCurves } from '../path/cubic2d.mjs';
|
|
4
|
+
import { make as make$4 } from '../vector/vector2.mjs';
|
|
5
|
+
import { make as make$2 } from '../vector/vector4.mjs';
|
|
6
|
+
import { fromPolynomials } from '../curve/cubic2d.mjs';
|
|
7
|
+
import { fromVector } from '../polynomial/cubic.mjs';
|
|
8
|
+
|
|
9
|
+
function* toPointQuads(points, stride) {
|
|
10
|
+
let p0;
|
|
11
|
+
let p1;
|
|
12
|
+
let p2;
|
|
13
|
+
let p3;
|
|
14
|
+
for (const point of points) {
|
|
15
|
+
if (p0 === void 0) {
|
|
16
|
+
p0 = point;
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
if (p1 === void 0) {
|
|
20
|
+
p1 = point;
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (p2 === void 0) {
|
|
24
|
+
p2 = point;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
p3 = point;
|
|
28
|
+
yield [p0, p1, p2, p3];
|
|
29
|
+
if (stride === 1) {
|
|
30
|
+
p0 = p1;
|
|
31
|
+
p1 = p2;
|
|
32
|
+
p2 = p3;
|
|
33
|
+
} else if (stride === 2) {
|
|
34
|
+
p0 = p2;
|
|
35
|
+
p1 = p3;
|
|
36
|
+
p2 = void 0;
|
|
37
|
+
} else if (stride === 3) {
|
|
38
|
+
p0 = p3;
|
|
39
|
+
p1 = void 0;
|
|
40
|
+
p2 = void 0;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function* toCurves(points, matrix, stride) {
|
|
45
|
+
for (const [p0, p1, p2, p3] of toPointQuads(points, stride)) {
|
|
46
|
+
yield fromPolynomials(
|
|
47
|
+
fromVector(
|
|
48
|
+
vectorProductLeft(
|
|
49
|
+
matrix,
|
|
50
|
+
make$2(p0.x, p1.x, p2.x, p3.x)
|
|
51
|
+
)
|
|
52
|
+
),
|
|
53
|
+
fromVector(
|
|
54
|
+
vectorProductLeft(
|
|
55
|
+
matrix,
|
|
56
|
+
make$2(p0.y, p1.y, p2.y, p3.y)
|
|
57
|
+
)
|
|
58
|
+
)
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const characteristic$1 = make$3(
|
|
64
|
+
1,
|
|
65
|
+
0,
|
|
66
|
+
0,
|
|
67
|
+
0,
|
|
68
|
+
-3,
|
|
69
|
+
3,
|
|
70
|
+
0,
|
|
71
|
+
0,
|
|
72
|
+
3,
|
|
73
|
+
-6,
|
|
74
|
+
3,
|
|
75
|
+
0,
|
|
76
|
+
-1,
|
|
77
|
+
3,
|
|
78
|
+
-3,
|
|
79
|
+
1
|
|
80
|
+
);
|
|
81
|
+
const Bezier2dTypeId = Symbol("curvy/splines/bezier2d");
|
|
82
|
+
class Bezier2dImpl extends Pipeable {
|
|
83
|
+
[Bezier2dTypeId] = Bezier2dTypeId;
|
|
84
|
+
points;
|
|
85
|
+
constructor(points) {
|
|
86
|
+
invariant(points.length >= 4, "cubic splines requires 4 or more points");
|
|
87
|
+
invariant(
|
|
88
|
+
points.length % 3 === 1,
|
|
89
|
+
"cubic splines requires (n * 3) + 1 points"
|
|
90
|
+
);
|
|
91
|
+
super();
|
|
92
|
+
this.points = points;
|
|
93
|
+
}
|
|
94
|
+
[Symbol.iterator]() {
|
|
95
|
+
return this.points[Symbol.iterator]();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const isCubicBezier2d$1 = (p) => typeof p === "object" && p !== null && Bezier2dTypeId in p;
|
|
99
|
+
const make$1 = (p0, p1, p2, p3) => new Bezier2dImpl([p0, p1, p2, p3]);
|
|
100
|
+
const fromArray$1 = (points) => new Bezier2dImpl(points);
|
|
101
|
+
const append$1 = dual(
|
|
102
|
+
4,
|
|
103
|
+
(p, p1, p2, p3) => new Bezier2dImpl(
|
|
104
|
+
(p instanceof Bezier2dImpl ? p.points : Array.from(p)).concat(p1, p2, p3)
|
|
105
|
+
)
|
|
106
|
+
);
|
|
107
|
+
const fromSpline$1 = (p, matrix, stride) => {
|
|
108
|
+
const points = [];
|
|
109
|
+
let x;
|
|
110
|
+
let y;
|
|
111
|
+
for (const [p0, p1, p2, p3] of toPointQuads(p, stride)) {
|
|
112
|
+
x = solveSystem(
|
|
113
|
+
characteristic$1,
|
|
114
|
+
vectorProductLeft(matrix, make$2(p0.x, p1.x, p2.x, p3.x))
|
|
115
|
+
);
|
|
116
|
+
y = solveSystem(
|
|
117
|
+
characteristic$1,
|
|
118
|
+
vectorProductLeft(matrix, make$2(p0.y, p1.y, p2.y, p3.y))
|
|
119
|
+
);
|
|
120
|
+
points.push(
|
|
121
|
+
make$4(x.x, y.x),
|
|
122
|
+
make$4(x.y, y.y),
|
|
123
|
+
make$4(x.z, y.z)
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
if (x && y) {
|
|
127
|
+
points.push(make$4(x.w, y.w));
|
|
128
|
+
}
|
|
129
|
+
return fromArray$1(points);
|
|
130
|
+
};
|
|
131
|
+
const appendTangentAligned$1 = dual(4, (p, a, p5, p6) => {
|
|
132
|
+
const points = p instanceof Bezier2dImpl ? p.points : Array.from(p);
|
|
133
|
+
const p2 = points[points.length - 2];
|
|
134
|
+
const p3 = points[points.length - 1];
|
|
135
|
+
const p4 = make$4(p3.x + (p3.x - p2.x) * a, p3.y + (p3.y - p2.y) * a);
|
|
136
|
+
return append$1(p, p4, p5, p6);
|
|
137
|
+
});
|
|
138
|
+
const appendCurvatureAligned = dual(
|
|
139
|
+
4,
|
|
140
|
+
(p, a, b, p6) => {
|
|
141
|
+
const points = p instanceof Bezier2dImpl ? p.points : Array.from(p);
|
|
142
|
+
const p1 = points[points.length - 3];
|
|
143
|
+
const p2 = points[points.length - 2];
|
|
144
|
+
const p3 = points[points.length - 1];
|
|
145
|
+
const p4 = make$4(p3.x + (p3.x - p2.x) * a, p3.y + (p3.y - p2.y) * a);
|
|
146
|
+
const p5 = make$4(
|
|
147
|
+
p3.x + (p3.x - p2.x) * (2 * a + a ** 2 + b / 2) + (p1.x - p2.x) * a ** 2,
|
|
148
|
+
p3.y + (p3.y - p2.y) * (2 * a + a ** 2 + b / 2) + (p1.y - p2.y) * a ** 2
|
|
149
|
+
);
|
|
150
|
+
return append$1(p, p4, p5, p6);
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
const appendVelocityAligned$1 = dual(
|
|
154
|
+
3,
|
|
155
|
+
(p, p5, p6) => appendTangentAligned$1(p, 1, p5, p6)
|
|
156
|
+
);
|
|
157
|
+
const appendAccelerationAligned$1 = dual(2, (p, p6) => {
|
|
158
|
+
const points = p instanceof Bezier2dImpl ? p.points : Array.from(p);
|
|
159
|
+
const p1 = points[points.length - 3];
|
|
160
|
+
const p2 = points[points.length - 2];
|
|
161
|
+
const p3 = points[points.length - 1];
|
|
162
|
+
const p4 = make$4(2 * p3.x - p2.x, 2 * p3.y - p2.y);
|
|
163
|
+
const p5 = make$4(p1.x + 4 * (p3.x - p2.x), p1.y + 4 * (p3.y - p2.y));
|
|
164
|
+
return append$1(p, p4, p5, p6);
|
|
165
|
+
});
|
|
166
|
+
const toPath$1 = (p) => fromCurves(...toCurves(p, characteristic$1, 3));
|
|
167
|
+
|
|
168
|
+
const characteristic = characteristic$1;
|
|
169
|
+
const make = make$1;
|
|
170
|
+
const fromArray = fromArray$1;
|
|
171
|
+
const fromSpline = fromSpline$1;
|
|
172
|
+
const isCubicBezier2d = isCubicBezier2d$1;
|
|
173
|
+
const append = append$1;
|
|
174
|
+
const appendTangentAligned = appendTangentAligned$1;
|
|
175
|
+
const appendCurvatureMirrored = appendCurvatureAligned;
|
|
176
|
+
const appendVelocityAligned = appendVelocityAligned$1;
|
|
177
|
+
const appendAccelerationAligned = appendAccelerationAligned$1;
|
|
178
|
+
const toPath = toPath$1;
|
|
179
|
+
|
|
180
|
+
export { fromArray as a, append as b, characteristic as c, appendTangentAligned as d, appendCurvatureMirrored as e, fromSpline as f, appendVelocityAligned as g, appendAccelerationAligned as h, isCubicBezier2d as i, toPath as j, make as m, toCurves as t };
|
|
@@ -19,4 +19,4 @@ interface FourDimensional<T> extends ThreeDimensional<T> {
|
|
|
19
19
|
readonly 3: T;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export type { FourDimensionalIndex as F,
|
|
22
|
+
export type { FourDimensionalIndex as F, TwoDimensional as T, FourDimensionalComponent as a, ThreeDimensionalIndex as b, ThreeDimensionalComponent as c, TwoDimensionalIndex as d, TwoDimensionalComponent as e, FourDimensional as f, ThreeDimensional as g };
|
|
@@ -19,4 +19,4 @@ interface FourDimensional<T> extends ThreeDimensional<T> {
|
|
|
19
19
|
readonly 3: T;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export type { FourDimensionalIndex as F,
|
|
22
|
+
export type { FourDimensionalIndex as F, TwoDimensional as T, FourDimensionalComponent as a, ThreeDimensionalIndex as b, ThreeDimensionalComponent as c, TwoDimensionalIndex as d, TwoDimensionalComponent as e, FourDimensional as f, ThreeDimensional as g };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as invariant, d as dual, r as round, P as Pipeable } from './curvy.
|
|
2
|
-
import { m as make$1, d as dot } from './curvy.
|
|
1
|
+
import { i as invariant, d as dual, r as round, P as Pipeable } from './curvy.DLOeble8.mjs';
|
|
2
|
+
import { m as make$1, d as dot } from './curvy.BPOevbwG.mjs';
|
|
3
3
|
|
|
4
4
|
function toIndex(input) {
|
|
5
5
|
if (typeof input === "number") {
|
|
@@ -98,6 +98,14 @@ function round(value, precision = PRECISION) {
|
|
|
98
98
|
}
|
|
99
99
|
return result;
|
|
100
100
|
}
|
|
101
|
+
function roundDown(value, precision = PRECISION) {
|
|
102
|
+
const scale = 10 ** precision;
|
|
103
|
+
const result = Math.floor(value * scale) / scale;
|
|
104
|
+
if (result === 0) {
|
|
105
|
+
return 0;
|
|
106
|
+
}
|
|
107
|
+
return result;
|
|
108
|
+
}
|
|
101
109
|
dual(
|
|
102
110
|
5,
|
|
103
111
|
(x, x1, x2, y1, y2) => {
|
|
@@ -116,4 +124,4 @@ function invariant(condition, message) {
|
|
|
116
124
|
}
|
|
117
125
|
}
|
|
118
126
|
|
|
119
|
-
export { Pipeable as P,
|
|
127
|
+
export { Pipeable as P, roundDown as a, dual as d, invariant as i, round as r };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { o as toThreeDimensionalIndex, d as determinant$1, m as make$1 } from './curvy.
|
|
2
|
-
import { d as dual, r as round, i as invariant, P as Pipeable } from './curvy.
|
|
3
|
-
import { c as components, m as make$2, d as dot } from './curvy.
|
|
1
|
+
import { o as toThreeDimensionalIndex, d as determinant$1, m as make$1 } from './curvy.BrrC9QVB.mjs';
|
|
2
|
+
import { d as dual, r as round, i as invariant, P as Pipeable } from './curvy.DLOeble8.mjs';
|
|
3
|
+
import { c as components, m as make$2, d as dot } from './curvy.DV4S13Cq.mjs';
|
|
4
4
|
|
|
5
5
|
const Matrix3x3TypeId = Symbol.for("curvy/matrix3x3");
|
|
6
6
|
class Matrix3x3Impl extends Pipeable {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as dual, r as round, P as Pipeable } from './curvy.
|
|
1
|
+
import { d as dual, r as round, P as Pipeable } from './curvy.DLOeble8.mjs';
|
|
2
2
|
|
|
3
3
|
const Vector3TypeId = Symbol.for("curvy/vector3");
|
|
4
4
|
class Vector3Impl extends Pipeable {
|
|
@@ -48,5 +48,6 @@ const make = (v0, v1 = v0, v2 = v1) => new Vector3Impl(v0, v1, v2);
|
|
|
48
48
|
const add = dual(2, (a, b) => make(a.x + b.x, a.y + b.y, a.z + b.z));
|
|
49
49
|
const subtract = dual(2, (a, b) => make(a.x - b.x, a.y - b.y, a.z - b.z));
|
|
50
50
|
const hadamard = dual(2, (a, b) => make(a.x * b.x, a.y * b.y, a.z * b.z));
|
|
51
|
+
const scale = dual(2, (v, s) => s === 1 ? v : make(v.x * s, v.y * s, v.z * s));
|
|
51
52
|
|
|
52
|
-
export { magnitude as a, add as b, components as c, dot as d, subtract as e, hadamard as h, isVector3 as i, make as m, normalize as n, softmax as s };
|
|
53
|
+
export { magnitude as a, add as b, components as c, dot as d, subtract as e, scale as f, hadamard as h, isVector3 as i, make as m, normalize as n, softmax as s };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as Pipeable, r as round, d as dual } from './curvy.
|
|
1
|
+
import { P as Pipeable, r as round, d as dual } from './curvy.DLOeble8.mjs';
|
|
2
2
|
import { size, contains, fromMinMax } from '../interval.mjs';
|
|
3
|
-
import { Q as QuadraticPolynomialImpl, b as QuadraticPolynomialTypeId, a as make$1, c as solveInverse$1, m as monotonicity$1, r as range$1, l as length$1, s as solve$1 } from './curvy.
|
|
3
|
+
import { Q as QuadraticPolynomialImpl, b as QuadraticPolynomialTypeId, a as make$1, c as solveInverse$1, m as monotonicity$1, r as range$1, l as length$1, s as solve$1 } from './curvy.O57gIOmy.mjs';
|
|
4
4
|
|
|
5
5
|
const CubicPolynomialTypeId = Symbol.for(
|
|
6
6
|
"curvy/polynomial/cubic"
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { P as Pipeable } from '../shared/curvy.BN-oFBsc.mjs';
|
|
2
|
+
import { Matrix4x4 } from '../matrix/matrix4x4.mjs';
|
|
3
|
+
import { CubicPath2d } from '../path/cubic2d.mjs';
|
|
4
|
+
import { Vector2 } from '../vector/vector2.mjs';
|
|
5
|
+
import { Bezier2d } from './bezier2d.mjs';
|
|
6
|
+
import '../shared/curvy.Bf5TIk31.mjs';
|
|
7
|
+
import '../vector/vector4.mjs';
|
|
8
|
+
import '../matrix/matrix3x3.mjs';
|
|
9
|
+
import '../vector/vector3.mjs';
|
|
10
|
+
import '../matrix/matrix2x2.mjs';
|
|
11
|
+
import '../curve/cubic2d.mjs';
|
|
12
|
+
import '../interval.mjs';
|
|
13
|
+
import '../shared/curvy.DwHW5Fqt.mjs';
|
|
14
|
+
|
|
15
|
+
declare const Basis2dTypeId: unique symbol;
|
|
16
|
+
type Basis2dTypeId = typeof Basis2dTypeId;
|
|
17
|
+
|
|
18
|
+
declare const characteristic: Matrix4x4;
|
|
19
|
+
interface Basis2d extends Pipeable {
|
|
20
|
+
readonly [Basis2dTypeId]: Basis2dTypeId;
|
|
21
|
+
[Symbol.iterator](): Iterator<Vector2>;
|
|
22
|
+
}
|
|
23
|
+
declare const isBasis2d: (p: unknown) => p is Basis2d;
|
|
24
|
+
declare const make: (p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2) => Basis2d;
|
|
25
|
+
declare const fromArray: (points: ReadonlyArray<Vector2>) => Basis2d;
|
|
26
|
+
declare const append: {
|
|
27
|
+
(...points: ReadonlyArray<Vector2>): (p: Basis2d) => Basis2d;
|
|
28
|
+
(p: Basis2d, ...points: ReadonlyArray<Vector2>): Basis2d;
|
|
29
|
+
};
|
|
30
|
+
declare const prepend: {
|
|
31
|
+
(...points: ReadonlyArray<Vector2>): (p: Basis2d) => Basis2d;
|
|
32
|
+
(p: Basis2d, ...points: ReadonlyArray<Vector2>): Basis2d;
|
|
33
|
+
};
|
|
34
|
+
declare const withTriplicatedEndpoints: (p: Basis2d) => Basis2d;
|
|
35
|
+
declare const toPath: (p: Basis2d) => CubicPath2d;
|
|
36
|
+
declare const toBezier: (p: Basis2d) => Bezier2d;
|
|
37
|
+
|
|
38
|
+
export { type Basis2d, append, characteristic, fromArray, isBasis2d, make, prepend, toBezier, toPath, withTriplicatedEndpoints };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { P as Pipeable } from '../shared/curvy.BN-oFBsc.js';
|
|
2
|
+
import { Matrix4x4 } from '../matrix/matrix4x4.js';
|
|
3
|
+
import { CubicPath2d } from '../path/cubic2d.js';
|
|
4
|
+
import { Vector2 } from '../vector/vector2.js';
|
|
5
|
+
import { Bezier2d } from './bezier2d.js';
|
|
6
|
+
import '../shared/curvy.Bf5TIk31.js';
|
|
7
|
+
import '../vector/vector4.js';
|
|
8
|
+
import '../matrix/matrix3x3.js';
|
|
9
|
+
import '../vector/vector3.js';
|
|
10
|
+
import '../matrix/matrix2x2.js';
|
|
11
|
+
import '../curve/cubic2d.js';
|
|
12
|
+
import '../interval.js';
|
|
13
|
+
import '../shared/curvy.CkJRVnqj.js';
|
|
14
|
+
|
|
15
|
+
declare const Basis2dTypeId: unique symbol;
|
|
16
|
+
type Basis2dTypeId = typeof Basis2dTypeId;
|
|
17
|
+
|
|
18
|
+
declare const characteristic: Matrix4x4;
|
|
19
|
+
interface Basis2d extends Pipeable {
|
|
20
|
+
readonly [Basis2dTypeId]: Basis2dTypeId;
|
|
21
|
+
[Symbol.iterator](): Iterator<Vector2>;
|
|
22
|
+
}
|
|
23
|
+
declare const isBasis2d: (p: unknown) => p is Basis2d;
|
|
24
|
+
declare const make: (p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2) => Basis2d;
|
|
25
|
+
declare const fromArray: (points: ReadonlyArray<Vector2>) => Basis2d;
|
|
26
|
+
declare const append: {
|
|
27
|
+
(...points: ReadonlyArray<Vector2>): (p: Basis2d) => Basis2d;
|
|
28
|
+
(p: Basis2d, ...points: ReadonlyArray<Vector2>): Basis2d;
|
|
29
|
+
};
|
|
30
|
+
declare const prepend: {
|
|
31
|
+
(...points: ReadonlyArray<Vector2>): (p: Basis2d) => Basis2d;
|
|
32
|
+
(p: Basis2d, ...points: ReadonlyArray<Vector2>): Basis2d;
|
|
33
|
+
};
|
|
34
|
+
declare const withTriplicatedEndpoints: (p: Basis2d) => Basis2d;
|
|
35
|
+
declare const toPath: (p: Basis2d) => CubicPath2d;
|
|
36
|
+
declare const toBezier: (p: Basis2d) => Bezier2d;
|
|
37
|
+
|
|
38
|
+
export { type Basis2d, append, characteristic, fromArray, isBasis2d, make, prepend, toBezier, toPath, withTriplicatedEndpoints };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { a as roundDown, d as dual, P as Pipeable, i as invariant } from '../shared/curvy.DLOeble8.mjs';
|
|
2
|
+
import { make as make$2 } from '../matrix/matrix4x4.mjs';
|
|
3
|
+
import { fromCurves } from '../path/cubic2d.mjs';
|
|
4
|
+
import { t as toCurves, f as fromSpline } from '../shared/curvy.BZXFCKQe.mjs';
|
|
5
|
+
import '../shared/curvy.BrrC9QVB.mjs';
|
|
6
|
+
import '../shared/curvy.BPOevbwG.mjs';
|
|
7
|
+
import '../shared/curvy.B1zfBfvf.mjs';
|
|
8
|
+
import '../shared/curvy.DTco5vku.mjs';
|
|
9
|
+
import '../shared/curvy.DV4S13Cq.mjs';
|
|
10
|
+
import '../curve/cubic2d.mjs';
|
|
11
|
+
import '../interval.mjs';
|
|
12
|
+
import '../shared/curvy.DmVFTi0N.mjs';
|
|
13
|
+
import '../polynomial/cubic.mjs';
|
|
14
|
+
import '../shared/curvy.ZjG-q57I.mjs';
|
|
15
|
+
import '../shared/curvy.O57gIOmy.mjs';
|
|
16
|
+
import '../polynomial/quadratic.mjs';
|
|
17
|
+
import '../vector/vector2.mjs';
|
|
18
|
+
import '../curve/linear2d.mjs';
|
|
19
|
+
import '../polynomial/linear.mjs';
|
|
20
|
+
import '../curve/quadratic2d.mjs';
|
|
21
|
+
import '../vector/vector4.mjs';
|
|
22
|
+
|
|
23
|
+
const characteristic$1 = make$2(
|
|
24
|
+
1 / 6,
|
|
25
|
+
4 / 6,
|
|
26
|
+
roundDown(1 / 6),
|
|
27
|
+
0,
|
|
28
|
+
-0.5,
|
|
29
|
+
0,
|
|
30
|
+
0.5,
|
|
31
|
+
0,
|
|
32
|
+
0.5,
|
|
33
|
+
-1,
|
|
34
|
+
0.5,
|
|
35
|
+
0,
|
|
36
|
+
-1 / 6,
|
|
37
|
+
0.5,
|
|
38
|
+
-0.5,
|
|
39
|
+
1 / 6
|
|
40
|
+
);
|
|
41
|
+
const Basis2dTypeId = Symbol("curvy/splines/basis2d");
|
|
42
|
+
class Basis2dImpl extends Pipeable {
|
|
43
|
+
[Basis2dTypeId] = Basis2dTypeId;
|
|
44
|
+
points;
|
|
45
|
+
constructor(points) {
|
|
46
|
+
invariant(points.length >= 4, "basis splines requires 4 or more points");
|
|
47
|
+
super();
|
|
48
|
+
this.points = points;
|
|
49
|
+
}
|
|
50
|
+
[Symbol.iterator]() {
|
|
51
|
+
return this.points[Symbol.iterator]();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const isBasis2d$1 = (p) => typeof p === "object" && p !== null && Basis2dTypeId in p;
|
|
55
|
+
const make$1 = (p0, p1, p2, p3) => new Basis2dImpl([p0, p1, p2, p3]);
|
|
56
|
+
const fromArray$1 = (points) => new Basis2dImpl(points);
|
|
57
|
+
const append$1 = dual(
|
|
58
|
+
(args) => isBasis2d$1(args[0]),
|
|
59
|
+
(p, ...points) => new Basis2dImpl([...p, ...points])
|
|
60
|
+
);
|
|
61
|
+
const prepend$1 = dual(
|
|
62
|
+
(args) => isBasis2d$1(args[0]),
|
|
63
|
+
(p, ...points) => new Basis2dImpl([...points, ...p])
|
|
64
|
+
);
|
|
65
|
+
const withTriplicatedEndpoints$1 = (p) => {
|
|
66
|
+
const points = p instanceof Basis2dImpl ? p.points : [...p];
|
|
67
|
+
return new Basis2dImpl([
|
|
68
|
+
points[0],
|
|
69
|
+
points[0],
|
|
70
|
+
...points,
|
|
71
|
+
points[points.length - 1],
|
|
72
|
+
points[points.length - 1]
|
|
73
|
+
]);
|
|
74
|
+
};
|
|
75
|
+
const toPath$1 = (p) => fromCurves(...toCurves(p, characteristic$1, 1));
|
|
76
|
+
const toBezier$1 = (p) => fromSpline(p, characteristic$1, 1);
|
|
77
|
+
|
|
78
|
+
const characteristic = characteristic$1;
|
|
79
|
+
const isBasis2d = isBasis2d$1;
|
|
80
|
+
const make = make$1;
|
|
81
|
+
const fromArray = fromArray$1;
|
|
82
|
+
const append = append$1;
|
|
83
|
+
const prepend = prepend$1;
|
|
84
|
+
const withTriplicatedEndpoints = withTriplicatedEndpoints$1;
|
|
85
|
+
const toPath = toPath$1;
|
|
86
|
+
const toBezier = toBezier$1;
|
|
87
|
+
|
|
88
|
+
export { append, characteristic, fromArray, isBasis2d, make, prepend, toBezier, toPath, withTriplicatedEndpoints };
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { P as Pipeable } from '../shared/curvy.BN-oFBsc.mjs';
|
|
2
|
+
import { Matrix4x4 } from '../matrix/matrix4x4.mjs';
|
|
2
3
|
import { CubicPath2d } from '../path/cubic2d.mjs';
|
|
3
4
|
import { Vector2 } from '../vector/vector2.mjs';
|
|
5
|
+
import '../shared/curvy.Bf5TIk31.mjs';
|
|
6
|
+
import '../vector/vector4.mjs';
|
|
7
|
+
import '../matrix/matrix3x3.mjs';
|
|
8
|
+
import '../vector/vector3.mjs';
|
|
9
|
+
import '../matrix/matrix2x2.mjs';
|
|
4
10
|
import '../curve/cubic2d.mjs';
|
|
5
|
-
import '../shared/curvy.CT38g_II.mjs';
|
|
6
11
|
import '../interval.mjs';
|
|
7
12
|
import '../shared/curvy.DwHW5Fqt.mjs';
|
|
8
|
-
import '../vector/vector3.mjs';
|
|
9
|
-
import '../vector/vector4.mjs';
|
|
10
13
|
|
|
11
14
|
declare const Bezier2dTypeId: unique symbol;
|
|
12
15
|
type Bezier2dTypeId = typeof Bezier2dTypeId;
|
|
@@ -15,8 +18,10 @@ interface Bezier2d extends Pipeable {
|
|
|
15
18
|
readonly [Bezier2dTypeId]: Bezier2dTypeId;
|
|
16
19
|
[Symbol.iterator](): IterableIterator<Vector2>;
|
|
17
20
|
}
|
|
21
|
+
declare const characteristic: Matrix4x4;
|
|
18
22
|
declare const make: (p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2) => Bezier2d;
|
|
19
23
|
declare const fromArray: (points: ReadonlyArray<Vector2>) => Bezier2d;
|
|
24
|
+
declare const fromSpline: (points: Iterable<Vector2>, matrix: Matrix4x4, stride: 1 | 2 | 3) => Bezier2d;
|
|
20
25
|
declare const isCubicBezier2d: (p: unknown) => p is Bezier2d;
|
|
21
26
|
declare const append: {
|
|
22
27
|
(p1: Vector2, p2: Vector2, p3: Vector2): (p: Bezier2d) => Bezier2d;
|
|
@@ -40,4 +45,4 @@ declare const appendAccelerationAligned: {
|
|
|
40
45
|
};
|
|
41
46
|
declare const toPath: (p: Bezier2d) => CubicPath2d;
|
|
42
47
|
|
|
43
|
-
export { type Bezier2d, append, appendAccelerationAligned, appendCurvatureMirrored, appendTangentAligned, appendVelocityAligned, fromArray, isCubicBezier2d, make, toPath };
|
|
48
|
+
export { type Bezier2d, append, appendAccelerationAligned, appendCurvatureMirrored, appendTangentAligned, appendVelocityAligned, characteristic, fromArray, fromSpline, isCubicBezier2d, make, toPath };
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { P as Pipeable } from '../shared/curvy.BN-oFBsc.js';
|
|
2
|
+
import { Matrix4x4 } from '../matrix/matrix4x4.js';
|
|
2
3
|
import { CubicPath2d } from '../path/cubic2d.js';
|
|
3
4
|
import { Vector2 } from '../vector/vector2.js';
|
|
5
|
+
import '../shared/curvy.Bf5TIk31.js';
|
|
6
|
+
import '../vector/vector4.js';
|
|
7
|
+
import '../matrix/matrix3x3.js';
|
|
8
|
+
import '../vector/vector3.js';
|
|
9
|
+
import '../matrix/matrix2x2.js';
|
|
4
10
|
import '../curve/cubic2d.js';
|
|
5
|
-
import '../shared/curvy.CT38g_II.js';
|
|
6
11
|
import '../interval.js';
|
|
7
12
|
import '../shared/curvy.CkJRVnqj.js';
|
|
8
|
-
import '../vector/vector3.js';
|
|
9
|
-
import '../vector/vector4.js';
|
|
10
13
|
|
|
11
14
|
declare const Bezier2dTypeId: unique symbol;
|
|
12
15
|
type Bezier2dTypeId = typeof Bezier2dTypeId;
|
|
@@ -15,8 +18,10 @@ interface Bezier2d extends Pipeable {
|
|
|
15
18
|
readonly [Bezier2dTypeId]: Bezier2dTypeId;
|
|
16
19
|
[Symbol.iterator](): IterableIterator<Vector2>;
|
|
17
20
|
}
|
|
21
|
+
declare const characteristic: Matrix4x4;
|
|
18
22
|
declare const make: (p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2) => Bezier2d;
|
|
19
23
|
declare const fromArray: (points: ReadonlyArray<Vector2>) => Bezier2d;
|
|
24
|
+
declare const fromSpline: (points: Iterable<Vector2>, matrix: Matrix4x4, stride: 1 | 2 | 3) => Bezier2d;
|
|
20
25
|
declare const isCubicBezier2d: (p: unknown) => p is Bezier2d;
|
|
21
26
|
declare const append: {
|
|
22
27
|
(p1: Vector2, p2: Vector2, p3: Vector2): (p: Bezier2d) => Bezier2d;
|
|
@@ -40,4 +45,4 @@ declare const appendAccelerationAligned: {
|
|
|
40
45
|
};
|
|
41
46
|
declare const toPath: (p: Bezier2d) => CubicPath2d;
|
|
42
47
|
|
|
43
|
-
export { type Bezier2d, append, appendAccelerationAligned, appendCurvatureMirrored, appendTangentAligned, appendVelocityAligned, fromArray, isCubicBezier2d, make, toPath };
|
|
48
|
+
export { type Bezier2d, append, appendAccelerationAligned, appendCurvatureMirrored, appendTangentAligned, appendVelocityAligned, characteristic, fromArray, fromSpline, isCubicBezier2d, make, toPath };
|
|
@@ -1,148 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
1
|
+
export { b as append, h as appendAccelerationAligned, e as appendCurvatureMirrored, d as appendTangentAligned, g as appendVelocityAligned, c as characteristic, a as fromArray, f as fromSpline, i as isCubicBezier2d, m as make, j as toPath } from '../shared/curvy.BZXFCKQe.mjs';
|
|
2
|
+
import '../shared/curvy.DLOeble8.mjs';
|
|
3
|
+
import '../matrix/matrix4x4.mjs';
|
|
4
|
+
import '../shared/curvy.BrrC9QVB.mjs';
|
|
5
|
+
import '../shared/curvy.BPOevbwG.mjs';
|
|
6
|
+
import '../shared/curvy.B1zfBfvf.mjs';
|
|
7
|
+
import '../shared/curvy.DTco5vku.mjs';
|
|
8
|
+
import '../shared/curvy.DV4S13Cq.mjs';
|
|
9
|
+
import '../path/cubic2d.mjs';
|
|
10
|
+
import '../curve/cubic2d.mjs';
|
|
8
11
|
import '../interval.mjs';
|
|
9
12
|
import '../shared/curvy.DmVFTi0N.mjs';
|
|
13
|
+
import '../polynomial/cubic.mjs';
|
|
14
|
+
import '../shared/curvy.ZjG-q57I.mjs';
|
|
15
|
+
import '../shared/curvy.O57gIOmy.mjs';
|
|
10
16
|
import '../polynomial/quadratic.mjs';
|
|
11
|
-
import '../
|
|
12
|
-
import '../shared/curvy.DB7nQmVs.mjs';
|
|
17
|
+
import '../vector/vector2.mjs';
|
|
13
18
|
import '../curve/linear2d.mjs';
|
|
14
19
|
import '../polynomial/linear.mjs';
|
|
15
20
|
import '../curve/quadratic2d.mjs';
|
|
16
|
-
import '../
|
|
17
|
-
import '../shared/curvy.DOSsf40r.mjs';
|
|
18
|
-
import '../shared/curvy.Cty3LrOR.mjs';
|
|
19
|
-
import '../shared/curvy.bvP77ZZm.mjs';
|
|
20
|
-
import '../shared/curvy.D7bhnwZy.mjs';
|
|
21
|
-
|
|
22
|
-
const characteristic = make$2(
|
|
23
|
-
1,
|
|
24
|
-
0,
|
|
25
|
-
0,
|
|
26
|
-
0,
|
|
27
|
-
-3,
|
|
28
|
-
3,
|
|
29
|
-
0,
|
|
30
|
-
0,
|
|
31
|
-
3,
|
|
32
|
-
-6,
|
|
33
|
-
3,
|
|
34
|
-
0,
|
|
35
|
-
-1,
|
|
36
|
-
3,
|
|
37
|
-
-3,
|
|
38
|
-
1
|
|
39
|
-
);
|
|
40
|
-
const Bezier2dTypeId = Symbol("curvy/splines/points");
|
|
41
|
-
class Bezier2dImpl extends Pipeable {
|
|
42
|
-
[Bezier2dTypeId] = Bezier2dTypeId;
|
|
43
|
-
points;
|
|
44
|
-
constructor(points) {
|
|
45
|
-
invariant(points.length >= 4, "cubic splines requires 4 or more points");
|
|
46
|
-
invariant(
|
|
47
|
-
points.length % 3 === 1,
|
|
48
|
-
"cubic splines requires (n * 3) + 1 points"
|
|
49
|
-
);
|
|
50
|
-
super();
|
|
51
|
-
this.points = points;
|
|
52
|
-
}
|
|
53
|
-
[Symbol.iterator]() {
|
|
54
|
-
return this.points[Symbol.iterator]();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
const isCubicBezier2d$1 = (p) => typeof p === "object" && p !== null && Bezier2dTypeId in p;
|
|
58
|
-
const make$1 = (p0, p1, p2, p3) => new Bezier2dImpl([p0, p1, p2, p3]);
|
|
59
|
-
const fromArray$1 = (points) => new Bezier2dImpl(points);
|
|
60
|
-
const append$1 = dual(
|
|
61
|
-
4,
|
|
62
|
-
(p, p1, p2, p3) => new Bezier2dImpl(
|
|
63
|
-
(p instanceof Bezier2dImpl ? p.points : Array.from(p)).concat(p1, p2, p3)
|
|
64
|
-
)
|
|
65
|
-
);
|
|
66
|
-
const appendTangentAligned$1 = dual(4, (p, a, p5, p6) => {
|
|
67
|
-
const points = p instanceof Bezier2dImpl ? p.points : Array.from(p);
|
|
68
|
-
const p2 = points[points.length - 2];
|
|
69
|
-
const p3 = points[points.length - 1];
|
|
70
|
-
const p4 = make$3(p3.x + (p3.x - p2.x) * a, p3.y + (p3.y - p2.y) * a);
|
|
71
|
-
return append$1(p, p4, p5, p6);
|
|
72
|
-
});
|
|
73
|
-
const appendCurvatureAligned = dual(
|
|
74
|
-
4,
|
|
75
|
-
(p, a, b, p6) => {
|
|
76
|
-
const points = p instanceof Bezier2dImpl ? p.points : Array.from(p);
|
|
77
|
-
const p1 = points[points.length - 3];
|
|
78
|
-
const p2 = points[points.length - 2];
|
|
79
|
-
const p3 = points[points.length - 1];
|
|
80
|
-
const p4 = make$3(p3.x + (p3.x - p2.x) * a, p3.y + (p3.y - p2.y) * a);
|
|
81
|
-
const p5 = make$3(
|
|
82
|
-
p3.x + (p3.x - p2.x) * (2 * a + a ** 2 + b / 2) + (p1.x - p2.x) * a ** 2,
|
|
83
|
-
p3.y + (p3.y - p2.y) * (2 * a + a ** 2 + b / 2) + (p1.y - p2.y) * a ** 2
|
|
84
|
-
);
|
|
85
|
-
return append$1(p, p4, p5, p6);
|
|
86
|
-
}
|
|
87
|
-
);
|
|
88
|
-
const appendVelocityAligned$1 = dual(
|
|
89
|
-
3,
|
|
90
|
-
(p, p5, p6) => appendTangentAligned$1(p, 1, p5, p6)
|
|
91
|
-
);
|
|
92
|
-
const appendAccelerationAligned$1 = dual(2, (p, p6) => {
|
|
93
|
-
const points = p instanceof Bezier2dImpl ? p.points : Array.from(p);
|
|
94
|
-
const p1 = points[points.length - 3];
|
|
95
|
-
const p2 = points[points.length - 2];
|
|
96
|
-
const p3 = points[points.length - 1];
|
|
97
|
-
const p4 = make$3(2 * p3.x - p2.x, 2 * p3.y - p2.y);
|
|
98
|
-
const p5 = make$3(p1.x + 4 * (p3.x - p2.x), p1.y + 4 * (p3.y - p2.y));
|
|
99
|
-
return append$1(p, p4, p5, p6);
|
|
100
|
-
});
|
|
101
|
-
function* toCurves(points) {
|
|
102
|
-
let p0;
|
|
103
|
-
let p1;
|
|
104
|
-
let p2;
|
|
105
|
-
let p3;
|
|
106
|
-
for (const point of points) {
|
|
107
|
-
if (p0 === void 0) {
|
|
108
|
-
p0 = point;
|
|
109
|
-
} else if (p1 === void 0) {
|
|
110
|
-
p1 = point;
|
|
111
|
-
} else if (p2 === void 0) {
|
|
112
|
-
p2 = point;
|
|
113
|
-
} else if (p3 === void 0) {
|
|
114
|
-
p3 = point;
|
|
115
|
-
yield fromPolynomials(
|
|
116
|
-
fromVector(
|
|
117
|
-
vectorProductLeft(
|
|
118
|
-
characteristic,
|
|
119
|
-
make$4(p0.x, p1.x, p2.x, p3.x)
|
|
120
|
-
)
|
|
121
|
-
),
|
|
122
|
-
fromVector(
|
|
123
|
-
vectorProductLeft(
|
|
124
|
-
characteristic,
|
|
125
|
-
make$4(p0.y, p1.y, p2.y, p3.y)
|
|
126
|
-
)
|
|
127
|
-
)
|
|
128
|
-
);
|
|
129
|
-
p0 = p3;
|
|
130
|
-
p1 = void 0;
|
|
131
|
-
p2 = void 0;
|
|
132
|
-
p3 = void 0;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
const toPath$1 = (p) => fromCurves(...toCurves(p));
|
|
137
|
-
|
|
138
|
-
const make = make$1;
|
|
139
|
-
const fromArray = fromArray$1;
|
|
140
|
-
const isCubicBezier2d = isCubicBezier2d$1;
|
|
141
|
-
const append = append$1;
|
|
142
|
-
const appendTangentAligned = appendTangentAligned$1;
|
|
143
|
-
const appendCurvatureMirrored = appendCurvatureAligned;
|
|
144
|
-
const appendVelocityAligned = appendVelocityAligned$1;
|
|
145
|
-
const appendAccelerationAligned = appendAccelerationAligned$1;
|
|
146
|
-
const toPath = toPath$1;
|
|
147
|
-
|
|
148
|
-
export { append, appendAccelerationAligned, appendCurvatureMirrored, appendTangentAligned, appendVelocityAligned, fromArray, isCubicBezier2d, make, toPath };
|
|
21
|
+
import '../vector/vector4.mjs';
|