curvy 1.0.8 → 2.0.0-alpha.0
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 +88 -0
- package/dist/characteristic/index.mjs +2 -0
- package/dist/curve/index.d.mts +2 -0
- package/dist/curve/index.mjs +2 -0
- package/dist/interval/index.d.mts +2 -0
- package/dist/interval/index.mjs +2 -0
- package/dist/matrix/index.d.mts +2 -0
- package/dist/matrix/index.mjs +267 -0
- package/dist/matrix/index.mjs.map +1 -0
- package/dist/number.d.mts +280 -0
- package/dist/number.mjs +140 -0
- package/dist/number.mjs.map +1 -0
- package/dist/path/index.d.mts +241 -0
- package/dist/path/index.mjs +292 -0
- package/dist/path/index.mjs.map +1 -0
- package/dist/polynomial/index.d.mts +2 -0
- package/dist/polynomial/index.mjs +3 -0
- package/dist/shared/characteristic-BGRxcxUH.mjs +104 -0
- package/dist/shared/characteristic-BGRxcxUH.mjs.map +1 -0
- package/dist/shared/chunk-25Hzd3z8.mjs +13 -0
- package/dist/shared/cubic-CYYEUHNm.mjs +479 -0
- package/dist/shared/cubic-CYYEUHNm.mjs.map +1 -0
- package/dist/shared/cubic-Dfn6DB02.d.mts +1099 -0
- package/dist/shared/interval-CCEqzPgA.mjs +376 -0
- package/dist/shared/interval-CCEqzPgA.mjs.map +1 -0
- package/dist/shared/interval-hQDiKqj0.d.mts +494 -0
- package/dist/shared/matrix4x4-Bt_DBlP0.d.mts +1182 -0
- package/dist/shared/matrix4x4-Ck2WROK-.mjs +440 -0
- package/dist/shared/matrix4x4-Ck2WROK-.mjs.map +1 -0
- package/dist/shared/quadratic-DEhuAKuE.mjs +330 -0
- package/dist/shared/quadratic-DEhuAKuE.mjs.map +1 -0
- package/dist/shared/rationalCubic2d-BPLohNuI.d.mts +787 -0
- package/dist/shared/rationalCubic2d-CP4oGpnk.mjs +658 -0
- package/dist/shared/rationalCubic2d-CP4oGpnk.mjs.map +1 -0
- package/dist/shared/rationalCubic2d-CXa7Yren.mjs +278 -0
- package/dist/shared/rationalCubic2d-CXa7Yren.mjs.map +1 -0
- package/dist/shared/rationalCubic2d-D_-XWxcm.d.mts +297 -0
- package/dist/shared/solution-BjoW7ov4.d.mts +251 -0
- package/dist/shared/solution-CbSWzXCn.mjs +306 -0
- package/dist/shared/solution-CbSWzXCn.mjs.map +1 -0
- package/dist/{pipe.d.mts → shared/utils-DqTGyXrP.d.mts} +44 -26
- package/dist/shared/vector2-CL1HDdPr.mjs +187 -0
- package/dist/shared/vector2-CL1HDdPr.mjs.map +1 -0
- package/dist/shared/vector2-TV0UnlxY.d.mts +1168 -0
- package/dist/shared/vector2.internal-DU_E808S.mjs +97 -0
- package/dist/shared/vector2.internal-DU_E808S.mjs.map +1 -0
- package/dist/shared/vector3-D-tv_aKL.mjs +204 -0
- package/dist/shared/vector3-D-tv_aKL.mjs.map +1 -0
- package/dist/shared/vector4-5KbjoHVj.mjs +109 -0
- package/dist/shared/vector4-5KbjoHVj.mjs.map +1 -0
- package/dist/shared/vector4.internal-5XcaX12X.mjs +163 -0
- package/dist/shared/vector4.internal-5XcaX12X.mjs.map +1 -0
- package/dist/solution/index.d.mts +2 -0
- package/dist/solution/index.mjs +2 -0
- package/dist/splines/index.d.mts +701 -0
- package/dist/splines/index.mjs +734 -0
- package/dist/splines/index.mjs.map +1 -0
- package/dist/utils.d.mts +2 -27
- package/dist/utils.mjs +88 -43
- package/dist/utils.mjs.map +1 -0
- package/dist/vector/index.d.mts +2 -0
- package/dist/vector/index.mjs +4 -0
- package/package.json +49 -92
- package/dist/curve/cubic2d.d.mts +0 -31
- package/dist/curve/cubic2d.d.ts +0 -31
- package/dist/curve/cubic2d.mjs +0 -97
- package/dist/curve/linear2d.d.mts +0 -28
- package/dist/curve/linear2d.d.ts +0 -28
- package/dist/curve/linear2d.mjs +0 -49
- package/dist/curve/quadratic2d.d.mts +0 -33
- package/dist/curve/quadratic2d.d.ts +0 -33
- package/dist/curve/quadratic2d.mjs +0 -87
- package/dist/interval.d.mts +0 -58
- package/dist/interval.d.ts +0 -58
- package/dist/interval.mjs +0 -89
- package/dist/matrix/matrix2x2.d.mts +0 -49
- package/dist/matrix/matrix2x2.d.ts +0 -49
- package/dist/matrix/matrix2x2.mjs +0 -24
- package/dist/matrix/matrix3x3.d.mts +0 -63
- package/dist/matrix/matrix3x3.d.ts +0 -63
- package/dist/matrix/matrix3x3.mjs +0 -27
- package/dist/matrix/matrix4x4.d.mts +0 -72
- package/dist/matrix/matrix4x4.d.ts +0 -72
- package/dist/matrix/matrix4x4.mjs +0 -215
- package/dist/path/cubic2d.d.mts +0 -29
- package/dist/path/cubic2d.d.ts +0 -29
- package/dist/path/cubic2d.mjs +0 -62
- package/dist/path/linear2d.d.mts +0 -29
- package/dist/path/linear2d.d.ts +0 -29
- package/dist/path/linear2d.mjs +0 -55
- package/dist/path/quadratic2d.d.mts +0 -30
- package/dist/path/quadratic2d.d.ts +0 -30
- package/dist/path/quadratic2d.mjs +0 -61
- package/dist/pipe.d.ts +0 -58
- package/dist/pipe.mjs +0 -91
- package/dist/polynomial/cubic.d.mts +0 -7
- package/dist/polynomial/cubic.d.ts +0 -7
- package/dist/polynomial/cubic.mjs +0 -148
- package/dist/polynomial/linear.d.mts +0 -7
- package/dist/polynomial/linear.d.ts +0 -7
- package/dist/polynomial/linear.mjs +0 -23
- package/dist/polynomial/quadratic.d.mts +0 -7
- package/dist/polynomial/quadratic.d.ts +0 -7
- package/dist/polynomial/quadratic.mjs +0 -24
- package/dist/shared/curvy.BDhiZ7He.mjs +0 -80
- package/dist/shared/curvy.BZ_mTkJe.mjs +0 -60
- package/dist/shared/curvy.Bf5TIk31.d.mts +0 -22
- package/dist/shared/curvy.Bf5TIk31.d.ts +0 -22
- package/dist/shared/curvy.BsHoYJNv.d.ts +0 -155
- package/dist/shared/curvy.BzVmUIKm.mjs +0 -131
- package/dist/shared/curvy.C2XGH0R0.mjs +0 -75
- package/dist/shared/curvy.CE4X6_Is.mjs +0 -181
- package/dist/shared/curvy.Cps2R_RU.mjs +0 -120
- package/dist/shared/curvy.Cv-wIzDr.mjs +0 -124
- package/dist/shared/curvy.DmVFTi0N.mjs +0 -34
- package/dist/shared/curvy.NsmY7zcr.d.mts +0 -155
- package/dist/shared/curvy.wYJQhFW-.mjs +0 -87
- package/dist/splines/basis2d.d.mts +0 -38
- package/dist/splines/basis2d.d.ts +0 -38
- package/dist/splines/basis2d.mjs +0 -89
- package/dist/splines/bezier2d.d.mts +0 -48
- package/dist/splines/bezier2d.d.ts +0 -48
- package/dist/splines/bezier2d.mjs +0 -22
- package/dist/splines/cardinal2d.d.mts +0 -49
- package/dist/splines/cardinal2d.d.ts +0 -49
- package/dist/splines/cardinal2d.mjs +0 -123
- package/dist/splines/hermite2d.d.mts +0 -33
- package/dist/splines/hermite2d.d.ts +0 -33
- package/dist/splines/hermite2d.mjs +0 -77
- package/dist/utils.d.ts +0 -27
- package/dist/vector/vector2.d.mts +0 -66
- package/dist/vector/vector2.d.ts +0 -66
- package/dist/vector/vector2.mjs +0 -28
- package/dist/vector/vector3.d.mts +0 -77
- package/dist/vector/vector3.d.ts +0 -77
- package/dist/vector/vector3.mjs +0 -32
- package/dist/vector/vector4.d.mts +0 -43
- package/dist/vector/vector4.d.ts +0 -43
- package/dist/vector/vector4.mjs +0 -18
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
import { vectorProductLeft, make as make$3, solveSystem } from '../matrix/matrix4x4.mjs';
|
|
2
|
-
import { fromCurves } from '../path/cubic2d.mjs';
|
|
3
|
-
import { dual, Pipeable } from '../pipe.mjs';
|
|
4
|
-
import { invariant } from '../utils.mjs';
|
|
5
|
-
import { make as make$4 } from '../vector/vector2.mjs';
|
|
6
|
-
import { make as make$2 } from '../vector/vector4.mjs';
|
|
7
|
-
import { fromPolynomials } from '../curve/cubic2d.mjs';
|
|
8
|
-
import { fromVector } from '../polynomial/cubic.mjs';
|
|
9
|
-
|
|
10
|
-
function* toPointQuads(points, stride) {
|
|
11
|
-
let p0;
|
|
12
|
-
let p1;
|
|
13
|
-
let p2;
|
|
14
|
-
let p3;
|
|
15
|
-
for (const point of points) {
|
|
16
|
-
if (p0 === void 0) {
|
|
17
|
-
p0 = point;
|
|
18
|
-
continue;
|
|
19
|
-
}
|
|
20
|
-
if (p1 === void 0) {
|
|
21
|
-
p1 = point;
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
if (p2 === void 0) {
|
|
25
|
-
p2 = point;
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
p3 = point;
|
|
29
|
-
yield [p0, p1, p2, p3];
|
|
30
|
-
if (stride === 1) {
|
|
31
|
-
p0 = p1;
|
|
32
|
-
p1 = p2;
|
|
33
|
-
p2 = p3;
|
|
34
|
-
} else if (stride === 2) {
|
|
35
|
-
p0 = p2;
|
|
36
|
-
p1 = p3;
|
|
37
|
-
p2 = void 0;
|
|
38
|
-
} else if (stride === 3) {
|
|
39
|
-
p0 = p3;
|
|
40
|
-
p1 = void 0;
|
|
41
|
-
p2 = void 0;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
function* toCurves(points, matrix, stride) {
|
|
46
|
-
for (const [p0, p1, p2, p3] of toPointQuads(points, stride)) {
|
|
47
|
-
yield fromPolynomials(
|
|
48
|
-
fromVector(
|
|
49
|
-
vectorProductLeft(
|
|
50
|
-
matrix,
|
|
51
|
-
make$2(p0.x, p1.x, p2.x, p3.x)
|
|
52
|
-
)
|
|
53
|
-
),
|
|
54
|
-
fromVector(
|
|
55
|
-
vectorProductLeft(
|
|
56
|
-
matrix,
|
|
57
|
-
make$2(p0.y, p1.y, p2.y, p3.y)
|
|
58
|
-
)
|
|
59
|
-
)
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const characteristic$1 = make$3(
|
|
65
|
-
1,
|
|
66
|
-
0,
|
|
67
|
-
0,
|
|
68
|
-
0,
|
|
69
|
-
-3,
|
|
70
|
-
3,
|
|
71
|
-
0,
|
|
72
|
-
0,
|
|
73
|
-
3,
|
|
74
|
-
-6,
|
|
75
|
-
3,
|
|
76
|
-
0,
|
|
77
|
-
-1,
|
|
78
|
-
3,
|
|
79
|
-
-3,
|
|
80
|
-
1
|
|
81
|
-
);
|
|
82
|
-
const Bezier2dTypeId = Symbol("curvy/splines/bezier2d");
|
|
83
|
-
class Bezier2dImpl extends Pipeable {
|
|
84
|
-
[Bezier2dTypeId] = Bezier2dTypeId;
|
|
85
|
-
points;
|
|
86
|
-
constructor(points) {
|
|
87
|
-
invariant(points.length >= 4, "cubic splines requires 4 or more points");
|
|
88
|
-
invariant(
|
|
89
|
-
points.length % 3 === 1,
|
|
90
|
-
"cubic splines requires (n * 3) + 1 points"
|
|
91
|
-
);
|
|
92
|
-
super();
|
|
93
|
-
this.points = points;
|
|
94
|
-
}
|
|
95
|
-
[Symbol.iterator]() {
|
|
96
|
-
return this.points[Symbol.iterator]();
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
const isCubicBezier2d$1 = (p) => typeof p === "object" && p !== null && Bezier2dTypeId in p;
|
|
100
|
-
const make$1 = (p0, p1, p2, p3) => new Bezier2dImpl([p0, p1, p2, p3]);
|
|
101
|
-
const fromArray$1 = (points) => new Bezier2dImpl(points);
|
|
102
|
-
const append$1 = dual(
|
|
103
|
-
4,
|
|
104
|
-
(p, p1, p2, p3) => new Bezier2dImpl(
|
|
105
|
-
(p instanceof Bezier2dImpl ? p.points : Array.from(p)).concat(p1, p2, p3)
|
|
106
|
-
)
|
|
107
|
-
);
|
|
108
|
-
const fromSpline$1 = (p, matrix, stride) => {
|
|
109
|
-
const points = [];
|
|
110
|
-
let x;
|
|
111
|
-
let y;
|
|
112
|
-
for (const [p0, p1, p2, p3] of toPointQuads(p, stride)) {
|
|
113
|
-
x = solveSystem(
|
|
114
|
-
characteristic$1,
|
|
115
|
-
vectorProductLeft(matrix, make$2(p0.x, p1.x, p2.x, p3.x))
|
|
116
|
-
);
|
|
117
|
-
y = solveSystem(
|
|
118
|
-
characteristic$1,
|
|
119
|
-
vectorProductLeft(matrix, make$2(p0.y, p1.y, p2.y, p3.y))
|
|
120
|
-
);
|
|
121
|
-
points.push(
|
|
122
|
-
make$4(x.x, y.x),
|
|
123
|
-
make$4(x.y, y.y),
|
|
124
|
-
make$4(x.z, y.z)
|
|
125
|
-
);
|
|
126
|
-
}
|
|
127
|
-
if (x && y) {
|
|
128
|
-
points.push(make$4(x.w, y.w));
|
|
129
|
-
}
|
|
130
|
-
return fromArray$1(points);
|
|
131
|
-
};
|
|
132
|
-
const appendTangentAligned$1 = dual(4, (p, a, p5, p6) => {
|
|
133
|
-
const points = p instanceof Bezier2dImpl ? p.points : Array.from(p);
|
|
134
|
-
const p2 = points[points.length - 2];
|
|
135
|
-
const p3 = points[points.length - 1];
|
|
136
|
-
const p4 = make$4(p3.x + (p3.x - p2.x) * a, p3.y + (p3.y - p2.y) * a);
|
|
137
|
-
return append$1(p, p4, p5, p6);
|
|
138
|
-
});
|
|
139
|
-
const appendCurvatureAligned = dual(
|
|
140
|
-
4,
|
|
141
|
-
(p, a, b, p6) => {
|
|
142
|
-
const points = p instanceof Bezier2dImpl ? p.points : Array.from(p);
|
|
143
|
-
const p1 = points[points.length - 3];
|
|
144
|
-
const p2 = points[points.length - 2];
|
|
145
|
-
const p3 = points[points.length - 1];
|
|
146
|
-
const p4 = make$4(p3.x + (p3.x - p2.x) * a, p3.y + (p3.y - p2.y) * a);
|
|
147
|
-
const p5 = make$4(
|
|
148
|
-
p3.x + (p3.x - p2.x) * (2 * a + a ** 2 + b / 2) + (p1.x - p2.x) * a ** 2,
|
|
149
|
-
p3.y + (p3.y - p2.y) * (2 * a + a ** 2 + b / 2) + (p1.y - p2.y) * a ** 2
|
|
150
|
-
);
|
|
151
|
-
return append$1(p, p4, p5, p6);
|
|
152
|
-
}
|
|
153
|
-
);
|
|
154
|
-
const appendVelocityAligned$1 = dual(
|
|
155
|
-
3,
|
|
156
|
-
(p, p5, p6) => appendTangentAligned$1(p, 1, p5, p6)
|
|
157
|
-
);
|
|
158
|
-
const appendAccelerationAligned$1 = dual(2, (p, p6) => {
|
|
159
|
-
const points = p instanceof Bezier2dImpl ? p.points : Array.from(p);
|
|
160
|
-
const p1 = points[points.length - 3];
|
|
161
|
-
const p2 = points[points.length - 2];
|
|
162
|
-
const p3 = points[points.length - 1];
|
|
163
|
-
const p4 = make$4(2 * p3.x - p2.x, 2 * p3.y - p2.y);
|
|
164
|
-
const p5 = make$4(p1.x + 4 * (p3.x - p2.x), p1.y + 4 * (p3.y - p2.y));
|
|
165
|
-
return append$1(p, p4, p5, p6);
|
|
166
|
-
});
|
|
167
|
-
const toPath$1 = (p) => fromCurves(...toCurves(p, characteristic$1, 3));
|
|
168
|
-
|
|
169
|
-
const characteristic = characteristic$1;
|
|
170
|
-
const make = make$1;
|
|
171
|
-
const fromArray = fromArray$1;
|
|
172
|
-
const fromSpline = fromSpline$1;
|
|
173
|
-
const isCubicBezier2d = isCubicBezier2d$1;
|
|
174
|
-
const append = append$1;
|
|
175
|
-
const appendTangentAligned = appendTangentAligned$1;
|
|
176
|
-
const appendCurvatureMirrored = appendCurvatureAligned;
|
|
177
|
-
const appendVelocityAligned = appendVelocityAligned$1;
|
|
178
|
-
const appendAccelerationAligned = appendAccelerationAligned$1;
|
|
179
|
-
const toPath = toPath$1;
|
|
180
|
-
|
|
181
|
-
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 };
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { invariant, round } from '../utils.mjs';
|
|
2
|
-
import { dual, Pipeable } from '../pipe.mjs';
|
|
3
|
-
import { m as make$1, d as dot } from './curvy.BZ_mTkJe.mjs';
|
|
4
|
-
|
|
5
|
-
function toIndex(input) {
|
|
6
|
-
if (typeof input === "number") {
|
|
7
|
-
invariant(input >= 0 && input <= 3, "Index out of bounds");
|
|
8
|
-
return input;
|
|
9
|
-
}
|
|
10
|
-
if (input === "x") {
|
|
11
|
-
return 0;
|
|
12
|
-
}
|
|
13
|
-
if (input === "y") {
|
|
14
|
-
return 1;
|
|
15
|
-
}
|
|
16
|
-
if (input === "z") {
|
|
17
|
-
return 2;
|
|
18
|
-
}
|
|
19
|
-
if (input === "w") {
|
|
20
|
-
return 3;
|
|
21
|
-
}
|
|
22
|
-
invariant(false, "Invalid component");
|
|
23
|
-
}
|
|
24
|
-
const toTwoDimensionalIndex = toIndex;
|
|
25
|
-
const toThreeDimensionalIndex = toIndex;
|
|
26
|
-
const toFourDimensionalIndex = toIndex;
|
|
27
|
-
|
|
28
|
-
const Matrix2x2TypeId = Symbol.for("curvy/matrix2x2");
|
|
29
|
-
class Matrix2x2Impl extends Pipeable {
|
|
30
|
-
[Matrix2x2TypeId] = Matrix2x2TypeId;
|
|
31
|
-
m00;
|
|
32
|
-
m01;
|
|
33
|
-
m10;
|
|
34
|
-
m11;
|
|
35
|
-
constructor(m00 = 0, m01 = 0, m10 = 0, m11 = 0) {
|
|
36
|
-
super();
|
|
37
|
-
this.m00 = round(m00);
|
|
38
|
-
this.m01 = round(m01);
|
|
39
|
-
this.m10 = round(m10);
|
|
40
|
-
this.m11 = round(m11);
|
|
41
|
-
}
|
|
42
|
-
get [Symbol.toStringTag]() {
|
|
43
|
-
return `Matrix2x2(${this.m00}, ${this.m01}, ${this.m10}, ${this.m11})`;
|
|
44
|
-
}
|
|
45
|
-
get [Symbol.for("nodejs.util.inspect.custom")]() {
|
|
46
|
-
return `Matrix2x2(${this.m00}, ${this.m01}, ${this.m10}, ${this.m11})`;
|
|
47
|
-
}
|
|
48
|
-
[Symbol.hasInstance](m) {
|
|
49
|
-
return isMatrix2x2(m);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
const isMatrix2x2 = (m) => typeof m === "object" && m !== null && Matrix2x2TypeId in m;
|
|
53
|
-
const make = (m00 = 0, m01 = m00, m10 = m01, m11 = m10) => new Matrix2x2Impl(m00, m01, m10, m11);
|
|
54
|
-
const fromRows = (v0, v1) => new Matrix2x2Impl(v0.x, v0.y, v1.x, v1.y);
|
|
55
|
-
const fromColumns = (v0, v1) => new Matrix2x2Impl(v0.x, v1.x, v0.y, v1.y);
|
|
56
|
-
const setRow = dual(
|
|
57
|
-
3,
|
|
58
|
-
(m, row, v) => fromRows(
|
|
59
|
-
...toRows(m).with(toTwoDimensionalIndex(row), v)
|
|
60
|
-
)
|
|
61
|
-
);
|
|
62
|
-
const setColumn = dual(
|
|
63
|
-
3,
|
|
64
|
-
(m, column, v) => fromColumns(
|
|
65
|
-
...toColumns(m).with(toTwoDimensionalIndex(column), v)
|
|
66
|
-
)
|
|
67
|
-
);
|
|
68
|
-
const determinant = (m) => round(m.m00 * m.m11 - m.m01 * m.m10);
|
|
69
|
-
const vectorProductLeft = dual(
|
|
70
|
-
2,
|
|
71
|
-
(m, v) => make$1(
|
|
72
|
-
dot(rowVector(m, 0), v),
|
|
73
|
-
dot(rowVector(m, 1), v)
|
|
74
|
-
)
|
|
75
|
-
);
|
|
76
|
-
const vectorProductRight = dual(
|
|
77
|
-
2,
|
|
78
|
-
(m, v) => make$1(
|
|
79
|
-
dot(columnVector(m, 0), v),
|
|
80
|
-
dot(columnVector(m, 1), v)
|
|
81
|
-
)
|
|
82
|
-
);
|
|
83
|
-
const solveSystem = dual(2, (m, v) => {
|
|
84
|
-
const inverseDeterminant = 1 / determinant(m);
|
|
85
|
-
invariant(
|
|
86
|
-
Number.isFinite(inverseDeterminant),
|
|
87
|
-
"cannot solve system when coefficient matrix determinant is zero"
|
|
88
|
-
);
|
|
89
|
-
return make$1(
|
|
90
|
-
determinant(setColumn(m, 0, v)) * inverseDeterminant,
|
|
91
|
-
determinant(setColumn(m, 1, v)) * inverseDeterminant
|
|
92
|
-
);
|
|
93
|
-
});
|
|
94
|
-
const toRows = (m) => [
|
|
95
|
-
make$1(m.m00, m.m01),
|
|
96
|
-
make$1(m.m10, m.m11)
|
|
97
|
-
];
|
|
98
|
-
const toColumns = (m) => [
|
|
99
|
-
make$1(m.m00, m.m10),
|
|
100
|
-
make$1(m.m01, m.m11)
|
|
101
|
-
];
|
|
102
|
-
const rowVector = dual(
|
|
103
|
-
2,
|
|
104
|
-
(m, row) => toRows(m)[toTwoDimensionalIndex(row)]
|
|
105
|
-
);
|
|
106
|
-
const columnVector = dual(
|
|
107
|
-
2,
|
|
108
|
-
(m, column) => toColumns(m)[toTwoDimensionalIndex(column)]
|
|
109
|
-
);
|
|
110
|
-
const transpose = (m) => fromColumns(...toRows(m));
|
|
111
|
-
const reverseRows = (m) => {
|
|
112
|
-
const [r0, r1] = toRows(m);
|
|
113
|
-
return fromRows(r1, r0);
|
|
114
|
-
};
|
|
115
|
-
const reverseColumns = (m) => {
|
|
116
|
-
const [c0, c1] = toColumns(m);
|
|
117
|
-
return fromColumns(c1, c0);
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
export { fromColumns as a, setColumn as b, vectorProductRight as c, determinant as d, solveSystem as e, fromRows as f, toColumns as g, columnVector as h, isMatrix2x2 as i, transpose as j, reverseRows as k, reverseColumns as l, make as m, toFourDimensionalIndex as n, toThreeDimensionalIndex as o, rowVector as r, setRow as s, toRows as t, vectorProductLeft as v };
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { o as toThreeDimensionalIndex, d as determinant$1, m as make$1 } from './curvy.Cps2R_RU.mjs';
|
|
2
|
-
import { dual, Pipeable } from '../pipe.mjs';
|
|
3
|
-
import { round, invariant } from '../utils.mjs';
|
|
4
|
-
import { b as components, m as make$2, d as dot } from './curvy.wYJQhFW-.mjs';
|
|
5
|
-
|
|
6
|
-
const Matrix3x3TypeId = Symbol.for("curvy/matrix3x3");
|
|
7
|
-
class Matrix3x3Impl extends Pipeable {
|
|
8
|
-
[Matrix3x3TypeId] = Matrix3x3TypeId;
|
|
9
|
-
m00;
|
|
10
|
-
m01;
|
|
11
|
-
m02;
|
|
12
|
-
m10;
|
|
13
|
-
m11;
|
|
14
|
-
m12;
|
|
15
|
-
m20;
|
|
16
|
-
m21;
|
|
17
|
-
m22;
|
|
18
|
-
constructor(m00 = 0, m01 = 0, m02 = 0, m10 = 0, m11 = 0, m12 = 0, m20 = 0, m21 = 0, m22 = 0) {
|
|
19
|
-
super();
|
|
20
|
-
this.m00 = round(m00);
|
|
21
|
-
this.m01 = round(m01);
|
|
22
|
-
this.m02 = round(m02);
|
|
23
|
-
this.m10 = round(m10);
|
|
24
|
-
this.m11 = round(m11);
|
|
25
|
-
this.m12 = round(m12);
|
|
26
|
-
this.m20 = round(m20);
|
|
27
|
-
this.m21 = round(m21);
|
|
28
|
-
this.m22 = round(m22);
|
|
29
|
-
}
|
|
30
|
-
get [Symbol.toStringTag]() {
|
|
31
|
-
return `Matrix3x3(${this.m00}, ${this.m01}, ${this.m02}, ${this.m10}, ${this.m11}, ${this.m12}, ${this.m20}, ${this.m21}, ${this.m22})`;
|
|
32
|
-
}
|
|
33
|
-
get [Symbol.for("nodejs.util.inspect.custom")]() {
|
|
34
|
-
return `Matrix3x3(${this.m00}, ${this.m01}, ${this.m02}, ${this.m10}, ${this.m11}, ${this.m12}, ${this.m20}, ${this.m21}, ${this.m22})`;
|
|
35
|
-
}
|
|
36
|
-
[Symbol.hasInstance](m) {
|
|
37
|
-
return isMatrix3x3(m);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
const isMatrix3x3 = (m) => typeof m === "object" && m !== null && Matrix3x3TypeId in m;
|
|
41
|
-
const make = (m00 = 0, m01 = m00, m02 = m01, m10 = m02, m11 = m10, m12 = m11, m20 = m12, m21 = m20, m22 = m21) => {
|
|
42
|
-
return new Matrix3x3Impl(m00, m01, m02, m10, m11, m12, m20, m21, m22);
|
|
43
|
-
};
|
|
44
|
-
const fromRows = (v0, v1, v2) => new Matrix3x3Impl(v0.x, v0.y, v0.z, v1.x, v1.y, v1.z, v2.x, v2.y, v2.z);
|
|
45
|
-
const fromColumns = (v0, v1, v2) => new Matrix3x3Impl(v0.x, v1.x, v2.x, v0.y, v1.y, v2.y, v0.z, v1.z, v2.z);
|
|
46
|
-
const setRow = dual(
|
|
47
|
-
3,
|
|
48
|
-
(m, row, v) => fromRows(
|
|
49
|
-
...toRows(m).with(toThreeDimensionalIndex(row), v)
|
|
50
|
-
)
|
|
51
|
-
);
|
|
52
|
-
const setColumn = dual(
|
|
53
|
-
3,
|
|
54
|
-
(m, column, v) => fromColumns(
|
|
55
|
-
...toColumns(m).with(toThreeDimensionalIndex(column), v)
|
|
56
|
-
)
|
|
57
|
-
);
|
|
58
|
-
const determinant = (m) => round(
|
|
59
|
-
m.m00 * determinant$1(minor(m, 0, 0)) - m.m01 * determinant$1(minor(m, 0, 1)) + m.m02 * determinant$1(minor(m, 0, 2))
|
|
60
|
-
);
|
|
61
|
-
const minor = dual(3, (m, row, column) => {
|
|
62
|
-
const [v0, v1] = toRows(m).toSpliced(toThreeDimensionalIndex(row), 1);
|
|
63
|
-
const columnIndex = toThreeDimensionalIndex(column);
|
|
64
|
-
const [m00, m01] = components(v0).toSpliced(columnIndex, 1);
|
|
65
|
-
const [m10, m11] = components(v1).toSpliced(columnIndex, 1);
|
|
66
|
-
return make$1(m00, m01, m10, m11);
|
|
67
|
-
});
|
|
68
|
-
const vectorProductLeft = dual(2, (m, v) => {
|
|
69
|
-
const [v0, v1, v2] = toRows(m);
|
|
70
|
-
return make$2(
|
|
71
|
-
dot(v0, v),
|
|
72
|
-
dot(v1, v),
|
|
73
|
-
dot(v2, v)
|
|
74
|
-
);
|
|
75
|
-
});
|
|
76
|
-
const vectorProductRight = dual(2, (m, v) => {
|
|
77
|
-
const [v0, v1, v2] = toColumns(m);
|
|
78
|
-
return make$2(
|
|
79
|
-
dot(v, v0),
|
|
80
|
-
dot(v, v1),
|
|
81
|
-
dot(v, v2)
|
|
82
|
-
);
|
|
83
|
-
});
|
|
84
|
-
const solveSystem = dual(2, (m, v) => {
|
|
85
|
-
const inverseDeterminant = 1 / determinant(m);
|
|
86
|
-
invariant(
|
|
87
|
-
Number.isFinite(inverseDeterminant),
|
|
88
|
-
"cannot solve system when coefficient matrix determinant is zero"
|
|
89
|
-
);
|
|
90
|
-
return make$2(
|
|
91
|
-
determinant(setColumn(m, 0, v)) * inverseDeterminant,
|
|
92
|
-
determinant(setColumn(m, 1, v)) * inverseDeterminant,
|
|
93
|
-
determinant(setColumn(m, 2, v)) * inverseDeterminant
|
|
94
|
-
);
|
|
95
|
-
});
|
|
96
|
-
const toRows = (m) => [
|
|
97
|
-
make$2(m.m00, m.m01, m.m02),
|
|
98
|
-
make$2(m.m10, m.m11, m.m12),
|
|
99
|
-
make$2(m.m20, m.m21, m.m22)
|
|
100
|
-
];
|
|
101
|
-
const toColumns = (m) => [
|
|
102
|
-
make$2(m.m00, m.m10, m.m20),
|
|
103
|
-
make$2(m.m01, m.m11, m.m21),
|
|
104
|
-
make$2(m.m02, m.m12, m.m22)
|
|
105
|
-
];
|
|
106
|
-
const rowVector = dual(
|
|
107
|
-
2,
|
|
108
|
-
(m, row) => toRows(m)[toThreeDimensionalIndex(row)]
|
|
109
|
-
);
|
|
110
|
-
const columnVector = dual(
|
|
111
|
-
2,
|
|
112
|
-
(m, column) => toColumns(m)[toThreeDimensionalIndex(column)]
|
|
113
|
-
);
|
|
114
|
-
const transpose = (m) => fromColumns(...toRows(m));
|
|
115
|
-
const reverseRows = (m) => {
|
|
116
|
-
const [v0, v1, v2] = toRows(m);
|
|
117
|
-
return fromRows(v2, v1, v0);
|
|
118
|
-
};
|
|
119
|
-
const reverseColumns = (m) => {
|
|
120
|
-
const [v0, v1, v2] = toColumns(m);
|
|
121
|
-
return fromColumns(v2, v1, v0);
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
export { fromColumns as a, setColumn as b, minor as c, determinant as d, vectorProductRight as e, fromRows as f, solveSystem as g, toColumns as h, isMatrix3x3 as i, columnVector as j, transpose as k, reverseRows as l, make as m, reverseColumns as n, rowVector as r, setRow as s, toRows as t, vectorProductLeft as v };
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
const GL32_X0 = 0.9972638618494816;
|
|
2
|
-
const GL32_X1 = 0.9856115115452684;
|
|
3
|
-
const GL32_X2 = 0.9647622555875064;
|
|
4
|
-
const GL32_X3 = 0.9349060759377397;
|
|
5
|
-
const GL32_X4 = 0.8963211557660521;
|
|
6
|
-
const GL32_X5 = 0.84936761373257;
|
|
7
|
-
const GL32_X6 = 0.7944837959679424;
|
|
8
|
-
const GL32_X7 = 0.7321821187402897;
|
|
9
|
-
const GL32_X8 = 0.6630442669302152;
|
|
10
|
-
const GL32_X9 = 0.5877157572407623;
|
|
11
|
-
const GL32_X10 = 0.5068999089322294;
|
|
12
|
-
const GL32_X11 = 0.42135127613063533;
|
|
13
|
-
const GL32_X12 = 0.33186860228212767;
|
|
14
|
-
const GL32_X13 = 0.23928736225213706;
|
|
15
|
-
const GL32_X14 = 0.1444719615827965;
|
|
16
|
-
const GL32_X15 = 0.04830766568773831;
|
|
17
|
-
const GL32_W0 = 0.007018610009470136;
|
|
18
|
-
const GL32_W1 = 0.01627439473090571;
|
|
19
|
-
const GL32_W2 = 0.02539206530926214;
|
|
20
|
-
const GL32_W3 = 0.03427386291302141;
|
|
21
|
-
const GL32_W4 = 0.042835898022226704;
|
|
22
|
-
const GL32_W5 = 0.050998059262376154;
|
|
23
|
-
const GL32_W6 = 0.05868409347853558;
|
|
24
|
-
const GL32_W7 = 0.06582222277636195;
|
|
25
|
-
const GL32_W8 = 0.07234579410884862;
|
|
26
|
-
const GL32_W9 = 0.07819389578707044;
|
|
27
|
-
const GL32_W10 = 0.08331192422694672;
|
|
28
|
-
const GL32_W11 = 0.08765209300440374;
|
|
29
|
-
const GL32_W12 = 0.0911738786957639;
|
|
30
|
-
const GL32_W13 = 0.09384439908080454;
|
|
31
|
-
const GL32_W14 = 0.09563872007927485;
|
|
32
|
-
const GL32_W15 = 0.09654008851472785;
|
|
33
|
-
|
|
34
|
-
export { GL32_X13 as A, GL32_W14 as B, GL32_X14 as C, GL32_W15 as D, GL32_X15 as E, GL32_W0 as G, GL32_X0 as a, GL32_W1 as b, GL32_X1 as c, GL32_W2 as d, GL32_X2 as e, GL32_W3 as f, GL32_X3 as g, GL32_W4 as h, GL32_X4 as i, GL32_W5 as j, GL32_X5 as k, GL32_W6 as l, GL32_X6 as m, GL32_W7 as n, GL32_X7 as o, GL32_W8 as p, GL32_X8 as q, GL32_W9 as r, GL32_X9 as s, GL32_W10 as t, GL32_X10 as u, GL32_W11 as v, GL32_X11 as w, GL32_W12 as x, GL32_X12 as y, GL32_W13 as z };
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { Interval } from '../interval.mjs';
|
|
2
|
-
import { Pipeable } from '../pipe.mjs';
|
|
3
|
-
import { Vector2 } from '../vector/vector2.mjs';
|
|
4
|
-
import { Vector3 } from '../vector/vector3.mjs';
|
|
5
|
-
import { Vector4 } from '../vector/vector4.mjs';
|
|
6
|
-
|
|
7
|
-
declare const CubicPolynomialTypeId: unique symbol;
|
|
8
|
-
type CubicPolynomialTypeId = typeof CubicPolynomialTypeId;
|
|
9
|
-
|
|
10
|
-
type Monotonicity = 'none' | 'increasing' | 'decreasing' | 'constant';
|
|
11
|
-
type GuaranteedMonotonicity = 'increasing' | 'decreasing' | 'constant';
|
|
12
|
-
|
|
13
|
-
type ZeroOrOneSolution = number | null;
|
|
14
|
-
type ZeroOrOneInterval = Interval | null;
|
|
15
|
-
type ZeroToTwoSolutions = readonly [] | readonly [number] | readonly [number, number];
|
|
16
|
-
type ZeroToThreeSolutions = readonly [] | readonly [number] | readonly [number, number] | readonly [number, number, number];
|
|
17
|
-
|
|
18
|
-
interface CubicPolynomial extends Pipeable {
|
|
19
|
-
readonly [CubicPolynomialTypeId]: CubicPolynomialTypeId;
|
|
20
|
-
readonly c0: number;
|
|
21
|
-
readonly c1: number;
|
|
22
|
-
readonly c2: number;
|
|
23
|
-
readonly c3: number;
|
|
24
|
-
}
|
|
25
|
-
declare const isCubicPolynomial: (value: unknown) => value is CubicPolynomial;
|
|
26
|
-
declare const make$2: (c0: number, c1: number, c2: number, c3: number) => CubicPolynomial;
|
|
27
|
-
declare const fromVector$2: (v: Vector4) => CubicPolynomial;
|
|
28
|
-
declare const solve$2: {
|
|
29
|
-
(p: CubicPolynomial, x: number): number;
|
|
30
|
-
(x: number): (p: CubicPolynomial) => number;
|
|
31
|
-
};
|
|
32
|
-
declare const toSolver$2: (p: CubicPolynomial) => (x: number) => number;
|
|
33
|
-
declare const solveInverse$2: {
|
|
34
|
-
(p: CubicPolynomial, y: number): ZeroToThreeSolutions;
|
|
35
|
-
(y: number): (p: CubicPolynomial) => ZeroToThreeSolutions;
|
|
36
|
-
};
|
|
37
|
-
declare const toInverseSolver$2: (p: CubicPolynomial) => (y: number) => ZeroToThreeSolutions;
|
|
38
|
-
declare const derivative$2: (p: CubicPolynomial) => QuadraticPolynomial;
|
|
39
|
-
declare const roots$1: (p: CubicPolynomial) => ZeroToThreeSolutions;
|
|
40
|
-
declare const extrema: (p: CubicPolynomial) => ZeroToTwoSolutions;
|
|
41
|
-
declare const monotonicity$2: {
|
|
42
|
-
(p: CubicPolynomial, i?: Interval): Monotonicity;
|
|
43
|
-
(i: Interval): (p: CubicPolynomial) => Monotonicity;
|
|
44
|
-
};
|
|
45
|
-
declare const domain$2: {
|
|
46
|
-
(p: CubicPolynomial, range: Interval): Interval;
|
|
47
|
-
(range: Interval): (p: CubicPolynomial) => Interval;
|
|
48
|
-
};
|
|
49
|
-
declare const range$2: {
|
|
50
|
-
(p: CubicPolynomial, domain: Interval): Interval;
|
|
51
|
-
(domain: Interval): (p: CubicPolynomial) => Interval;
|
|
52
|
-
};
|
|
53
|
-
declare const length$2: {
|
|
54
|
-
(p: CubicPolynomial, domain: Interval): number;
|
|
55
|
-
(domain: Interval): (p: CubicPolynomial) => number;
|
|
56
|
-
};
|
|
57
|
-
declare const curvature$1: {
|
|
58
|
-
(p: CubicPolynomial, x: number): number;
|
|
59
|
-
(x: number): (p: CubicPolynomial) => number;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
declare const QuadraticPolynomialTypeId: unique symbol;
|
|
63
|
-
type QuadraticPolynomialTypeId = typeof QuadraticPolynomialTypeId;
|
|
64
|
-
|
|
65
|
-
interface QuadraticPolynomial extends Pipeable {
|
|
66
|
-
readonly [QuadraticPolynomialTypeId]: QuadraticPolynomialTypeId;
|
|
67
|
-
readonly c0: number;
|
|
68
|
-
readonly c1: number;
|
|
69
|
-
readonly c2: number;
|
|
70
|
-
}
|
|
71
|
-
declare const isQuadraticPolynomial: (v: unknown) => v is QuadraticPolynomial;
|
|
72
|
-
declare const make$1: (c0?: number, c1?: number, c2?: number) => QuadraticPolynomial;
|
|
73
|
-
declare const fromVector$1: (v: Vector3) => QuadraticPolynomial;
|
|
74
|
-
declare const solve$1: {
|
|
75
|
-
(p: QuadraticPolynomial, x: number): number;
|
|
76
|
-
(x: number): (p: QuadraticPolynomial) => number;
|
|
77
|
-
};
|
|
78
|
-
declare const toSolver$1: (p: QuadraticPolynomial) => (x: number) => number;
|
|
79
|
-
declare const solveInverse$1: {
|
|
80
|
-
(p: QuadraticPolynomial, y: number): ZeroToTwoSolutions;
|
|
81
|
-
(y: number): (p: QuadraticPolynomial) => ZeroToTwoSolutions;
|
|
82
|
-
};
|
|
83
|
-
declare const toInverseSolver$1: (p: QuadraticPolynomial) => (y: number) => ZeroToTwoSolutions;
|
|
84
|
-
declare const derivative$1: (p: QuadraticPolynomial) => LinearPolynomial;
|
|
85
|
-
declare const roots: (p: QuadraticPolynomial) => ZeroToTwoSolutions;
|
|
86
|
-
declare const extreme: (p: QuadraticPolynomial) => ZeroOrOneSolution;
|
|
87
|
-
declare const monotonicity$1: {
|
|
88
|
-
(p: QuadraticPolynomial, i?: Interval): Monotonicity;
|
|
89
|
-
(i: Interval): (p: QuadraticPolynomial) => Monotonicity;
|
|
90
|
-
};
|
|
91
|
-
declare const antiderivative$1: {
|
|
92
|
-
(p: QuadraticPolynomial, constant?: number): CubicPolynomial;
|
|
93
|
-
(constant: number): (p: QuadraticPolynomial) => CubicPolynomial;
|
|
94
|
-
};
|
|
95
|
-
declare const domain$1: {
|
|
96
|
-
(p: QuadraticPolynomial, range: Interval): Interval | null;
|
|
97
|
-
(range: Interval): (p: QuadraticPolynomial) => Interval | null;
|
|
98
|
-
};
|
|
99
|
-
declare const range$1: {
|
|
100
|
-
(p: QuadraticPolynomial, domain: Interval): Interval;
|
|
101
|
-
(domain: Interval): (p: QuadraticPolynomial) => Interval;
|
|
102
|
-
};
|
|
103
|
-
declare const length$1: {
|
|
104
|
-
(p: QuadraticPolynomial, i: Interval): number;
|
|
105
|
-
(i: Interval): (p: QuadraticPolynomial) => number;
|
|
106
|
-
};
|
|
107
|
-
declare const curvature: {
|
|
108
|
-
(p: QuadraticPolynomial, x: number): number;
|
|
109
|
-
(x: number): (p: QuadraticPolynomial) => number;
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
declare const LinearPolynomialTypeId: unique symbol;
|
|
113
|
-
type LinearPolynomialTypeId = typeof LinearPolynomialTypeId;
|
|
114
|
-
|
|
115
|
-
interface LinearPolynomial extends Pipeable {
|
|
116
|
-
readonly [LinearPolynomialTypeId]: LinearPolynomialTypeId;
|
|
117
|
-
readonly c0: number;
|
|
118
|
-
readonly c1: number;
|
|
119
|
-
}
|
|
120
|
-
declare const isLinearPolynomial: (v: unknown) => v is LinearPolynomial;
|
|
121
|
-
declare const make: (c0?: number, c1?: number) => LinearPolynomial;
|
|
122
|
-
declare const fromVector: (v: Vector2) => LinearPolynomial;
|
|
123
|
-
declare const fromPointSlope: (p: Vector2, slope: number) => LinearPolynomial;
|
|
124
|
-
declare const fromPoints: (p1: Vector2, p2: Vector2) => LinearPolynomial;
|
|
125
|
-
declare const solve: {
|
|
126
|
-
(p: LinearPolynomial, x: number): number;
|
|
127
|
-
(x: number): (p: LinearPolynomial) => number;
|
|
128
|
-
};
|
|
129
|
-
declare const toSolver: (p: LinearPolynomial) => (x: number) => number;
|
|
130
|
-
declare const solveInverse: {
|
|
131
|
-
(p: LinearPolynomial, y: number): ZeroOrOneSolution;
|
|
132
|
-
(y: number): (p: LinearPolynomial) => ZeroOrOneSolution;
|
|
133
|
-
};
|
|
134
|
-
declare const toInverseSolver: (p: LinearPolynomial) => (y: number) => ZeroOrOneSolution;
|
|
135
|
-
declare const root: (p: LinearPolynomial) => ZeroOrOneSolution;
|
|
136
|
-
declare const monotonicity: (p: LinearPolynomial) => GuaranteedMonotonicity;
|
|
137
|
-
declare const derivative: (p: LinearPolynomial) => number;
|
|
138
|
-
declare const antiderivative: {
|
|
139
|
-
(p: LinearPolynomial, constant?: number): QuadraticPolynomial;
|
|
140
|
-
(constant: number): (p: LinearPolynomial) => QuadraticPolynomial;
|
|
141
|
-
};
|
|
142
|
-
declare const domain: {
|
|
143
|
-
(p: LinearPolynomial, range: Interval): ZeroOrOneInterval;
|
|
144
|
-
(range: Interval): (p: LinearPolynomial) => ZeroOrOneInterval;
|
|
145
|
-
};
|
|
146
|
-
declare const range: {
|
|
147
|
-
(p: LinearPolynomial, domain: Interval): Interval;
|
|
148
|
-
(domain: Interval): (p: LinearPolynomial) => Interval;
|
|
149
|
-
};
|
|
150
|
-
declare const length: {
|
|
151
|
-
(p: LinearPolynomial, domain: Interval): number;
|
|
152
|
-
(domain: Interval): (p: LinearPolynomial) => number;
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
export { antiderivative$1 as A, domain$1 as B, type CubicPolynomial as C, range$1 as D, length$1 as E, curvature as F, isLinearPolynomial as G, make as H, fromVector as I, fromPointSlope as J, fromPoints as K, type LinearPolynomial as L, solve as M, toSolver as N, solveInverse as O, toInverseSolver as P, type QuadraticPolynomial as Q, root as R, monotonicity as S, derivative as T, antiderivative as U, domain as V, range as W, length as X, solveInverse$2 as a, toInverseSolver$2 as b, monotonicity$2 as c, derivative$2 as d, extrema as e, fromVector$2 as f, domain$2 as g, range$2 as h, isCubicPolynomial as i, curvature$1 as j, isQuadraticPolynomial as k, length$2 as l, make$2 as m, make$1 as n, fromVector$1 as o, solve$1 as p, toSolver$1 as q, roots$1 as r, solve$2 as s, toSolver$2 as t, solveInverse$1 as u, toInverseSolver$1 as v, derivative$1 as w, roots as x, extreme as y, monotonicity$1 as z };
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { dual, Pipeable } from '../pipe.mjs';
|
|
2
|
-
import { round } from '../utils.mjs';
|
|
3
|
-
|
|
4
|
-
const Vector3TypeId = Symbol.for("curvy/vector3");
|
|
5
|
-
class Vector3Impl extends Pipeable {
|
|
6
|
-
[Vector3TypeId] = Vector3TypeId;
|
|
7
|
-
x;
|
|
8
|
-
y;
|
|
9
|
-
z;
|
|
10
|
-
constructor(v0 = 0, v1 = 0, v2 = 0) {
|
|
11
|
-
super();
|
|
12
|
-
this.x = round(v0);
|
|
13
|
-
this.y = round(v1);
|
|
14
|
-
this.z = round(v2);
|
|
15
|
-
}
|
|
16
|
-
get [0]() {
|
|
17
|
-
return this.x;
|
|
18
|
-
}
|
|
19
|
-
get [1]() {
|
|
20
|
-
return this.y;
|
|
21
|
-
}
|
|
22
|
-
get [2]() {
|
|
23
|
-
return this.z;
|
|
24
|
-
}
|
|
25
|
-
get [Symbol.toStringTag]() {
|
|
26
|
-
return `Vector3(${this.x}, ${this.y}, ${this.z})`;
|
|
27
|
-
}
|
|
28
|
-
get [Symbol.for("nodejs.util.inspect.custom")]() {
|
|
29
|
-
return this[Symbol.toStringTag];
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
const isVector3 = (v) => typeof v === "object" && v !== null && Vector3TypeId in v;
|
|
33
|
-
const make = (v0, v1 = v0, v2 = v1) => new Vector3Impl(v0, v1, v2);
|
|
34
|
-
const fromSpherical = (r, theta, phi) => make(
|
|
35
|
-
r * Math.sin(phi) * Math.cos(theta),
|
|
36
|
-
r * Math.sin(phi) * Math.sin(theta),
|
|
37
|
-
r * Math.cos(phi)
|
|
38
|
-
);
|
|
39
|
-
const magnitude = (vector) => round(Math.hypot(vector.x, vector.y, vector.z));
|
|
40
|
-
const normalize = (vector) => {
|
|
41
|
-
const m = magnitude(vector);
|
|
42
|
-
return make(vector.x / m, vector.y / m, vector.z / m);
|
|
43
|
-
};
|
|
44
|
-
const dot = dual(2, (a, b) => round(a.x * b.x + a.y * b.y + a.z * b.z));
|
|
45
|
-
const cross = dual(2, (a, b) => {
|
|
46
|
-
const x = a.y * b.z - a.z * b.y;
|
|
47
|
-
const y = a.z * b.x - a.x * b.z;
|
|
48
|
-
const z = a.x * b.y - a.y * b.x;
|
|
49
|
-
return make(x, y, z);
|
|
50
|
-
});
|
|
51
|
-
const components = (v) => [v.x, v.y, v.z];
|
|
52
|
-
const softmax = (v) => {
|
|
53
|
-
const max = Math.max(v.x, v.y, v.z);
|
|
54
|
-
const v0 = Math.exp(v.x - max);
|
|
55
|
-
const v1 = Math.exp(v.y - max);
|
|
56
|
-
const v2 = Math.exp(v.z - max);
|
|
57
|
-
const sum = v0 + v1 + v2;
|
|
58
|
-
return make(v0 / sum, v1 / sum, v2 / sum);
|
|
59
|
-
};
|
|
60
|
-
const add = dual(2, (a, b) => make(a.x + b.x, a.y + b.y, a.z + b.z));
|
|
61
|
-
const subtract = dual(2, (a, b) => make(a.x - b.x, a.y - b.y, a.z - b.z));
|
|
62
|
-
const hadamard = dual(2, (a, b) => make(a.x * b.x, a.y * b.y, a.z * b.z));
|
|
63
|
-
const scale = dual(2, (v, s) => s === 1 ? v : make(v.x * s, v.y * s, v.z * s));
|
|
64
|
-
const getX = (v) => v.x;
|
|
65
|
-
const setX = dual(2, (v, x) => make(x, v.y, v.z));
|
|
66
|
-
const getY = (v) => v.y;
|
|
67
|
-
const setY = dual(2, (v, y) => make(v.x, y, v.z));
|
|
68
|
-
const getZ = (v) => v.z;
|
|
69
|
-
const setZ = dual(2, (v, z) => make(v.x, v.y, z));
|
|
70
|
-
const setR = dual(2, (v, r) => scale(r / magnitude(v))(v));
|
|
71
|
-
const getTheta = (v) => Math.acos(v.z / magnitude(v));
|
|
72
|
-
const setTheta = dual(2, (v, phi) => {
|
|
73
|
-
const m = magnitude(v);
|
|
74
|
-
const sinTheta = Math.sin(phi);
|
|
75
|
-
return make(
|
|
76
|
-
m * sinTheta * Math.cos(v.y),
|
|
77
|
-
m * sinTheta * Math.sin(v.y),
|
|
78
|
-
m * Math.cos(phi)
|
|
79
|
-
);
|
|
80
|
-
});
|
|
81
|
-
const getPhi = (v) => round(Math.atan2(v.y, v.x));
|
|
82
|
-
const setPhi = dual(2, (v, theta) => {
|
|
83
|
-
const m = magnitude(v);
|
|
84
|
-
return make(m * Math.cos(theta), m * Math.sin(theta), v.z);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
export { magnitude as a, components as b, cross as c, dot as d, add as e, fromSpherical as f, subtract as g, hadamard as h, isVector3 as i, scale as j, getX as k, setX as l, make as m, normalize as n, getY as o, setY as p, getZ as q, setZ as r, softmax as s, setR as t, getTheta as u, setTheta as v, getPhi as w, setPhi as x };
|