pimath 0.1.2 → 0.1.4
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/pimath.js
CHANGED
|
@@ -47,16 +47,16 @@ function Ci(...o) {
|
|
|
47
47
|
function $i(o, e = 3) {
|
|
48
48
|
return +o.toFixed(e);
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function Pi(o) {
|
|
51
51
|
if (Number.isSafeInteger(o) || o.toString().split(".")[0].length < 10)
|
|
52
52
|
return 0;
|
|
53
53
|
throw new Error("Periodic value: Not implemented yet");
|
|
54
54
|
}
|
|
55
|
-
function
|
|
55
|
+
function Si(o) {
|
|
56
56
|
const e = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919, 7927, 7933, 7937, 7949, 7951, 7963, 7993, 8009, 8011, 8017, 8039, 8053, 8059, 8069, 8081, 8087, 8089, 8093, 8101, 8111, 8117, 8123, 8147, 8161, 8167, 8171, 8179, 8191, 8209, 8219, 8221, 8231, 8233, 8237, 8243, 8263, 8269, 8273, 8287, 8291, 8293, 8297, 8311, 8317, 8329, 8353, 8363, 8369, 8377, 8387, 8389, 8419, 8423, 8429, 8431, 8443, 8447, 8461, 8467, 8501, 8513, 8521, 8527, 8537, 8539, 8543, 8563, 8573, 8581, 8597, 8599, 8609, 8623, 8627, 8629, 8641, 8647, 8663, 8669, 8677, 8681, 8689, 8693, 8699, 8707, 8713, 8719, 8731, 8737, 8741, 8747, 8753, 8761, 8779, 8783, 8803, 8807, 8819, 8821, 8831, 8837, 8839, 8849, 8861, 8863, 8867, 8887, 8893, 8923, 8929, 8933, 8941, 8951, 8963, 8969, 8971, 8999, 9001, 9007, 9011, 9013, 9029, 9041, 9043, 9049, 9059, 9067, 9091, 9103, 9109, 9127, 9133, 9137, 9151, 9157, 9161, 9173, 9181, 9187, 9199, 9203, 9209, 9221, 9227, 9239, 9241, 9257, 9277, 9281, 9283, 9293, 9311, 9319, 9323, 9337, 9341, 9343, 9349, 9371, 9377, 9391, 9397, 9403, 9413, 9419, 9421, 9431, 9433, 9437, 9439, 9461, 9463, 9467, 9473, 9479, 9491, 9497, 9511, 9521, 9533, 9539, 9547, 9551, 9587, 9601, 9613, 9619, 9623, 9629, 9631, 9643, 9649, 9661, 9677, 9679, 9689, 9697, 9719, 9721, 9733, 9739, 9743, 9749, 9767, 9769, 9781, 9787, 9791, 9803, 9811, 9817, 9829, 9833, 9839, 9851, 9857, 9859, 9871, 9883, 9887, 9901, 9907, 9923, 9929, 9931, 9941, 9949, 9967, 9973];
|
|
57
57
|
return o === void 0 ? e : e.slice(0, Math.min(e.length, o));
|
|
58
58
|
}
|
|
59
|
-
function
|
|
59
|
+
function Bi(o, e) {
|
|
60
60
|
const t = [], s = e === !0 ? +o : o ** 2;
|
|
61
61
|
for (let r = 0; r <= o; r++)
|
|
62
62
|
for (let n = 0; n <= o; n++)
|
|
@@ -73,19 +73,19 @@ const G = {
|
|
|
73
73
|
gcd: ei,
|
|
74
74
|
lcm: Ci,
|
|
75
75
|
numberCorrection: $i,
|
|
76
|
-
periodic:
|
|
77
|
-
primes:
|
|
78
|
-
pythagoreanTripletsWithTarget:
|
|
76
|
+
periodic: Pi,
|
|
77
|
+
primes: Si,
|
|
78
|
+
pythagoreanTripletsWithTarget: Bi,
|
|
79
79
|
round: Ri
|
|
80
80
|
};
|
|
81
|
-
var w, b, ot,
|
|
81
|
+
var w, b, ot, Be;
|
|
82
82
|
const $ = class $ {
|
|
83
83
|
constructor(e, t) {
|
|
84
84
|
// #region Class fields (2)
|
|
85
85
|
f(this, w, 1);
|
|
86
86
|
f(this, b, 1);
|
|
87
87
|
f(this, ot, !1);
|
|
88
|
-
f(this,
|
|
88
|
+
f(this, Be, "frac");
|
|
89
89
|
// ------------------------------------------
|
|
90
90
|
/**
|
|
91
91
|
* Parse the value to get the numerator and denominator
|
|
@@ -272,17 +272,17 @@ const $ = class $ {
|
|
|
272
272
|
h(this, w, e);
|
|
273
273
|
}
|
|
274
274
|
get tfrac() {
|
|
275
|
-
return h(this,
|
|
275
|
+
return h(this, Be, "tfrac"), this;
|
|
276
276
|
}
|
|
277
277
|
get dfrac() {
|
|
278
|
-
return h(this,
|
|
278
|
+
return h(this, Be, "dfrac"), this;
|
|
279
279
|
}
|
|
280
280
|
get frac() {
|
|
281
|
-
return h(this,
|
|
281
|
+
return h(this, Be, "frac"), this;
|
|
282
282
|
}
|
|
283
283
|
// Display getter
|
|
284
284
|
get tex() {
|
|
285
|
-
return this.isInfinity() ? `${this.sign() === 1 ? "+" : "-"}\\infty` : this.isExact() ? i(this, b) === 1 ? `${i(this, w)}` : i(this, w) < 0 ? `-\\${i(this,
|
|
285
|
+
return this.isInfinity() ? `${this.sign() === 1 ? "+" : "-"}\\infty` : this.isExact() ? i(this, b) === 1 ? `${i(this, w)}` : i(this, w) < 0 ? `-\\${i(this, Be)}{ ${-i(this, w)} }{ ${i(this, b)} }` : `\\${i(this, Be)}{ ${i(this, w)} }{ ${i(this, b)} }` : this.value.toFixed(3);
|
|
286
286
|
}
|
|
287
287
|
get texWithSign() {
|
|
288
288
|
return this.isPositive() ? `+${this.tex}` : this.tex;
|
|
@@ -292,7 +292,7 @@ const $ = class $ {
|
|
|
292
292
|
}
|
|
293
293
|
// #endregion Getters And Setters (11)
|
|
294
294
|
};
|
|
295
|
-
w = new WeakMap(), b = new WeakMap(), ot = new WeakMap(),
|
|
295
|
+
w = new WeakMap(), b = new WeakMap(), ot = new WeakMap(), Be = new WeakMap(), a($, "average", (...e) => {
|
|
296
296
|
const t = new $().zero();
|
|
297
297
|
for (const s of e)
|
|
298
298
|
t.add(s);
|
|
@@ -406,23 +406,23 @@ function zi(o, e) {
|
|
|
406
406
|
if (o.length <= 1)
|
|
407
407
|
return o;
|
|
408
408
|
const t = Object.keys(e).filter((E) => e[E].type === d.FUNCTION).map((E) => E);
|
|
409
|
-
t.sort((E,
|
|
409
|
+
t.sort((E, L) => L.length - E.length);
|
|
410
410
|
const s = new RegExp(`^(${t.join("|")})\\(`), r = Object.keys(li);
|
|
411
|
-
r.sort((E,
|
|
411
|
+
r.sort((E, L) => L.length - E.length);
|
|
412
412
|
const n = new RegExp(`^(${r.join("|")})`), l = /^(\d+(\.\d+)?)/;
|
|
413
|
-
let u = "", p, m,
|
|
413
|
+
let u = "", p, m, g;
|
|
414
414
|
for (; o.length > 0; ) {
|
|
415
|
-
if (p = m,
|
|
416
|
-
const E = t.find((
|
|
417
|
-
E && (
|
|
415
|
+
if (p = m, g = void 0, t.length > 0 && s.exec(o)) {
|
|
416
|
+
const E = t.find((L) => o.startsWith(L));
|
|
417
|
+
E && (g = E + "(", o = o.slice(E.length + 1), m = d.FUNCTION);
|
|
418
418
|
} else if (r.length > 0 && n.exec(o)) {
|
|
419
|
-
const E = r.find((
|
|
420
|
-
E && (
|
|
419
|
+
const E = r.find((L) => o.startsWith(L));
|
|
420
|
+
E && (g = E, o = o.slice(E.length), m = d.CONSTANT);
|
|
421
421
|
} else if (l.exec(o)) {
|
|
422
422
|
const E = l.exec(o);
|
|
423
|
-
E && (
|
|
423
|
+
E && (g = E[0], o = o.slice(E[0].length), m = d.COEFFICIENT);
|
|
424
424
|
} else
|
|
425
|
-
switch (
|
|
425
|
+
switch (g = o[0], o = o.slice(1), g) {
|
|
426
426
|
case "(":
|
|
427
427
|
m = d.LEFT_PARENTHESIS;
|
|
428
428
|
break;
|
|
@@ -442,9 +442,9 @@ function zi(o, e) {
|
|
|
442
442
|
default:
|
|
443
443
|
m = d.VARIABLE;
|
|
444
444
|
}
|
|
445
|
-
if (
|
|
445
|
+
if (g === void 0 || m === void 0)
|
|
446
446
|
throw new Error("The token is undefined");
|
|
447
|
-
u += ki(p, m), u +=
|
|
447
|
+
u += ki(p, m), u += g;
|
|
448
448
|
}
|
|
449
449
|
return u;
|
|
450
450
|
}
|
|
@@ -554,7 +554,7 @@ class ci {
|
|
|
554
554
|
let n = "", l = 0, u;
|
|
555
555
|
(t ?? K(this, ke)) && (e = zi(e, K(this, ie)));
|
|
556
556
|
const p = 50;
|
|
557
|
-
let m = 50,
|
|
557
|
+
let m = 50, g;
|
|
558
558
|
for (; l < e.length; ) {
|
|
559
559
|
if (m--, m === 0) {
|
|
560
560
|
console.log("SECURITY LEVEL 1 EXIT");
|
|
@@ -573,10 +573,10 @@ class ci {
|
|
|
573
573
|
case d.OPERATION:
|
|
574
574
|
if (r.length > 0) {
|
|
575
575
|
let E = r[r.length - 1];
|
|
576
|
-
for (
|
|
576
|
+
for (g = +p; E.token in K(this, ie) && //either o1 is left-associative and its precedence is less than or equal to that of o2,
|
|
577
577
|
(K(this, ie)[n].associative === "left" && K(this, ie)[n].precedence <= K(this, ie)[E.token].precedence || //or o1 is right associative, and has precedence less than that of o2,
|
|
578
578
|
K(this, ie)[n].associative === "right" && K(this, ie)[n].precedence < K(this, ie)[E.token].precedence); ) {
|
|
579
|
-
if (
|
|
579
|
+
if (g--, g === 0) {
|
|
580
580
|
console.log("SECURITY LEVEL 2 OPERATION EXIT");
|
|
581
581
|
break;
|
|
582
582
|
}
|
|
@@ -588,8 +588,8 @@ class ci {
|
|
|
588
588
|
r.push({ token: n, tokenType: u });
|
|
589
589
|
break;
|
|
590
590
|
case d.FUNCTION_ARGUMENT:
|
|
591
|
-
for (
|
|
592
|
-
if (
|
|
591
|
+
for (g = +p; r[r.length - 1].token !== "(" && r.length > 0; ) {
|
|
592
|
+
if (g--, g === 0) {
|
|
593
593
|
console.log("SECURITY LEVEL 2 FUNCTION ARGUMENT EXIT");
|
|
594
594
|
break;
|
|
595
595
|
}
|
|
@@ -600,8 +600,8 @@ class ci {
|
|
|
600
600
|
r.push({ token: n, tokenType: u }), e[l] === "-" && s.push({ token: "0", tokenType: d.COEFFICIENT });
|
|
601
601
|
break;
|
|
602
602
|
case d.RIGHT_PARENTHESIS:
|
|
603
|
-
for (
|
|
604
|
-
if (
|
|
603
|
+
for (g = +p; r[r.length - 1].token !== "(" && r.length > 1; ) {
|
|
604
|
+
if (g--, g === 0) {
|
|
605
605
|
console.log("SECURITY LEVEL 2 CLOSING PARENTHESIS EXIT");
|
|
606
606
|
break;
|
|
607
607
|
}
|
|
@@ -621,7 +621,7 @@ class ci {
|
|
|
621
621
|
}
|
|
622
622
|
je = /* @__PURE__ */ new WeakMap(), st = /* @__PURE__ */ new WeakMap(), ie = /* @__PURE__ */ new WeakMap(), dt = /* @__PURE__ */ new WeakMap(), ke = /* @__PURE__ */ new WeakMap();
|
|
623
623
|
var O, v, He, pt, Re, bt, xt;
|
|
624
|
-
const
|
|
624
|
+
const P = class P {
|
|
625
625
|
constructor(e) {
|
|
626
626
|
f(this, He);
|
|
627
627
|
f(this, O);
|
|
@@ -630,7 +630,7 @@ const B = class B {
|
|
|
630
630
|
* Clone the current Monom.
|
|
631
631
|
*/
|
|
632
632
|
a(this, "clone", () => {
|
|
633
|
-
const e = new
|
|
633
|
+
const e = new P();
|
|
634
634
|
e.coefficient = i(this, O).clone();
|
|
635
635
|
for (const t in i(this, v))
|
|
636
636
|
e.setLetter(t, i(this, v)[t].clone());
|
|
@@ -642,7 +642,7 @@ const B = class B {
|
|
|
642
642
|
*/
|
|
643
643
|
a(this, "add", (...e) => {
|
|
644
644
|
for (const t of e) {
|
|
645
|
-
const s = t instanceof
|
|
645
|
+
const s = t instanceof P ? t : new P(t);
|
|
646
646
|
this.isSameAs(s) ? (this.isZero() && M(this, He, pt).call(this, s), i(this, O).add(s.coefficient)) : console.log("Add monom: " + this.display + " is not similar with ", s.display);
|
|
647
647
|
}
|
|
648
648
|
return this;
|
|
@@ -662,7 +662,7 @@ const B = class B {
|
|
|
662
662
|
const t = i(this, v)[e].clone(), s = this.clone();
|
|
663
663
|
return i(s, v)[e].subtract(1), i(s, O).multiply(new c(t.clone())), s;
|
|
664
664
|
} else
|
|
665
|
-
return new
|
|
665
|
+
return new P().zero();
|
|
666
666
|
});
|
|
667
667
|
/**
|
|
668
668
|
* Divide the current monoms by multiple monoms
|
|
@@ -670,7 +670,7 @@ const B = class B {
|
|
|
670
670
|
*/
|
|
671
671
|
a(this, "divide", (...e) => {
|
|
672
672
|
for (const t of e) {
|
|
673
|
-
const s = t instanceof
|
|
673
|
+
const s = t instanceof P ? t : new P(t);
|
|
674
674
|
i(this, O).divide(s.coefficient);
|
|
675
675
|
for (const r in s.literal)
|
|
676
676
|
i(this, v)[r] = this.hasVariable(r) ? i(this, v)[r].subtract(s.literal[r]) : s.literal[r].clone().opposite(), i(this, v)[r].isZero() && this.removeVariable(r);
|
|
@@ -777,7 +777,7 @@ const B = class B {
|
|
|
777
777
|
*/
|
|
778
778
|
a(this, "multiply", (...e) => {
|
|
779
779
|
for (const t of e) {
|
|
780
|
-
const s = t instanceof
|
|
780
|
+
const s = t instanceof P ? t : new P(t);
|
|
781
781
|
i(this, O).multiply(s.coefficient);
|
|
782
782
|
for (const r in s.literal)
|
|
783
783
|
this.hasVariable(r) ? i(this, v)[r].add(s.literal[r]) : i(this, v)[r] = s.literal[r].clone();
|
|
@@ -846,7 +846,7 @@ const B = class B {
|
|
|
846
846
|
*/
|
|
847
847
|
a(this, "subtract", (...e) => {
|
|
848
848
|
for (const t of e) {
|
|
849
|
-
const s = t instanceof
|
|
849
|
+
const s = t instanceof P ? t : new P(t);
|
|
850
850
|
this.isSameAs(s) ? (this.isZero() && M(this, He, pt).call(this, s), i(this, O).add(s.clone().coefficient.opposite())) : console.log("Subtract: Is not similar: ", s.display);
|
|
851
851
|
}
|
|
852
852
|
return this;
|
|
@@ -893,23 +893,23 @@ const B = class B {
|
|
|
893
893
|
var p;
|
|
894
894
|
let s, r, n, l, u;
|
|
895
895
|
if (t.tokenType === d.COEFFICIENT)
|
|
896
|
-
e.push(new
|
|
896
|
+
e.push(new P(new c(t.token)));
|
|
897
897
|
else if (t.tokenType === d.VARIABLE) {
|
|
898
|
-
const m = new
|
|
898
|
+
const m = new P().one();
|
|
899
899
|
m.setLetter(t.token, 1), e.push(m.clone());
|
|
900
900
|
} else if (t.tokenType === d.OPERATION)
|
|
901
901
|
switch (t.token) {
|
|
902
902
|
case "-":
|
|
903
|
-
r = e.pop() ?? new
|
|
903
|
+
r = e.pop() ?? new P().zero(), s = e.pop() ?? new P().zero(), e.push(s.subtract(r));
|
|
904
904
|
break;
|
|
905
905
|
case "*":
|
|
906
|
-
r = e.pop() ?? new
|
|
906
|
+
r = e.pop() ?? new P().one(), s = e.pop() ?? new P().one(), e.push(s.multiply(r));
|
|
907
907
|
break;
|
|
908
908
|
case "/":
|
|
909
|
-
r = e.pop() ?? new
|
|
909
|
+
r = e.pop() ?? new P().one(), s = e.pop() ?? new P().one(), e.push(s.divide(r));
|
|
910
910
|
break;
|
|
911
911
|
case "^": {
|
|
912
|
-
u = ((p = e.pop()) == null ? void 0 : p.coefficient) ?? new c().one(), n = e.pop() ?? new
|
|
912
|
+
u = ((p = e.pop()) == null ? void 0 : p.coefficient) ?? new c().one(), n = e.pop() ?? new P().one(), l = n.variables[0], l && n.setLetter(l, u), e.push(n);
|
|
913
913
|
break;
|
|
914
914
|
}
|
|
915
915
|
}
|
|
@@ -922,7 +922,7 @@ const B = class B {
|
|
|
922
922
|
* @param inputStr
|
|
923
923
|
*/
|
|
924
924
|
parse(e) {
|
|
925
|
-
return h(this, O, new c()), h(this, v, {}), typeof e == "string" ? i(this, bt).call(this, e) : typeof e == "number" ? h(this, O, new c(e)) : e instanceof c ? h(this, O, e.clone()) : e instanceof
|
|
925
|
+
return h(this, O, new c()), h(this, v, {}), typeof e == "string" ? i(this, bt).call(this, e) : typeof e == "number" ? h(this, O, new c(e)) : e instanceof c ? h(this, O, e.clone()) : e instanceof P && (h(this, O, i(e, O).clone()), M(this, He, pt).call(this, e)), this;
|
|
926
926
|
}
|
|
927
927
|
/**
|
|
928
928
|
* Get the coefficient \\(k\\) of the Monom \\(k\\cdot x^{n}\\)
|
|
@@ -964,20 +964,20 @@ const B = class B {
|
|
|
964
964
|
if (t.length > 0 && e.length > 0)
|
|
965
965
|
for (const r of e)
|
|
966
966
|
for (const n of t) {
|
|
967
|
-
const l = new
|
|
967
|
+
const l = new P();
|
|
968
968
|
l.coefficient = new c(r), l.literal = n, s.push(l);
|
|
969
969
|
}
|
|
970
970
|
else if (e.length === 0)
|
|
971
971
|
for (const r of t) {
|
|
972
|
-
const n = new
|
|
972
|
+
const n = new P();
|
|
973
973
|
n.coefficient = new c().one(), n.literal = r, s.push(n);
|
|
974
974
|
}
|
|
975
975
|
else
|
|
976
976
|
for (const r of e) {
|
|
977
|
-
const n = new
|
|
977
|
+
const n = new P();
|
|
978
978
|
n.coefficient = new c(r), s.push(n);
|
|
979
979
|
}
|
|
980
|
-
return s.length === 0 ? [new
|
|
980
|
+
return s.length === 0 ? [new P().one()] : s;
|
|
981
981
|
}
|
|
982
982
|
integrate(e, t, s) {
|
|
983
983
|
const r = this.primitive(s);
|
|
@@ -1073,11 +1073,11 @@ const B = class B {
|
|
|
1073
1073
|
O = new WeakMap(), v = new WeakMap(), He = new WeakSet(), pt = function(e) {
|
|
1074
1074
|
for (const t in e.literal)
|
|
1075
1075
|
i(this, v)[t] = e.literal[t].clone();
|
|
1076
|
-
}, Re = new WeakMap(), bt = new WeakMap(), xt = new WeakMap(), a(
|
|
1076
|
+
}, Re = new WeakMap(), bt = new WeakMap(), xt = new WeakMap(), a(P, "gcd", (...e) => {
|
|
1077
1077
|
for (const n of e)
|
|
1078
1078
|
if (n.containsRationalPower())
|
|
1079
|
-
return new
|
|
1080
|
-
const t = new
|
|
1079
|
+
return new P().zero();
|
|
1080
|
+
const t = new P(), s = G.gcd(...e.map((n) => n.coefficient.numerator)), r = G.lcm(...e.map((n) => n.coefficient.denominator));
|
|
1081
1081
|
t.coefficient = new c(s, r).reduce();
|
|
1082
1082
|
for (const n of e) {
|
|
1083
1083
|
for (const l in t.literal)
|
|
@@ -1090,17 +1090,17 @@ O = new WeakMap(), v = new WeakMap(), He = new WeakSet(), pt = function(e) {
|
|
|
1090
1090
|
* Multiply two monoms and return a NEW monom.
|
|
1091
1091
|
* @param monoms
|
|
1092
1092
|
*/
|
|
1093
|
-
a(
|
|
1094
|
-
const t = new
|
|
1093
|
+
a(P, "xMultiply", (...e) => {
|
|
1094
|
+
const t = new P().one();
|
|
1095
1095
|
for (const s of e)
|
|
1096
1096
|
t.multiply(s);
|
|
1097
1097
|
return t;
|
|
1098
1098
|
});
|
|
1099
|
-
let I =
|
|
1100
|
-
var ue, De,
|
|
1099
|
+
let I = P;
|
|
1100
|
+
var ue, De, S, ye, rt, ui, fi, di, Ht, pi;
|
|
1101
1101
|
const ii = class ii {
|
|
1102
1102
|
constructor(e, t, s = "x") {
|
|
1103
|
-
f(this,
|
|
1103
|
+
f(this, S);
|
|
1104
1104
|
f(this, ue);
|
|
1105
1105
|
f(this, De);
|
|
1106
1106
|
if (h(this, De, s), Object.hasOwn(e, "moveLeft")) {
|
|
@@ -1111,25 +1111,25 @@ const ii = class ii {
|
|
|
1111
1111
|
}
|
|
1112
1112
|
solve() {
|
|
1113
1113
|
if (i(this, ue).degree().isOne())
|
|
1114
|
-
return M(this,
|
|
1114
|
+
return M(this, S, ui).call(this);
|
|
1115
1115
|
if (i(this, ue).degree().value === 2)
|
|
1116
|
-
return M(this,
|
|
1117
|
-
const e = M(this,
|
|
1116
|
+
return M(this, S, fi).call(this);
|
|
1117
|
+
const e = M(this, S, pi).call(this);
|
|
1118
1118
|
if (e.length > 0)
|
|
1119
1119
|
return e;
|
|
1120
1120
|
if (i(this, ue).degree().value === 3)
|
|
1121
|
-
return M(this,
|
|
1121
|
+
return M(this, S, Ht).call(this);
|
|
1122
1122
|
throw new Error("The equation degree is too high.");
|
|
1123
1123
|
}
|
|
1124
1124
|
solveAsCardan() {
|
|
1125
1125
|
if (i(this, ue).degree().value !== 3)
|
|
1126
1126
|
throw new Error("The equation is not cubic.");
|
|
1127
|
-
return M(this,
|
|
1127
|
+
return M(this, S, Ht).call(this);
|
|
1128
1128
|
}
|
|
1129
1129
|
};
|
|
1130
|
-
ue = new WeakMap(), De = new WeakMap(),
|
|
1130
|
+
ue = new WeakMap(), De = new WeakMap(), S = new WeakSet(), ye = function(e) {
|
|
1131
1131
|
if (e instanceof c && e.isApproximative())
|
|
1132
|
-
return M(this,
|
|
1132
|
+
return M(this, S, rt).call(this, e.value);
|
|
1133
1133
|
const t = new c(e);
|
|
1134
1134
|
return {
|
|
1135
1135
|
variable: i(this, De),
|
|
@@ -1149,7 +1149,7 @@ ue = new WeakMap(), De = new WeakMap(), P = new WeakSet(), ge = function(e) {
|
|
|
1149
1149
|
}, ui = function() {
|
|
1150
1150
|
const e = i(this, ue).monomByDegree(0).coefficient.clone().opposite().divide(i(this, ue).monomByDegree(1).coefficient);
|
|
1151
1151
|
return [
|
|
1152
|
-
M(this,
|
|
1152
|
+
M(this, S, ye).call(this, e)
|
|
1153
1153
|
];
|
|
1154
1154
|
}, fi = function() {
|
|
1155
1155
|
const e = i(this, ue), t = e.monomByDegree(2).coefficient, s = e.monomByDegree(1).coefficient, r = e.monomByDegree(0).coefficient, n = s.clone().pow(2).subtract(t.clone().multiply(r).multiply(4));
|
|
@@ -1157,49 +1157,49 @@ ue = new WeakMap(), De = new WeakMap(), P = new WeakSet(), ge = function(e) {
|
|
|
1157
1157
|
return [];
|
|
1158
1158
|
if (n.isSquare()) {
|
|
1159
1159
|
const l = n.sqrt(), u = s.clone().opposite().add(l).divide(t.clone().multiply(2)), p = s.clone().opposite().subtract(l).divide(t.clone().multiply(2));
|
|
1160
|
-
return l.isZero() ? [M(this,
|
|
1161
|
-
M(this,
|
|
1162
|
-
M(this,
|
|
1163
|
-
].sort((m,
|
|
1160
|
+
return l.isZero() ? [M(this, S, ye).call(this, u)] : [
|
|
1161
|
+
M(this, S, ye).call(this, u),
|
|
1162
|
+
M(this, S, ye).call(this, p)
|
|
1163
|
+
].sort((m, g) => m.value - g.value);
|
|
1164
1164
|
}
|
|
1165
|
-
return M(this,
|
|
1165
|
+
return M(this, S, di).call(this, t, s, n);
|
|
1166
1166
|
}, di = function(e, t, s) {
|
|
1167
|
-
const r = G.dividers(s.value).filter((pe) => Math.sqrt(pe) % 1 === 0).map((pe) => Math.sqrt(pe)).pop() ?? 1, n = G.gcd(2 * e.value, t.value, r) * (e.isNegative() ? -1 : 1), l = t.clone().divide(n).opposite(), u = e.clone().divide(n).multiply(2), p = s.clone().divide(r ** 2), m = Math.abs(r / n),
|
|
1168
|
-
function
|
|
1167
|
+
const r = G.dividers(s.value).filter((pe) => Math.sqrt(pe) % 1 === 0).map((pe) => Math.sqrt(pe)).pop() ?? 1, n = G.gcd(2 * e.value, t.value, r) * (e.isNegative() ? -1 : 1), l = t.clone().divide(n).opposite(), u = e.clone().divide(n).multiply(2), p = s.clone().divide(r ** 2), m = Math.abs(r / n), g = r === 1 ? "-" : `-${m} `, E = r === 1 ? "+" : `+${m} `;
|
|
1168
|
+
function L(pe, ce, et, Ut) {
|
|
1169
1169
|
return `\\frac{ ${ce} ${et}\\sqrt{ ${Ut} } }{ ${pe} }`;
|
|
1170
1170
|
}
|
|
1171
1171
|
function te(pe, ce, et, Ut) {
|
|
1172
1172
|
return `(${ce}${et}sqrt(${Ut}))/${pe}`;
|
|
1173
1173
|
}
|
|
1174
|
-
const ae = s.value ** 0.5, le = (-t.value - ae) / (2 * e.value),
|
|
1174
|
+
const ae = s.value ** 0.5, le = (-t.value - ae) / (2 * e.value), ge = (-t.value + ae) / (2 * e.value);
|
|
1175
1175
|
return [
|
|
1176
|
-
M(this,
|
|
1177
|
-
tex:
|
|
1178
|
-
display: te(u.display, l.display,
|
|
1176
|
+
M(this, S, rt).call(this, le, {
|
|
1177
|
+
tex: L(u.tex, l.tex, g.toString(), p.tex),
|
|
1178
|
+
display: te(u.display, l.display, g.toString(), p.display)
|
|
1179
1179
|
}),
|
|
1180
|
-
M(this,
|
|
1181
|
-
tex:
|
|
1180
|
+
M(this, S, rt).call(this, ge, {
|
|
1181
|
+
tex: L(u.tex, l.tex, E.toString(), p.tex),
|
|
1182
1182
|
display: te(u.display, l.display, E.toString(), p.display)
|
|
1183
1183
|
})
|
|
1184
1184
|
].sort((pe, ce) => pe.value - ce.value);
|
|
1185
1185
|
}, Ht = function() {
|
|
1186
|
-
const e = i(this, ue), t = e.monomByDegree(3).coefficient, s = e.monomByDegree(2).coefficient, r = e.monomByDegree(1).coefficient, n = e.monomByDegree(0).coefficient, l = s.clone().divide(t), u = r.clone().divide(t), p = n.clone().divide(t), m = u.clone().subtract(l.clone().pow(2).divide(3)),
|
|
1186
|
+
const e = i(this, ue), t = e.monomByDegree(3).coefficient, s = e.monomByDegree(2).coefficient, r = e.monomByDegree(1).coefficient, n = e.monomByDegree(0).coefficient, l = s.clone().divide(t), u = r.clone().divide(t), p = n.clone().divide(t), m = u.clone().subtract(l.clone().pow(2).divide(3)), g = p.clone().subtract(l.clone().multiply(u).divide(3)).add(l.clone().pow(3).multiply(2).divide(27)), E = g.clone().opposite(), L = m.clone().opposite().pow(3).divide(27), te = E.clone().pow(2).subtract(L.clone().multiply(4)).opposite();
|
|
1187
1187
|
if (te.isNegative()) {
|
|
1188
|
-
const ae =
|
|
1189
|
-
return [M(this,
|
|
1188
|
+
const ae = g.clone().opposite().add(te.clone().opposite().sqrt()).divide(2).root(3), le = g.clone().opposite().subtract(te.clone().opposite().sqrt()).divide(2).root(3), ge = ae.clone().add(le).subtract(l.clone().divide(3));
|
|
1189
|
+
return [M(this, S, ye).call(this, ge)];
|
|
1190
1190
|
}
|
|
1191
1191
|
if (te.isZero()) {
|
|
1192
|
-
const ae =
|
|
1193
|
-
return le.isEqual(
|
|
1194
|
-
M(this,
|
|
1195
|
-
M(this,
|
|
1192
|
+
const ae = g.clone().opposite().divide(2).root(3), le = ae.clone().opposite().subtract(l.clone().divide(3)), ge = ae.clone().multiply(2).subtract(l.clone().divide(3));
|
|
1193
|
+
return le.isEqual(ge) ? [M(this, S, ye).call(this, le)] : [
|
|
1194
|
+
M(this, S, ye).call(this, ge),
|
|
1195
|
+
M(this, S, ye).call(this, le)
|
|
1196
1196
|
].sort((pe, ce) => pe.value - ce.value);
|
|
1197
1197
|
}
|
|
1198
1198
|
if (te.isPositive()) {
|
|
1199
|
-
const ae = [], le = m.value,
|
|
1199
|
+
const ae = [], le = m.value, ge = g.value, pe = l.value;
|
|
1200
1200
|
for (let ce = 0; ce < 3; ce++)
|
|
1201
|
-
ae.push(2 * Math.sqrt(-le / 3) * Math.cos(Math.acos(3 *
|
|
1202
|
-
return ae.map((ce) => M(this,
|
|
1201
|
+
ae.push(2 * Math.sqrt(-le / 3) * Math.cos(Math.acos(3 * ge / (2 * le) * Math.sqrt(-3 / le)) / 3 + 2 * Math.PI * ce / 3) - pe / 3);
|
|
1202
|
+
return ae.map((ce) => M(this, S, rt).call(this, ce)).sort((ce, et) => ce.value - et.value);
|
|
1203
1203
|
}
|
|
1204
1204
|
return [];
|
|
1205
1205
|
}, pi = function() {
|
|
@@ -1209,37 +1209,37 @@ ue = new WeakMap(), De = new WeakMap(), P = new WeakSet(), ge = function(e) {
|
|
|
1209
1209
|
const r = e.monomByDegree().coefficient;
|
|
1210
1210
|
let n = e.monomByDegree(0).coefficient;
|
|
1211
1211
|
for (; n.isZero(); )
|
|
1212
|
-
t.length === 0 && t.push(M(this,
|
|
1212
|
+
t.length === 0 && t.push(M(this, S, ye).call(this, 0)), e = e.divide("x"), n = e.monomByDegree(0).coefficient;
|
|
1213
1213
|
const l = G.dividers(r.value), u = G.dividers(n.value);
|
|
1214
|
-
for (const
|
|
1214
|
+
for (const g of l)
|
|
1215
1215
|
for (const E of u) {
|
|
1216
|
-
const
|
|
1217
|
-
e.evaluate(
|
|
1216
|
+
const L = new c(E, g);
|
|
1217
|
+
e.evaluate(L).isZero() && !t.find((te) => te.value === L.value) && t.push(M(this, S, ye).call(this, L)), L.opposite(), e.evaluate(L).isZero() && !t.find((te) => te.value === L.value) && t.push(M(this, S, ye).call(this, L));
|
|
1218
1218
|
}
|
|
1219
|
-
for (const
|
|
1220
|
-
if (
|
|
1219
|
+
for (const g of t) {
|
|
1220
|
+
if (g.exact !== !1 && g.exact.isZero())
|
|
1221
1221
|
continue;
|
|
1222
|
-
const E = i(this, ue).clone().parse("x",
|
|
1222
|
+
const E = i(this, ue).clone().parse("x", g.exact.denominator, -g.exact.numerator);
|
|
1223
1223
|
for (; e.isDividableBy(E); )
|
|
1224
1224
|
console.log(e.display, E.display), e = e.divide(E);
|
|
1225
1225
|
}
|
|
1226
1226
|
if (e.degree().isZero())
|
|
1227
|
-
return t.sort((
|
|
1227
|
+
return t.sort((g, E) => g.value - E.value);
|
|
1228
1228
|
if (e.degree().value > 3)
|
|
1229
1229
|
return [];
|
|
1230
1230
|
const p = e.clone().parse("0");
|
|
1231
1231
|
console.log(e.display), console.log(p.display);
|
|
1232
1232
|
const m = new ii(e, e.clone().parse("0"), i(this, De));
|
|
1233
|
-
return t = t.concat(m.solve()), t.sort((
|
|
1233
|
+
return t = t.concat(m.solve()), t.sort((g, E) => g.value - E.value);
|
|
1234
1234
|
};
|
|
1235
|
-
let
|
|
1236
|
-
var Ze,
|
|
1235
|
+
let gt = ii;
|
|
1236
|
+
var Ze, y, Xe, ht, Et, Nt, Ot, qt, at, Tt, At, Mt, It, mi, Ct, Ye, $t;
|
|
1237
1237
|
const C = class C {
|
|
1238
1238
|
constructor(e, ...t) {
|
|
1239
1239
|
f(this, It);
|
|
1240
1240
|
// #region Class fields (8)
|
|
1241
1241
|
f(this, Ze);
|
|
1242
|
-
f(this,
|
|
1242
|
+
f(this, y);
|
|
1243
1243
|
// #endregion Constructors (7)
|
|
1244
1244
|
// #region Properties and methods (49)
|
|
1245
1245
|
/**
|
|
@@ -1248,17 +1248,17 @@ const C = class C {
|
|
|
1248
1248
|
* @param values
|
|
1249
1249
|
*/
|
|
1250
1250
|
a(this, "parse", (e, ...t) => {
|
|
1251
|
-
if (h(this,
|
|
1251
|
+
if (h(this, y, []), h(this, Ze, []), typeof e == "string")
|
|
1252
1252
|
return M(this, It, mi).call(this, e, ...t);
|
|
1253
1253
|
if ((typeof e == "number" || e instanceof c || e instanceof I) && t.length === 0)
|
|
1254
|
-
i(this,
|
|
1254
|
+
i(this, y).push(new I(e));
|
|
1255
1255
|
else if (e instanceof I && t.length > 0)
|
|
1256
|
-
i(this,
|
|
1257
|
-
i(this,
|
|
1256
|
+
i(this, y).push(new I(e)), t.forEach((s) => {
|
|
1257
|
+
i(this, y).push(new I(s));
|
|
1258
1258
|
});
|
|
1259
1259
|
else if (e instanceof C)
|
|
1260
1260
|
for (const s of e.monoms)
|
|
1261
|
-
i(this,
|
|
1261
|
+
i(this, y).push(s.clone());
|
|
1262
1262
|
return this;
|
|
1263
1263
|
});
|
|
1264
1264
|
/**
|
|
@@ -1266,13 +1266,13 @@ const C = class C {
|
|
|
1266
1266
|
*/
|
|
1267
1267
|
a(this, "clone", () => {
|
|
1268
1268
|
const e = new C(), t = [];
|
|
1269
|
-
for (const s of i(this,
|
|
1269
|
+
for (const s of i(this, y))
|
|
1270
1270
|
t.push(s.clone());
|
|
1271
1271
|
return e.monoms = t, e;
|
|
1272
1272
|
});
|
|
1273
1273
|
a(this, "add", (...e) => {
|
|
1274
1274
|
for (const t of e)
|
|
1275
|
-
t instanceof C ? h(this,
|
|
1275
|
+
t instanceof C ? h(this, y, i(this, y).concat(t.monoms)) : t instanceof I ? i(this, y).push(t.clone()) : typeof t == "number" && Number.isSafeInteger(t) ? i(this, y).push(new I(t.toString())) : i(this, y).push(new I(t));
|
|
1276
1276
|
return this.reduce();
|
|
1277
1277
|
});
|
|
1278
1278
|
a(this, "commonMonom", () => {
|
|
@@ -1280,7 +1280,7 @@ const C = class C {
|
|
|
1280
1280
|
e.coefficient = new c(t, s);
|
|
1281
1281
|
for (const n of this.variables) {
|
|
1282
1282
|
e.setLetter(n, r);
|
|
1283
|
-
for (const l of i(this,
|
|
1283
|
+
for (const l of i(this, y))
|
|
1284
1284
|
if (e.setLetter(n, c.min(l.degree(n), e.degree(n))), e.degree(n).isZero())
|
|
1285
1285
|
break;
|
|
1286
1286
|
}
|
|
@@ -1288,13 +1288,13 @@ const C = class C {
|
|
|
1288
1288
|
});
|
|
1289
1289
|
a(this, "degree", (e) => {
|
|
1290
1290
|
let t = new c().zero();
|
|
1291
|
-
for (const s of i(this,
|
|
1291
|
+
for (const s of i(this, y))
|
|
1292
1292
|
t = c.max(s.degree(e).value, t);
|
|
1293
1293
|
return t;
|
|
1294
1294
|
});
|
|
1295
1295
|
a(this, "derivative", (e) => {
|
|
1296
1296
|
const t = new C();
|
|
1297
|
-
for (const s of i(this,
|
|
1297
|
+
for (const s of i(this, y))
|
|
1298
1298
|
t.add(s.derivative(e));
|
|
1299
1299
|
return t;
|
|
1300
1300
|
});
|
|
@@ -1311,13 +1311,13 @@ const C = class C {
|
|
|
1311
1311
|
{
|
|
1312
1312
|
const { quotient: t, reminder: s } = this.euclidean(e);
|
|
1313
1313
|
if (s.isZero())
|
|
1314
|
-
return t;
|
|
1314
|
+
return h(this, y, t.monoms), this;
|
|
1315
1315
|
}
|
|
1316
1316
|
} else if (typeof e == "string")
|
|
1317
1317
|
return this.divide(new C(e));
|
|
1318
1318
|
throw new Error(`Cannot divide by ${e}`);
|
|
1319
1319
|
});
|
|
1320
|
-
a(this, "empty", () => (h(this,
|
|
1320
|
+
a(this, "empty", () => (h(this, y, []), this));
|
|
1321
1321
|
/**
|
|
1322
1322
|
* Divide the current polynom by another polynom.
|
|
1323
1323
|
* @param P
|
|
@@ -1340,7 +1340,7 @@ const C = class C {
|
|
|
1340
1340
|
if (t)
|
|
1341
1341
|
return i(this, Nt).call(this, e);
|
|
1342
1342
|
const s = new c().zero();
|
|
1343
|
-
return i(this,
|
|
1343
|
+
return i(this, y).forEach((r) => {
|
|
1344
1344
|
s.add(r.evaluate(e, t));
|
|
1345
1345
|
}), s;
|
|
1346
1346
|
});
|
|
@@ -1372,9 +1372,9 @@ const C = class C {
|
|
|
1372
1372
|
u.shift();
|
|
1373
1373
|
else {
|
|
1374
1374
|
const m = s.euclidean(p);
|
|
1375
|
-
t.push(p), s = m.quotient.clone(), u = u.filter((
|
|
1376
|
-
const E = s.monoms[0],
|
|
1377
|
-
return
|
|
1375
|
+
t.push(p), s = m.quotient.clone(), u = u.filter((g) => {
|
|
1376
|
+
const E = s.monoms[0], L = s.monoms[s.monoms.length - 1], te = g.monoms[0], ae = g.monoms[g.monoms.length - 1];
|
|
1377
|
+
return L.isDivisible(ae) ? E.isDivisible(te) : !1;
|
|
1378
1378
|
});
|
|
1379
1379
|
}
|
|
1380
1380
|
}
|
|
@@ -1386,17 +1386,17 @@ const C = class C {
|
|
|
1386
1386
|
// Next functions are used for for commonMonom, which is used in the factorize method.
|
|
1387
1387
|
a(this, "getDenominators", () => {
|
|
1388
1388
|
const e = [];
|
|
1389
|
-
for (const t of i(this,
|
|
1389
|
+
for (const t of i(this, y))
|
|
1390
1390
|
e.push(t.coefficient.denominator);
|
|
1391
1391
|
return e;
|
|
1392
1392
|
});
|
|
1393
1393
|
a(this, "getNumerators", () => {
|
|
1394
1394
|
const e = [];
|
|
1395
|
-
for (const t of i(this,
|
|
1395
|
+
for (const t of i(this, y))
|
|
1396
1396
|
e.push(t.coefficient.numerator);
|
|
1397
1397
|
return e;
|
|
1398
1398
|
});
|
|
1399
|
-
a(this, "getZeroes", () => new
|
|
1399
|
+
a(this, "getZeroes", () => new gt(this.clone()).solve());
|
|
1400
1400
|
a(this, "integrate", (e, t, s = "x") => {
|
|
1401
1401
|
const r = this.primitive(s), n = {}, l = {};
|
|
1402
1402
|
return n[s] = new c(e), l[s] = new c(t), r.evaluate(l).subtract(r.evaluate(n));
|
|
@@ -1440,7 +1440,7 @@ const C = class C {
|
|
|
1440
1440
|
a(this, "lcmNumerator", () => G.lcm(...this.getNumerators()));
|
|
1441
1441
|
a(this, "letters", () => {
|
|
1442
1442
|
let e = /* @__PURE__ */ new Set();
|
|
1443
|
-
for (const t of i(this,
|
|
1443
|
+
for (const t of i(this, y))
|
|
1444
1444
|
e = /* @__PURE__ */ new Set([...e, ...t.variables]);
|
|
1445
1445
|
return [...e];
|
|
1446
1446
|
});
|
|
@@ -1456,7 +1456,7 @@ const C = class C {
|
|
|
1456
1456
|
if (e === void 0)
|
|
1457
1457
|
return this.monomByDegree(this.degree(t), t);
|
|
1458
1458
|
const s = this.clone().reduce();
|
|
1459
|
-
for (const r of i(s,
|
|
1459
|
+
for (const r of i(s, y))
|
|
1460
1460
|
if (r.degree(t).isEqual(e))
|
|
1461
1461
|
return r.clone();
|
|
1462
1462
|
return new I().zero();
|
|
@@ -1464,7 +1464,7 @@ const C = class C {
|
|
|
1464
1464
|
// Used in LinearSystem.tex
|
|
1465
1465
|
a(this, "monomByLetter", (e) => {
|
|
1466
1466
|
const t = this.clone().reduce();
|
|
1467
|
-
for (const s of i(t,
|
|
1467
|
+
for (const s of i(t, y))
|
|
1468
1468
|
if (s.hasVariable(e))
|
|
1469
1469
|
return s.clone();
|
|
1470
1470
|
return new I().zero();
|
|
@@ -1473,14 +1473,14 @@ const C = class C {
|
|
|
1473
1473
|
if (e === void 0)
|
|
1474
1474
|
return this.monomsByDegree(this.degree(t));
|
|
1475
1475
|
const s = [], r = this.clone().reduce();
|
|
1476
|
-
for (const n of i(r,
|
|
1476
|
+
for (const n of i(r, y))
|
|
1477
1477
|
n.degree(t) === e && s.push(n.clone());
|
|
1478
1478
|
return s;
|
|
1479
1479
|
});
|
|
1480
1480
|
a(this, "multiply", (e) => e instanceof C ? i(this, Mt).call(this, e) : e instanceof c ? i(this, at).call(this, e) : e instanceof I ? i(this, At).call(this, e) : Number.isSafeInteger(e) && typeof e == "number" ? i(this, Tt).call(this, e) : this);
|
|
1481
|
-
a(this, "one", () => (h(this,
|
|
1481
|
+
a(this, "one", () => (h(this, y, []), i(this, y).push(new I().one()), this));
|
|
1482
1482
|
// ------------------------------------------
|
|
1483
|
-
a(this, "opposite", () => (h(this,
|
|
1483
|
+
a(this, "opposite", () => (h(this, y, i(this, y).map((e) => e.opposite())), this));
|
|
1484
1484
|
a(this, "pow", (e) => {
|
|
1485
1485
|
if (!Number.isSafeInteger(e))
|
|
1486
1486
|
return this.zero();
|
|
@@ -1495,34 +1495,34 @@ const C = class C {
|
|
|
1495
1495
|
});
|
|
1496
1496
|
a(this, "primitive", (e) => {
|
|
1497
1497
|
const t = new C();
|
|
1498
|
-
for (const s of i(this,
|
|
1498
|
+
for (const s of i(this, y))
|
|
1499
1499
|
t.add(s.primitive(e));
|
|
1500
1500
|
return t;
|
|
1501
1501
|
});
|
|
1502
1502
|
a(this, "reduce", () => {
|
|
1503
1503
|
let e = 0;
|
|
1504
|
-
for (; e < i(this,
|
|
1505
|
-
for (let t = e + 1; t < i(this,
|
|
1506
|
-
i(this,
|
|
1504
|
+
for (; e < i(this, y).length; ) {
|
|
1505
|
+
for (let t = e + 1; t < i(this, y).length; t++)
|
|
1506
|
+
i(this, y)[e].isSameAs(i(this, y)[t]) && (i(this, y)[e].add(i(this, y)[t]), i(this, y).splice(t, 1), i(this, y)[e].isZero() && (i(this, y)[e] = new I().zero()), t--);
|
|
1507
1507
|
e++;
|
|
1508
1508
|
}
|
|
1509
|
-
h(this,
|
|
1510
|
-
for (const t of i(this,
|
|
1509
|
+
h(this, y, i(this, y).filter((t) => !t.coefficient.isZero()));
|
|
1510
|
+
for (const t of i(this, y))
|
|
1511
1511
|
t.coefficient.reduce();
|
|
1512
1512
|
return this.length === 0 ? new C().zero() : this.reorder();
|
|
1513
1513
|
});
|
|
1514
1514
|
a(this, "reorder", (e = "x", t) => {
|
|
1515
1515
|
t === void 0 && (t = !1);
|
|
1516
1516
|
const s = this.variables.filter((r) => r !== e);
|
|
1517
|
-
return i(this,
|
|
1517
|
+
return i(this, y).sort(function(r, n) {
|
|
1518
1518
|
const l = r.degree(e).value, u = n.degree(e).value;
|
|
1519
1519
|
if (l !== u)
|
|
1520
1520
|
return t ? l - u : u - l;
|
|
1521
1521
|
if (s.length > 0)
|
|
1522
1522
|
for (const p of s) {
|
|
1523
|
-
const m = r.degree(p).value,
|
|
1524
|
-
if (m !==
|
|
1525
|
-
return t ? m -
|
|
1523
|
+
const m = r.degree(p).value, g = n.degree(p).value;
|
|
1524
|
+
if (m !== g)
|
|
1525
|
+
return t ? m - g : g - m;
|
|
1526
1526
|
}
|
|
1527
1527
|
return 0;
|
|
1528
1528
|
}), this;
|
|
@@ -1537,26 +1537,26 @@ const C = class C {
|
|
|
1537
1537
|
const r = new C().zero();
|
|
1538
1538
|
for (const n of this.monoms)
|
|
1539
1539
|
!n.hasVariable(e) || n.literal[e].isZero() ? r.add(n.clone()) : (s = n.literal[e].clone(), n.removeVariable(e), r.add(t.clone().pow(Math.abs(s.numerator)).multiply(n)));
|
|
1540
|
-
return h(this,
|
|
1540
|
+
return h(this, y, r.reduce().monoms), this;
|
|
1541
1541
|
});
|
|
1542
1542
|
a(this, "subtract", (...e) => {
|
|
1543
1543
|
for (const t of e)
|
|
1544
|
-
t instanceof C ? this.add(t.clone().opposite()) : t instanceof I ? i(this,
|
|
1544
|
+
t instanceof C ? this.add(t.clone().opposite()) : t instanceof I ? i(this, y).push(t.clone().opposite()) : i(this, y).push(new I(t).opposite());
|
|
1545
1545
|
return this.reduce();
|
|
1546
1546
|
});
|
|
1547
1547
|
/**
|
|
1548
1548
|
* Set the polynom to zero.
|
|
1549
1549
|
* @returns {this}
|
|
1550
1550
|
*/
|
|
1551
|
-
a(this, "zero", () => (h(this,
|
|
1551
|
+
a(this, "zero", () => (h(this, y, []), i(this, y).push(new I().zero()), this));
|
|
1552
1552
|
// #endregion Getters And Setters (22)
|
|
1553
1553
|
// #region Private methods (15)
|
|
1554
1554
|
f(this, Xe, (e, t) => {
|
|
1555
1555
|
t === void 0 && (t = "=");
|
|
1556
|
-
const s = this.clone().reduce(), r = e.clone().reduce();
|
|
1556
|
+
const s = this.clone().reduce().reorder(), r = e.clone().reduce().reorder();
|
|
1557
1557
|
switch (t) {
|
|
1558
1558
|
case "=":
|
|
1559
|
-
return s.length !== r.length || s.degree().
|
|
1559
|
+
return s.length !== r.length || !s.degree().isEqual(r.degree()) ? !1 : s.monoms.every((n, l) => n.isEqual(r.monoms[l]));
|
|
1560
1560
|
case "same":
|
|
1561
1561
|
return s.length !== r.length || !s.degree().isEqual(r.degree()) ? !1 : s.monoms.every((n, l) => n.isSameAs(r.monoms[l]));
|
|
1562
1562
|
default:
|
|
@@ -1564,40 +1564,40 @@ const C = class C {
|
|
|
1564
1564
|
}
|
|
1565
1565
|
});
|
|
1566
1566
|
f(this, ht, (e) => {
|
|
1567
|
-
for (const t of i(this,
|
|
1567
|
+
for (const t of i(this, y))
|
|
1568
1568
|
t.coefficient.divide(e);
|
|
1569
1569
|
return this;
|
|
1570
1570
|
});
|
|
1571
1571
|
f(this, Et, (e) => {
|
|
1572
1572
|
const t = new c(e);
|
|
1573
|
-
for (const s of i(this,
|
|
1573
|
+
for (const s of i(this, y))
|
|
1574
1574
|
s.coefficient.divide(t);
|
|
1575
1575
|
return this;
|
|
1576
1576
|
});
|
|
1577
1577
|
f(this, Nt, (e) => {
|
|
1578
1578
|
let t = 0;
|
|
1579
|
-
return i(this,
|
|
1579
|
+
return i(this, y).forEach((s) => {
|
|
1580
1580
|
t += s.evaluate(e, !0);
|
|
1581
1581
|
}), t;
|
|
1582
1582
|
});
|
|
1583
1583
|
f(this, Ot, (e) => {
|
|
1584
1584
|
var E;
|
|
1585
|
-
let t, s, r, n, l, u, p, m,
|
|
1585
|
+
let t, s, r, n, l, u, p, m, g;
|
|
1586
1586
|
if (this.numberOfVars === 1)
|
|
1587
|
-
return r = this.monomByDegree(2, e).coefficient, n = this.monomByDegree(1, e).coefficient, l = this.monomByDegree(0, e).coefficient, u = n.clone().pow(2).subtract(r.clone().multiply(l).multiply(4)), u.isZero() ? (p = n.clone().opposite().divide(r.clone().multiply(2)), t = new C(e).subtract(p.display).multiply(p.denominator), s = new C(e).subtract(p.display).multiply(p.denominator),
|
|
1587
|
+
return r = this.monomByDegree(2, e).coefficient, n = this.monomByDegree(1, e).coefficient, l = this.monomByDegree(0, e).coefficient, u = n.clone().pow(2).subtract(r.clone().multiply(l).multiply(4)), u.isZero() ? (p = n.clone().opposite().divide(r.clone().multiply(2)), t = new C(e).subtract(p.display).multiply(p.denominator), s = new C(e).subtract(p.display).multiply(p.denominator), g = r.divide(p.denominator).divide(p.denominator), g.isOne() ? [t, s] : [new C(g.display), t, s]) : u.isPositive() && u.isSquare() ? (p = n.clone().opposite().add(u.clone().sqrt()).divide(r.clone().multiply(2)), m = n.clone().opposite().subtract(u.clone().sqrt()).divide(r.clone().multiply(2)), g = r.divide(p.denominator).divide(m.denominator), g.isOne() ? [
|
|
1588
1588
|
new C(e).subtract(p.display).multiply(p.denominator),
|
|
1589
1589
|
new C(e).subtract(m.display).multiply(m.denominator)
|
|
1590
1590
|
] : [
|
|
1591
|
-
new C(
|
|
1591
|
+
new C(g.display),
|
|
1592
1592
|
new C(e).subtract(p.display).multiply(p.denominator),
|
|
1593
1593
|
new C(e).subtract(m.display).multiply(m.denominator)
|
|
1594
1594
|
]) : [this.clone()];
|
|
1595
1595
|
if (r = this.monomByDegree(2, e), n = this.monomByDegree(1, e), l = this.monomByDegree(0, e), r.isLiteralSquare() && l.isLiteralSquare() && n.clone().pow(2).isSameAs(r.clone().multiply(l))) {
|
|
1596
|
-
const
|
|
1596
|
+
const L = new C("x", r.coefficient, n.coefficient, l.coefficient), te = i(E = L, Ot).call(E, "x"), ae = [];
|
|
1597
1597
|
let le;
|
|
1598
1598
|
if (te.length >= 2) {
|
|
1599
|
-
for (const
|
|
1600
|
-
|
|
1599
|
+
for (const ge of te)
|
|
1600
|
+
ge.degree().isZero() ? ae.push(ge.clone()) : (le = ge.clone(), le.monoms[0].literal = r.literalSqrt, le.monoms[1].literal = l.literalSqrt, ae.push(le.clone()));
|
|
1601
1601
|
return ae;
|
|
1602
1602
|
}
|
|
1603
1603
|
}
|
|
@@ -1612,22 +1612,22 @@ const C = class C {
|
|
|
1612
1612
|
}), l;
|
|
1613
1613
|
});
|
|
1614
1614
|
f(this, at, (e) => {
|
|
1615
|
-
for (const t of i(this,
|
|
1615
|
+
for (const t of i(this, y))
|
|
1616
1616
|
t.coefficient.multiply(e);
|
|
1617
1617
|
return this.reduce();
|
|
1618
1618
|
});
|
|
1619
1619
|
f(this, Tt, (e) => i(this, at).call(this, new c(e)));
|
|
1620
1620
|
f(this, At, (e) => {
|
|
1621
|
-
for (const t of i(this,
|
|
1621
|
+
for (const t of i(this, y))
|
|
1622
1622
|
t.multiply(e);
|
|
1623
1623
|
return this.reduce();
|
|
1624
1624
|
});
|
|
1625
1625
|
f(this, Mt, (e) => {
|
|
1626
1626
|
const t = [];
|
|
1627
|
-
for (const s of i(this,
|
|
1627
|
+
for (const s of i(this, y))
|
|
1628
1628
|
for (const r of e.monoms)
|
|
1629
1629
|
t.push(I.xMultiply(s, r));
|
|
1630
|
-
return h(this,
|
|
1630
|
+
return h(this, y, t), this.reduce();
|
|
1631
1631
|
});
|
|
1632
1632
|
f(this, Ct, (e, t) => {
|
|
1633
1633
|
switch (t.tokenType) {
|
|
@@ -1680,7 +1680,7 @@ const C = class C {
|
|
|
1680
1680
|
});
|
|
1681
1681
|
f(this, Ye, (e, t, s, r) => {
|
|
1682
1682
|
let n = "";
|
|
1683
|
-
for (const l of i(this,
|
|
1683
|
+
for (const l of i(this, y)) {
|
|
1684
1684
|
if (l.coefficient.value === 0)
|
|
1685
1685
|
continue;
|
|
1686
1686
|
let u;
|
|
@@ -1700,7 +1700,7 @@ const C = class C {
|
|
|
1700
1700
|
i(this, Ct).call(this, r, n);
|
|
1701
1701
|
return r.length === 1 && this.add(r[0]), this.reorder();
|
|
1702
1702
|
});
|
|
1703
|
-
return h(this,
|
|
1703
|
+
return h(this, y, []), h(this, Ze, []), e !== void 0 && this.parse(e, ...t), this;
|
|
1704
1704
|
}
|
|
1705
1705
|
hasVariable(e) {
|
|
1706
1706
|
return this.variables.includes(e);
|
|
@@ -1708,10 +1708,10 @@ const C = class C {
|
|
|
1708
1708
|
inverse() {
|
|
1709
1709
|
}
|
|
1710
1710
|
isOne() {
|
|
1711
|
-
return i(this,
|
|
1711
|
+
return i(this, y).length === 1 && i(this, y)[0].coefficient.isOne() && this.degree().isZero();
|
|
1712
1712
|
}
|
|
1713
1713
|
isZero() {
|
|
1714
|
-
return i(this,
|
|
1714
|
+
return i(this, y).length === 1 && i(this, y)[0].coefficient.isZero() || i(this, y).length === 0;
|
|
1715
1715
|
}
|
|
1716
1716
|
root() {
|
|
1717
1717
|
throw new Error("Cannot take the root from a polynom");
|
|
@@ -1726,17 +1726,17 @@ const C = class C {
|
|
|
1726
1726
|
return i(this, Ye).call(this);
|
|
1727
1727
|
}
|
|
1728
1728
|
get isMultiVariable() {
|
|
1729
|
-
return i(this,
|
|
1729
|
+
return i(this, y).some((e) => e.variables.length > 1);
|
|
1730
1730
|
}
|
|
1731
1731
|
get length() {
|
|
1732
|
-
return i(this,
|
|
1732
|
+
return i(this, y).length;
|
|
1733
1733
|
}
|
|
1734
1734
|
// ------------------------------------------
|
|
1735
1735
|
get monoms() {
|
|
1736
|
-
return i(this,
|
|
1736
|
+
return i(this, y);
|
|
1737
1737
|
}
|
|
1738
1738
|
set monoms(e) {
|
|
1739
|
-
h(this,
|
|
1739
|
+
h(this, y, e);
|
|
1740
1740
|
}
|
|
1741
1741
|
get numberOfVars() {
|
|
1742
1742
|
return this.variables.length;
|
|
@@ -1749,7 +1749,7 @@ const C = class C {
|
|
|
1749
1749
|
}
|
|
1750
1750
|
get variables() {
|
|
1751
1751
|
let e = [];
|
|
1752
|
-
for (const t of i(this,
|
|
1752
|
+
for (const t of i(this, y))
|
|
1753
1753
|
e = e.concat(t.variables);
|
|
1754
1754
|
return e = [...new Set(e)], e.sort(), e;
|
|
1755
1755
|
}
|
|
@@ -1758,7 +1758,7 @@ const C = class C {
|
|
|
1758
1758
|
}
|
|
1759
1759
|
// #endregion Private methods (15)
|
|
1760
1760
|
};
|
|
1761
|
-
Ze = new WeakMap(),
|
|
1761
|
+
Ze = new WeakMap(), y = new WeakMap(), Xe = new WeakMap(), ht = new WeakMap(), Et = new WeakMap(), Nt = new WeakMap(), Ot = new WeakMap(), qt = new WeakMap(), at = new WeakMap(), Tt = new WeakMap(), At = new WeakMap(), Mt = new WeakMap(), It = new WeakSet(), mi = function(e, ...t) {
|
|
1762
1762
|
if (t.length === 0) {
|
|
1763
1763
|
if (e = "" + e, e !== "" && !isNaN(Number(e))) {
|
|
1764
1764
|
this.empty();
|
|
@@ -1933,191 +1933,7 @@ const we = class we {
|
|
|
1933
1933
|
};
|
|
1934
1934
|
Ee = new WeakMap(), Qe = new WeakMap(), Ne = new WeakMap(), Oe = new WeakMap();
|
|
1935
1935
|
let fe = we;
|
|
1936
|
-
var Ue = /* @__PURE__ */ ((o) => (o[o.ROOT = 0] = "ROOT", o[o.POWER = 1] = "POWER", o))(Ue || {}),
|
|
1937
|
-
const me = class me {
|
|
1938
|
-
// #endregion Class fields (1)
|
|
1939
|
-
// #region Constructors (1)
|
|
1940
|
-
constructor(...e) {
|
|
1941
|
-
// #region Class fields (1)
|
|
1942
|
-
f(this, N, []);
|
|
1943
|
-
f(this, Ve, Ue.POWER);
|
|
1944
|
-
return this.parse(...e), this;
|
|
1945
|
-
}
|
|
1946
|
-
// #endregion Constructors (1)
|
|
1947
|
-
// #region Properties and methods (25)
|
|
1948
|
-
parse(...e) {
|
|
1949
|
-
return e.length === 0 ? this : (h(this, N, []), e.forEach((t) => {
|
|
1950
|
-
if (typeof t == "string") {
|
|
1951
|
-
const s = t.split(")(").join(")*(").split("*");
|
|
1952
|
-
i(this, N).push(...s.map((r) => new fe(r)));
|
|
1953
|
-
} else t instanceof me ? i(this, N).push(...t.factors.map((s) => s.clone())) : i(this, N).push(new fe(t));
|
|
1954
|
-
}), this);
|
|
1955
|
-
}
|
|
1956
|
-
clone() {
|
|
1957
|
-
return new me(...i(this, N).map((e) => e.clone()));
|
|
1958
|
-
}
|
|
1959
|
-
add(...e) {
|
|
1960
|
-
let t = [this, ...e];
|
|
1961
|
-
const s = me.gcd(...t);
|
|
1962
|
-
t = t.map((n) => n.divide(s).reduce());
|
|
1963
|
-
const r = new T("0");
|
|
1964
|
-
return t.forEach((n) => r.add(n.develop())), h(this, N, [
|
|
1965
|
-
...s.factors,
|
|
1966
|
-
new fe(r)
|
|
1967
|
-
]), this;
|
|
1968
|
-
}
|
|
1969
|
-
degree(e) {
|
|
1970
|
-
return i(this, N).reduce((t, s) => t.add(s.degree(e)), new c("0"));
|
|
1971
|
-
}
|
|
1972
|
-
derivative() {
|
|
1973
|
-
const e = [], t = i(this, N).length;
|
|
1974
|
-
for (let r = 0; r < t; r++) {
|
|
1975
|
-
const n = i(this, N).slice(), l = n.splice(r, 1)[0];
|
|
1976
|
-
e.push(new me(...n).multiply(new me(...l.derivative())));
|
|
1977
|
-
}
|
|
1978
|
-
e.forEach((r) => r.reduce());
|
|
1979
|
-
const s = e.shift();
|
|
1980
|
-
return s !== void 0 && h(this, N, s.factors), this.add(...e);
|
|
1981
|
-
}
|
|
1982
|
-
develop() {
|
|
1983
|
-
const e = new T("1");
|
|
1984
|
-
return i(this, N).forEach((t) => {
|
|
1985
|
-
e.multiply(t.develop());
|
|
1986
|
-
}), e;
|
|
1987
|
-
}
|
|
1988
|
-
divide(e) {
|
|
1989
|
-
return h(this, N, i(this, N).concat(e.clone().factors.map((t) => t.inverse()))), this;
|
|
1990
|
-
}
|
|
1991
|
-
evaluate(e, t) {
|
|
1992
|
-
return t ? i(this, N).reduce((s, r) => s * r.evaluate(e, t), 1) : i(this, N).reduce((s, r) => s.multiply(r.evaluate(e)), new c("1"));
|
|
1993
|
-
}
|
|
1994
|
-
hasVariable(e) {
|
|
1995
|
-
return i(this, N).some((t) => t.hasVariable(e));
|
|
1996
|
-
}
|
|
1997
|
-
inverse() {
|
|
1998
|
-
return h(this, N, i(this, N).map((e) => e.inverse())), this;
|
|
1999
|
-
}
|
|
2000
|
-
isEqual(e) {
|
|
2001
|
-
const t = me.gcd(this, e), s = this.clone().divide(t).reduce(), r = e.clone().divide(t).reduce();
|
|
2002
|
-
return s.isOne() && r.isOne();
|
|
2003
|
-
}
|
|
2004
|
-
isOne() {
|
|
2005
|
-
return i(this, N).every((e) => e.isOne());
|
|
2006
|
-
}
|
|
2007
|
-
isZero() {
|
|
2008
|
-
return i(this, N).every((e) => e.isZero());
|
|
2009
|
-
}
|
|
2010
|
-
multiply(...e) {
|
|
2011
|
-
return e.forEach((t) => {
|
|
2012
|
-
h(this, N, i(this, N).concat(t.clone().factors));
|
|
2013
|
-
}), this;
|
|
2014
|
-
}
|
|
2015
|
-
one() {
|
|
2016
|
-
return h(this, N, [new fe("1", "1")]), this;
|
|
2017
|
-
}
|
|
2018
|
-
opposite() {
|
|
2019
|
-
const e = i(this, N).findIndex((t) => t.display === "(-1)");
|
|
2020
|
-
return e >= 0 ? i(this, N).splice(e, 1) : i(this, N).push(new fe("-1", "1")), this;
|
|
2021
|
-
}
|
|
2022
|
-
pow(e) {
|
|
2023
|
-
return h(this, N, i(this, N).map((t) => t.pow(e))), this;
|
|
2024
|
-
}
|
|
2025
|
-
primitive() {
|
|
2026
|
-
throw new Error("Method not implemented.");
|
|
2027
|
-
}
|
|
2028
|
-
reduce() {
|
|
2029
|
-
const e = Wt(this);
|
|
2030
|
-
return h(this, N, Object.values(e).map((t) => {
|
|
2031
|
-
const s = t[0].polynom, r = t.reduce((n, l) => n.add(l.power), new c("0"));
|
|
2032
|
-
return new fe(s, r.reduce());
|
|
2033
|
-
}).filter((t) => !t.power.isZero())), this;
|
|
2034
|
-
}
|
|
2035
|
-
root(e) {
|
|
2036
|
-
return h(this, N, i(this, N).map((t) => t.root(e))), this;
|
|
2037
|
-
}
|
|
2038
|
-
sort() {
|
|
2039
|
-
return h(this, N, i(this, N).sort((e, t) => e.degree().isLeq(t.degree()) ? -1 : 1)), this;
|
|
2040
|
-
}
|
|
2041
|
-
sqrt() {
|
|
2042
|
-
return h(this, N, i(this, N).map((e) => e.sqrt())), this;
|
|
2043
|
-
}
|
|
2044
|
-
subtract(...e) {
|
|
2045
|
-
return this.add(...e.map((t) => t.opposite()));
|
|
2046
|
-
}
|
|
2047
|
-
zero() {
|
|
2048
|
-
return h(this, N, [new fe("0", "1")]), this;
|
|
2049
|
-
}
|
|
2050
|
-
static gcd(...e) {
|
|
2051
|
-
var s;
|
|
2052
|
-
if (e.length === 0)
|
|
2053
|
-
return new me().one();
|
|
2054
|
-
if (e.length === 1)
|
|
2055
|
-
return e[0];
|
|
2056
|
-
if (e.length === 2)
|
|
2057
|
-
return M(s = me, lt, Yt).call(s, e[0], e[1]);
|
|
2058
|
-
let t = e[0];
|
|
2059
|
-
return e.shift(), e.forEach((r) => {
|
|
2060
|
-
var n;
|
|
2061
|
-
return t = M(n = me, lt, Yt).call(n, t, r);
|
|
2062
|
-
}), t;
|
|
2063
|
-
}
|
|
2064
|
-
// #endregion Properties and methods (25)
|
|
2065
|
-
// #region Getters And Setters (5)
|
|
2066
|
-
get factors() {
|
|
2067
|
-
return i(this, N);
|
|
2068
|
-
}
|
|
2069
|
-
set factors(e) {
|
|
2070
|
-
h(this, N, e);
|
|
2071
|
-
}
|
|
2072
|
-
get variables() {
|
|
2073
|
-
return i(this, N).reduce((e, t) => e.concat(t.variables), []);
|
|
2074
|
-
}
|
|
2075
|
-
get asRoot() {
|
|
2076
|
-
return h(this, Ve, Ue.ROOT), this;
|
|
2077
|
-
}
|
|
2078
|
-
get asPower() {
|
|
2079
|
-
return h(this, Ve, Ue.POWER), this;
|
|
2080
|
-
}
|
|
2081
|
-
get numerator() {
|
|
2082
|
-
return i(this, N).filter((e) => e.power.isPositive());
|
|
2083
|
-
}
|
|
2084
|
-
get denominator() {
|
|
2085
|
-
return i(this, N).filter((e) => e.power.isNegative());
|
|
2086
|
-
}
|
|
2087
|
-
get display() {
|
|
2088
|
-
let e = [], t = [];
|
|
2089
|
-
if (i(this, Ve) === Ue.ROOT ? (e = this.numerator, t = this.denominator.map((n) => n.clone().inverse())) : e = i(this, N), e.length === 0 && (e = [new fe("1")]), t.length === 0)
|
|
2090
|
-
return e.length === 1 ? e[0].asSingle.display : e.map((n) => n.display).join("");
|
|
2091
|
-
const s = e.length === 1 ? e[0].asSingle.display : e.map((n) => n.display).join(""), r = t.length === 1 ? t[0].asSingle.display : t.map((n) => n.display).join("");
|
|
2092
|
-
return `(${s})/(${r})`;
|
|
2093
|
-
}
|
|
2094
|
-
get tex() {
|
|
2095
|
-
let e = [], t = [];
|
|
2096
|
-
if (i(this, Ve) === Ue.ROOT ? (e = this.numerator, t = this.denominator.map((n) => n.clone().inverse())) : e = i(this, N), e.length === 0 && (e = [new fe("1")]), t.length === 0)
|
|
2097
|
-
return e.length === 1 ? e[0].asSingle.tex : e.map((n) => n.tex).join("");
|
|
2098
|
-
const s = e.length === 1 ? e[0].asSingle.tex : e.map((n) => n.tex).join(""), r = t.length === 1 ? t[0].asSingle.tex : t.map((n) => n.tex).join("");
|
|
2099
|
-
return `\\frac{ ${s} }{ ${r} }`;
|
|
2100
|
-
}
|
|
2101
|
-
// #endregion Private methods (1)
|
|
2102
|
-
};
|
|
2103
|
-
N = new WeakMap(), Ve = new WeakMap(), lt = new WeakSet(), Yt = function(e, t) {
|
|
2104
|
-
const s = Wt(e), r = Wt(t), l = Object.keys(s).filter((u) => Object.hasOwn(r, u)).map((u) => {
|
|
2105
|
-
const p = s[u].reduce((y, E) => y.add(E.power), new c("0")), m = r[u].reduce((y, E) => y.add(E.power), new c("0"));
|
|
2106
|
-
return new fe(u, c.min(p, m));
|
|
2107
|
-
});
|
|
2108
|
-
return new me(...l);
|
|
2109
|
-
}, f(me, lt);
|
|
2110
|
-
let Xt = me;
|
|
2111
|
-
function Wt(o) {
|
|
2112
|
-
const e = new c().one(), t = o.factors.reduce((s, r) => {
|
|
2113
|
-
if (r.polynom.degree().isZero())
|
|
2114
|
-
return r.polynom.monoms.length > 0 && e.multiply(r.polynom.monoms[0].coefficient), s;
|
|
2115
|
-
const n = r.polynom.display;
|
|
2116
|
-
return Object.hasOwn(s, n) ? s[n].push(r) : s[n] = [r], s;
|
|
2117
|
-
}, {});
|
|
2118
|
-
return e.isOne() || (t[e.display] = [new fe(e.display, 1)]), t;
|
|
2119
|
-
}
|
|
2120
|
-
var q, A, re, Bt, Ke, Pt;
|
|
1936
|
+
var Ue = /* @__PURE__ */ ((o) => (o[o.ROOT = 0] = "ROOT", o[o.POWER = 1] = "POWER", o))(Ue || {}), q, A, re, Pt, Ke, St;
|
|
2121
1937
|
const xe = class xe {
|
|
2122
1938
|
constructor(e, t, s) {
|
|
2123
1939
|
// Left part of the equation
|
|
@@ -2130,7 +1946,7 @@ const xe = class xe {
|
|
|
2130
1946
|
// #region Properties and methods (26)
|
|
2131
1947
|
// ------------------------------------------
|
|
2132
1948
|
a(this, "parse", (e) => {
|
|
2133
|
-
const t = i(this,
|
|
1949
|
+
const t = i(this, Pt).call(this, e);
|
|
2134
1950
|
if (t === !1)
|
|
2135
1951
|
throw new Error("The equation is not valid (no sign found)");
|
|
2136
1952
|
const s = e.split(t);
|
|
@@ -2212,7 +2028,7 @@ const xe = class xe {
|
|
|
2212
2028
|
*/
|
|
2213
2029
|
a(this, "multiply", (e) => {
|
|
2214
2030
|
const t = new c(e);
|
|
2215
|
-
return i(this, q).multiply(t), i(this, A).multiply(t), i(this, re) !== "=" && t.sign() === -1 && i(this,
|
|
2031
|
+
return i(this, q).multiply(t), i(this, A).multiply(t), i(this, re) !== "=" && t.sign() === -1 && i(this, St).call(this), this;
|
|
2216
2032
|
});
|
|
2217
2033
|
a(this, "opposite", () => (h(this, q, i(this, q).opposite()), h(this, A, i(this, A).opposite()), this));
|
|
2218
2034
|
a(this, "reorder", (e) => (i(this, q).subtract(i(this, A)), i(this, A).zero(), i(this, q).reorder(), e ? this : (i(this, q).monoms.filter((t) => t.degree().isZero()).forEach((t) => {
|
|
@@ -2226,11 +2042,11 @@ const xe = class xe {
|
|
|
2226
2042
|
*/
|
|
2227
2043
|
a(this, "simplify", () => (this.multiply(G.lcm(...i(this, q).getDenominators(), ...i(this, A).getDenominators())), this.divide(G.gcd(...i(this, q).getNumerators(), ...i(this, A).getNumerators())), this));
|
|
2228
2044
|
// -----------------------------------------------
|
|
2229
|
-
a(this, "solve", () => new
|
|
2045
|
+
a(this, "solve", () => new gt(this.clone()).solve());
|
|
2230
2046
|
a(this, "test", (e) => this.left.evaluate(e).isEqual(this.right.evaluate(e)));
|
|
2231
2047
|
// #endregion Getters And Setters (13)
|
|
2232
2048
|
// #region Private methods (6)
|
|
2233
|
-
f(this,
|
|
2049
|
+
f(this, Pt, (e) => {
|
|
2234
2050
|
if (e.includes("geq"))
|
|
2235
2051
|
return e.includes("\\geq") ? "\\geq" : "geq";
|
|
2236
2052
|
if (e.includes("leq"))
|
|
@@ -2254,7 +2070,7 @@ const xe = class xe {
|
|
|
2254
2070
|
// -----------------------------------------------
|
|
2255
2071
|
// Equations solving algorithms
|
|
2256
2072
|
f(this, Ke, (e) => e === void 0 ? "=" : e.includes("geq") || e.includes(">=") || e.includes("=>") ? ">=" : e.includes(">") ? ">" : e.includes("leq") || e.includes("<=") || e.includes("=<") ? "<=" : e.includes("<") ? "<" : "=");
|
|
2257
|
-
f(this,
|
|
2073
|
+
f(this, St, () => i(this, re) === "=" ? this : i(this, re).includes("<") ? (i(this, re).replace("<", ">"), this) : i(this, re).includes(">") ? (i(this, re).replace(">", "<"), this) : this);
|
|
2258
2074
|
if (h(this, q, new T().zero()), h(this, A, new T().zero()), h(this, re, "="), e !== void 0 && t === void 0) {
|
|
2259
2075
|
if (e instanceof xe)
|
|
2260
2076
|
return e.clone();
|
|
@@ -2355,16 +2171,203 @@ const xe = class xe {
|
|
|
2355
2171
|
}
|
|
2356
2172
|
// #endregion Private methods (6)
|
|
2357
2173
|
};
|
|
2358
|
-
q = new WeakMap(), A = new WeakMap(), re = new WeakMap(),
|
|
2174
|
+
q = new WeakMap(), A = new WeakMap(), re = new WeakMap(), Pt = new WeakMap(), Ke = new WeakMap(), St = new WeakMap();
|
|
2359
2175
|
let H = xe;
|
|
2360
|
-
var
|
|
2176
|
+
var N, Ve, lt, Yt;
|
|
2177
|
+
const me = class me {
|
|
2178
|
+
// #endregion Class fields (1)
|
|
2179
|
+
// #region Constructors (1)
|
|
2180
|
+
constructor(...e) {
|
|
2181
|
+
// #region Class fields (1)
|
|
2182
|
+
f(this, N, []);
|
|
2183
|
+
f(this, Ve, Ue.POWER);
|
|
2184
|
+
return this.parse(...e), this;
|
|
2185
|
+
}
|
|
2186
|
+
// #endregion Constructors (1)
|
|
2187
|
+
// #region Properties and methods (25)
|
|
2188
|
+
parse(...e) {
|
|
2189
|
+
return e.length === 0 ? this : (h(this, N, []), e.forEach((t) => {
|
|
2190
|
+
if (typeof t == "string") {
|
|
2191
|
+
const s = t.split(")(").join(")*(").split("*");
|
|
2192
|
+
i(this, N).push(...s.map((r) => new fe(r)));
|
|
2193
|
+
} else t instanceof me ? i(this, N).push(...t.factors.map((s) => s.clone())) : i(this, N).push(new fe(t));
|
|
2194
|
+
}), this);
|
|
2195
|
+
}
|
|
2196
|
+
fromPolynom(e, t) {
|
|
2197
|
+
return h(this, N, new T(e).factorize(t).map((s) => new fe(s))), this;
|
|
2198
|
+
}
|
|
2199
|
+
clone() {
|
|
2200
|
+
return new me(...i(this, N).map((e) => e.clone()));
|
|
2201
|
+
}
|
|
2202
|
+
add(...e) {
|
|
2203
|
+
let t = [this, ...e];
|
|
2204
|
+
const s = me.gcd(...t);
|
|
2205
|
+
t = t.map((n) => n.divide(s).reduce());
|
|
2206
|
+
const r = new T("0");
|
|
2207
|
+
return t.forEach((n) => r.add(n.develop())), h(this, N, [
|
|
2208
|
+
...s.factors,
|
|
2209
|
+
new fe(r)
|
|
2210
|
+
]), this;
|
|
2211
|
+
}
|
|
2212
|
+
degree(e) {
|
|
2213
|
+
return i(this, N).reduce((t, s) => t.add(s.degree(e)), new c("0"));
|
|
2214
|
+
}
|
|
2215
|
+
derivative() {
|
|
2216
|
+
const e = [], t = i(this, N).length;
|
|
2217
|
+
for (let r = 0; r < t; r++) {
|
|
2218
|
+
const n = i(this, N).slice(), l = n.splice(r, 1)[0];
|
|
2219
|
+
e.push(new me(...n).multiply(new me(...l.derivative())));
|
|
2220
|
+
}
|
|
2221
|
+
e.forEach((r) => r.reduce());
|
|
2222
|
+
const s = e.shift();
|
|
2223
|
+
return s !== void 0 && h(this, N, s.factors), this.add(...e);
|
|
2224
|
+
}
|
|
2225
|
+
develop() {
|
|
2226
|
+
const e = new T("1");
|
|
2227
|
+
return i(this, N).forEach((t) => {
|
|
2228
|
+
e.multiply(t.develop());
|
|
2229
|
+
}), e;
|
|
2230
|
+
}
|
|
2231
|
+
divide(e) {
|
|
2232
|
+
return h(this, N, i(this, N).concat(e.clone().factors.map((t) => t.inverse()))), this;
|
|
2233
|
+
}
|
|
2234
|
+
evaluate(e, t) {
|
|
2235
|
+
return t ? i(this, N).reduce((s, r) => s * r.evaluate(e, t), 1) : i(this, N).reduce((s, r) => s.multiply(r.evaluate(e)), new c("1"));
|
|
2236
|
+
}
|
|
2237
|
+
hasVariable(e) {
|
|
2238
|
+
return i(this, N).some((t) => t.hasVariable(e));
|
|
2239
|
+
}
|
|
2240
|
+
inverse() {
|
|
2241
|
+
return h(this, N, i(this, N).map((e) => e.inverse())), this;
|
|
2242
|
+
}
|
|
2243
|
+
isEqual(e) {
|
|
2244
|
+
const t = me.gcd(this, e), s = this.clone().divide(t).reduce(), r = e.clone().divide(t).reduce();
|
|
2245
|
+
return s.isOne() && r.isOne();
|
|
2246
|
+
}
|
|
2247
|
+
isOne() {
|
|
2248
|
+
return i(this, N).every((e) => e.isOne());
|
|
2249
|
+
}
|
|
2250
|
+
isZero() {
|
|
2251
|
+
return i(this, N).every((e) => e.isZero());
|
|
2252
|
+
}
|
|
2253
|
+
multiply(...e) {
|
|
2254
|
+
return e.forEach((t) => {
|
|
2255
|
+
h(this, N, i(this, N).concat(t.clone().factors));
|
|
2256
|
+
}), this;
|
|
2257
|
+
}
|
|
2258
|
+
one() {
|
|
2259
|
+
return h(this, N, [new fe("1", "1")]), this;
|
|
2260
|
+
}
|
|
2261
|
+
opposite() {
|
|
2262
|
+
const e = i(this, N).findIndex((t) => t.display === "(-1)");
|
|
2263
|
+
return e >= 0 ? i(this, N).splice(e, 1) : i(this, N).push(new fe("-1", "1")), this;
|
|
2264
|
+
}
|
|
2265
|
+
pow(e) {
|
|
2266
|
+
return h(this, N, i(this, N).map((t) => t.pow(e))), this;
|
|
2267
|
+
}
|
|
2268
|
+
primitive() {
|
|
2269
|
+
throw new Error("Method not implemented.");
|
|
2270
|
+
}
|
|
2271
|
+
reduce() {
|
|
2272
|
+
const e = Wt(this);
|
|
2273
|
+
return h(this, N, Object.values(e).map((t) => {
|
|
2274
|
+
const s = t[0].polynom, r = t.reduce((n, l) => n.add(l.power), new c("0"));
|
|
2275
|
+
return new fe(s, r.reduce());
|
|
2276
|
+
}).filter((t) => !t.power.isZero())), this;
|
|
2277
|
+
}
|
|
2278
|
+
root(e) {
|
|
2279
|
+
return h(this, N, i(this, N).map((t) => t.root(e))), this;
|
|
2280
|
+
}
|
|
2281
|
+
sort() {
|
|
2282
|
+
return h(this, N, i(this, N).sort((e, t) => e.degree().isLeq(t.degree()) ? -1 : 1)), this;
|
|
2283
|
+
}
|
|
2284
|
+
sqrt() {
|
|
2285
|
+
return h(this, N, i(this, N).map((e) => e.sqrt())), this;
|
|
2286
|
+
}
|
|
2287
|
+
subtract(...e) {
|
|
2288
|
+
return this.add(...e.map((t) => t.opposite()));
|
|
2289
|
+
}
|
|
2290
|
+
zero() {
|
|
2291
|
+
return h(this, N, [new fe("0", "1")]), this;
|
|
2292
|
+
}
|
|
2293
|
+
static gcd(...e) {
|
|
2294
|
+
var s;
|
|
2295
|
+
if (e.length === 0)
|
|
2296
|
+
return new me().one();
|
|
2297
|
+
if (e.length === 1)
|
|
2298
|
+
return e[0];
|
|
2299
|
+
if (e.length === 2)
|
|
2300
|
+
return M(s = me, lt, Yt).call(s, e[0], e[1]);
|
|
2301
|
+
let t = e[0];
|
|
2302
|
+
return e.shift(), e.forEach((r) => {
|
|
2303
|
+
var n;
|
|
2304
|
+
return t = M(n = me, lt, Yt).call(n, t, r);
|
|
2305
|
+
}), t;
|
|
2306
|
+
}
|
|
2307
|
+
// #endregion Properties and methods (25)
|
|
2308
|
+
// #region Getters And Setters (5)
|
|
2309
|
+
get factors() {
|
|
2310
|
+
return i(this, N);
|
|
2311
|
+
}
|
|
2312
|
+
set factors(e) {
|
|
2313
|
+
h(this, N, e);
|
|
2314
|
+
}
|
|
2315
|
+
get variables() {
|
|
2316
|
+
return i(this, N).reduce((e, t) => e.concat(t.variables), []);
|
|
2317
|
+
}
|
|
2318
|
+
get asRoot() {
|
|
2319
|
+
return h(this, Ve, Ue.ROOT), this;
|
|
2320
|
+
}
|
|
2321
|
+
get asPower() {
|
|
2322
|
+
return h(this, Ve, Ue.POWER), this;
|
|
2323
|
+
}
|
|
2324
|
+
get numerator() {
|
|
2325
|
+
return i(this, N).filter((e) => e.power.isPositive());
|
|
2326
|
+
}
|
|
2327
|
+
get denominator() {
|
|
2328
|
+
return i(this, N).filter((e) => e.power.isNegative());
|
|
2329
|
+
}
|
|
2330
|
+
get display() {
|
|
2331
|
+
let e = [], t = [];
|
|
2332
|
+
if (i(this, Ve) === Ue.ROOT ? (e = this.numerator, t = this.denominator.map((n) => n.clone().inverse())) : e = i(this, N), e.length === 0 && (e = [new fe("1")]), t.length === 0)
|
|
2333
|
+
return e.length === 1 ? e[0].asSingle.display : e.map((n) => n.display).join("");
|
|
2334
|
+
const s = e.length === 1 ? e[0].asSingle.display : e.map((n) => n.display).join(""), r = t.length === 1 ? t[0].asSingle.display : t.map((n) => n.display).join("");
|
|
2335
|
+
return `(${s})/(${r})`;
|
|
2336
|
+
}
|
|
2337
|
+
get tex() {
|
|
2338
|
+
let e = [], t = [];
|
|
2339
|
+
if (i(this, Ve) === Ue.ROOT ? (e = this.numerator, t = this.denominator.map((n) => n.clone().inverse())) : e = i(this, N), e.length === 0 && (e = [new fe("1")]), t.length === 0)
|
|
2340
|
+
return e.length === 1 ? e[0].asSingle.tex : e.map((n) => n.tex).join("");
|
|
2341
|
+
const s = e.length === 1 ? e[0].asSingle.tex : e.map((n) => n.tex).join(""), r = t.length === 1 ? t[0].asSingle.tex : t.map((n) => n.tex).join("");
|
|
2342
|
+
return `\\frac{ ${s} }{ ${r} }`;
|
|
2343
|
+
}
|
|
2344
|
+
// #endregion Private methods (1)
|
|
2345
|
+
};
|
|
2346
|
+
N = new WeakMap(), Ve = new WeakMap(), lt = new WeakSet(), Yt = function(e, t) {
|
|
2347
|
+
const s = Wt(e), r = Wt(t), l = Object.keys(s).filter((u) => Object.hasOwn(r, u)).map((u) => {
|
|
2348
|
+
const p = s[u].reduce((g, E) => g.add(E.power), new c("0")), m = r[u].reduce((g, E) => g.add(E.power), new c("0"));
|
|
2349
|
+
return new fe(u, c.min(p, m));
|
|
2350
|
+
});
|
|
2351
|
+
return new me(...l);
|
|
2352
|
+
}, f(me, lt);
|
|
2353
|
+
let Xt = me;
|
|
2354
|
+
function Wt(o) {
|
|
2355
|
+
const e = new c().one(), t = o.factors.reduce((s, r) => {
|
|
2356
|
+
if (r.polynom.degree().isZero())
|
|
2357
|
+
return r.polynom.monoms.length > 0 && e.multiply(r.polynom.monoms[0].coefficient), s;
|
|
2358
|
+
const n = r.polynom.display;
|
|
2359
|
+
return Object.hasOwn(s, n) ? s[n].push(r) : s[n] = [r], s;
|
|
2360
|
+
}, {});
|
|
2361
|
+
return e.isOne() || (t[e.display] = [new fe(e.display, 1)]), t;
|
|
2362
|
+
}
|
|
2363
|
+
var k, Ie, Bt, Rt;
|
|
2361
2364
|
const Ge = class Ge {
|
|
2362
2365
|
constructor(...e) {
|
|
2363
|
-
f(this,
|
|
2366
|
+
f(this, k);
|
|
2364
2367
|
// Determine the letters in the linear system, usually ['x', 'y']
|
|
2365
2368
|
f(this, Ie);
|
|
2366
|
-
a(this, "parse", (...e) => (h(this,
|
|
2367
|
-
a(this, "clone", () => new Ge().parse(...i(this,
|
|
2369
|
+
a(this, "parse", (...e) => (h(this, k, e.map((t) => new H(t))), i(this, Bt).call(this), this));
|
|
2370
|
+
a(this, "clone", () => new Ge().parse(...i(this, k).map((e) => e.clone())));
|
|
2368
2371
|
a(this, "buildTex", (e, t) => {
|
|
2369
2372
|
let s, r, n = [];
|
|
2370
2373
|
const l = [];
|
|
@@ -2374,12 +2377,12 @@ const Ge = class Ge {
|
|
|
2374
2377
|
for (let p = 0; p < e.length; p++) {
|
|
2375
2378
|
const m = e[p];
|
|
2376
2379
|
s = [];
|
|
2377
|
-
for (const
|
|
2378
|
-
r = m.left.monomByLetter(
|
|
2380
|
+
for (const g of n)
|
|
2381
|
+
r = m.left.monomByLetter(g), s.length === 0 ? s.push(r.isZero() ? "" : r.tex) : s.push(r.isZero() ? "" : (r.coefficient.sign() === 1 ? "+" : "") + r.tex);
|
|
2379
2382
|
if (s.push("="), s.push(m.right.tex), (t == null ? void 0 : t[p]) !== void 0) {
|
|
2380
2383
|
s[s.length - 1] = s[s.length - 1] + " \\phantom{\\quad}";
|
|
2381
|
-
for (const
|
|
2382
|
-
s.push(`\\ \\cdot\\ ${
|
|
2384
|
+
for (const g of t[p])
|
|
2385
|
+
s.push(`\\ \\cdot\\ ${g.startsWith("-") ? "\\left(" + g + "\\right)" : g}`);
|
|
2383
2386
|
}
|
|
2384
2387
|
l.push(s.join("&"));
|
|
2385
2388
|
}
|
|
@@ -2392,7 +2395,7 @@ const Ge = class Ge {
|
|
|
2392
2395
|
});
|
|
2393
2396
|
// ------------------------------------------
|
|
2394
2397
|
a(this, "reorder", () => {
|
|
2395
|
-
for (const e of i(this,
|
|
2398
|
+
for (const e of i(this, k))
|
|
2396
2399
|
e.reorder();
|
|
2397
2400
|
return this;
|
|
2398
2401
|
});
|
|
@@ -2413,10 +2416,10 @@ const Ge = class Ge {
|
|
|
2413
2416
|
}
|
|
2414
2417
|
return s.map((r) => r[r.length - 1]);
|
|
2415
2418
|
});
|
|
2416
|
-
f(this,
|
|
2419
|
+
f(this, Bt, () => (h(this, Ie, i(this, k).reduce((e, t) => [.../* @__PURE__ */ new Set([...e, ...t.variables])], [])), i(this, Ie).sort(), this));
|
|
2417
2420
|
f(this, Rt, () => {
|
|
2418
2421
|
const e = [], t = [];
|
|
2419
|
-
for (const s of i(this,
|
|
2422
|
+
for (const s of i(this, k)) {
|
|
2420
2423
|
const r = [], n = s.clone().reorder();
|
|
2421
2424
|
for (const l of this.variables) {
|
|
2422
2425
|
const u = n.left.monomByLetter(l);
|
|
@@ -2426,7 +2429,7 @@ const Ge = class Ge {
|
|
|
2426
2429
|
}
|
|
2427
2430
|
return [e, t];
|
|
2428
2431
|
});
|
|
2429
|
-
return h(this,
|
|
2432
|
+
return h(this, k, []), h(this, Ie, []), e.length > 0 && this.parse(...e), this;
|
|
2430
2433
|
}
|
|
2431
2434
|
static fromMatrix(e, t = "xyz") {
|
|
2432
2435
|
const s = e[0].length;
|
|
@@ -2443,30 +2446,30 @@ const Ge = class Ge {
|
|
|
2443
2446
|
add(e, t) {
|
|
2444
2447
|
if (e instanceof Ge) {
|
|
2445
2448
|
const s = e.equations.length;
|
|
2446
|
-
if (s !== i(this,
|
|
2449
|
+
if (s !== i(this, k).length)
|
|
2447
2450
|
throw new Error("The number of equations must be the same");
|
|
2448
2451
|
for (let r = 0; r < s; r++)
|
|
2449
|
-
i(this,
|
|
2452
|
+
i(this, k)[r].add(e.equations[r]);
|
|
2450
2453
|
} else {
|
|
2451
|
-
if (t === void 0 || t < 0 || t >= i(this,
|
|
2454
|
+
if (t === void 0 || t < 0 || t >= i(this, k).length)
|
|
2452
2455
|
throw new Error("Index out of range");
|
|
2453
2456
|
const s = new H(e);
|
|
2454
|
-
i(this,
|
|
2457
|
+
i(this, k)[t].add(s);
|
|
2455
2458
|
}
|
|
2456
2459
|
return this;
|
|
2457
2460
|
}
|
|
2458
2461
|
degree(e) {
|
|
2459
|
-
return c.max(...i(this,
|
|
2462
|
+
return c.max(...i(this, k).map((t) => t.degree(e)));
|
|
2460
2463
|
}
|
|
2461
2464
|
get display() {
|
|
2462
2465
|
return this.tex + "as display";
|
|
2463
2466
|
}
|
|
2464
2467
|
// ------------------------------------------
|
|
2465
2468
|
get equations() {
|
|
2466
|
-
return i(this,
|
|
2469
|
+
return i(this, k);
|
|
2467
2470
|
}
|
|
2468
2471
|
set equations(e) {
|
|
2469
|
-
h(this,
|
|
2472
|
+
h(this, k, e);
|
|
2470
2473
|
}
|
|
2471
2474
|
evaluate(e, t) {
|
|
2472
2475
|
throw new Error("Method not implemented.");
|
|
@@ -2478,22 +2481,22 @@ const Ge = class Ge {
|
|
|
2478
2481
|
return this.equations.every((t, s) => t.isEqual(e.equations[s]));
|
|
2479
2482
|
}
|
|
2480
2483
|
get isSolvable() {
|
|
2481
|
-
return this.variables.length === i(this,
|
|
2484
|
+
return this.variables.length === i(this, k).length;
|
|
2482
2485
|
}
|
|
2483
2486
|
get matrix() {
|
|
2484
2487
|
return i(this, Rt).call(this);
|
|
2485
2488
|
}
|
|
2486
2489
|
multiply(e, t) {
|
|
2487
2490
|
if (Array.isArray(e)) {
|
|
2488
|
-
if (e.length !== i(this,
|
|
2491
|
+
if (e.length !== i(this, k).length)
|
|
2489
2492
|
throw new Error("The number of values must be the same as the number of equations");
|
|
2490
2493
|
for (let s = 0; s < e.length; s++)
|
|
2491
|
-
i(this,
|
|
2494
|
+
i(this, k)[s].multiply(e[s]);
|
|
2492
2495
|
return this;
|
|
2493
2496
|
}
|
|
2494
|
-
if (t === void 0 || t < 0 || t >= i(this,
|
|
2497
|
+
if (t === void 0 || t < 0 || t >= i(this, k).length)
|
|
2495
2498
|
throw new Error("Index out of range");
|
|
2496
|
-
return i(this,
|
|
2499
|
+
return i(this, k)[t].multiply(e), this;
|
|
2497
2500
|
}
|
|
2498
2501
|
reduce() {
|
|
2499
2502
|
throw new Error("Method not implemented.");
|
|
@@ -2504,15 +2507,15 @@ const Ge = class Ge {
|
|
|
2504
2507
|
subtract(e, t) {
|
|
2505
2508
|
if (e instanceof Ge) {
|
|
2506
2509
|
const s = e.equations.length;
|
|
2507
|
-
if (s !== i(this,
|
|
2510
|
+
if (s !== i(this, k).length)
|
|
2508
2511
|
throw new Error("The number of equations must be the same");
|
|
2509
2512
|
for (let r = 0; r < s; r++)
|
|
2510
|
-
i(this,
|
|
2513
|
+
i(this, k)[r].subtract(e.equations[r]);
|
|
2511
2514
|
} else {
|
|
2512
|
-
if (t === void 0 || t < 0 || t >= i(this,
|
|
2515
|
+
if (t === void 0 || t < 0 || t >= i(this, k).length)
|
|
2513
2516
|
throw new Error("Index out of range");
|
|
2514
2517
|
const s = new H(e);
|
|
2515
|
-
i(this,
|
|
2518
|
+
i(this, k)[t].subtract(s);
|
|
2516
2519
|
}
|
|
2517
2520
|
return this;
|
|
2518
2521
|
}
|
|
@@ -2528,7 +2531,7 @@ const Ge = class Ge {
|
|
|
2528
2531
|
t.sort(), h(this, Ie, t);
|
|
2529
2532
|
}
|
|
2530
2533
|
};
|
|
2531
|
-
|
|
2534
|
+
k = new WeakMap(), Ie = new WeakMap(), Bt = new WeakMap(), Rt = new WeakMap();
|
|
2532
2535
|
let Qt = Ge;
|
|
2533
2536
|
function Fi(o, e) {
|
|
2534
2537
|
return o.dimension === e.dimension && o.array.every(
|
|
@@ -2559,7 +2562,7 @@ function Gi(...o) {
|
|
|
2559
2562
|
).add(o[0].array[2].clone().multiply(o[1].array[0].clone().multiply(o[2].array[1]).subtract(o[1].array[1].clone().multiply(o[2].array[0]))));
|
|
2560
2563
|
}
|
|
2561
2564
|
var V, ze, zt;
|
|
2562
|
-
const
|
|
2565
|
+
const Se = class Se {
|
|
2563
2566
|
constructor(...e) {
|
|
2564
2567
|
f(this, V, []);
|
|
2565
2568
|
f(this, ze, !1);
|
|
@@ -2686,7 +2689,7 @@ const Pe = class Pe {
|
|
|
2686
2689
|
if (e.length === 0)
|
|
2687
2690
|
throw new Error("Invalid value");
|
|
2688
2691
|
if (e.length === 1) {
|
|
2689
|
-
if (e[0] instanceof
|
|
2692
|
+
if (e[0] instanceof Se)
|
|
2690
2693
|
return e[0].clone();
|
|
2691
2694
|
if (typeof e[0] == "string")
|
|
2692
2695
|
return i(this, zt).call(this, e[0]);
|
|
@@ -2694,7 +2697,7 @@ const Pe = class Pe {
|
|
|
2694
2697
|
}
|
|
2695
2698
|
if (e.length === 2) {
|
|
2696
2699
|
const [t, s] = e;
|
|
2697
|
-
if (t instanceof
|
|
2700
|
+
if (t instanceof Se && s instanceof Se) {
|
|
2698
2701
|
if (t.dimension !== s.dimension)
|
|
2699
2702
|
throw new Error("Vectors must have the same dimension");
|
|
2700
2703
|
return h(this, V, s.array.map((r, n) => r.clone().subtract(t.array[n]))), this;
|
|
@@ -2703,7 +2706,7 @@ const Pe = class Pe {
|
|
|
2703
2706
|
return h(this, V, e.map((t) => new c(t))), this;
|
|
2704
2707
|
}
|
|
2705
2708
|
clone() {
|
|
2706
|
-
const e = new
|
|
2709
|
+
const e = new Se();
|
|
2707
2710
|
return e.array = this.copy(), e.asPoint = this.asPoint, e;
|
|
2708
2711
|
}
|
|
2709
2712
|
copy() {
|
|
@@ -2722,7 +2725,7 @@ const Pe = class Pe {
|
|
|
2722
2725
|
cross(e) {
|
|
2723
2726
|
if (this.dimension !== 3 || e.dimension !== 3)
|
|
2724
2727
|
throw new Error("Cross product can only be determined in 3D");
|
|
2725
|
-
return new
|
|
2728
|
+
return new Se(
|
|
2726
2729
|
this.y.clone().multiply(e.z).subtract(this.z.clone().multiply(e.y)),
|
|
2727
2730
|
this.z.clone().multiply(e.x).subtract(this.x.clone().multiply(e.z)),
|
|
2728
2731
|
this.x.clone().multiply(e.y).subtract(this.y.clone().multiply(e.x))
|
|
@@ -2735,7 +2738,7 @@ const Pe = class Pe {
|
|
|
2735
2738
|
return this.array.every((e, t) => t === 0 ? e.isOne() : e.isZero());
|
|
2736
2739
|
}
|
|
2737
2740
|
distanceTo(e) {
|
|
2738
|
-
const t = new
|
|
2741
|
+
const t = new Se(this, e);
|
|
2739
2742
|
return {
|
|
2740
2743
|
value: t.norm,
|
|
2741
2744
|
fraction: t.normSquare,
|
|
@@ -2744,8 +2747,8 @@ const Pe = class Pe {
|
|
|
2744
2747
|
}
|
|
2745
2748
|
};
|
|
2746
2749
|
V = new WeakMap(), ze = new WeakMap(), zt = new WeakMap();
|
|
2747
|
-
let x =
|
|
2748
|
-
function
|
|
2750
|
+
let x = Se;
|
|
2751
|
+
function gi(o = 0.5) {
|
|
2749
2752
|
return Math.random() < o;
|
|
2750
2753
|
}
|
|
2751
2754
|
function de(o, e, t) {
|
|
@@ -2763,19 +2766,19 @@ function de(o, e, t) {
|
|
|
2763
2766
|
return s;
|
|
2764
2767
|
}
|
|
2765
2768
|
function X(o, e) {
|
|
2766
|
-
return e === !1 ?
|
|
2769
|
+
return e === !1 ? gi() ? de(1, o) : -de(1, o) : de(-o, o);
|
|
2767
2770
|
}
|
|
2768
2771
|
function Wi(o) {
|
|
2769
2772
|
let e = G.primes();
|
|
2770
2773
|
return o !== void 0 && (e = e.filter((t) => t < o)), ti(e);
|
|
2771
2774
|
}
|
|
2772
2775
|
function Hi(o, e) {
|
|
2773
|
-
return e === void 0 && (e = 1), o.length <= 0 ? Object.values(o) :
|
|
2776
|
+
return e === void 0 && (e = 1), o.length <= 0 ? Object.values(o) : yi(o).slice(0, e);
|
|
2774
2777
|
}
|
|
2775
2778
|
function ti(o) {
|
|
2776
2779
|
return o.length === 0 ? null : o[de(0, o.length - 1)];
|
|
2777
2780
|
}
|
|
2778
|
-
function
|
|
2781
|
+
function yi(o) {
|
|
2779
2782
|
const e = Object.values(o);
|
|
2780
2783
|
for (let t = e.length - 1; t > 0; t--) {
|
|
2781
2784
|
const s = Math.floor(Math.random() * (t + 1)), r = e[t];
|
|
@@ -2783,7 +2786,7 @@ function gi(o) {
|
|
|
2783
2786
|
}
|
|
2784
2787
|
return e;
|
|
2785
2788
|
}
|
|
2786
|
-
class
|
|
2789
|
+
class D extends x {
|
|
2787
2790
|
constructor(...e) {
|
|
2788
2791
|
super(), e.length > 0 && this.parse(...e);
|
|
2789
2792
|
}
|
|
@@ -2809,11 +2812,11 @@ class R extends x {
|
|
|
2809
2812
|
return this;
|
|
2810
2813
|
}
|
|
2811
2814
|
clone() {
|
|
2812
|
-
const e = new
|
|
2815
|
+
const e = new D();
|
|
2813
2816
|
return e.array = this.copy(), e.asPoint = !0, e;
|
|
2814
2817
|
}
|
|
2815
2818
|
}
|
|
2816
|
-
var wi = /* @__PURE__ */ ((o) => (o.None = "none", o.Parallel = "parallel", o.Perpendicular = "perpendicular", o.Tangent = "tangent", o))(wi || {}), Ce,
|
|
2819
|
+
var wi = /* @__PURE__ */ ((o) => (o.None = "none", o.Parallel = "parallel", o.Perpendicular = "perpendicular", o.Tangent = "tangent", o))(wi || {}), Ce, B, R, U, ne, Y, $e, ve;
|
|
2817
2820
|
const Le = class Le {
|
|
2818
2821
|
/**
|
|
2819
2822
|
* Value can be a mix of:
|
|
@@ -2823,8 +2826,8 @@ const Le = class Le {
|
|
|
2823
2826
|
constructor(...e) {
|
|
2824
2827
|
f(this, Ce);
|
|
2825
2828
|
// ax + by + c = 0
|
|
2826
|
-
f(this,
|
|
2827
|
-
f(this,
|
|
2829
|
+
f(this, B);
|
|
2830
|
+
f(this, R);
|
|
2828
2831
|
f(this, U);
|
|
2829
2832
|
f(this, ne);
|
|
2830
2833
|
f(this, Y);
|
|
@@ -2853,7 +2856,7 @@ const Le = class Le {
|
|
|
2853
2856
|
if (e[0] instanceof Le)
|
|
2854
2857
|
return e[0].clone();
|
|
2855
2858
|
if (e[0] instanceof H)
|
|
2856
|
-
return this.
|
|
2859
|
+
return this.fromEquation(e[0]);
|
|
2857
2860
|
if (typeof e[0] == "string")
|
|
2858
2861
|
try {
|
|
2859
2862
|
const t = new H(e[0]);
|
|
@@ -2862,30 +2865,31 @@ const Le = class Le {
|
|
|
2862
2865
|
return this;
|
|
2863
2866
|
}
|
|
2864
2867
|
}
|
|
2865
|
-
if (e.length === 2) {
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2868
|
+
if (e.length === 2 && e.every((t) => t instanceof x)) {
|
|
2869
|
+
const t = e;
|
|
2870
|
+
if (t[0].asPoint && t[1].asPoint)
|
|
2871
|
+
return this.fromPointAndDirection(t[0], new x(t[0], t[1]));
|
|
2872
|
+
if (t[0].asPoint && !t[1].asPoint)
|
|
2873
|
+
return this.fromPointAndDirection(t[0], t[1]);
|
|
2870
2874
|
}
|
|
2871
2875
|
if (e.length === 3) {
|
|
2872
2876
|
if (e[0] instanceof x && e[1] instanceof x) {
|
|
2873
2877
|
if (e[2] === "perpendicular")
|
|
2874
|
-
return this.
|
|
2878
|
+
return this.fromPointAndNormal(e[0], e[1]);
|
|
2875
2879
|
if (e[2] === "parallel")
|
|
2876
|
-
return this.
|
|
2880
|
+
return this.fromPointAndDirection(e[0], e[1]);
|
|
2877
2881
|
}
|
|
2878
|
-
return e[0] instanceof x && e[1] instanceof Le ? e[2] === "parallel" || e[2] === null ? this.
|
|
2882
|
+
return e[0] instanceof x && e[1] instanceof Le ? e[2] === "parallel" || e[2] === null ? this.fromPointAndLine(
|
|
2879
2883
|
e[0],
|
|
2880
2884
|
e[1],
|
|
2881
2885
|
"parallel"
|
|
2882
2886
|
/* Parallel */
|
|
2883
|
-
) : this.
|
|
2887
|
+
) : this.fromPointAndLine(
|
|
2884
2888
|
e[0],
|
|
2885
2889
|
e[1],
|
|
2886
2890
|
"perpendicular"
|
|
2887
2891
|
/* Perpendicular */
|
|
2888
|
-
) : this.
|
|
2892
|
+
) : this.fromCoefficient(
|
|
2889
2893
|
e[0],
|
|
2890
2894
|
e[1],
|
|
2891
2895
|
e[2]
|
|
@@ -2893,43 +2897,43 @@ const Le = class Le {
|
|
|
2893
2897
|
}
|
|
2894
2898
|
return console.log("Something wrong happened while creating the line"), this;
|
|
2895
2899
|
});
|
|
2896
|
-
a(this, "
|
|
2900
|
+
a(this, "fromEquation", (e) => {
|
|
2897
2901
|
e.reorder(!0);
|
|
2898
2902
|
const t = new Set(e.letters());
|
|
2899
2903
|
if (!(t.has("x") || t.has("y")))
|
|
2900
2904
|
return this;
|
|
2901
2905
|
for (const s of ["x", "y"])
|
|
2902
2906
|
t.has(s) && t.delete(s);
|
|
2903
|
-
return t.size > 0 ? this : this.
|
|
2907
|
+
return t.size > 0 ? this : this.fromCoefficient(e.left.monomByLetter("x").coefficient, e.left.monomByLetter("y").coefficient, e.left.monomByDegree(0).coefficient);
|
|
2904
2908
|
});
|
|
2905
|
-
a(this, "
|
|
2906
|
-
a(this, "
|
|
2909
|
+
a(this, "fromCoefficient", (e, t, s) => (h(this, B, new c(e)), h(this, R, new c(t)), h(this, U, new c(s)), h(this, Y, new x(i(this, R).clone(), i(this, B).clone().opposite())), h(this, ne, new x(new c().zero(), i(this, U).clone())), h(this, $e, i(this, Y).clone().normal()), this));
|
|
2910
|
+
a(this, "fromPointAndDirection", (e, t) => (this.fromCoefficient(
|
|
2907
2911
|
t.y,
|
|
2908
2912
|
t.x.clone().opposite(),
|
|
2909
2913
|
e.x.clone().multiply(t.y).subtract(e.y.clone().multiply(t.x)).opposite()
|
|
2910
2914
|
), h(this, ne, e.clone()), h(this, Y, t.clone()), h(this, $e, i(this, Y).clone().normal()), this));
|
|
2911
|
-
a(this, "
|
|
2915
|
+
a(this, "fromPointAndNormal", (e, t) => this.fromCoefficient(
|
|
2912
2916
|
t.x,
|
|
2913
2917
|
t.y,
|
|
2914
2918
|
e.x.clone().multiply(t.x).add(e.y.clone().multiply(t.y)).opposite()
|
|
2915
2919
|
));
|
|
2916
|
-
a(this, "
|
|
2917
|
-
a(this, "clone", () => (h(this,
|
|
2920
|
+
a(this, "fromPointAndLine", (e, t, s) => (s === void 0 && (s = "parallel"), s === "parallel" ? this.fromPointAndNormal(e, t.normal) : s === "perpendicular" ? this.fromPointAndNormal(e, t.director) : this));
|
|
2921
|
+
a(this, "clone", () => (h(this, B, i(this, B).clone()), h(this, R, i(this, R).clone()), h(this, U, i(this, U).clone()), h(this, Y, i(this, Y).clone()), h(this, ne, i(this, ne).clone()), h(this, $e, i(this, $e).clone()), this));
|
|
2918
2922
|
// ------------------------------------------
|
|
2919
2923
|
// Mathematical operations
|
|
2920
2924
|
// ------------------------------------------
|
|
2921
|
-
a(this, "isOnLine", (e) => i(this,
|
|
2922
|
-
i(this,
|
|
2925
|
+
a(this, "isOnLine", (e) => i(this, B).clone().multiply(e.x).add(
|
|
2926
|
+
i(this, R).clone().multiply(e.y)
|
|
2923
2927
|
).add(i(this, U)).isZero());
|
|
2924
2928
|
a(this, "isParallelTo", (e) => this.slope.isEqual(e.slope) && this.height.isNotEqual(e.height));
|
|
2925
2929
|
a(this, "isSameAs", (e) => this.slope.isEqual(e.slope) && this.height.isEqual(e.height));
|
|
2926
2930
|
a(this, "isPerpendicularTo", (e) => this.d.isNormalTo(e.d));
|
|
2927
2931
|
a(this, "isVertical", () => this.slope.isInfinity());
|
|
2928
2932
|
a(this, "simplify", () => {
|
|
2929
|
-
const e = G.lcm(i(this,
|
|
2930
|
-
return this.
|
|
2931
|
-
i(this,
|
|
2932
|
-
i(this,
|
|
2933
|
+
const e = G.lcm(i(this, B).denominator, i(this, R).denominator, i(this, U).denominator), t = G.gcd(i(this, B).numerator, i(this, R).numerator, i(this, U).numerator);
|
|
2934
|
+
return this.fromCoefficient(
|
|
2935
|
+
i(this, B).clone().multiply(e).divide(t),
|
|
2936
|
+
i(this, R).clone().multiply(e).divide(t),
|
|
2933
2937
|
i(this, U).clone().multiply(e).divide(t)
|
|
2934
2938
|
), this;
|
|
2935
2939
|
});
|
|
@@ -2937,7 +2941,7 @@ const Le = class Le {
|
|
|
2937
2941
|
a(this, "intersection", (e) => {
|
|
2938
2942
|
const t = new x();
|
|
2939
2943
|
let s = !1, r = !1;
|
|
2940
|
-
return i(this,
|
|
2944
|
+
return i(this, R).isZero() || e.b.isZero(), this.isParallelTo(e) ? (t.x = new c().invalid(), t.y = new c().invalid(), s = !0) : this.isSameAs(e) ? (t.x = new c().invalid(), t.y = new c().invalid(), r = !0) : (t.x = i(this, R).clone().multiply(e.c).subtract(i(this, U).clone().multiply(e.b)).divide(i(this, B).clone().multiply(e.b).subtract(i(this, R).clone().multiply(e.a))), t.y = i(this, B).clone().multiply(e.c).subtract(i(this, U).clone().multiply(e.a)).divide(i(this, R).clone().multiply(e.a).subtract(i(this, B).clone().multiply(e.b)))), {
|
|
2941
2945
|
point: t,
|
|
2942
2946
|
hasIntersection: !(s || r),
|
|
2943
2947
|
isParallel: s,
|
|
@@ -2952,21 +2956,21 @@ const Le = class Le {
|
|
|
2952
2956
|
const t = this.getEquation().isolate("x"), s = new c(e);
|
|
2953
2957
|
return t instanceof H ? t.right.evaluate({ y: s }) : new c().invalid();
|
|
2954
2958
|
});
|
|
2955
|
-
return h(this,
|
|
2959
|
+
return h(this, B, new c().zero()), h(this, R, new c().zero()), h(this, U, new c().zero()), h(this, ne, new x()), h(this, Y, new x()), h(this, $e, new x()), h(this, Ce, !0), e.length > 0 && this.parse(...e), this;
|
|
2956
2960
|
}
|
|
2957
2961
|
get a() {
|
|
2958
|
-
return i(this,
|
|
2962
|
+
return i(this, B);
|
|
2959
2963
|
}
|
|
2960
2964
|
// ------------------------------------------
|
|
2961
2965
|
// Getter and setter
|
|
2962
2966
|
set a(e) {
|
|
2963
|
-
h(this,
|
|
2967
|
+
h(this, B, e);
|
|
2964
2968
|
}
|
|
2965
2969
|
get b() {
|
|
2966
|
-
return i(this,
|
|
2970
|
+
return i(this, R);
|
|
2967
2971
|
}
|
|
2968
2972
|
set b(e) {
|
|
2969
|
-
h(this,
|
|
2973
|
+
h(this, R, e);
|
|
2970
2974
|
}
|
|
2971
2975
|
get c() {
|
|
2972
2976
|
return i(this, U);
|
|
@@ -2991,7 +2995,7 @@ const Le = class Le {
|
|
|
2991
2995
|
}
|
|
2992
2996
|
// ------------------------------------------
|
|
2993
2997
|
getEquation() {
|
|
2994
|
-
const e = new H(new T().parse("xy", i(this,
|
|
2998
|
+
const e = new H(new T().parse("xy", i(this, B), i(this, R), i(this, U)), new T("0"));
|
|
2995
2999
|
return i(this, Ce) ? e.simplify() : e;
|
|
2996
3000
|
}
|
|
2997
3001
|
// get system(): { x: Equation, y: Equation } {
|
|
@@ -3039,7 +3043,7 @@ const Le = class Le {
|
|
|
3039
3043
|
}
|
|
3040
3044
|
default: {
|
|
3041
3045
|
const t = this.getEquation();
|
|
3042
|
-
return i(this,
|
|
3046
|
+
return i(this, B).isNegative() && t.multiply(-1), t.tex;
|
|
3043
3047
|
}
|
|
3044
3048
|
}
|
|
3045
3049
|
}
|
|
@@ -3062,24 +3066,27 @@ const Le = class Le {
|
|
|
3062
3066
|
}
|
|
3063
3067
|
default: {
|
|
3064
3068
|
const t = this.getEquation();
|
|
3065
|
-
return i(this,
|
|
3069
|
+
return i(this, B).isNegative() && t.multiply(-1), t.display;
|
|
3066
3070
|
}
|
|
3067
3071
|
}
|
|
3068
3072
|
}
|
|
3069
3073
|
get normal() {
|
|
3070
|
-
return new x(i(this,
|
|
3074
|
+
return new x(i(this, B), i(this, R));
|
|
3071
3075
|
}
|
|
3072
3076
|
get director() {
|
|
3073
3077
|
return i(this, Y).clone();
|
|
3074
3078
|
}
|
|
3075
3079
|
get slope() {
|
|
3076
|
-
return i(this,
|
|
3080
|
+
return i(this, B).clone().opposite().divide(i(this, R));
|
|
3077
3081
|
}
|
|
3078
3082
|
get height() {
|
|
3079
|
-
return i(this, U).clone().opposite().divide(i(this,
|
|
3083
|
+
return i(this, U).clone().opposite().divide(i(this, R));
|
|
3084
|
+
}
|
|
3085
|
+
fromPoints(e, t) {
|
|
3086
|
+
return this.fromPointAndDirection(e, new x(e, t));
|
|
3080
3087
|
}
|
|
3081
3088
|
distanceTo(e) {
|
|
3082
|
-
const t = e.x.clone().multiply(i(this,
|
|
3089
|
+
const t = e.x.clone().multiply(i(this, B)).add(e.y.clone().multiply(i(this, R))).add(i(this, U)).abs(), s = this.normal.normSquare;
|
|
3083
3090
|
if (s.isZero())
|
|
3084
3091
|
return {
|
|
3085
3092
|
value: NaN,
|
|
@@ -3109,10 +3116,10 @@ const Le = class Le {
|
|
|
3109
3116
|
canonicalAsFloatCoefficient(e) {
|
|
3110
3117
|
e === void 0 && (e = 2);
|
|
3111
3118
|
let t = "";
|
|
3112
|
-
return i(this,
|
|
3119
|
+
return i(this, B).isZero() || (i(this, B).isOne() ? t = "x" : i(this, B).clone().opposite().isOne() ? t = "-x" : t = i(this, B).value.toFixed(e) + "x"), i(this, R).isZero() || (i(this, R).isPositive() && (t += "+"), t += i(this, R).value.toFixed(e) + "y"), i(this, U).isZero() || (i(this, U).isPositive() && (t += "+"), t += i(this, U).value.toFixed(e)), t + "=0";
|
|
3113
3120
|
}
|
|
3114
3121
|
};
|
|
3115
|
-
Ce = new WeakMap(),
|
|
3122
|
+
Ce = new WeakMap(), B = new WeakMap(), R = new WeakMap(), U = new WeakMap(), ne = new WeakMap(), Y = new WeakMap(), $e = new WeakMap(), ve = new WeakMap(), // A line is defined as the canonical form
|
|
3116
3123
|
a(Le, "PERPENDICULAR", "perpendicular"), a(Le, "PARALLEL", "parallel");
|
|
3117
3124
|
let j = Le;
|
|
3118
3125
|
var oe, F, qe, kt, Lt, Dt, he, vi, mt, bi, xi, Ei, Kt;
|
|
@@ -3150,7 +3157,7 @@ const Zt = class Zt {
|
|
|
3150
3157
|
return t.forEach((r) => {
|
|
3151
3158
|
for (const n of [[1, 1], [-1, 1], [-1, -1], [1, -1]])
|
|
3152
3159
|
s.push(
|
|
3153
|
-
new
|
|
3160
|
+
new D(
|
|
3154
3161
|
this.center.x.clone().add(n[0] * r[0]),
|
|
3155
3162
|
this.center.y.clone().add(n[1] * r[1])
|
|
3156
3163
|
)
|
|
@@ -3158,7 +3165,7 @@ const Zt = class Zt {
|
|
|
3158
3165
|
}), s;
|
|
3159
3166
|
});
|
|
3160
3167
|
f(this, kt, (e) => {
|
|
3161
|
-
const t = new
|
|
3168
|
+
const t = new D(this.center, e);
|
|
3162
3169
|
return [new j(e, t, wi.Perpendicular)];
|
|
3163
3170
|
});
|
|
3164
3171
|
f(this, Lt, (e) => {
|
|
@@ -3172,7 +3179,7 @@ const Zt = class Zt {
|
|
|
3172
3179
|
e.length > 0 && this.parse(...e);
|
|
3173
3180
|
}
|
|
3174
3181
|
get center() {
|
|
3175
|
-
return i(this, oe) ?? new
|
|
3182
|
+
return i(this, oe) ?? new D();
|
|
3176
3183
|
}
|
|
3177
3184
|
get squareRadius() {
|
|
3178
3185
|
return i(this, F) ?? new c(0);
|
|
@@ -3215,7 +3222,7 @@ const Zt = class Zt {
|
|
|
3215
3222
|
return t ? h(this, F, new c(e)) : h(this, F, new c(e).pow(2)), M(this, he, mt).call(this), this;
|
|
3216
3223
|
}
|
|
3217
3224
|
parse(...e) {
|
|
3218
|
-
return M(this, he, vi).call(this), typeof e[0] == "string" ? M(this, he, Kt).call(this, new H(e[0])) : e[0] instanceof H ? M(this, he, Kt).call(this, e[0]) : e[0] instanceof Zt ? M(this, he, bi).call(this, e[0]) : e[0] instanceof
|
|
3225
|
+
return M(this, he, vi).call(this), typeof e[0] == "string" ? M(this, he, Kt).call(this, new H(e[0])) : e[0] instanceof H ? M(this, he, Kt).call(this, e[0]) : e[0] instanceof Zt ? M(this, he, bi).call(this, e[0]) : e[0] instanceof D && e.length > 1 && (e[1] instanceof D ? e[2] instanceof D || M(this, he, Ei).call(this, e[0], e[1]) : (e[1] instanceof c || typeof e[1] == "number") && M(this, he, xi).call(this, e[0], e[1], typeof e[2] == "boolean" ? e[2] : !1)), M(this, he, mt).call(this), this;
|
|
3219
3226
|
}
|
|
3220
3227
|
// private _parseThroughtThreePoints(A: Point, B: Point, C: Point): this {
|
|
3221
3228
|
// const T = new Triangle(A, B, C), mAB = T.remarquables.mediators.AB.clone(),
|
|
@@ -3241,12 +3248,12 @@ oe = new WeakMap(), F = new WeakMap(), qe = new WeakMap(), kt = new WeakMap(), L
|
|
|
3241
3248
|
if (e.moveLeft(), e.degree("x").value === 2 && e.degree("y").value === 2) {
|
|
3242
3249
|
const t = e.left.monomByDegree(2, "x"), s = e.left.monomByDegree(2, "y");
|
|
3243
3250
|
let r, n, l;
|
|
3244
|
-
t.coefficient.isEqual(s.coefficient) ? (e.divide(t.coefficient), r = e.left.monomByDegree(1, "x"), n = e.left.monomByDegree(1, "y"), l = e.left.monomByDegree(0), h(this, oe, new
|
|
3251
|
+
t.coefficient.isEqual(s.coefficient) ? (e.divide(t.coefficient), r = e.left.monomByDegree(1, "x"), n = e.left.monomByDegree(1, "y"), l = e.left.monomByDegree(0), h(this, oe, new D(r.coefficient.clone().divide(2).opposite(), n.coefficient.clone().divide(2).opposite())), h(this, F, l.coefficient.clone().opposite().add(i(this, oe).x.clone().pow(2)).add(i(this, oe).y.clone().pow(2)))) : (h(this, oe, void 0), h(this, F, void 0));
|
|
3245
3252
|
}
|
|
3246
3253
|
return this;
|
|
3247
3254
|
};
|
|
3248
|
-
let
|
|
3249
|
-
var Q, _, ee, Je, Te, ct, Vt, ut,
|
|
3255
|
+
let yt = Zt;
|
|
3256
|
+
var Q, _, ee, Je, Te, ct, Vt, ut, Pe, Ft, _e;
|
|
3250
3257
|
const jt = class jt {
|
|
3251
3258
|
constructor(...e) {
|
|
3252
3259
|
f(this, Q);
|
|
@@ -3294,7 +3301,7 @@ const jt = class jt {
|
|
|
3294
3301
|
h(this, Q, n.point.clone());
|
|
3295
3302
|
else
|
|
3296
3303
|
throw new Error("Lines do not intersect !");
|
|
3297
|
-
} else e.every((t) => t instanceof
|
|
3304
|
+
} else e.every((t) => t instanceof D) && (h(this, Q, e[0].clone()), h(this, _, e[1].clone()), h(this, ee, e[2].clone()), h(this, Je, {
|
|
3298
3305
|
AB: new j(i(this, Q), i(this, _)),
|
|
3299
3306
|
BC: new j(i(this, _), i(this, ee)),
|
|
3300
3307
|
AC: new j(i(this, Q), i(this, ee))
|
|
@@ -3319,9 +3326,9 @@ const jt = class jt {
|
|
|
3319
3326
|
*/
|
|
3320
3327
|
f(this, Vt, () => {
|
|
3321
3328
|
h(this, Te, {
|
|
3322
|
-
AB: new
|
|
3323
|
-
AC: new
|
|
3324
|
-
BC: new
|
|
3329
|
+
AB: new D().middleOf(i(this, Q), i(this, _)),
|
|
3330
|
+
AC: new D().middleOf(i(this, Q), i(this, ee)),
|
|
3331
|
+
BC: new D().middleOf(i(this, _), i(this, ee))
|
|
3325
3332
|
}), h(this, ct, i(this, Ft).call(this));
|
|
3326
3333
|
});
|
|
3327
3334
|
/**
|
|
@@ -3344,7 +3351,7 @@ const jt = class jt {
|
|
|
3344
3351
|
* @param ptName1
|
|
3345
3352
|
* @param ptName2
|
|
3346
3353
|
*/
|
|
3347
|
-
f(this,
|
|
3354
|
+
f(this, Pe, (e, t) => new x(
|
|
3348
3355
|
i(this, ut).call(this, e),
|
|
3349
3356
|
i(this, ut).call(this, t)
|
|
3350
3357
|
));
|
|
@@ -3388,8 +3395,8 @@ const jt = class jt {
|
|
|
3388
3395
|
let s, r;
|
|
3389
3396
|
if (e === "A" ? (s = t.AB, r = t.AC) : e === "B" ? (s = t.AB, r = t.BC) : e === "C" && (s = t.BC, r = t.AC), s === void 0 || r === void 0)
|
|
3390
3397
|
throw new Error(`The point ${e} does not exist`);
|
|
3391
|
-
const n = s.n.simplify().norm, l = r.n.simplify().norm, u = s.getEquation().multiply(l), p = r.getEquation().multiply(n), m = new j(u.clone().subtract(p).simplify()),
|
|
3392
|
-
return e === "A" ? m.hitSegment(this.B, this.C) ? { internal: m, external:
|
|
3398
|
+
const n = s.n.simplify().norm, l = r.n.simplify().norm, u = s.getEquation().multiply(l), p = r.getEquation().multiply(n), m = new j(u.clone().subtract(p).simplify()), g = new j(p.clone().subtract(u).simplify());
|
|
3399
|
+
return e === "A" ? m.hitSegment(this.B, this.C) ? { internal: m, external: g } : { internal: g, external: m } : e === "B" ? m.hitSegment(this.A, this.C) ? { internal: m, external: g } : { internal: g, external: m } : e === "C" ? m.hitSegment(this.B, this.A) ? { internal: m, external: g } : { internal: g, external: m } : { internal: m, external: g };
|
|
3393
3400
|
});
|
|
3394
3401
|
return e.length > 0 && this.parse(...e), this;
|
|
3395
3402
|
}
|
|
@@ -3406,22 +3413,22 @@ const jt = class jt {
|
|
|
3406
3413
|
return i(this, ee);
|
|
3407
3414
|
}
|
|
3408
3415
|
get AB() {
|
|
3409
|
-
return i(this,
|
|
3416
|
+
return i(this, Pe).call(this, "A", "B");
|
|
3410
3417
|
}
|
|
3411
3418
|
get BA() {
|
|
3412
|
-
return i(this,
|
|
3419
|
+
return i(this, Pe).call(this, "B", "A");
|
|
3413
3420
|
}
|
|
3414
3421
|
get BC() {
|
|
3415
|
-
return i(this,
|
|
3422
|
+
return i(this, Pe).call(this, "B", "C");
|
|
3416
3423
|
}
|
|
3417
3424
|
get CB() {
|
|
3418
|
-
return i(this,
|
|
3425
|
+
return i(this, Pe).call(this, "C", "B");
|
|
3419
3426
|
}
|
|
3420
3427
|
get AC() {
|
|
3421
|
-
return i(this,
|
|
3428
|
+
return i(this, Pe).call(this, "A", "C");
|
|
3422
3429
|
}
|
|
3423
3430
|
get CA() {
|
|
3424
|
-
return i(this,
|
|
3431
|
+
return i(this, Pe).call(this, "C", "A");
|
|
3425
3432
|
}
|
|
3426
3433
|
get isRectangle() {
|
|
3427
3434
|
return !!(this.AB.isNormalTo(this.BC) || this.AB.isNormalTo(this.AC) || this.BC.isNormalTo(this.AC));
|
|
@@ -3439,15 +3446,15 @@ const jt = class jt {
|
|
|
3439
3446
|
return i(this, ct);
|
|
3440
3447
|
}
|
|
3441
3448
|
};
|
|
3442
|
-
Q = new WeakMap(), _ = new WeakMap(), ee = new WeakMap(), Je = new WeakMap(), Te = new WeakMap(), ct = new WeakMap(), Vt = new WeakMap(), ut = new WeakMap(),
|
|
3449
|
+
Q = new WeakMap(), _ = new WeakMap(), ee = new WeakMap(), Je = new WeakMap(), Te = new WeakMap(), ct = new WeakMap(), Vt = new WeakMap(), ut = new WeakMap(), Pe = new WeakMap(), Ft = new WeakMap(), _e = new WeakMap();
|
|
3443
3450
|
let Jt = jt;
|
|
3444
|
-
var
|
|
3451
|
+
var z, W;
|
|
3445
3452
|
const nt = class nt {
|
|
3446
3453
|
constructor(e, t) {
|
|
3447
3454
|
// ax + by + c = 0
|
|
3448
|
-
f(this,
|
|
3455
|
+
f(this, z, new D());
|
|
3449
3456
|
f(this, W, new x());
|
|
3450
|
-
a(this, "clone", () => (h(this, W, i(this, W).clone()), h(this,
|
|
3457
|
+
a(this, "clone", () => (h(this, W, i(this, W).clone()), h(this, z, i(this, z).clone()), this));
|
|
3451
3458
|
// ------------------------------------------
|
|
3452
3459
|
// Mathematical operations
|
|
3453
3460
|
// ------------------------------------------
|
|
@@ -3487,23 +3494,23 @@ const nt = class nt {
|
|
|
3487
3494
|
// return new Fraction().invalid()
|
|
3488
3495
|
// }
|
|
3489
3496
|
a(this, "randomPoint", (e = 5) => {
|
|
3490
|
-
const t = i(this,
|
|
3491
|
-
return new
|
|
3497
|
+
const t = i(this, z).clone(), s = new c(X(e, !1));
|
|
3498
|
+
return new D(
|
|
3492
3499
|
t.x.clone().add(i(this, W).x.clone().multiply(s)),
|
|
3493
3500
|
t.y.clone().add(i(this, W).y.clone().multiply(s)),
|
|
3494
3501
|
t.z.clone().add(i(this, W).z.clone().multiply(s))
|
|
3495
3502
|
);
|
|
3496
3503
|
});
|
|
3497
|
-
return h(this,
|
|
3504
|
+
return h(this, z, e.clone()), h(this, W, t.asPoint ? new x(e, t) : t.clone()), this;
|
|
3498
3505
|
}
|
|
3499
3506
|
get OA() {
|
|
3500
|
-
return i(this,
|
|
3507
|
+
return i(this, z);
|
|
3501
3508
|
}
|
|
3502
3509
|
set OA(e) {
|
|
3503
|
-
h(this,
|
|
3510
|
+
h(this, z, e);
|
|
3504
3511
|
}
|
|
3505
3512
|
get point() {
|
|
3506
|
-
return i(this,
|
|
3513
|
+
return i(this, z).clone();
|
|
3507
3514
|
}
|
|
3508
3515
|
get d() {
|
|
3509
3516
|
return i(this, W);
|
|
@@ -3513,19 +3520,19 @@ const nt = class nt {
|
|
|
3513
3520
|
}
|
|
3514
3521
|
get tex() {
|
|
3515
3522
|
return {
|
|
3516
|
-
parametric: `${x.asTex("x", "y", "z")} = ${x.asTex(i(this,
|
|
3523
|
+
parametric: `${x.asTex("x", "y", "z")} = ${x.asTex(i(this, z).x.tex, i(this, z).y.tex, i(this, z).z.tex)} + k\\cdot ${x.asTex(i(this, W).x.tex, i(this, W).y.tex, i(this, W).z.tex)}`,
|
|
3517
3524
|
system: `\\left\\{\\begin{aligned}
|
|
3518
|
-
x &= ${new T(i(this,
|
|
3519
|
-
y &= ${new T(i(this,
|
|
3520
|
-
z &= ${new T(i(this,
|
|
3525
|
+
x &= ${new T(i(this, z).x).add(new I(i(this, W).x).multiply(new I("k"))).reorder("k", !0).tex}\\\\
|
|
3526
|
+
y &= ${new T(i(this, z).y).add(new I(i(this, W).y).multiply(new I("k"))).reorder("k", !0).tex}\\\\
|
|
3527
|
+
z &= ${new T(i(this, z).z).add(new I(i(this, W).z).multiply(new I("k"))).reorder("k", !0).tex}
|
|
3521
3528
|
\\end{aligned}\\right.`,
|
|
3522
|
-
cartesian: `\\frac{ ${new T("x", 1, i(this,
|
|
3529
|
+
cartesian: `\\frac{ ${new T("x", 1, i(this, z).x.clone().opposite()).tex} }{ ${this.direction.x.tex} } = \\frac{ ${new T("y", 1, i(this, z).y.clone().opposite()).tex} }{ ${this.direction.y.tex} } = \\frac{ ${new T("z", 1, i(this, z).z.clone().opposite()).tex} }{ ${this.direction.z.tex} }`
|
|
3523
3530
|
};
|
|
3524
3531
|
}
|
|
3525
3532
|
get display() {
|
|
3526
|
-
const e = i(this,
|
|
3533
|
+
const e = i(this, z).x.display, t = i(this, z).y.display, s = i(this, z).z.display, r = this.direction.simplify(), n = r.x.display, l = r.y.display, u = r.z.display;
|
|
3527
3534
|
return {
|
|
3528
|
-
parametric: `${x.asDisplay("x", "y", "z")} = ${x.asDisplay(i(this,
|
|
3535
|
+
parametric: `${x.asDisplay("x", "y", "z")} = ${x.asDisplay(i(this, z).x.display, i(this, z).y.display, i(this, z).z.display)} + k\\cdot ${x.asDisplay(i(this, W).x.display, i(this, W).y.display, i(this, W).z.display)}`,
|
|
3529
3536
|
system: "",
|
|
3530
3537
|
cartesian: `(x-${e})/${n} = (y-${t})/${l} = (z-${s})/${u}`
|
|
3531
3538
|
};
|
|
@@ -3534,7 +3541,7 @@ const nt = class nt {
|
|
|
3534
3541
|
return i(this, W).clone();
|
|
3535
3542
|
}
|
|
3536
3543
|
distanceTo(e) {
|
|
3537
|
-
const t = new x(i(this,
|
|
3544
|
+
const t = new x(i(this, z), e), s = this.direction, r = this.direction.normSquare, n = t.cross(s).normSquare, l = n.clone().divide(r), u = l.clone().sqrt();
|
|
3538
3545
|
return console.log("CROSS", t.cross(s).display), {
|
|
3539
3546
|
value: Math.sqrt(l.value),
|
|
3540
3547
|
fraction: l.clone().sqrt(),
|
|
@@ -3548,14 +3555,14 @@ const nt = class nt {
|
|
|
3548
3555
|
return s.hasIntersection ? s.point.x.value >= Math.min(e.x.value, t.x.value) && s.point.x.value <= Math.max(e.x.value, t.x.value) && s.point.y.value >= Math.min(e.y.value, t.y.value) && s.point.y.value <= Math.max(e.y.value, t.y.value) && s.point.z.value >= Math.min(e.z.value, t.z.value) && s.point.z.value <= Math.max(e.z.value, t.z.value) : !1;
|
|
3549
3556
|
}
|
|
3550
3557
|
};
|
|
3551
|
-
|
|
3558
|
+
z = new WeakMap(), W = new WeakMap(), // A line is defined as the canonical form
|
|
3552
3559
|
a(nt, "PERPENDICULAR", "perpendicular"), a(nt, "PARALLEL", "parallel");
|
|
3553
3560
|
let wt = nt;
|
|
3554
3561
|
var Ae, Fe;
|
|
3555
3562
|
const si = class si {
|
|
3556
3563
|
constructor(e) {
|
|
3557
3564
|
f(this, Ae, new x(0, 0, 1));
|
|
3558
|
-
f(this, Fe, new
|
|
3565
|
+
f(this, Fe, new D(0, 0, 0));
|
|
3559
3566
|
return e && this.parse(e), this;
|
|
3560
3567
|
}
|
|
3561
3568
|
get normal() {
|
|
@@ -3602,7 +3609,7 @@ const si = class si {
|
|
|
3602
3609
|
}
|
|
3603
3610
|
if (e.equation) {
|
|
3604
3611
|
const n = e.equation.moveLeft().reduce().left, l = n.monomByLetter("x").coefficient, u = n.monomByLetter("y").coefficient, p = n.monomByLetter("z").coefficient, m = n.monomByDegree(0).coefficient;
|
|
3605
|
-
this.normal = new x(l, u, p), l.isNotZero() ? this.point = new
|
|
3612
|
+
this.normal = new x(l, u, p), l.isNotZero() ? this.point = new D(m.clone().divide(l).opposite(), 0, 0) : u.isNotZero() ? this.point = new D(0, m.clone().divide(u).opposite(), 0) : this.point = new D(0, 0, m.clone().divide(p).opposite());
|
|
3606
3613
|
return;
|
|
3607
3614
|
}
|
|
3608
3615
|
if (((s = e.points) == null ? void 0 : s.length) === 3 && e.points.every((n) => n instanceof x)) {
|
|
@@ -3612,7 +3619,7 @@ const si = class si {
|
|
|
3612
3619
|
}
|
|
3613
3620
|
if (((r = e.coefficients) == null ? void 0 : r.length) === 4) {
|
|
3614
3621
|
const [n, l, u, p] = e.coefficients;
|
|
3615
|
-
this.normal = new x(n, l, u), this.point = new
|
|
3622
|
+
this.normal = new x(n, l, u), this.point = new D(0, 0, -p);
|
|
3616
3623
|
return;
|
|
3617
3624
|
}
|
|
3618
3625
|
}
|
|
@@ -3636,7 +3643,7 @@ const si = class si {
|
|
|
3636
3643
|
return t.clone().add(s.clone().multiplyByScalar(r));
|
|
3637
3644
|
}
|
|
3638
3645
|
intersectWithPlane(e) {
|
|
3639
|
-
throw this.normal.cross(e.normal), new
|
|
3646
|
+
throw this.normal.cross(e.normal), new D(0, 0, 0), new Error("Intersection with plane not yet implemented !");
|
|
3640
3647
|
}
|
|
3641
3648
|
isPointOnPlane(e) {
|
|
3642
3649
|
return this.normal.dot(e).add(this.d).isZero();
|
|
@@ -3788,7 +3795,7 @@ function qi(o) {
|
|
|
3788
3795
|
},
|
|
3789
3796
|
o
|
|
3790
3797
|
), t = e.axis === "x", s = e.axis === "y", r = e.fraction ? vt({ max: e.max, zero: t }) : new c(X(e.max, t)), n = e.fraction ? vt({ max: e.max, zero: s }) : new c(X(e.max, s));
|
|
3791
|
-
return Number(e.quadrant) === 1 && (r.abs(), n.abs()), Number(e.quadrant) === 2 && (r.isPositive() && r.opposite(), n.isNegative() && n.opposite()), Number(e.quadrant) === 3 && (r.isPositive() && r.opposite(), n.isPositive() && n.opposite()), Number(e.quadrant) === 4 && (r.isNegative() && r.opposite(), n.isPositive() && n.opposite()), new
|
|
3798
|
+
return Number(e.quadrant) === 1 && (r.abs(), n.abs()), Number(e.quadrant) === 2 && (r.isPositive() && r.opposite(), n.isNegative() && n.opposite()), Number(e.quadrant) === 3 && (r.isPositive() && r.opposite(), n.isPositive() && n.opposite()), Number(e.quadrant) === 4 && (r.isNegative() && r.opposite(), n.isPositive() && n.opposite()), new D(r, n);
|
|
3792
3799
|
}
|
|
3793
3800
|
function Ki(o) {
|
|
3794
3801
|
const e = Object.assign(
|
|
@@ -3802,7 +3809,7 @@ function Ki(o) {
|
|
|
3802
3809
|
o
|
|
3803
3810
|
), t = qi(e.center);
|
|
3804
3811
|
let s, r;
|
|
3805
|
-
return e.pointsOnCircle === 8 ? (s = de(1, 3), r = s ** 2 + (s + 1) ** 2) : r = de(1, 20), new
|
|
3812
|
+
return e.pointsOnCircle === 8 ? (s = de(1, 3), r = s ** 2 + (s + 1) ** 2) : r = de(1, 20), new yt(t, r, !0);
|
|
3806
3813
|
}
|
|
3807
3814
|
function Ji(o) {
|
|
3808
3815
|
const e = Object.assign(
|
|
@@ -3836,7 +3843,7 @@ function _i(o) {
|
|
|
3836
3843
|
}
|
|
3837
3844
|
},
|
|
3838
3845
|
o
|
|
3839
|
-
), t = new
|
|
3846
|
+
), t = new D(e.A.x, e.A.y, e.A.z), s = new x(e.direction.x, e.direction.y, e.direction.z);
|
|
3840
3847
|
return new wt(t, s);
|
|
3841
3848
|
}
|
|
3842
3849
|
const es = {
|
|
@@ -3847,20 +3854,20 @@ const es = {
|
|
|
3847
3854
|
number: (o, e, t) => de(o, e, t),
|
|
3848
3855
|
numberSym: (o, e) => X(o, e),
|
|
3849
3856
|
prime: (o) => Wi(o),
|
|
3850
|
-
bool: (o) =>
|
|
3857
|
+
bool: (o) => gi(o),
|
|
3851
3858
|
array: (o, e) => Hi(o, e),
|
|
3852
3859
|
item: (o) => ti(o),
|
|
3853
|
-
shuffle: (o) =>
|
|
3860
|
+
shuffle: (o) => yi(o),
|
|
3854
3861
|
line: (o) => Ji(o),
|
|
3855
3862
|
line3: (o) => _i(o),
|
|
3856
3863
|
point: (o) => qi(o),
|
|
3857
3864
|
circle: (o) => Ki(o)
|
|
3858
3865
|
}, ts = {
|
|
3859
3866
|
Vector: x,
|
|
3860
|
-
Point:
|
|
3867
|
+
Point: D,
|
|
3861
3868
|
Line: j,
|
|
3862
3869
|
Triangle: Jt,
|
|
3863
|
-
Circle:
|
|
3870
|
+
Circle: yt,
|
|
3864
3871
|
Line3: wt,
|
|
3865
3872
|
Plane3: _t
|
|
3866
3873
|
}, ss = {
|