pimath 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pimath.js +310 -306
- package/package.json +1 -1
- package/types/algebra/polynom.d.ts.map +1 -1
- package/types/geometry/line.d.ts +13 -5
- package/types/geometry/line.d.ts.map +1 -1
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();
|
|
@@ -2102,7 +2102,7 @@ const me = class me {
|
|
|
2102
2102
|
};
|
|
2103
2103
|
N = new WeakMap(), Ve = new WeakMap(), lt = new WeakSet(), Yt = function(e, t) {
|
|
2104
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((
|
|
2105
|
+
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"));
|
|
2106
2106
|
return new fe(u, c.min(p, m));
|
|
2107
2107
|
});
|
|
2108
2108
|
return new me(...l);
|
|
@@ -2117,7 +2117,7 @@ function Wt(o) {
|
|
|
2117
2117
|
}, {});
|
|
2118
2118
|
return e.isOne() || (t[e.display] = [new fe(e.display, 1)]), t;
|
|
2119
2119
|
}
|
|
2120
|
-
var q, A, re,
|
|
2120
|
+
var q, A, re, Pt, Ke, St;
|
|
2121
2121
|
const xe = class xe {
|
|
2122
2122
|
constructor(e, t, s) {
|
|
2123
2123
|
// Left part of the equation
|
|
@@ -2130,7 +2130,7 @@ const xe = class xe {
|
|
|
2130
2130
|
// #region Properties and methods (26)
|
|
2131
2131
|
// ------------------------------------------
|
|
2132
2132
|
a(this, "parse", (e) => {
|
|
2133
|
-
const t = i(this,
|
|
2133
|
+
const t = i(this, Pt).call(this, e);
|
|
2134
2134
|
if (t === !1)
|
|
2135
2135
|
throw new Error("The equation is not valid (no sign found)");
|
|
2136
2136
|
const s = e.split(t);
|
|
@@ -2212,7 +2212,7 @@ const xe = class xe {
|
|
|
2212
2212
|
*/
|
|
2213
2213
|
a(this, "multiply", (e) => {
|
|
2214
2214
|
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,
|
|
2215
|
+
return i(this, q).multiply(t), i(this, A).multiply(t), i(this, re) !== "=" && t.sign() === -1 && i(this, St).call(this), this;
|
|
2216
2216
|
});
|
|
2217
2217
|
a(this, "opposite", () => (h(this, q, i(this, q).opposite()), h(this, A, i(this, A).opposite()), this));
|
|
2218
2218
|
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 +2226,11 @@ const xe = class xe {
|
|
|
2226
2226
|
*/
|
|
2227
2227
|
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
2228
|
// -----------------------------------------------
|
|
2229
|
-
a(this, "solve", () => new
|
|
2229
|
+
a(this, "solve", () => new gt(this.clone()).solve());
|
|
2230
2230
|
a(this, "test", (e) => this.left.evaluate(e).isEqual(this.right.evaluate(e)));
|
|
2231
2231
|
// #endregion Getters And Setters (13)
|
|
2232
2232
|
// #region Private methods (6)
|
|
2233
|
-
f(this,
|
|
2233
|
+
f(this, Pt, (e) => {
|
|
2234
2234
|
if (e.includes("geq"))
|
|
2235
2235
|
return e.includes("\\geq") ? "\\geq" : "geq";
|
|
2236
2236
|
if (e.includes("leq"))
|
|
@@ -2254,7 +2254,7 @@ const xe = class xe {
|
|
|
2254
2254
|
// -----------------------------------------------
|
|
2255
2255
|
// Equations solving algorithms
|
|
2256
2256
|
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,
|
|
2257
|
+
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
2258
|
if (h(this, q, new T().zero()), h(this, A, new T().zero()), h(this, re, "="), e !== void 0 && t === void 0) {
|
|
2259
2259
|
if (e instanceof xe)
|
|
2260
2260
|
return e.clone();
|
|
@@ -2355,16 +2355,16 @@ const xe = class xe {
|
|
|
2355
2355
|
}
|
|
2356
2356
|
// #endregion Private methods (6)
|
|
2357
2357
|
};
|
|
2358
|
-
q = new WeakMap(), A = new WeakMap(), re = new WeakMap(),
|
|
2358
|
+
q = new WeakMap(), A = new WeakMap(), re = new WeakMap(), Pt = new WeakMap(), Ke = new WeakMap(), St = new WeakMap();
|
|
2359
2359
|
let H = xe;
|
|
2360
|
-
var
|
|
2360
|
+
var k, Ie, Bt, Rt;
|
|
2361
2361
|
const Ge = class Ge {
|
|
2362
2362
|
constructor(...e) {
|
|
2363
|
-
f(this,
|
|
2363
|
+
f(this, k);
|
|
2364
2364
|
// Determine the letters in the linear system, usually ['x', 'y']
|
|
2365
2365
|
f(this, Ie);
|
|
2366
|
-
a(this, "parse", (...e) => (h(this,
|
|
2367
|
-
a(this, "clone", () => new Ge().parse(...i(this,
|
|
2366
|
+
a(this, "parse", (...e) => (h(this, k, e.map((t) => new H(t))), i(this, Bt).call(this), this));
|
|
2367
|
+
a(this, "clone", () => new Ge().parse(...i(this, k).map((e) => e.clone())));
|
|
2368
2368
|
a(this, "buildTex", (e, t) => {
|
|
2369
2369
|
let s, r, n = [];
|
|
2370
2370
|
const l = [];
|
|
@@ -2374,12 +2374,12 @@ const Ge = class Ge {
|
|
|
2374
2374
|
for (let p = 0; p < e.length; p++) {
|
|
2375
2375
|
const m = e[p];
|
|
2376
2376
|
s = [];
|
|
2377
|
-
for (const
|
|
2378
|
-
r = m.left.monomByLetter(
|
|
2377
|
+
for (const g of n)
|
|
2378
|
+
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
2379
|
if (s.push("="), s.push(m.right.tex), (t == null ? void 0 : t[p]) !== void 0) {
|
|
2380
2380
|
s[s.length - 1] = s[s.length - 1] + " \\phantom{\\quad}";
|
|
2381
|
-
for (const
|
|
2382
|
-
s.push(`\\ \\cdot\\ ${
|
|
2381
|
+
for (const g of t[p])
|
|
2382
|
+
s.push(`\\ \\cdot\\ ${g.startsWith("-") ? "\\left(" + g + "\\right)" : g}`);
|
|
2383
2383
|
}
|
|
2384
2384
|
l.push(s.join("&"));
|
|
2385
2385
|
}
|
|
@@ -2392,7 +2392,7 @@ const Ge = class Ge {
|
|
|
2392
2392
|
});
|
|
2393
2393
|
// ------------------------------------------
|
|
2394
2394
|
a(this, "reorder", () => {
|
|
2395
|
-
for (const e of i(this,
|
|
2395
|
+
for (const e of i(this, k))
|
|
2396
2396
|
e.reorder();
|
|
2397
2397
|
return this;
|
|
2398
2398
|
});
|
|
@@ -2413,10 +2413,10 @@ const Ge = class Ge {
|
|
|
2413
2413
|
}
|
|
2414
2414
|
return s.map((r) => r[r.length - 1]);
|
|
2415
2415
|
});
|
|
2416
|
-
f(this,
|
|
2416
|
+
f(this, Bt, () => (h(this, Ie, i(this, k).reduce((e, t) => [.../* @__PURE__ */ new Set([...e, ...t.variables])], [])), i(this, Ie).sort(), this));
|
|
2417
2417
|
f(this, Rt, () => {
|
|
2418
2418
|
const e = [], t = [];
|
|
2419
|
-
for (const s of i(this,
|
|
2419
|
+
for (const s of i(this, k)) {
|
|
2420
2420
|
const r = [], n = s.clone().reorder();
|
|
2421
2421
|
for (const l of this.variables) {
|
|
2422
2422
|
const u = n.left.monomByLetter(l);
|
|
@@ -2426,7 +2426,7 @@ const Ge = class Ge {
|
|
|
2426
2426
|
}
|
|
2427
2427
|
return [e, t];
|
|
2428
2428
|
});
|
|
2429
|
-
return h(this,
|
|
2429
|
+
return h(this, k, []), h(this, Ie, []), e.length > 0 && this.parse(...e), this;
|
|
2430
2430
|
}
|
|
2431
2431
|
static fromMatrix(e, t = "xyz") {
|
|
2432
2432
|
const s = e[0].length;
|
|
@@ -2443,30 +2443,30 @@ const Ge = class Ge {
|
|
|
2443
2443
|
add(e, t) {
|
|
2444
2444
|
if (e instanceof Ge) {
|
|
2445
2445
|
const s = e.equations.length;
|
|
2446
|
-
if (s !== i(this,
|
|
2446
|
+
if (s !== i(this, k).length)
|
|
2447
2447
|
throw new Error("The number of equations must be the same");
|
|
2448
2448
|
for (let r = 0; r < s; r++)
|
|
2449
|
-
i(this,
|
|
2449
|
+
i(this, k)[r].add(e.equations[r]);
|
|
2450
2450
|
} else {
|
|
2451
|
-
if (t === void 0 || t < 0 || t >= i(this,
|
|
2451
|
+
if (t === void 0 || t < 0 || t >= i(this, k).length)
|
|
2452
2452
|
throw new Error("Index out of range");
|
|
2453
2453
|
const s = new H(e);
|
|
2454
|
-
i(this,
|
|
2454
|
+
i(this, k)[t].add(s);
|
|
2455
2455
|
}
|
|
2456
2456
|
return this;
|
|
2457
2457
|
}
|
|
2458
2458
|
degree(e) {
|
|
2459
|
-
return c.max(...i(this,
|
|
2459
|
+
return c.max(...i(this, k).map((t) => t.degree(e)));
|
|
2460
2460
|
}
|
|
2461
2461
|
get display() {
|
|
2462
2462
|
return this.tex + "as display";
|
|
2463
2463
|
}
|
|
2464
2464
|
// ------------------------------------------
|
|
2465
2465
|
get equations() {
|
|
2466
|
-
return i(this,
|
|
2466
|
+
return i(this, k);
|
|
2467
2467
|
}
|
|
2468
2468
|
set equations(e) {
|
|
2469
|
-
h(this,
|
|
2469
|
+
h(this, k, e);
|
|
2470
2470
|
}
|
|
2471
2471
|
evaluate(e, t) {
|
|
2472
2472
|
throw new Error("Method not implemented.");
|
|
@@ -2478,22 +2478,22 @@ const Ge = class Ge {
|
|
|
2478
2478
|
return this.equations.every((t, s) => t.isEqual(e.equations[s]));
|
|
2479
2479
|
}
|
|
2480
2480
|
get isSolvable() {
|
|
2481
|
-
return this.variables.length === i(this,
|
|
2481
|
+
return this.variables.length === i(this, k).length;
|
|
2482
2482
|
}
|
|
2483
2483
|
get matrix() {
|
|
2484
2484
|
return i(this, Rt).call(this);
|
|
2485
2485
|
}
|
|
2486
2486
|
multiply(e, t) {
|
|
2487
2487
|
if (Array.isArray(e)) {
|
|
2488
|
-
if (e.length !== i(this,
|
|
2488
|
+
if (e.length !== i(this, k).length)
|
|
2489
2489
|
throw new Error("The number of values must be the same as the number of equations");
|
|
2490
2490
|
for (let s = 0; s < e.length; s++)
|
|
2491
|
-
i(this,
|
|
2491
|
+
i(this, k)[s].multiply(e[s]);
|
|
2492
2492
|
return this;
|
|
2493
2493
|
}
|
|
2494
|
-
if (t === void 0 || t < 0 || t >= i(this,
|
|
2494
|
+
if (t === void 0 || t < 0 || t >= i(this, k).length)
|
|
2495
2495
|
throw new Error("Index out of range");
|
|
2496
|
-
return i(this,
|
|
2496
|
+
return i(this, k)[t].multiply(e), this;
|
|
2497
2497
|
}
|
|
2498
2498
|
reduce() {
|
|
2499
2499
|
throw new Error("Method not implemented.");
|
|
@@ -2504,15 +2504,15 @@ const Ge = class Ge {
|
|
|
2504
2504
|
subtract(e, t) {
|
|
2505
2505
|
if (e instanceof Ge) {
|
|
2506
2506
|
const s = e.equations.length;
|
|
2507
|
-
if (s !== i(this,
|
|
2507
|
+
if (s !== i(this, k).length)
|
|
2508
2508
|
throw new Error("The number of equations must be the same");
|
|
2509
2509
|
for (let r = 0; r < s; r++)
|
|
2510
|
-
i(this,
|
|
2510
|
+
i(this, k)[r].subtract(e.equations[r]);
|
|
2511
2511
|
} else {
|
|
2512
|
-
if (t === void 0 || t < 0 || t >= i(this,
|
|
2512
|
+
if (t === void 0 || t < 0 || t >= i(this, k).length)
|
|
2513
2513
|
throw new Error("Index out of range");
|
|
2514
2514
|
const s = new H(e);
|
|
2515
|
-
i(this,
|
|
2515
|
+
i(this, k)[t].subtract(s);
|
|
2516
2516
|
}
|
|
2517
2517
|
return this;
|
|
2518
2518
|
}
|
|
@@ -2528,7 +2528,7 @@ const Ge = class Ge {
|
|
|
2528
2528
|
t.sort(), h(this, Ie, t);
|
|
2529
2529
|
}
|
|
2530
2530
|
};
|
|
2531
|
-
|
|
2531
|
+
k = new WeakMap(), Ie = new WeakMap(), Bt = new WeakMap(), Rt = new WeakMap();
|
|
2532
2532
|
let Qt = Ge;
|
|
2533
2533
|
function Fi(o, e) {
|
|
2534
2534
|
return o.dimension === e.dimension && o.array.every(
|
|
@@ -2559,7 +2559,7 @@ function Gi(...o) {
|
|
|
2559
2559
|
).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
2560
|
}
|
|
2561
2561
|
var V, ze, zt;
|
|
2562
|
-
const
|
|
2562
|
+
const Se = class Se {
|
|
2563
2563
|
constructor(...e) {
|
|
2564
2564
|
f(this, V, []);
|
|
2565
2565
|
f(this, ze, !1);
|
|
@@ -2686,7 +2686,7 @@ const Pe = class Pe {
|
|
|
2686
2686
|
if (e.length === 0)
|
|
2687
2687
|
throw new Error("Invalid value");
|
|
2688
2688
|
if (e.length === 1) {
|
|
2689
|
-
if (e[0] instanceof
|
|
2689
|
+
if (e[0] instanceof Se)
|
|
2690
2690
|
return e[0].clone();
|
|
2691
2691
|
if (typeof e[0] == "string")
|
|
2692
2692
|
return i(this, zt).call(this, e[0]);
|
|
@@ -2694,7 +2694,7 @@ const Pe = class Pe {
|
|
|
2694
2694
|
}
|
|
2695
2695
|
if (e.length === 2) {
|
|
2696
2696
|
const [t, s] = e;
|
|
2697
|
-
if (t instanceof
|
|
2697
|
+
if (t instanceof Se && s instanceof Se) {
|
|
2698
2698
|
if (t.dimension !== s.dimension)
|
|
2699
2699
|
throw new Error("Vectors must have the same dimension");
|
|
2700
2700
|
return h(this, V, s.array.map((r, n) => r.clone().subtract(t.array[n]))), this;
|
|
@@ -2703,7 +2703,7 @@ const Pe = class Pe {
|
|
|
2703
2703
|
return h(this, V, e.map((t) => new c(t))), this;
|
|
2704
2704
|
}
|
|
2705
2705
|
clone() {
|
|
2706
|
-
const e = new
|
|
2706
|
+
const e = new Se();
|
|
2707
2707
|
return e.array = this.copy(), e.asPoint = this.asPoint, e;
|
|
2708
2708
|
}
|
|
2709
2709
|
copy() {
|
|
@@ -2722,7 +2722,7 @@ const Pe = class Pe {
|
|
|
2722
2722
|
cross(e) {
|
|
2723
2723
|
if (this.dimension !== 3 || e.dimension !== 3)
|
|
2724
2724
|
throw new Error("Cross product can only be determined in 3D");
|
|
2725
|
-
return new
|
|
2725
|
+
return new Se(
|
|
2726
2726
|
this.y.clone().multiply(e.z).subtract(this.z.clone().multiply(e.y)),
|
|
2727
2727
|
this.z.clone().multiply(e.x).subtract(this.x.clone().multiply(e.z)),
|
|
2728
2728
|
this.x.clone().multiply(e.y).subtract(this.y.clone().multiply(e.x))
|
|
@@ -2735,7 +2735,7 @@ const Pe = class Pe {
|
|
|
2735
2735
|
return this.array.every((e, t) => t === 0 ? e.isOne() : e.isZero());
|
|
2736
2736
|
}
|
|
2737
2737
|
distanceTo(e) {
|
|
2738
|
-
const t = new
|
|
2738
|
+
const t = new Se(this, e);
|
|
2739
2739
|
return {
|
|
2740
2740
|
value: t.norm,
|
|
2741
2741
|
fraction: t.normSquare,
|
|
@@ -2744,8 +2744,8 @@ const Pe = class Pe {
|
|
|
2744
2744
|
}
|
|
2745
2745
|
};
|
|
2746
2746
|
V = new WeakMap(), ze = new WeakMap(), zt = new WeakMap();
|
|
2747
|
-
let x =
|
|
2748
|
-
function
|
|
2747
|
+
let x = Se;
|
|
2748
|
+
function gi(o = 0.5) {
|
|
2749
2749
|
return Math.random() < o;
|
|
2750
2750
|
}
|
|
2751
2751
|
function de(o, e, t) {
|
|
@@ -2763,19 +2763,19 @@ function de(o, e, t) {
|
|
|
2763
2763
|
return s;
|
|
2764
2764
|
}
|
|
2765
2765
|
function X(o, e) {
|
|
2766
|
-
return e === !1 ?
|
|
2766
|
+
return e === !1 ? gi() ? de(1, o) : -de(1, o) : de(-o, o);
|
|
2767
2767
|
}
|
|
2768
2768
|
function Wi(o) {
|
|
2769
2769
|
let e = G.primes();
|
|
2770
2770
|
return o !== void 0 && (e = e.filter((t) => t < o)), ti(e);
|
|
2771
2771
|
}
|
|
2772
2772
|
function Hi(o, e) {
|
|
2773
|
-
return e === void 0 && (e = 1), o.length <= 0 ? Object.values(o) :
|
|
2773
|
+
return e === void 0 && (e = 1), o.length <= 0 ? Object.values(o) : yi(o).slice(0, e);
|
|
2774
2774
|
}
|
|
2775
2775
|
function ti(o) {
|
|
2776
2776
|
return o.length === 0 ? null : o[de(0, o.length - 1)];
|
|
2777
2777
|
}
|
|
2778
|
-
function
|
|
2778
|
+
function yi(o) {
|
|
2779
2779
|
const e = Object.values(o);
|
|
2780
2780
|
for (let t = e.length - 1; t > 0; t--) {
|
|
2781
2781
|
const s = Math.floor(Math.random() * (t + 1)), r = e[t];
|
|
@@ -2783,7 +2783,7 @@ function gi(o) {
|
|
|
2783
2783
|
}
|
|
2784
2784
|
return e;
|
|
2785
2785
|
}
|
|
2786
|
-
class
|
|
2786
|
+
class D extends x {
|
|
2787
2787
|
constructor(...e) {
|
|
2788
2788
|
super(), e.length > 0 && this.parse(...e);
|
|
2789
2789
|
}
|
|
@@ -2809,11 +2809,11 @@ class R extends x {
|
|
|
2809
2809
|
return this;
|
|
2810
2810
|
}
|
|
2811
2811
|
clone() {
|
|
2812
|
-
const e = new
|
|
2812
|
+
const e = new D();
|
|
2813
2813
|
return e.array = this.copy(), e.asPoint = !0, e;
|
|
2814
2814
|
}
|
|
2815
2815
|
}
|
|
2816
|
-
var wi = /* @__PURE__ */ ((o) => (o.None = "none", o.Parallel = "parallel", o.Perpendicular = "perpendicular", o.Tangent = "tangent", o))(wi || {}), Ce,
|
|
2816
|
+
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
2817
|
const Le = class Le {
|
|
2818
2818
|
/**
|
|
2819
2819
|
* Value can be a mix of:
|
|
@@ -2823,8 +2823,8 @@ const Le = class Le {
|
|
|
2823
2823
|
constructor(...e) {
|
|
2824
2824
|
f(this, Ce);
|
|
2825
2825
|
// ax + by + c = 0
|
|
2826
|
-
f(this,
|
|
2827
|
-
f(this,
|
|
2826
|
+
f(this, B);
|
|
2827
|
+
f(this, R);
|
|
2828
2828
|
f(this, U);
|
|
2829
2829
|
f(this, ne);
|
|
2830
2830
|
f(this, Y);
|
|
@@ -2853,7 +2853,7 @@ const Le = class Le {
|
|
|
2853
2853
|
if (e[0] instanceof Le)
|
|
2854
2854
|
return e[0].clone();
|
|
2855
2855
|
if (e[0] instanceof H)
|
|
2856
|
-
return this.
|
|
2856
|
+
return this.fromEquation(e[0]);
|
|
2857
2857
|
if (typeof e[0] == "string")
|
|
2858
2858
|
try {
|
|
2859
2859
|
const t = new H(e[0]);
|
|
@@ -2862,30 +2862,31 @@ const Le = class Le {
|
|
|
2862
2862
|
return this;
|
|
2863
2863
|
}
|
|
2864
2864
|
}
|
|
2865
|
-
if (e.length === 2) {
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2865
|
+
if (e.length === 2 && e.every((t) => t instanceof x)) {
|
|
2866
|
+
const t = e;
|
|
2867
|
+
if (t[0].asPoint && t[1].asPoint)
|
|
2868
|
+
return this.fromPointAndDirection(t[0], new x(t[0], t[1]));
|
|
2869
|
+
if (t[0].asPoint && !t[1].asPoint)
|
|
2870
|
+
return this.fromPointAndDirection(t[0], t[1]);
|
|
2870
2871
|
}
|
|
2871
2872
|
if (e.length === 3) {
|
|
2872
2873
|
if (e[0] instanceof x && e[1] instanceof x) {
|
|
2873
2874
|
if (e[2] === "perpendicular")
|
|
2874
|
-
return this.
|
|
2875
|
+
return this.fromPointAndNormal(e[0], e[1]);
|
|
2875
2876
|
if (e[2] === "parallel")
|
|
2876
|
-
return this.
|
|
2877
|
+
return this.fromPointAndDirection(e[0], e[1]);
|
|
2877
2878
|
}
|
|
2878
|
-
return e[0] instanceof x && e[1] instanceof Le ? e[2] === "parallel" || e[2] === null ? this.
|
|
2879
|
+
return e[0] instanceof x && e[1] instanceof Le ? e[2] === "parallel" || e[2] === null ? this.fromPointAndLine(
|
|
2879
2880
|
e[0],
|
|
2880
2881
|
e[1],
|
|
2881
2882
|
"parallel"
|
|
2882
2883
|
/* Parallel */
|
|
2883
|
-
) : this.
|
|
2884
|
+
) : this.fromPointAndLine(
|
|
2884
2885
|
e[0],
|
|
2885
2886
|
e[1],
|
|
2886
2887
|
"perpendicular"
|
|
2887
2888
|
/* Perpendicular */
|
|
2888
|
-
) : this.
|
|
2889
|
+
) : this.fromCoefficient(
|
|
2889
2890
|
e[0],
|
|
2890
2891
|
e[1],
|
|
2891
2892
|
e[2]
|
|
@@ -2893,43 +2894,43 @@ const Le = class Le {
|
|
|
2893
2894
|
}
|
|
2894
2895
|
return console.log("Something wrong happened while creating the line"), this;
|
|
2895
2896
|
});
|
|
2896
|
-
a(this, "
|
|
2897
|
+
a(this, "fromEquation", (e) => {
|
|
2897
2898
|
e.reorder(!0);
|
|
2898
2899
|
const t = new Set(e.letters());
|
|
2899
2900
|
if (!(t.has("x") || t.has("y")))
|
|
2900
2901
|
return this;
|
|
2901
2902
|
for (const s of ["x", "y"])
|
|
2902
2903
|
t.has(s) && t.delete(s);
|
|
2903
|
-
return t.size > 0 ? this : this.
|
|
2904
|
+
return t.size > 0 ? this : this.fromCoefficient(e.left.monomByLetter("x").coefficient, e.left.monomByLetter("y").coefficient, e.left.monomByDegree(0).coefficient);
|
|
2904
2905
|
});
|
|
2905
|
-
a(this, "
|
|
2906
|
-
a(this, "
|
|
2906
|
+
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));
|
|
2907
|
+
a(this, "fromPointAndDirection", (e, t) => (this.fromCoefficient(
|
|
2907
2908
|
t.y,
|
|
2908
2909
|
t.x.clone().opposite(),
|
|
2909
2910
|
e.x.clone().multiply(t.y).subtract(e.y.clone().multiply(t.x)).opposite()
|
|
2910
2911
|
), h(this, ne, e.clone()), h(this, Y, t.clone()), h(this, $e, i(this, Y).clone().normal()), this));
|
|
2911
|
-
a(this, "
|
|
2912
|
+
a(this, "fromPointAndNormal", (e, t) => this.fromCoefficient(
|
|
2912
2913
|
t.x,
|
|
2913
2914
|
t.y,
|
|
2914
2915
|
e.x.clone().multiply(t.x).add(e.y.clone().multiply(t.y)).opposite()
|
|
2915
2916
|
));
|
|
2916
|
-
a(this, "
|
|
2917
|
-
a(this, "clone", () => (h(this,
|
|
2917
|
+
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));
|
|
2918
|
+
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
2919
|
// ------------------------------------------
|
|
2919
2920
|
// Mathematical operations
|
|
2920
2921
|
// ------------------------------------------
|
|
2921
|
-
a(this, "isOnLine", (e) => i(this,
|
|
2922
|
-
i(this,
|
|
2922
|
+
a(this, "isOnLine", (e) => i(this, B).clone().multiply(e.x).add(
|
|
2923
|
+
i(this, R).clone().multiply(e.y)
|
|
2923
2924
|
).add(i(this, U)).isZero());
|
|
2924
2925
|
a(this, "isParallelTo", (e) => this.slope.isEqual(e.slope) && this.height.isNotEqual(e.height));
|
|
2925
2926
|
a(this, "isSameAs", (e) => this.slope.isEqual(e.slope) && this.height.isEqual(e.height));
|
|
2926
2927
|
a(this, "isPerpendicularTo", (e) => this.d.isNormalTo(e.d));
|
|
2927
2928
|
a(this, "isVertical", () => this.slope.isInfinity());
|
|
2928
2929
|
a(this, "simplify", () => {
|
|
2929
|
-
const e = G.lcm(i(this,
|
|
2930
|
-
return this.
|
|
2931
|
-
i(this,
|
|
2932
|
-
i(this,
|
|
2930
|
+
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);
|
|
2931
|
+
return this.fromCoefficient(
|
|
2932
|
+
i(this, B).clone().multiply(e).divide(t),
|
|
2933
|
+
i(this, R).clone().multiply(e).divide(t),
|
|
2933
2934
|
i(this, U).clone().multiply(e).divide(t)
|
|
2934
2935
|
), this;
|
|
2935
2936
|
});
|
|
@@ -2937,7 +2938,7 @@ const Le = class Le {
|
|
|
2937
2938
|
a(this, "intersection", (e) => {
|
|
2938
2939
|
const t = new x();
|
|
2939
2940
|
let s = !1, r = !1;
|
|
2940
|
-
return i(this,
|
|
2941
|
+
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
2942
|
point: t,
|
|
2942
2943
|
hasIntersection: !(s || r),
|
|
2943
2944
|
isParallel: s,
|
|
@@ -2952,21 +2953,21 @@ const Le = class Le {
|
|
|
2952
2953
|
const t = this.getEquation().isolate("x"), s = new c(e);
|
|
2953
2954
|
return t instanceof H ? t.right.evaluate({ y: s }) : new c().invalid();
|
|
2954
2955
|
});
|
|
2955
|
-
return h(this,
|
|
2956
|
+
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
2957
|
}
|
|
2957
2958
|
get a() {
|
|
2958
|
-
return i(this,
|
|
2959
|
+
return i(this, B);
|
|
2959
2960
|
}
|
|
2960
2961
|
// ------------------------------------------
|
|
2961
2962
|
// Getter and setter
|
|
2962
2963
|
set a(e) {
|
|
2963
|
-
h(this,
|
|
2964
|
+
h(this, B, e);
|
|
2964
2965
|
}
|
|
2965
2966
|
get b() {
|
|
2966
|
-
return i(this,
|
|
2967
|
+
return i(this, R);
|
|
2967
2968
|
}
|
|
2968
2969
|
set b(e) {
|
|
2969
|
-
h(this,
|
|
2970
|
+
h(this, R, e);
|
|
2970
2971
|
}
|
|
2971
2972
|
get c() {
|
|
2972
2973
|
return i(this, U);
|
|
@@ -2991,7 +2992,7 @@ const Le = class Le {
|
|
|
2991
2992
|
}
|
|
2992
2993
|
// ------------------------------------------
|
|
2993
2994
|
getEquation() {
|
|
2994
|
-
const e = new H(new T().parse("xy", i(this,
|
|
2995
|
+
const e = new H(new T().parse("xy", i(this, B), i(this, R), i(this, U)), new T("0"));
|
|
2995
2996
|
return i(this, Ce) ? e.simplify() : e;
|
|
2996
2997
|
}
|
|
2997
2998
|
// get system(): { x: Equation, y: Equation } {
|
|
@@ -3039,7 +3040,7 @@ const Le = class Le {
|
|
|
3039
3040
|
}
|
|
3040
3041
|
default: {
|
|
3041
3042
|
const t = this.getEquation();
|
|
3042
|
-
return i(this,
|
|
3043
|
+
return i(this, B).isNegative() && t.multiply(-1), t.tex;
|
|
3043
3044
|
}
|
|
3044
3045
|
}
|
|
3045
3046
|
}
|
|
@@ -3062,24 +3063,27 @@ const Le = class Le {
|
|
|
3062
3063
|
}
|
|
3063
3064
|
default: {
|
|
3064
3065
|
const t = this.getEquation();
|
|
3065
|
-
return i(this,
|
|
3066
|
+
return i(this, B).isNegative() && t.multiply(-1), t.display;
|
|
3066
3067
|
}
|
|
3067
3068
|
}
|
|
3068
3069
|
}
|
|
3069
3070
|
get normal() {
|
|
3070
|
-
return new x(i(this,
|
|
3071
|
+
return new x(i(this, B), i(this, R));
|
|
3071
3072
|
}
|
|
3072
3073
|
get director() {
|
|
3073
3074
|
return i(this, Y).clone();
|
|
3074
3075
|
}
|
|
3075
3076
|
get slope() {
|
|
3076
|
-
return i(this,
|
|
3077
|
+
return i(this, B).clone().opposite().divide(i(this, R));
|
|
3077
3078
|
}
|
|
3078
3079
|
get height() {
|
|
3079
|
-
return i(this, U).clone().opposite().divide(i(this,
|
|
3080
|
+
return i(this, U).clone().opposite().divide(i(this, R));
|
|
3081
|
+
}
|
|
3082
|
+
fromPoints(e, t) {
|
|
3083
|
+
return this.fromPointAndDirection(e, new x(e, t));
|
|
3080
3084
|
}
|
|
3081
3085
|
distanceTo(e) {
|
|
3082
|
-
const t = e.x.clone().multiply(i(this,
|
|
3086
|
+
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
3087
|
if (s.isZero())
|
|
3084
3088
|
return {
|
|
3085
3089
|
value: NaN,
|
|
@@ -3109,10 +3113,10 @@ const Le = class Le {
|
|
|
3109
3113
|
canonicalAsFloatCoefficient(e) {
|
|
3110
3114
|
e === void 0 && (e = 2);
|
|
3111
3115
|
let t = "";
|
|
3112
|
-
return i(this,
|
|
3116
|
+
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
3117
|
}
|
|
3114
3118
|
};
|
|
3115
|
-
Ce = new WeakMap(),
|
|
3119
|
+
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
3120
|
a(Le, "PERPENDICULAR", "perpendicular"), a(Le, "PARALLEL", "parallel");
|
|
3117
3121
|
let j = Le;
|
|
3118
3122
|
var oe, F, qe, kt, Lt, Dt, he, vi, mt, bi, xi, Ei, Kt;
|
|
@@ -3150,7 +3154,7 @@ const Zt = class Zt {
|
|
|
3150
3154
|
return t.forEach((r) => {
|
|
3151
3155
|
for (const n of [[1, 1], [-1, 1], [-1, -1], [1, -1]])
|
|
3152
3156
|
s.push(
|
|
3153
|
-
new
|
|
3157
|
+
new D(
|
|
3154
3158
|
this.center.x.clone().add(n[0] * r[0]),
|
|
3155
3159
|
this.center.y.clone().add(n[1] * r[1])
|
|
3156
3160
|
)
|
|
@@ -3158,7 +3162,7 @@ const Zt = class Zt {
|
|
|
3158
3162
|
}), s;
|
|
3159
3163
|
});
|
|
3160
3164
|
f(this, kt, (e) => {
|
|
3161
|
-
const t = new
|
|
3165
|
+
const t = new D(this.center, e);
|
|
3162
3166
|
return [new j(e, t, wi.Perpendicular)];
|
|
3163
3167
|
});
|
|
3164
3168
|
f(this, Lt, (e) => {
|
|
@@ -3172,7 +3176,7 @@ const Zt = class Zt {
|
|
|
3172
3176
|
e.length > 0 && this.parse(...e);
|
|
3173
3177
|
}
|
|
3174
3178
|
get center() {
|
|
3175
|
-
return i(this, oe) ?? new
|
|
3179
|
+
return i(this, oe) ?? new D();
|
|
3176
3180
|
}
|
|
3177
3181
|
get squareRadius() {
|
|
3178
3182
|
return i(this, F) ?? new c(0);
|
|
@@ -3215,7 +3219,7 @@ const Zt = class Zt {
|
|
|
3215
3219
|
return t ? h(this, F, new c(e)) : h(this, F, new c(e).pow(2)), M(this, he, mt).call(this), this;
|
|
3216
3220
|
}
|
|
3217
3221
|
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
|
|
3222
|
+
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
3223
|
}
|
|
3220
3224
|
// private _parseThroughtThreePoints(A: Point, B: Point, C: Point): this {
|
|
3221
3225
|
// const T = new Triangle(A, B, C), mAB = T.remarquables.mediators.AB.clone(),
|
|
@@ -3241,12 +3245,12 @@ oe = new WeakMap(), F = new WeakMap(), qe = new WeakMap(), kt = new WeakMap(), L
|
|
|
3241
3245
|
if (e.moveLeft(), e.degree("x").value === 2 && e.degree("y").value === 2) {
|
|
3242
3246
|
const t = e.left.monomByDegree(2, "x"), s = e.left.monomByDegree(2, "y");
|
|
3243
3247
|
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
|
|
3248
|
+
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
3249
|
}
|
|
3246
3250
|
return this;
|
|
3247
3251
|
};
|
|
3248
|
-
let
|
|
3249
|
-
var Q, _, ee, Je, Te, ct, Vt, ut,
|
|
3252
|
+
let yt = Zt;
|
|
3253
|
+
var Q, _, ee, Je, Te, ct, Vt, ut, Pe, Ft, _e;
|
|
3250
3254
|
const jt = class jt {
|
|
3251
3255
|
constructor(...e) {
|
|
3252
3256
|
f(this, Q);
|
|
@@ -3294,7 +3298,7 @@ const jt = class jt {
|
|
|
3294
3298
|
h(this, Q, n.point.clone());
|
|
3295
3299
|
else
|
|
3296
3300
|
throw new Error("Lines do not intersect !");
|
|
3297
|
-
} else e.every((t) => t instanceof
|
|
3301
|
+
} 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
3302
|
AB: new j(i(this, Q), i(this, _)),
|
|
3299
3303
|
BC: new j(i(this, _), i(this, ee)),
|
|
3300
3304
|
AC: new j(i(this, Q), i(this, ee))
|
|
@@ -3319,9 +3323,9 @@ const jt = class jt {
|
|
|
3319
3323
|
*/
|
|
3320
3324
|
f(this, Vt, () => {
|
|
3321
3325
|
h(this, Te, {
|
|
3322
|
-
AB: new
|
|
3323
|
-
AC: new
|
|
3324
|
-
BC: new
|
|
3326
|
+
AB: new D().middleOf(i(this, Q), i(this, _)),
|
|
3327
|
+
AC: new D().middleOf(i(this, Q), i(this, ee)),
|
|
3328
|
+
BC: new D().middleOf(i(this, _), i(this, ee))
|
|
3325
3329
|
}), h(this, ct, i(this, Ft).call(this));
|
|
3326
3330
|
});
|
|
3327
3331
|
/**
|
|
@@ -3344,7 +3348,7 @@ const jt = class jt {
|
|
|
3344
3348
|
* @param ptName1
|
|
3345
3349
|
* @param ptName2
|
|
3346
3350
|
*/
|
|
3347
|
-
f(this,
|
|
3351
|
+
f(this, Pe, (e, t) => new x(
|
|
3348
3352
|
i(this, ut).call(this, e),
|
|
3349
3353
|
i(this, ut).call(this, t)
|
|
3350
3354
|
));
|
|
@@ -3388,8 +3392,8 @@ const jt = class jt {
|
|
|
3388
3392
|
let s, r;
|
|
3389
3393
|
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
3394
|
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:
|
|
3395
|
+
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());
|
|
3396
|
+
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
3397
|
});
|
|
3394
3398
|
return e.length > 0 && this.parse(...e), this;
|
|
3395
3399
|
}
|
|
@@ -3406,22 +3410,22 @@ const jt = class jt {
|
|
|
3406
3410
|
return i(this, ee);
|
|
3407
3411
|
}
|
|
3408
3412
|
get AB() {
|
|
3409
|
-
return i(this,
|
|
3413
|
+
return i(this, Pe).call(this, "A", "B");
|
|
3410
3414
|
}
|
|
3411
3415
|
get BA() {
|
|
3412
|
-
return i(this,
|
|
3416
|
+
return i(this, Pe).call(this, "B", "A");
|
|
3413
3417
|
}
|
|
3414
3418
|
get BC() {
|
|
3415
|
-
return i(this,
|
|
3419
|
+
return i(this, Pe).call(this, "B", "C");
|
|
3416
3420
|
}
|
|
3417
3421
|
get CB() {
|
|
3418
|
-
return i(this,
|
|
3422
|
+
return i(this, Pe).call(this, "C", "B");
|
|
3419
3423
|
}
|
|
3420
3424
|
get AC() {
|
|
3421
|
-
return i(this,
|
|
3425
|
+
return i(this, Pe).call(this, "A", "C");
|
|
3422
3426
|
}
|
|
3423
3427
|
get CA() {
|
|
3424
|
-
return i(this,
|
|
3428
|
+
return i(this, Pe).call(this, "C", "A");
|
|
3425
3429
|
}
|
|
3426
3430
|
get isRectangle() {
|
|
3427
3431
|
return !!(this.AB.isNormalTo(this.BC) || this.AB.isNormalTo(this.AC) || this.BC.isNormalTo(this.AC));
|
|
@@ -3439,15 +3443,15 @@ const jt = class jt {
|
|
|
3439
3443
|
return i(this, ct);
|
|
3440
3444
|
}
|
|
3441
3445
|
};
|
|
3442
|
-
Q = new WeakMap(), _ = new WeakMap(), ee = new WeakMap(), Je = new WeakMap(), Te = new WeakMap(), ct = new WeakMap(), Vt = new WeakMap(), ut = new WeakMap(),
|
|
3446
|
+
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
3447
|
let Jt = jt;
|
|
3444
|
-
var
|
|
3448
|
+
var z, W;
|
|
3445
3449
|
const nt = class nt {
|
|
3446
3450
|
constructor(e, t) {
|
|
3447
3451
|
// ax + by + c = 0
|
|
3448
|
-
f(this,
|
|
3452
|
+
f(this, z, new D());
|
|
3449
3453
|
f(this, W, new x());
|
|
3450
|
-
a(this, "clone", () => (h(this, W, i(this, W).clone()), h(this,
|
|
3454
|
+
a(this, "clone", () => (h(this, W, i(this, W).clone()), h(this, z, i(this, z).clone()), this));
|
|
3451
3455
|
// ------------------------------------------
|
|
3452
3456
|
// Mathematical operations
|
|
3453
3457
|
// ------------------------------------------
|
|
@@ -3487,23 +3491,23 @@ const nt = class nt {
|
|
|
3487
3491
|
// return new Fraction().invalid()
|
|
3488
3492
|
// }
|
|
3489
3493
|
a(this, "randomPoint", (e = 5) => {
|
|
3490
|
-
const t = i(this,
|
|
3491
|
-
return new
|
|
3494
|
+
const t = i(this, z).clone(), s = new c(X(e, !1));
|
|
3495
|
+
return new D(
|
|
3492
3496
|
t.x.clone().add(i(this, W).x.clone().multiply(s)),
|
|
3493
3497
|
t.y.clone().add(i(this, W).y.clone().multiply(s)),
|
|
3494
3498
|
t.z.clone().add(i(this, W).z.clone().multiply(s))
|
|
3495
3499
|
);
|
|
3496
3500
|
});
|
|
3497
|
-
return h(this,
|
|
3501
|
+
return h(this, z, e.clone()), h(this, W, t.asPoint ? new x(e, t) : t.clone()), this;
|
|
3498
3502
|
}
|
|
3499
3503
|
get OA() {
|
|
3500
|
-
return i(this,
|
|
3504
|
+
return i(this, z);
|
|
3501
3505
|
}
|
|
3502
3506
|
set OA(e) {
|
|
3503
|
-
h(this,
|
|
3507
|
+
h(this, z, e);
|
|
3504
3508
|
}
|
|
3505
3509
|
get point() {
|
|
3506
|
-
return i(this,
|
|
3510
|
+
return i(this, z).clone();
|
|
3507
3511
|
}
|
|
3508
3512
|
get d() {
|
|
3509
3513
|
return i(this, W);
|
|
@@ -3513,19 +3517,19 @@ const nt = class nt {
|
|
|
3513
3517
|
}
|
|
3514
3518
|
get tex() {
|
|
3515
3519
|
return {
|
|
3516
|
-
parametric: `${x.asTex("x", "y", "z")} = ${x.asTex(i(this,
|
|
3520
|
+
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
3521
|
system: `\\left\\{\\begin{aligned}
|
|
3518
|
-
x &= ${new T(i(this,
|
|
3519
|
-
y &= ${new T(i(this,
|
|
3520
|
-
z &= ${new T(i(this,
|
|
3522
|
+
x &= ${new T(i(this, z).x).add(new I(i(this, W).x).multiply(new I("k"))).reorder("k", !0).tex}\\\\
|
|
3523
|
+
y &= ${new T(i(this, z).y).add(new I(i(this, W).y).multiply(new I("k"))).reorder("k", !0).tex}\\\\
|
|
3524
|
+
z &= ${new T(i(this, z).z).add(new I(i(this, W).z).multiply(new I("k"))).reorder("k", !0).tex}
|
|
3521
3525
|
\\end{aligned}\\right.`,
|
|
3522
|
-
cartesian: `\\frac{ ${new T("x", 1, i(this,
|
|
3526
|
+
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
3527
|
};
|
|
3524
3528
|
}
|
|
3525
3529
|
get display() {
|
|
3526
|
-
const e = i(this,
|
|
3530
|
+
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
3531
|
return {
|
|
3528
|
-
parametric: `${x.asDisplay("x", "y", "z")} = ${x.asDisplay(i(this,
|
|
3532
|
+
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
3533
|
system: "",
|
|
3530
3534
|
cartesian: `(x-${e})/${n} = (y-${t})/${l} = (z-${s})/${u}`
|
|
3531
3535
|
};
|
|
@@ -3534,7 +3538,7 @@ const nt = class nt {
|
|
|
3534
3538
|
return i(this, W).clone();
|
|
3535
3539
|
}
|
|
3536
3540
|
distanceTo(e) {
|
|
3537
|
-
const t = new x(i(this,
|
|
3541
|
+
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
3542
|
return console.log("CROSS", t.cross(s).display), {
|
|
3539
3543
|
value: Math.sqrt(l.value),
|
|
3540
3544
|
fraction: l.clone().sqrt(),
|
|
@@ -3548,14 +3552,14 @@ const nt = class nt {
|
|
|
3548
3552
|
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
3553
|
}
|
|
3550
3554
|
};
|
|
3551
|
-
|
|
3555
|
+
z = new WeakMap(), W = new WeakMap(), // A line is defined as the canonical form
|
|
3552
3556
|
a(nt, "PERPENDICULAR", "perpendicular"), a(nt, "PARALLEL", "parallel");
|
|
3553
3557
|
let wt = nt;
|
|
3554
3558
|
var Ae, Fe;
|
|
3555
3559
|
const si = class si {
|
|
3556
3560
|
constructor(e) {
|
|
3557
3561
|
f(this, Ae, new x(0, 0, 1));
|
|
3558
|
-
f(this, Fe, new
|
|
3562
|
+
f(this, Fe, new D(0, 0, 0));
|
|
3559
3563
|
return e && this.parse(e), this;
|
|
3560
3564
|
}
|
|
3561
3565
|
get normal() {
|
|
@@ -3602,7 +3606,7 @@ const si = class si {
|
|
|
3602
3606
|
}
|
|
3603
3607
|
if (e.equation) {
|
|
3604
3608
|
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
|
|
3609
|
+
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
3610
|
return;
|
|
3607
3611
|
}
|
|
3608
3612
|
if (((s = e.points) == null ? void 0 : s.length) === 3 && e.points.every((n) => n instanceof x)) {
|
|
@@ -3612,7 +3616,7 @@ const si = class si {
|
|
|
3612
3616
|
}
|
|
3613
3617
|
if (((r = e.coefficients) == null ? void 0 : r.length) === 4) {
|
|
3614
3618
|
const [n, l, u, p] = e.coefficients;
|
|
3615
|
-
this.normal = new x(n, l, u), this.point = new
|
|
3619
|
+
this.normal = new x(n, l, u), this.point = new D(0, 0, -p);
|
|
3616
3620
|
return;
|
|
3617
3621
|
}
|
|
3618
3622
|
}
|
|
@@ -3636,7 +3640,7 @@ const si = class si {
|
|
|
3636
3640
|
return t.clone().add(s.clone().multiplyByScalar(r));
|
|
3637
3641
|
}
|
|
3638
3642
|
intersectWithPlane(e) {
|
|
3639
|
-
throw this.normal.cross(e.normal), new
|
|
3643
|
+
throw this.normal.cross(e.normal), new D(0, 0, 0), new Error("Intersection with plane not yet implemented !");
|
|
3640
3644
|
}
|
|
3641
3645
|
isPointOnPlane(e) {
|
|
3642
3646
|
return this.normal.dot(e).add(this.d).isZero();
|
|
@@ -3788,7 +3792,7 @@ function qi(o) {
|
|
|
3788
3792
|
},
|
|
3789
3793
|
o
|
|
3790
3794
|
), 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
|
|
3795
|
+
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
3796
|
}
|
|
3793
3797
|
function Ki(o) {
|
|
3794
3798
|
const e = Object.assign(
|
|
@@ -3802,7 +3806,7 @@ function Ki(o) {
|
|
|
3802
3806
|
o
|
|
3803
3807
|
), t = qi(e.center);
|
|
3804
3808
|
let s, r;
|
|
3805
|
-
return e.pointsOnCircle === 8 ? (s = de(1, 3), r = s ** 2 + (s + 1) ** 2) : r = de(1, 20), new
|
|
3809
|
+
return e.pointsOnCircle === 8 ? (s = de(1, 3), r = s ** 2 + (s + 1) ** 2) : r = de(1, 20), new yt(t, r, !0);
|
|
3806
3810
|
}
|
|
3807
3811
|
function Ji(o) {
|
|
3808
3812
|
const e = Object.assign(
|
|
@@ -3836,7 +3840,7 @@ function _i(o) {
|
|
|
3836
3840
|
}
|
|
3837
3841
|
},
|
|
3838
3842
|
o
|
|
3839
|
-
), t = new
|
|
3843
|
+
), 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
3844
|
return new wt(t, s);
|
|
3841
3845
|
}
|
|
3842
3846
|
const es = {
|
|
@@ -3847,20 +3851,20 @@ const es = {
|
|
|
3847
3851
|
number: (o, e, t) => de(o, e, t),
|
|
3848
3852
|
numberSym: (o, e) => X(o, e),
|
|
3849
3853
|
prime: (o) => Wi(o),
|
|
3850
|
-
bool: (o) =>
|
|
3854
|
+
bool: (o) => gi(o),
|
|
3851
3855
|
array: (o, e) => Hi(o, e),
|
|
3852
3856
|
item: (o) => ti(o),
|
|
3853
|
-
shuffle: (o) =>
|
|
3857
|
+
shuffle: (o) => yi(o),
|
|
3854
3858
|
line: (o) => Ji(o),
|
|
3855
3859
|
line3: (o) => _i(o),
|
|
3856
3860
|
point: (o) => qi(o),
|
|
3857
3861
|
circle: (o) => Ki(o)
|
|
3858
3862
|
}, ts = {
|
|
3859
3863
|
Vector: x,
|
|
3860
|
-
Point:
|
|
3864
|
+
Point: D,
|
|
3861
3865
|
Line: j,
|
|
3862
3866
|
Triangle: Jt,
|
|
3863
|
-
Circle:
|
|
3867
|
+
Circle: yt,
|
|
3864
3868
|
Line3: wt,
|
|
3865
3869
|
Plane3: _t
|
|
3866
3870
|
}, ss = {
|