pimath 0.1.5 → 0.1.6
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 +269 -265
- package/package.json +1 -1
package/dist/pimath.js
CHANGED
|
@@ -4,7 +4,7 @@ var si = (o) => {
|
|
|
4
4
|
};
|
|
5
5
|
var Ti = (o, e, t) => e in o ? qi(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
6
6
|
var a = (o, e, t) => Ti(o, typeof e != "symbol" ? e + "" : e, t), Ut = (o, e, t) => e.has(o) || si("Cannot " + t);
|
|
7
|
-
var i = (o, e, t) => (Ut(o, e, "read from private field"), t ? t.call(o) : e.get(o)),
|
|
7
|
+
var i = (o, e, t) => (Ut(o, e, "read from private field"), t ? t.call(o) : e.get(o)), d = (o, e, t) => e.has(o) ? si("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(o) : e.set(o, t), h = (o, e, t, s) => (Ut(o, e, "write to private field"), s ? s.call(o, t) : e.set(o, t), t), M = (o, e, t) => (Ut(o, e, "access private method"), t);
|
|
8
8
|
function Ai(o) {
|
|
9
9
|
const e = ni(o), t = [];
|
|
10
10
|
let s, r;
|
|
@@ -82,10 +82,10 @@ var w, b, ot, Be;
|
|
|
82
82
|
const $ = class $ {
|
|
83
83
|
constructor(e, t) {
|
|
84
84
|
// #region Class fields (2)
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
85
|
+
d(this, w, 1);
|
|
86
|
+
d(this, b, 1);
|
|
87
|
+
d(this, ot, !1);
|
|
88
|
+
d(this, Be, "frac");
|
|
89
89
|
// ------------------------------------------
|
|
90
90
|
/**
|
|
91
91
|
* Parse the value to get the numerator and denominator
|
|
@@ -331,10 +331,10 @@ let c = $;
|
|
|
331
331
|
var Z, J, se, We;
|
|
332
332
|
class ft {
|
|
333
333
|
constructor(...e) {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
334
|
+
d(this, Z);
|
|
335
|
+
d(this, J);
|
|
336
|
+
d(this, se);
|
|
337
|
+
d(this, We);
|
|
338
338
|
// ------------------------------------------
|
|
339
339
|
// Creation / parsing functions
|
|
340
340
|
// ------------------------------------------
|
|
@@ -401,94 +401,94 @@ const ai = {
|
|
|
401
401
|
pi: Math.PI,
|
|
402
402
|
e: Math.exp(1)
|
|
403
403
|
};
|
|
404
|
-
var
|
|
404
|
+
var m = /* @__PURE__ */ ((o) => (o.VARIABLE = "variable", o.COEFFICIENT = "coefficient", o.OPERATION = "operation", o.CONSTANT = "constant", o.FUNCTION = "function", o.FUNCTION_ARGUMENT = "function-argument", o.MONOM = "monom", o.LEFT_PARENTHESIS = "(", o.RIGHT_PARENTHESIS = ")", o))(m || {}), it = /* @__PURE__ */ ((o) => (o.EXPRESSION = "expression", o.POLYNOM = "polynom", o.SET = "set", o.NUMERIC = "numeric", o))(it || {});
|
|
405
405
|
function Ri(o, e) {
|
|
406
406
|
if (o.length <= 1)
|
|
407
407
|
return o;
|
|
408
|
-
const t = Object.keys(e).filter((E) => e[E].type ===
|
|
408
|
+
const t = Object.keys(e).filter((E) => e[E].type === m.FUNCTION).map((E) => E);
|
|
409
409
|
t.sort((E, L) => L.length - E.length);
|
|
410
410
|
const s = new RegExp(`^(${t.join("|")})\\(`), r = Object.keys(ai);
|
|
411
411
|
r.sort((E, L) => L.length - E.length);
|
|
412
412
|
const n = new RegExp(`^(${r.join("|")})`), l = /^(\d+(\.\d+)?)/;
|
|
413
|
-
let u = "",
|
|
413
|
+
let u = "", f, p, g;
|
|
414
414
|
for (; o.length > 0; ) {
|
|
415
|
-
if (
|
|
415
|
+
if (f = p, g = void 0, t.length > 0 && s.exec(o)) {
|
|
416
416
|
const E = t.find((L) => o.startsWith(L));
|
|
417
|
-
E && (g = E + "(", o = o.slice(E.length + 1),
|
|
417
|
+
E && (g = E + "(", o = o.slice(E.length + 1), p = m.FUNCTION);
|
|
418
418
|
} else if (r.length > 0 && n.exec(o)) {
|
|
419
419
|
const E = r.find((L) => o.startsWith(L));
|
|
420
|
-
E && (g = E, o = o.slice(E.length),
|
|
420
|
+
E && (g = E, o = o.slice(E.length), p = m.CONSTANT);
|
|
421
421
|
} else if (l.exec(o)) {
|
|
422
422
|
const E = l.exec(o);
|
|
423
|
-
E && (g = E[0], o = o.slice(E[0].length),
|
|
423
|
+
E && (g = E[0], o = o.slice(E[0].length), p = m.COEFFICIENT);
|
|
424
424
|
} else
|
|
425
425
|
switch (g = o[0], o = o.slice(1), g) {
|
|
426
426
|
case "(":
|
|
427
|
-
|
|
427
|
+
p = m.LEFT_PARENTHESIS;
|
|
428
428
|
break;
|
|
429
429
|
case ")":
|
|
430
|
-
|
|
430
|
+
p = m.RIGHT_PARENTHESIS;
|
|
431
431
|
break;
|
|
432
432
|
case ",":
|
|
433
|
-
|
|
433
|
+
p = m.FUNCTION_ARGUMENT;
|
|
434
434
|
break;
|
|
435
435
|
case "+":
|
|
436
436
|
case "-":
|
|
437
437
|
case "*":
|
|
438
438
|
case "/":
|
|
439
439
|
case "^":
|
|
440
|
-
|
|
440
|
+
p = m.OPERATION;
|
|
441
441
|
break;
|
|
442
442
|
default:
|
|
443
|
-
|
|
443
|
+
p = m.VARIABLE;
|
|
444
444
|
}
|
|
445
|
-
if (g === void 0 ||
|
|
445
|
+
if (g === void 0 || p === void 0)
|
|
446
446
|
throw new Error("The token is undefined");
|
|
447
|
-
u += zi(
|
|
447
|
+
u += zi(f, p), u += g;
|
|
448
448
|
}
|
|
449
449
|
return u;
|
|
450
450
|
}
|
|
451
451
|
function zi(o, e) {
|
|
452
|
-
return o === void 0 || o ===
|
|
452
|
+
return o === void 0 || o === m.OPERATION || e === m.OPERATION || o === m.LEFT_PARENTHESIS || o === m.FUNCTION || o === m.FUNCTION_ARGUMENT || e === m.RIGHT_PARENTHESIS || e === m.FUNCTION_ARGUMENT ? "" : "*";
|
|
453
453
|
}
|
|
454
454
|
const ki = {
|
|
455
|
-
"^": { precedence: 4, associative: "right", type:
|
|
456
|
-
"*": { precedence: 3, associative: "left", type:
|
|
457
|
-
"/": { precedence: 3, associative: "left", type:
|
|
458
|
-
"+": { precedence: 2, associative: "left", type:
|
|
459
|
-
"-": { precedence: 2, associative: "left", type:
|
|
455
|
+
"^": { precedence: 4, associative: "right", type: m.OPERATION },
|
|
456
|
+
"*": { precedence: 3, associative: "left", type: m.OPERATION },
|
|
457
|
+
"/": { precedence: 3, associative: "left", type: m.OPERATION },
|
|
458
|
+
"+": { precedence: 2, associative: "left", type: m.OPERATION },
|
|
459
|
+
"-": { precedence: 2, associative: "left", type: m.OPERATION }
|
|
460
460
|
}, Li = {
|
|
461
|
-
"^": { precedence: 4, associative: "right", type:
|
|
462
|
-
"*": { precedence: 3, associative: "left", type:
|
|
463
|
-
"/": { precedence: 3, associative: "left", type:
|
|
464
|
-
"+": { precedence: 2, associative: "left", type:
|
|
465
|
-
"-": { precedence: 2, associative: "left", type:
|
|
466
|
-
"%": { precedence: 3, associative: "right", type:
|
|
467
|
-
sin: { precedence: 4, associative: "right", type:
|
|
468
|
-
cos: { precedence: 4, associative: "right", type:
|
|
469
|
-
tan: { precedence: 4, associative: "right", type:
|
|
470
|
-
sqrt: { precedence: 4, associative: "right", type:
|
|
471
|
-
nthrt: { precedence: 4, associative: "right", type:
|
|
472
|
-
",": { precedence: 2, associative: "left", type:
|
|
461
|
+
"^": { precedence: 4, associative: "right", type: m.OPERATION },
|
|
462
|
+
"*": { precedence: 3, associative: "left", type: m.OPERATION },
|
|
463
|
+
"/": { precedence: 3, associative: "left", type: m.OPERATION },
|
|
464
|
+
"+": { precedence: 2, associative: "left", type: m.OPERATION },
|
|
465
|
+
"-": { precedence: 2, associative: "left", type: m.OPERATION },
|
|
466
|
+
"%": { precedence: 3, associative: "right", type: m.OPERATION },
|
|
467
|
+
sin: { precedence: 4, associative: "right", type: m.FUNCTION },
|
|
468
|
+
cos: { precedence: 4, associative: "right", type: m.FUNCTION },
|
|
469
|
+
tan: { precedence: 4, associative: "right", type: m.FUNCTION },
|
|
470
|
+
sqrt: { precedence: 4, associative: "right", type: m.FUNCTION },
|
|
471
|
+
nthrt: { precedence: 4, associative: "right", type: m.FUNCTION },
|
|
472
|
+
",": { precedence: 2, associative: "left", type: m.FUNCTION_ARGUMENT }
|
|
473
473
|
}, Di = {
|
|
474
|
-
"^": { precedence: 4, associative: "right", type:
|
|
475
|
-
"*": { precedence: 3, associative: "left", type:
|
|
476
|
-
"/": { precedence: 3, associative: "left", type:
|
|
477
|
-
"+": { precedence: 2, associative: "left", type:
|
|
478
|
-
"-": { precedence: 2, associative: "left", type:
|
|
479
|
-
"%": { precedence: 3, associative: "right", type:
|
|
480
|
-
sin: { precedence: 4, associative: "right", type:
|
|
481
|
-
cos: { precedence: 4, associative: "right", type:
|
|
482
|
-
tan: { precedence: 4, associative: "right", type:
|
|
483
|
-
sqrt: { precedence: 4, associative: "right", type:
|
|
484
|
-
nthrt: { precedence: 4, associative: "right", type:
|
|
485
|
-
ln: { precedence: 4, associative: "right", type:
|
|
486
|
-
log: { precedence: 4, associative: "right", type:
|
|
474
|
+
"^": { precedence: 4, associative: "right", type: m.OPERATION },
|
|
475
|
+
"*": { precedence: 3, associative: "left", type: m.OPERATION },
|
|
476
|
+
"/": { precedence: 3, associative: "left", type: m.OPERATION },
|
|
477
|
+
"+": { precedence: 2, associative: "left", type: m.OPERATION },
|
|
478
|
+
"-": { precedence: 2, associative: "left", type: m.OPERATION },
|
|
479
|
+
"%": { precedence: 3, associative: "right", type: m.OPERATION },
|
|
480
|
+
sin: { precedence: 4, associative: "right", type: m.FUNCTION },
|
|
481
|
+
cos: { precedence: 4, associative: "right", type: m.FUNCTION },
|
|
482
|
+
tan: { precedence: 4, associative: "right", type: m.FUNCTION },
|
|
483
|
+
sqrt: { precedence: 4, associative: "right", type: m.FUNCTION },
|
|
484
|
+
nthrt: { precedence: 4, associative: "right", type: m.FUNCTION },
|
|
485
|
+
ln: { precedence: 4, associative: "right", type: m.FUNCTION },
|
|
486
|
+
log: { precedence: 4, associative: "right", type: m.FUNCTION }
|
|
487
487
|
}, Zi = {
|
|
488
|
-
"&": { precedence: 3, associative: "left", type:
|
|
489
|
-
"|": { precedence: 3, associative: "left", type:
|
|
490
|
-
"!": { precedence: 4, associative: "right", type:
|
|
491
|
-
"-": { precedence: 2, associative: "left", type:
|
|
488
|
+
"&": { precedence: 3, associative: "left", type: m.OPERATION },
|
|
489
|
+
"|": { precedence: 3, associative: "left", type: m.OPERATION },
|
|
490
|
+
"!": { precedence: 4, associative: "right", type: m.OPERATION },
|
|
491
|
+
"-": { precedence: 2, associative: "left", type: m.OPERATION }
|
|
492
492
|
};
|
|
493
493
|
var je, st, ie, dt, ke;
|
|
494
494
|
class li {
|
|
@@ -513,11 +513,11 @@ class li {
|
|
|
513
513
|
NextToken(e, t) {
|
|
514
514
|
let s, r;
|
|
515
515
|
if (s = "", r = void 0, e[t] === "(")
|
|
516
|
-
s = "(", r =
|
|
516
|
+
s = "(", r = m.LEFT_PARENTHESIS;
|
|
517
517
|
else if (e[t] === ")")
|
|
518
|
-
s = ")", r =
|
|
518
|
+
s = ")", r = m.RIGHT_PARENTHESIS;
|
|
519
519
|
else if (e[t] === ",")
|
|
520
|
-
s = ",", r =
|
|
520
|
+
s = ",", r = m.FUNCTION_ARGUMENT;
|
|
521
521
|
else {
|
|
522
522
|
for (const n of K(this, dt))
|
|
523
523
|
if (e.substring(t, t + n.length) === n) {
|
|
@@ -526,18 +526,18 @@ class li {
|
|
|
526
526
|
}
|
|
527
527
|
for (const n in ai)
|
|
528
528
|
if (e.substring(t, t + n.length) === n) {
|
|
529
|
-
s += n, r =
|
|
529
|
+
s += n, r = m.CONSTANT;
|
|
530
530
|
break;
|
|
531
531
|
}
|
|
532
532
|
if (s === "")
|
|
533
533
|
if (/[0-9.]/.exec(e[t])) {
|
|
534
534
|
const n = /^([0-9.]+)/.exec(e.substring(t));
|
|
535
|
-
s = n ? n[0] : "", r =
|
|
535
|
+
s = n ? n[0] : "", r = m.COEFFICIENT;
|
|
536
536
|
} else if (/[a-zA-Z]/.exec(e[t])) {
|
|
537
537
|
const n = /^([a-zA-Z])/.exec(e.substring(t));
|
|
538
|
-
s = n ? n[0] : "", r =
|
|
538
|
+
s = n ? n[0] : "", r = m.VARIABLE;
|
|
539
539
|
} else
|
|
540
|
-
console.log("Unidentified token", e[t], e, t), s = e[t], r =
|
|
540
|
+
console.log("Unidentified token", e[t], e, t), s = e[t], r = m.MONOM;
|
|
541
541
|
}
|
|
542
542
|
if (r === void 0)
|
|
543
543
|
throw new Error(`Token type is undefined for token ${s}`);
|
|
@@ -553,42 +553,42 @@ class li {
|
|
|
553
553
|
const s = [], r = [];
|
|
554
554
|
let n = "", l = 0, u;
|
|
555
555
|
(t ?? K(this, ke)) && (e = Ri(e, K(this, ie)));
|
|
556
|
-
const
|
|
557
|
-
let
|
|
556
|
+
const f = 50;
|
|
557
|
+
let p = 50, g;
|
|
558
558
|
for (; l < e.length; ) {
|
|
559
|
-
if (
|
|
559
|
+
if (p--, p === 0) {
|
|
560
560
|
console.log("SECURITY LEVEL 1 EXIT");
|
|
561
561
|
break;
|
|
562
562
|
}
|
|
563
563
|
switch ([n, l, u] = this.NextToken(e, l), u) {
|
|
564
|
-
case
|
|
565
|
-
case
|
|
566
|
-
case
|
|
567
|
-
case
|
|
564
|
+
case m.MONOM:
|
|
565
|
+
case m.COEFFICIENT:
|
|
566
|
+
case m.VARIABLE:
|
|
567
|
+
case m.CONSTANT:
|
|
568
568
|
s.push({
|
|
569
569
|
token: n,
|
|
570
570
|
tokenType: u
|
|
571
571
|
});
|
|
572
572
|
break;
|
|
573
|
-
case
|
|
573
|
+
case m.OPERATION:
|
|
574
574
|
if (r.length > 0) {
|
|
575
575
|
let E = r[r.length - 1];
|
|
576
|
-
for (g = +
|
|
576
|
+
for (g = +f; 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
579
|
if (g--, g === 0) {
|
|
580
580
|
console.log("SECURITY LEVEL 2 OPERATION EXIT");
|
|
581
581
|
break;
|
|
582
582
|
}
|
|
583
|
-
if (s.push(r.pop() ?? { token: "", tokenType:
|
|
583
|
+
if (s.push(r.pop() ?? { token: "", tokenType: m.OPERATION }), r.length === 0)
|
|
584
584
|
break;
|
|
585
585
|
E = r[r.length - 1];
|
|
586
586
|
}
|
|
587
587
|
}
|
|
588
588
|
r.push({ token: n, tokenType: u });
|
|
589
589
|
break;
|
|
590
|
-
case
|
|
591
|
-
for (g = +
|
|
590
|
+
case m.FUNCTION_ARGUMENT:
|
|
591
|
+
for (g = +f; r[r.length - 1].token !== "(" && r.length > 0; ) {
|
|
592
592
|
if (g--, g === 0) {
|
|
593
593
|
console.log("SECURITY LEVEL 2 FUNCTION ARGUMENT EXIT");
|
|
594
594
|
break;
|
|
@@ -596,11 +596,11 @@ class li {
|
|
|
596
596
|
s.push(r.pop() ?? { token: n, tokenType: u });
|
|
597
597
|
}
|
|
598
598
|
break;
|
|
599
|
-
case
|
|
600
|
-
r.push({ token: n, tokenType: u }), e[l] === "-" && s.push({ token: "0", tokenType:
|
|
599
|
+
case m.LEFT_PARENTHESIS:
|
|
600
|
+
r.push({ token: n, tokenType: u }), e[l] === "-" && s.push({ token: "0", tokenType: m.COEFFICIENT });
|
|
601
601
|
break;
|
|
602
|
-
case
|
|
603
|
-
for (g = +
|
|
602
|
+
case m.RIGHT_PARENTHESIS:
|
|
603
|
+
for (g = +f; r[r.length - 1].token !== "(" && r.length > 1; ) {
|
|
604
604
|
if (g--, g === 0) {
|
|
605
605
|
console.log("SECURITY LEVEL 2 CLOSING PARENTHESIS EXIT");
|
|
606
606
|
break;
|
|
@@ -609,7 +609,7 @@ class li {
|
|
|
609
609
|
}
|
|
610
610
|
r.pop();
|
|
611
611
|
break;
|
|
612
|
-
case
|
|
612
|
+
case m.FUNCTION:
|
|
613
613
|
r.push({ token: n, tokenType: u });
|
|
614
614
|
break;
|
|
615
615
|
default:
|
|
@@ -623,9 +623,9 @@ je = /* @__PURE__ */ new WeakMap(), st = /* @__PURE__ */ new WeakMap(), ie = /*
|
|
|
623
623
|
var O, v, He, pt, Re, bt, xt;
|
|
624
624
|
const P = class P {
|
|
625
625
|
constructor(e) {
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
626
|
+
d(this, He);
|
|
627
|
+
d(this, O);
|
|
628
|
+
d(this, v);
|
|
629
629
|
/**
|
|
630
630
|
* Clone the current Monom.
|
|
631
631
|
*/
|
|
@@ -855,7 +855,7 @@ const P = class P {
|
|
|
855
855
|
* Create a zero value monom
|
|
856
856
|
*/
|
|
857
857
|
a(this, "zero", () => (h(this, O, new c().zero()), h(this, v, {}), this));
|
|
858
|
-
|
|
858
|
+
d(this, Re, (e) => {
|
|
859
859
|
let t = this.coefficient.value;
|
|
860
860
|
if (typeof e == "number") {
|
|
861
861
|
const s = {}, r = this.variables[0];
|
|
@@ -877,27 +877,27 @@ const P = class P {
|
|
|
877
877
|
}
|
|
878
878
|
return t;
|
|
879
879
|
});
|
|
880
|
-
|
|
880
|
+
d(this, bt, (e) => {
|
|
881
881
|
const s = new li().parse(e).rpn, r = [];
|
|
882
882
|
if (s.length === 0)
|
|
883
883
|
return this.zero(), this;
|
|
884
884
|
if (s.length === 1) {
|
|
885
885
|
const n = s[0];
|
|
886
|
-
return this.one(), n.tokenType ===
|
|
886
|
+
return this.one(), n.tokenType === m.COEFFICIENT ? this.coefficient = new c(n.token) : n.tokenType === m.VARIABLE && this.setLetter(n.token, 1), this;
|
|
887
887
|
} else
|
|
888
888
|
for (const n of s)
|
|
889
889
|
i(this, xt).call(this, r, n);
|
|
890
890
|
return this.one(), this.multiply(r[0]), this;
|
|
891
891
|
});
|
|
892
|
-
|
|
893
|
-
var
|
|
892
|
+
d(this, xt, (e, t) => {
|
|
893
|
+
var f;
|
|
894
894
|
let s, r, n, l, u;
|
|
895
|
-
if (t.tokenType ===
|
|
895
|
+
if (t.tokenType === m.COEFFICIENT)
|
|
896
896
|
e.push(new P(new c(t.token)));
|
|
897
|
-
else if (t.tokenType ===
|
|
898
|
-
const
|
|
899
|
-
|
|
900
|
-
} else if (t.tokenType ===
|
|
897
|
+
else if (t.tokenType === m.VARIABLE) {
|
|
898
|
+
const p = new P().one();
|
|
899
|
+
p.setLetter(t.token, 1), e.push(p.clone());
|
|
900
|
+
} else if (t.tokenType === m.OPERATION)
|
|
901
901
|
switch (t.token) {
|
|
902
902
|
case "-":
|
|
903
903
|
r = e.pop() ?? new P().zero(), s = e.pop() ?? new P().zero(), e.push(s.subtract(r));
|
|
@@ -909,7 +909,7 @@ const P = class P {
|
|
|
909
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 = ((
|
|
912
|
+
u = ((f = e.pop()) == null ? void 0 : f.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
|
}
|
|
@@ -1100,9 +1100,9 @@ let I = P;
|
|
|
1100
1100
|
var ue, De, S, ye, rt, ci, ui, fi, Wt, di;
|
|
1101
1101
|
const ti = class ti {
|
|
1102
1102
|
constructor(e, t, s = "x") {
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1103
|
+
d(this, S);
|
|
1104
|
+
d(this, ue);
|
|
1105
|
+
d(this, De);
|
|
1106
1106
|
if (h(this, De, s), Object.hasOwn(e, "moveLeft")) {
|
|
1107
1107
|
const r = e;
|
|
1108
1108
|
h(this, ue, r.left.clone().subtract(r.right));
|
|
@@ -1156,15 +1156,15 @@ ue = new WeakMap(), De = new WeakMap(), S = new WeakSet(), ye = function(e) {
|
|
|
1156
1156
|
if (n.isNegative())
|
|
1157
1157
|
return [];
|
|
1158
1158
|
if (n.isSquare()) {
|
|
1159
|
-
const l = n.sqrt(), u = s.clone().opposite().add(l).divide(t.clone().multiply(2)),
|
|
1159
|
+
const l = n.sqrt(), u = s.clone().opposite().add(l).divide(t.clone().multiply(2)), f = s.clone().opposite().subtract(l).divide(t.clone().multiply(2));
|
|
1160
1160
|
return l.isZero() ? [M(this, S, ye).call(this, u)] : [
|
|
1161
1161
|
M(this, S, ye).call(this, u),
|
|
1162
|
-
M(this, S, ye).call(this,
|
|
1163
|
-
].sort((
|
|
1162
|
+
M(this, S, ye).call(this, f)
|
|
1163
|
+
].sort((p, g) => p.value - g.value);
|
|
1164
1164
|
}
|
|
1165
1165
|
return M(this, S, fi).call(this, t, s, n);
|
|
1166
1166
|
}, fi = 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),
|
|
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), f = s.clone().divide(r ** 2), p = Math.abs(r / n), g = r === 1 ? "-" : `-${p} `, E = r === 1 ? "+" : `+${p} `;
|
|
1168
1168
|
function L(pe, ce, et, jt) {
|
|
1169
1169
|
return `\\frac{ ${ce} ${et}\\sqrt{ ${jt} } }{ ${pe} }`;
|
|
1170
1170
|
}
|
|
@@ -1174,16 +1174,16 @@ ue = new WeakMap(), De = new WeakMap(), S = new WeakSet(), ye = function(e) {
|
|
|
1174
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
1176
|
M(this, S, rt).call(this, le, {
|
|
1177
|
-
tex: L(u.tex, l.tex, g.toString(),
|
|
1178
|
-
display: te(u.display, l.display, g.toString(),
|
|
1177
|
+
tex: L(u.tex, l.tex, g.toString(), f.tex),
|
|
1178
|
+
display: te(u.display, l.display, g.toString(), f.display)
|
|
1179
1179
|
}),
|
|
1180
1180
|
M(this, S, rt).call(this, ge, {
|
|
1181
|
-
tex: L(u.tex, l.tex, E.toString(),
|
|
1182
|
-
display: te(u.display, l.display, E.toString(),
|
|
1181
|
+
tex: L(u.tex, l.tex, E.toString(), f.tex),
|
|
1182
|
+
display: te(u.display, l.display, E.toString(), f.display)
|
|
1183
1183
|
})
|
|
1184
1184
|
].sort((pe, ce) => pe.value - ce.value);
|
|
1185
1185
|
}, Wt = 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),
|
|
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), f = n.clone().divide(t), p = u.clone().subtract(l.clone().pow(2).divide(3)), g = f.clone().subtract(l.clone().multiply(u).divide(3)).add(l.clone().pow(3).multiply(2).divide(27)), E = g.clone().opposite(), L = p.clone().opposite().pow(3).divide(27), te = E.clone().pow(2).subtract(L.clone().multiply(4)).opposite();
|
|
1187
1187
|
if (te.isNegative()) {
|
|
1188
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
1189
|
return [M(this, S, ye).call(this, ge)];
|
|
@@ -1196,7 +1196,7 @@ ue = new WeakMap(), De = new WeakMap(), S = new WeakSet(), ye = function(e) {
|
|
|
1196
1196
|
].sort((pe, ce) => pe.value - ce.value);
|
|
1197
1197
|
}
|
|
1198
1198
|
if (te.isPositive()) {
|
|
1199
|
-
const ae = [], le =
|
|
1199
|
+
const ae = [], le = p.value, ge = g.value, pe = l.value;
|
|
1200
1200
|
for (let ce = 0; ce < 3; ce++)
|
|
1201
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
1202
|
return ae.map((ce) => M(this, S, rt).call(this, ce)).sort((ce, et) => ce.value - et.value);
|
|
@@ -1227,19 +1227,19 @@ ue = new WeakMap(), De = new WeakMap(), S = new WeakSet(), ye = function(e) {
|
|
|
1227
1227
|
return t.sort((g, E) => g.value - E.value);
|
|
1228
1228
|
if (e.degree().value > 3)
|
|
1229
1229
|
return [];
|
|
1230
|
-
const
|
|
1231
|
-
console.log(e.display), console.log(
|
|
1232
|
-
const
|
|
1233
|
-
return t = t.concat(
|
|
1230
|
+
const f = e.clone().parse("0");
|
|
1231
|
+
console.log(e.display), console.log(f.display);
|
|
1232
|
+
const p = new ti(e, e.clone().parse("0"), i(this, De));
|
|
1233
|
+
return t = t.concat(p.solve()), t.sort((g, E) => g.value - E.value);
|
|
1234
1234
|
};
|
|
1235
1235
|
let gt = ti;
|
|
1236
1236
|
var Ze, y, Xe, ht, Et, Nt, Ot, qt, at, Tt, At, Mt, It, pi, Ct, Ye, $t;
|
|
1237
1237
|
const C = class C {
|
|
1238
1238
|
constructor(e, ...t) {
|
|
1239
|
-
|
|
1239
|
+
d(this, It);
|
|
1240
1240
|
// #region Class fields (8)
|
|
1241
|
-
|
|
1242
|
-
|
|
1241
|
+
d(this, Ze);
|
|
1242
|
+
d(this, y);
|
|
1243
1243
|
// #endregion Constructors (7)
|
|
1244
1244
|
// #region Properties and methods (49)
|
|
1245
1245
|
/**
|
|
@@ -1331,8 +1331,8 @@ const C = class C {
|
|
|
1331
1331
|
reminder: new C().zero()
|
|
1332
1332
|
};
|
|
1333
1333
|
const n = e.monomByDegree(void 0, t), l = e.degree(t);
|
|
1334
|
-
let u,
|
|
1335
|
-
for (; r.degree(t).isGeq(l) &&
|
|
1334
|
+
let u, f = this.degree(t).value * 2;
|
|
1335
|
+
for (; r.degree(t).isGeq(l) && f > 0 && (f--, u = r.monomByDegree(void 0, t).clone().divide(n), !(!u.isZero() && (s.add(u), r.subtract(e.clone().multiply(u)).reduce(), u.degree(t).isZero()))); )
|
|
1336
1336
|
;
|
|
1337
1337
|
return s.reduce(), r.reduce(), { quotient: s, reminder: r };
|
|
1338
1338
|
});
|
|
@@ -1367,12 +1367,12 @@ const C = class C {
|
|
|
1367
1367
|
} else {
|
|
1368
1368
|
let u = i(this, qt).call(this, s, l, e ?? "x");
|
|
1369
1369
|
for (l = s.degree(e).value; u.length > 0; ) {
|
|
1370
|
-
const
|
|
1371
|
-
if (!s.isDividableBy(
|
|
1370
|
+
const f = u[0];
|
|
1371
|
+
if (!s.isDividableBy(f))
|
|
1372
1372
|
u.shift();
|
|
1373
1373
|
else {
|
|
1374
|
-
const
|
|
1375
|
-
t.push(
|
|
1374
|
+
const p = s.euclidean(f);
|
|
1375
|
+
t.push(f), s = p.quotient.clone(), u = u.filter((g) => {
|
|
1376
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
1377
|
return L.isDivisible(ae) ? E.isDivisible(te) : !1;
|
|
1378
1378
|
});
|
|
@@ -1519,10 +1519,10 @@ const C = class C {
|
|
|
1519
1519
|
if (l !== u)
|
|
1520
1520
|
return t ? l - u : u - l;
|
|
1521
1521
|
if (s.length > 0)
|
|
1522
|
-
for (const
|
|
1523
|
-
const
|
|
1524
|
-
if (
|
|
1525
|
-
return t ?
|
|
1522
|
+
for (const f of s) {
|
|
1523
|
+
const p = r.degree(f).value, g = n.degree(f).value;
|
|
1524
|
+
if (p !== g)
|
|
1525
|
+
return t ? p - g : g - p;
|
|
1526
1526
|
}
|
|
1527
1527
|
return 0;
|
|
1528
1528
|
}), this;
|
|
@@ -1551,7 +1551,7 @@ const C = class C {
|
|
|
1551
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
|
+
d(this, Xe, (e, t) => {
|
|
1555
1555
|
t === void 0 && (t = "=");
|
|
1556
1556
|
const s = this.clone().reduce().reorder(), r = e.clone().reduce().reorder();
|
|
1557
1557
|
switch (t) {
|
|
@@ -1563,34 +1563,34 @@ const C = class C {
|
|
|
1563
1563
|
return !1;
|
|
1564
1564
|
}
|
|
1565
1565
|
});
|
|
1566
|
-
|
|
1566
|
+
d(this, ht, (e) => {
|
|
1567
1567
|
for (const t of i(this, y))
|
|
1568
1568
|
t.coefficient.divide(e);
|
|
1569
1569
|
return this;
|
|
1570
1570
|
});
|
|
1571
|
-
|
|
1571
|
+
d(this, Et, (e) => {
|
|
1572
1572
|
const t = new c(e);
|
|
1573
1573
|
for (const s of i(this, y))
|
|
1574
1574
|
s.coefficient.divide(t);
|
|
1575
1575
|
return this;
|
|
1576
1576
|
});
|
|
1577
|
-
|
|
1577
|
+
d(this, Nt, (e) => {
|
|
1578
1578
|
let t = 0;
|
|
1579
1579
|
return i(this, y).forEach((s) => {
|
|
1580
1580
|
t += s.evaluate(e, !0);
|
|
1581
1581
|
}), t;
|
|
1582
1582
|
});
|
|
1583
|
-
|
|
1583
|
+
d(this, Ot, (e) => {
|
|
1584
1584
|
var E;
|
|
1585
|
-
let t, s, r, n, l, u,
|
|
1585
|
+
let t, s, r, n, l, u, f, p, 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() ? (
|
|
1588
|
-
new C(e).subtract(
|
|
1589
|
-
new C(e).subtract(
|
|
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() ? (f = n.clone().opposite().divide(r.clone().multiply(2)), t = new C(e).subtract(f.display).multiply(f.denominator), s = new C(e).subtract(f.display).multiply(f.denominator), g = r.divide(f.denominator).divide(f.denominator), g.isOne() ? [t, s] : [new C(g.display), t, s]) : u.isPositive() && u.isSquare() ? (f = n.clone().opposite().add(u.clone().sqrt()).divide(r.clone().multiply(2)), p = n.clone().opposite().subtract(u.clone().sqrt()).divide(r.clone().multiply(2)), g = r.divide(f.denominator).divide(p.denominator), g.isOne() ? [
|
|
1588
|
+
new C(e).subtract(f.display).multiply(f.denominator),
|
|
1589
|
+
new C(e).subtract(p.display).multiply(p.denominator)
|
|
1590
1590
|
] : [
|
|
1591
1591
|
new C(g.display),
|
|
1592
|
-
new C(e).subtract(
|
|
1593
|
-
new C(e).subtract(
|
|
1592
|
+
new C(e).subtract(f.display).multiply(f.denominator),
|
|
1593
|
+
new C(e).subtract(p.display).multiply(p.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
1596
|
const L = new C("x", r.coefficient, n.coefficient, l.coefficient), te = i(E = L, Ot).call(E, "x"), ae = [];
|
|
@@ -1603,44 +1603,44 @@ const C = class C {
|
|
|
1603
1603
|
}
|
|
1604
1604
|
return [this.clone()];
|
|
1605
1605
|
});
|
|
1606
|
-
|
|
1606
|
+
d(this, qt, (e, t, s) => {
|
|
1607
1607
|
const r = e.monoms[0].dividers, n = e.monoms[e.monoms.length - 1].dividers, l = [];
|
|
1608
1608
|
return r.forEach((u) => {
|
|
1609
|
-
u.degree(s).isLeq(t) && n.forEach((
|
|
1610
|
-
u.degree(s).isNotEqual(
|
|
1609
|
+
u.degree(s).isLeq(t) && n.forEach((f) => {
|
|
1610
|
+
u.degree(s).isNotEqual(f.degree(s)) && (l.push(new C(u, f)), l.push(new C(u, f.clone().opposite())));
|
|
1611
1611
|
});
|
|
1612
1612
|
}), l;
|
|
1613
1613
|
});
|
|
1614
|
-
|
|
1614
|
+
d(this, at, (e) => {
|
|
1615
1615
|
for (const t of i(this, y))
|
|
1616
1616
|
t.coefficient.multiply(e);
|
|
1617
1617
|
return this.reduce();
|
|
1618
1618
|
});
|
|
1619
|
-
|
|
1620
|
-
|
|
1619
|
+
d(this, Tt, (e) => i(this, at).call(this, new c(e)));
|
|
1620
|
+
d(this, At, (e) => {
|
|
1621
1621
|
for (const t of i(this, y))
|
|
1622
1622
|
t.multiply(e);
|
|
1623
1623
|
return this.reduce();
|
|
1624
1624
|
});
|
|
1625
|
-
|
|
1625
|
+
d(this, Mt, (e) => {
|
|
1626
1626
|
const t = [];
|
|
1627
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
1630
|
return h(this, y, t), this.reduce();
|
|
1631
1631
|
});
|
|
1632
|
-
|
|
1632
|
+
d(this, Ct, (e, t) => {
|
|
1633
1633
|
switch (t.tokenType) {
|
|
1634
|
-
case
|
|
1634
|
+
case m.COEFFICIENT:
|
|
1635
1635
|
e.push(new C(t.token));
|
|
1636
1636
|
break;
|
|
1637
|
-
case
|
|
1637
|
+
case m.VARIABLE:
|
|
1638
1638
|
e.push(new C().add(new I(t.token)));
|
|
1639
1639
|
break;
|
|
1640
|
-
case
|
|
1640
|
+
case m.CONSTANT:
|
|
1641
1641
|
console.log("Actually, not supported - will be added later !");
|
|
1642
1642
|
break;
|
|
1643
|
-
case
|
|
1643
|
+
case m.OPERATION:
|
|
1644
1644
|
if (e.length >= 2) {
|
|
1645
1645
|
const s = e.pop(), r = e.pop();
|
|
1646
1646
|
if (r === void 0 || s === void 0)
|
|
@@ -1670,15 +1670,15 @@ const C = class C {
|
|
|
1670
1670
|
} else
|
|
1671
1671
|
throw new Error("Error parsing the polynom");
|
|
1672
1672
|
break;
|
|
1673
|
-
case
|
|
1673
|
+
case m.MONOM:
|
|
1674
1674
|
console.error("The monom token should not appear here");
|
|
1675
1675
|
break;
|
|
1676
|
-
case
|
|
1676
|
+
case m.FUNCTION:
|
|
1677
1677
|
console.error("The function token should not appear here - might be introduced later.");
|
|
1678
1678
|
break;
|
|
1679
1679
|
}
|
|
1680
1680
|
});
|
|
1681
|
-
|
|
1681
|
+
d(this, Ye, (e, t, s, r) => {
|
|
1682
1682
|
let n = "";
|
|
1683
1683
|
for (const l of i(this, y)) {
|
|
1684
1684
|
if (l.coefficient.value === 0)
|
|
@@ -1692,7 +1692,7 @@ const C = class C {
|
|
|
1692
1692
|
* Main parse using a shutting yard class
|
|
1693
1693
|
* @param inputStr
|
|
1694
1694
|
*/
|
|
1695
|
-
|
|
1695
|
+
d(this, $t, (e) => {
|
|
1696
1696
|
const s = new li().parse(e).rpn;
|
|
1697
1697
|
this.zero();
|
|
1698
1698
|
const r = [];
|
|
@@ -1794,10 +1794,10 @@ function ri(o, e = !0) {
|
|
|
1794
1794
|
var Ee, Qe, Ne, Oe;
|
|
1795
1795
|
const we = class we {
|
|
1796
1796
|
constructor(e, t) {
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1797
|
+
d(this, Ee);
|
|
1798
|
+
d(this, Qe, !1);
|
|
1799
|
+
d(this, Ne);
|
|
1800
|
+
d(this, Oe);
|
|
1801
1801
|
if (e instanceof we)
|
|
1802
1802
|
h(this, Ne, e.polynom.clone()), h(this, Oe, e.power.clone());
|
|
1803
1803
|
else if (typeof e == "string" && t === void 0) {
|
|
@@ -1937,11 +1937,11 @@ var Ue = /* @__PURE__ */ ((o) => (o[o.ROOT = 0] = "ROOT", o[o.POWER = 1] = "POWE
|
|
|
1937
1937
|
const xe = class xe {
|
|
1938
1938
|
constructor(e, t, s) {
|
|
1939
1939
|
// Left part of the equation
|
|
1940
|
-
|
|
1940
|
+
d(this, q);
|
|
1941
1941
|
// Right part of the equation
|
|
1942
|
-
|
|
1942
|
+
d(this, A);
|
|
1943
1943
|
// Signe of the equation
|
|
1944
|
-
|
|
1944
|
+
d(this, re);
|
|
1945
1945
|
// #endregion Constructors (3)
|
|
1946
1946
|
// #region Properties and methods (26)
|
|
1947
1947
|
// ------------------------------------------
|
|
@@ -2046,7 +2046,7 @@ const xe = class xe {
|
|
|
2046
2046
|
a(this, "test", (e) => this.left.evaluate(e).isEqual(this.right.evaluate(e)));
|
|
2047
2047
|
// #endregion Getters And Setters (13)
|
|
2048
2048
|
// #region Private methods (6)
|
|
2049
|
-
|
|
2049
|
+
d(this, Pt, (e) => {
|
|
2050
2050
|
if (e.includes("geq"))
|
|
2051
2051
|
return e.includes("\\geq") ? "\\geq" : "geq";
|
|
2052
2052
|
if (e.includes("leq"))
|
|
@@ -2069,8 +2069,8 @@ const xe = class xe {
|
|
|
2069
2069
|
});
|
|
2070
2070
|
// -----------------------------------------------
|
|
2071
2071
|
// Equations solving algorithms
|
|
2072
|
-
|
|
2073
|
-
|
|
2072
|
+
d(this, Ke, (e) => e === void 0 ? "=" : e.includes("geq") || e.includes(">=") || e.includes("=>") ? ">=" : e.includes(">") ? ">" : e.includes("leq") || e.includes("<=") || e.includes("=<") ? "<=" : e.includes("<") ? "<" : "=");
|
|
2073
|
+
d(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);
|
|
2074
2074
|
if (h(this, q, new T().zero()), h(this, A, new T().zero()), h(this, re, "="), e !== void 0 && t === void 0) {
|
|
2075
2075
|
if (e instanceof xe)
|
|
2076
2076
|
return e.clone();
|
|
@@ -2179,8 +2179,8 @@ const me = class me {
|
|
|
2179
2179
|
// #region Constructors (1)
|
|
2180
2180
|
constructor(...e) {
|
|
2181
2181
|
// #region Class fields (1)
|
|
2182
|
-
|
|
2183
|
-
|
|
2182
|
+
d(this, N, []);
|
|
2183
|
+
d(this, Ve, Ue.POWER);
|
|
2184
2184
|
return this.parse(...e), this;
|
|
2185
2185
|
}
|
|
2186
2186
|
// #endregion Constructors (1)
|
|
@@ -2345,11 +2345,11 @@ const me = class me {
|
|
|
2345
2345
|
};
|
|
2346
2346
|
N = new WeakMap(), Ve = new WeakMap(), lt = new WeakSet(), Xt = function(e, t) {
|
|
2347
2347
|
const s = Gt(e), r = Gt(t), l = Object.keys(s).filter((u) => Object.hasOwn(r, u)).map((u) => {
|
|
2348
|
-
const
|
|
2349
|
-
return new fe(u, c.min(
|
|
2348
|
+
const f = s[u].reduce((g, E) => g.add(E.power), new c("0")), p = r[u].reduce((g, E) => g.add(E.power), new c("0"));
|
|
2349
|
+
return new fe(u, c.min(f, p));
|
|
2350
2350
|
});
|
|
2351
2351
|
return new me(...l);
|
|
2352
|
-
},
|
|
2352
|
+
}, d(me, lt);
|
|
2353
2353
|
let Ht = me;
|
|
2354
2354
|
function Gt(o) {
|
|
2355
2355
|
const e = new c().one(), t = o.factors.reduce((s, r) => {
|
|
@@ -2363,25 +2363,25 @@ function Gt(o) {
|
|
|
2363
2363
|
var k, Ie, Bt, Rt;
|
|
2364
2364
|
const Ge = class Ge {
|
|
2365
2365
|
constructor(...e) {
|
|
2366
|
-
|
|
2366
|
+
d(this, k);
|
|
2367
2367
|
// Determine the letters in the linear system, usually ['x', 'y']
|
|
2368
|
-
|
|
2368
|
+
d(this, Ie);
|
|
2369
2369
|
a(this, "parse", (...e) => (h(this, k, e.map((t) => new H(t))), i(this, Bt).call(this), this));
|
|
2370
2370
|
a(this, "clone", () => new Ge().parse(...i(this, k).map((e) => e.clone())));
|
|
2371
2371
|
a(this, "buildTex", (e, t) => {
|
|
2372
2372
|
let s, r, n = [];
|
|
2373
2373
|
const l = [];
|
|
2374
|
-
for (const
|
|
2375
|
-
n = n.concat(
|
|
2374
|
+
for (const f of e)
|
|
2375
|
+
n = n.concat(f.letters());
|
|
2376
2376
|
n = [...new Set(n)], n.sort();
|
|
2377
|
-
for (let
|
|
2378
|
-
const
|
|
2377
|
+
for (let f = 0; f < e.length; f++) {
|
|
2378
|
+
const p = e[f];
|
|
2379
2379
|
s = [];
|
|
2380
2380
|
for (const g of n)
|
|
2381
|
-
r =
|
|
2382
|
-
if (s.push("="), s.push(
|
|
2381
|
+
r = p.left.monomByLetter(g), s.length === 0 ? s.push(r.isZero() ? "" : r.tex) : s.push(r.isZero() ? "" : (r.coefficient.sign() === 1 ? "+" : "") + r.tex);
|
|
2382
|
+
if (s.push("="), s.push(p.right.tex), (t == null ? void 0 : t[f]) !== void 0) {
|
|
2383
2383
|
s[s.length - 1] = s[s.length - 1] + " \\phantom{\\quad}";
|
|
2384
|
-
for (const g of t[
|
|
2384
|
+
for (const g of t[f])
|
|
2385
2385
|
s.push(`\\ \\cdot\\ ${g.startsWith("-") ? "\\left(" + g + "\\right)" : g}`);
|
|
2386
2386
|
}
|
|
2387
2387
|
l.push(s.join("&"));
|
|
@@ -2408,16 +2408,16 @@ const Ge = class Ge {
|
|
|
2408
2408
|
if (l === r)
|
|
2409
2409
|
continue;
|
|
2410
2410
|
const u = s[l][r].clone().opposite();
|
|
2411
|
-
for (let
|
|
2412
|
-
s[l][
|
|
2413
|
-
if (s[l].slice(0, s[l].length - 1).every((
|
|
2411
|
+
for (let f = 0; f < s[l].length; f++)
|
|
2412
|
+
s[l][f].add(s[r][f].clone().multiply(u));
|
|
2413
|
+
if (s[l].slice(0, s[l].length - 1).every((f) => f.isZero()))
|
|
2414
2414
|
return s[l][s[l].length - 1].isZero() ? [new c().infinite()] : [];
|
|
2415
2415
|
}
|
|
2416
2416
|
}
|
|
2417
2417
|
return s.map((r) => r[r.length - 1]);
|
|
2418
2418
|
});
|
|
2419
|
-
|
|
2420
|
-
|
|
2419
|
+
d(this, Bt, () => (h(this, Ie, i(this, k).reduce((e, t) => [.../* @__PURE__ */ new Set([...e, ...t.variables])], [])), i(this, Ie).sort(), this));
|
|
2420
|
+
d(this, Rt, () => {
|
|
2421
2421
|
const e = [], t = [];
|
|
2422
2422
|
for (const s of i(this, k)) {
|
|
2423
2423
|
const r = [], n = s.clone().reorder();
|
|
@@ -2564,8 +2564,8 @@ function Ui(...o) {
|
|
|
2564
2564
|
var V, ze;
|
|
2565
2565
|
const Se = class Se {
|
|
2566
2566
|
constructor(...e) {
|
|
2567
|
-
|
|
2568
|
-
|
|
2567
|
+
d(this, V, []);
|
|
2568
|
+
d(this, ze, !1);
|
|
2569
2569
|
a(this, "zero", () => (i(this, V).forEach((e) => e.zero()), this));
|
|
2570
2570
|
a(this, "one", () => (this.zero(), this.x.one(), this));
|
|
2571
2571
|
a(this, "opposite", () => (i(this, V).forEach((e) => e.opposite()), this));
|
|
@@ -2786,7 +2786,7 @@ function gi(o) {
|
|
|
2786
2786
|
}
|
|
2787
2787
|
return e;
|
|
2788
2788
|
}
|
|
2789
|
-
class
|
|
2789
|
+
class j extends x {
|
|
2790
2790
|
constructor(...e) {
|
|
2791
2791
|
super(), e.length > 0 && this.parse(...e);
|
|
2792
2792
|
}
|
|
@@ -2808,7 +2808,7 @@ class D extends x {
|
|
|
2808
2808
|
return this;
|
|
2809
2809
|
}
|
|
2810
2810
|
clone() {
|
|
2811
|
-
const e = new
|
|
2811
|
+
const e = new j();
|
|
2812
2812
|
return e.array = this.copy(), e.asPoint = !0, e;
|
|
2813
2813
|
}
|
|
2814
2814
|
}
|
|
@@ -2820,15 +2820,15 @@ const Le = class Le {
|
|
|
2820
2820
|
* @param values
|
|
2821
2821
|
*/
|
|
2822
2822
|
constructor(...e) {
|
|
2823
|
-
|
|
2823
|
+
d(this, Ce);
|
|
2824
2824
|
// ax + by + c = 0
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2825
|
+
d(this, B);
|
|
2826
|
+
d(this, R);
|
|
2827
|
+
d(this, U);
|
|
2828
|
+
d(this, ne);
|
|
2829
|
+
d(this, Y);
|
|
2830
|
+
d(this, $e);
|
|
2831
|
+
d(this, ve, "canonical");
|
|
2832
2832
|
a(this, "randomPoint", (e) => i(this, Y).clone().multiplyByScalar(X(e === void 0 || e <= 1 ? 3 : e, !1)).add(i(this, ne)));
|
|
2833
2833
|
a(this, "randomNearPoint", (e) => {
|
|
2834
2834
|
const t = this.randomPoint(e);
|
|
@@ -3117,14 +3117,14 @@ const Le = class Le {
|
|
|
3117
3117
|
};
|
|
3118
3118
|
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
|
|
3119
3119
|
a(Le, "PERPENDICULAR", "perpendicular"), a(Le, "PARALLEL", "parallel");
|
|
3120
|
-
let
|
|
3120
|
+
let D = Le;
|
|
3121
3121
|
var oe, F, qe, zt, kt, Lt, he, wi, mt, vi, bi, xi, Qt;
|
|
3122
3122
|
const Dt = class Dt {
|
|
3123
3123
|
constructor(...e) {
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3124
|
+
d(this, he);
|
|
3125
|
+
d(this, oe);
|
|
3126
|
+
d(this, F);
|
|
3127
|
+
d(this, qe);
|
|
3128
3128
|
/**
|
|
3129
3129
|
* Get the relative position between circle and line. It corresponds to the number of intersection.
|
|
3130
3130
|
* @param {Line} L
|
|
@@ -3143,7 +3143,7 @@ const Dt = class Dt {
|
|
|
3143
3143
|
const s = i(this, qe).clone(), r = e.getEquation().clone().isolate("x"), n = e.getEquation().clone().isolate("y");
|
|
3144
3144
|
return r instanceof H && n instanceof H && (s.replaceBy("y", n.right).simplify(), s.solve()), t;
|
|
3145
3145
|
});
|
|
3146
|
-
a(this, "tangents", (e) => e instanceof c ? i(this, Lt).call(this, e) : this.isPointOnCircle(e) ? i(this, zt).call(this, e) : i(this, oe) !== void 0 && i(this, oe).distanceTo(e).value > this.radius.value ?
|
|
3146
|
+
a(this, "tangents", (e) => e instanceof c ? i(this, Lt).call(this, e) : this.isPointOnCircle(e) ? i(this, zt).call(this, e) : i(this, oe) !== void 0 && i(this, oe).distanceTo(e).value > this.radius.value ? i(this, kt).call(this, e) : (console.log("No tangents as the point is inside !"), []));
|
|
3147
3147
|
a(this, "isPointOnCircle", (e) => {
|
|
3148
3148
|
var t;
|
|
3149
3149
|
return ((t = i(this, qe)) == null ? void 0 : t.test({ x: e.x, y: e.y })) ?? !1;
|
|
@@ -3153,29 +3153,33 @@ const Dt = class Dt {
|
|
|
3153
3153
|
return t.forEach((r) => {
|
|
3154
3154
|
for (const n of [[1, 1], [-1, 1], [-1, -1], [1, -1]])
|
|
3155
3155
|
s.push(
|
|
3156
|
-
new
|
|
3156
|
+
new j(
|
|
3157
3157
|
this.center.x.clone().add(n[0] * r[0]),
|
|
3158
3158
|
this.center.y.clone().add(n[1] * r[1])
|
|
3159
3159
|
)
|
|
3160
3160
|
);
|
|
3161
3161
|
}), s;
|
|
3162
3162
|
});
|
|
3163
|
-
|
|
3164
|
-
const t = new
|
|
3165
|
-
return [new
|
|
3163
|
+
d(this, zt, (e) => {
|
|
3164
|
+
const t = new x(this.center, e);
|
|
3165
|
+
return [new D(e, t, yi.Perpendicular)];
|
|
3166
3166
|
});
|
|
3167
|
-
|
|
3167
|
+
d(this, kt, (e) => {
|
|
3168
3168
|
const t = this.center.x.clone().subtract(e.x), s = this.center.y.clone().subtract(e.y), r = new T("x"), n = new T("x^2+1");
|
|
3169
|
-
r.multiply(t).subtract(s).pow(2), n.multiply(this.squareRadius), new H(r, n).
|
|
3169
|
+
return r.multiply(t).subtract(s).pow(2), n.multiply(this.squareRadius), new H(r, n).solve().map((f) => {
|
|
3170
|
+
let p;
|
|
3171
|
+
const g = new H("y", "x");
|
|
3172
|
+
return f.exact instanceof c ? (p = e.x.clone().opposite().multiply(f.exact).add(e.y), g.right.multiply(f.exact).add(p)) : (p = e.x.clone().opposite().multiply(f.value).add(e.y), g.right.multiply(f.value).add(p)), new D(g);
|
|
3173
|
+
});
|
|
3170
3174
|
});
|
|
3171
|
-
|
|
3172
|
-
const t = e.numerator, s = -e.denominator, r = this.center.x.clone(), n = this.center.y.clone(), l = this.squareRadius.clone().multiply(e.numerator ** 2 + e.denominator ** 2), u = r.clone().multiply(t).opposite().subtract(n.clone().multiply(s)).add(l.clone().sqrt()),
|
|
3173
|
-
return [new
|
|
3175
|
+
d(this, Lt, (e) => {
|
|
3176
|
+
const t = e.numerator, s = -e.denominator, r = this.center.x.clone(), n = this.center.y.clone(), l = this.squareRadius.clone().multiply(e.numerator ** 2 + e.denominator ** 2), u = r.clone().multiply(t).opposite().subtract(n.clone().multiply(s)).add(l.clone().sqrt()), f = r.clone().multiply(t).opposite().subtract(n.clone().multiply(s)).subtract(l.clone().sqrt());
|
|
3177
|
+
return [new D(t, s, u), new D(t, s, f)];
|
|
3174
3178
|
});
|
|
3175
3179
|
e.length > 0 && this.parse(...e);
|
|
3176
3180
|
}
|
|
3177
3181
|
get center() {
|
|
3178
|
-
return i(this, oe) ?? new
|
|
3182
|
+
return i(this, oe) ?? new j();
|
|
3179
3183
|
}
|
|
3180
3184
|
get squareRadius() {
|
|
3181
3185
|
return i(this, F) ?? new c(0);
|
|
@@ -3218,7 +3222,7 @@ const Dt = class Dt {
|
|
|
3218
3222
|
return t ? h(this, F, new c(e)) : h(this, F, new c(e).pow(2)), M(this, he, mt).call(this), this;
|
|
3219
3223
|
}
|
|
3220
3224
|
parse(...e) {
|
|
3221
|
-
return M(this, he, wi).call(this), typeof e[0] == "string" ? M(this, he, Qt).call(this, new H(e[0])) : e[0] instanceof H ? M(this, he, Qt).call(this, e[0]) : e[0] instanceof Dt ? M(this, he, vi).call(this, e[0]) : e[0] instanceof
|
|
3225
|
+
return M(this, he, wi).call(this), typeof e[0] == "string" ? M(this, he, Qt).call(this, new H(e[0])) : e[0] instanceof H ? M(this, he, Qt).call(this, e[0]) : e[0] instanceof Dt ? M(this, he, vi).call(this, e[0]) : e[0] instanceof j && e.length > 1 && (e[1] instanceof j ? e[2] instanceof j || M(this, he, xi).call(this, e[0], e[1]) : (e[1] instanceof c || typeof e[1] == "number") && M(this, he, bi).call(this, e[0], e[1], typeof e[2] == "boolean" ? e[2] : !1)), M(this, he, mt).call(this), this;
|
|
3222
3226
|
}
|
|
3223
3227
|
// private _parseThroughtThreePoints(A: Point, B: Point, C: Point): this {
|
|
3224
3228
|
// const T = new Triangle(A, B, C), mAB = T.remarquables.mediators.AB.clone(),
|
|
@@ -3244,7 +3248,7 @@ oe = new WeakMap(), F = new WeakMap(), qe = new WeakMap(), zt = new WeakMap(), k
|
|
|
3244
3248
|
if (e.moveLeft(), e.degree("x").value === 2 && e.degree("y").value === 2) {
|
|
3245
3249
|
const t = e.left.monomByDegree(2, "x"), s = e.left.monomByDegree(2, "y");
|
|
3246
3250
|
let r, n, l;
|
|
3247
|
-
t.coefficient.isEqual(s.coefficient) ? (e.divide(t.coefficient), r = e.left.monomByDegree(1, "x"), n = e.left.monomByDegree(1, "y"), l = e.left.monomByDegree(0), h(this, oe, new
|
|
3251
|
+
t.coefficient.isEqual(s.coefficient) ? (e.divide(t.coefficient), r = e.left.monomByDegree(1, "x"), n = e.left.monomByDegree(1, "y"), l = e.left.monomByDegree(0), h(this, oe, new j(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));
|
|
3248
3252
|
}
|
|
3249
3253
|
return this;
|
|
3250
3254
|
};
|
|
@@ -3252,12 +3256,12 @@ let yt = Dt;
|
|
|
3252
3256
|
var Q, _, ee, Je, Te, ct, Zt, ut, Pe, Vt, _e;
|
|
3253
3257
|
const Ft = class Ft {
|
|
3254
3258
|
constructor(...e) {
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3259
|
+
d(this, Q);
|
|
3260
|
+
d(this, _);
|
|
3261
|
+
d(this, ee);
|
|
3262
|
+
d(this, Je);
|
|
3263
|
+
d(this, Te);
|
|
3264
|
+
d(this, ct);
|
|
3261
3265
|
// ------------------------------------------
|
|
3262
3266
|
// Creation / parsing functions
|
|
3263
3267
|
// ------------------------------------------
|
|
@@ -3280,8 +3284,8 @@ const Ft = class Ft {
|
|
|
3280
3284
|
);
|
|
3281
3285
|
} else if (e.length === 3) {
|
|
3282
3286
|
if (e.every((t) => typeof t == "string"))
|
|
3283
|
-
return this.parse(...e.map((t) => new
|
|
3284
|
-
if (e.every((t) => t instanceof
|
|
3287
|
+
return this.parse(...e.map((t) => new D(t)));
|
|
3288
|
+
if (e.every((t) => t instanceof D)) {
|
|
3285
3289
|
const t = e[0].clone(), s = e[1].clone(), r = e[2].clone();
|
|
3286
3290
|
h(this, Je, { AB: t, BC: s, AC: r });
|
|
3287
3291
|
let n = t.intersection(s);
|
|
@@ -3297,10 +3301,10 @@ const Ft = class Ft {
|
|
|
3297
3301
|
h(this, Q, n.point.clone());
|
|
3298
3302
|
else
|
|
3299
3303
|
throw new Error("Lines do not intersect !");
|
|
3300
|
-
} else e.every((t) => t instanceof
|
|
3301
|
-
AB: new
|
|
3302
|
-
BC: new
|
|
3303
|
-
AC: new
|
|
3304
|
+
} else e.every((t) => t instanceof j) && (h(this, Q, e[0].clone()), h(this, _, e[1].clone()), h(this, ee, e[2].clone()), h(this, Je, {
|
|
3305
|
+
AB: new D(i(this, Q), i(this, _)),
|
|
3306
|
+
BC: new D(i(this, _), i(this, ee)),
|
|
3307
|
+
AC: new D(i(this, Q), i(this, ee))
|
|
3304
3308
|
}));
|
|
3305
3309
|
} else if (e.length === 1 && e[0] instanceof Ft)
|
|
3306
3310
|
return e[0].clone();
|
|
@@ -3320,18 +3324,18 @@ const Ft = class Ft {
|
|
|
3320
3324
|
/**
|
|
3321
3325
|
* Generate the Line object for the three segments of the triangle
|
|
3322
3326
|
*/
|
|
3323
|
-
|
|
3327
|
+
d(this, Zt, () => {
|
|
3324
3328
|
h(this, Te, {
|
|
3325
|
-
AB: new
|
|
3326
|
-
AC: new
|
|
3327
|
-
BC: new
|
|
3329
|
+
AB: new j().middleOf(i(this, Q), i(this, _)),
|
|
3330
|
+
AC: new j().middleOf(i(this, Q), i(this, ee)),
|
|
3331
|
+
BC: new j().middleOf(i(this, _), i(this, ee))
|
|
3328
3332
|
}), h(this, ct, i(this, Vt).call(this));
|
|
3329
3333
|
});
|
|
3330
3334
|
/**
|
|
3331
3335
|
* Get the Vector2D class for the given name
|
|
3332
3336
|
* @param ptName
|
|
3333
3337
|
*/
|
|
3334
|
-
|
|
3338
|
+
d(this, ut, (e) => {
|
|
3335
3339
|
switch (e.toUpperCase()) {
|
|
3336
3340
|
case "A":
|
|
3337
3341
|
return i(this, Q);
|
|
@@ -3347,52 +3351,52 @@ const Ft = class Ft {
|
|
|
3347
3351
|
* @param ptName1
|
|
3348
3352
|
* @param ptName2
|
|
3349
3353
|
*/
|
|
3350
|
-
|
|
3354
|
+
d(this, Pe, (e, t) => new x(
|
|
3351
3355
|
i(this, ut).call(this, e),
|
|
3352
3356
|
i(this, ut).call(this, t)
|
|
3353
3357
|
));
|
|
3354
|
-
|
|
3358
|
+
d(this, Vt, () => {
|
|
3355
3359
|
const e = {
|
|
3356
|
-
A: new
|
|
3357
|
-
B: new
|
|
3358
|
-
C: new
|
|
3360
|
+
A: new D(i(this, Q), i(this, Te).BC),
|
|
3361
|
+
B: new D(i(this, _), i(this, Te).AC),
|
|
3362
|
+
C: new D(i(this, ee), i(this, Te).AB),
|
|
3359
3363
|
intersection: null
|
|
3360
3364
|
}, t = {
|
|
3361
|
-
AB: new
|
|
3362
|
-
AC: new
|
|
3363
|
-
BC: new
|
|
3365
|
+
AB: new D(i(this, Te).AB, new x(i(this, Q), i(this, _)).normal()),
|
|
3366
|
+
AC: new D(i(this, Te).AC, new x(i(this, Q), i(this, ee)).normal()),
|
|
3367
|
+
BC: new D(i(this, Te).BC, new x(i(this, _), i(this, ee)).normal()),
|
|
3364
3368
|
intersection: null
|
|
3365
3369
|
}, s = {
|
|
3366
|
-
A: new
|
|
3367
|
-
B: new
|
|
3368
|
-
C: new
|
|
3370
|
+
A: new D(i(this, Q), new x(i(this, _), i(this, ee)).normal()),
|
|
3371
|
+
B: new D(i(this, _), new x(i(this, Q), i(this, ee)).normal()),
|
|
3372
|
+
C: new D(i(this, ee), new x(i(this, Q), i(this, _)).normal()),
|
|
3369
3373
|
intersection: null
|
|
3370
3374
|
}, r = i(this, _e).call(this, "A"), n = i(this, _e).call(this, "B"), l = i(this, _e).call(this, "C"), u = {
|
|
3371
3375
|
A: r.internal,
|
|
3372
3376
|
B: n.internal,
|
|
3373
3377
|
C: n.internal,
|
|
3374
3378
|
intersection: null
|
|
3375
|
-
},
|
|
3379
|
+
}, f = {
|
|
3376
3380
|
A: r.external,
|
|
3377
3381
|
B: n.external,
|
|
3378
3382
|
C: l.external,
|
|
3379
3383
|
intersection: null
|
|
3380
|
-
},
|
|
3384
|
+
}, p = {
|
|
3381
3385
|
medians: e,
|
|
3382
3386
|
mediators: t,
|
|
3383
3387
|
heights: s,
|
|
3384
3388
|
bisectors: u,
|
|
3385
|
-
externalBisectors:
|
|
3389
|
+
externalBisectors: f
|
|
3386
3390
|
};
|
|
3387
|
-
return
|
|
3391
|
+
return p.medians.intersection = p.medians.A.intersection(p.medians.B).point, p.mediators.intersection = p.mediators.AB.intersection(p.mediators.BC).point, p.heights.intersection = p.heights.A.intersection(p.heights.B).point, p.bisectors.intersection = p.bisectors.A.intersection(p.bisectors.B).point, p;
|
|
3388
3392
|
});
|
|
3389
|
-
|
|
3393
|
+
d(this, _e, (e) => {
|
|
3390
3394
|
const t = this.lines;
|
|
3391
3395
|
let s, r;
|
|
3392
3396
|
if (e === "A" ? (s = t.AB, r = t.AC) : e === "B" ? (s = t.AB, r = t.BC) : e === "C" && (s = t.BC, r = t.AC), s === void 0 || r === void 0)
|
|
3393
3397
|
throw new Error(`The point ${e} does not exist`);
|
|
3394
|
-
const n = s.n.simplify().norm, l = r.n.simplify().norm, u = s.getEquation().multiply(l),
|
|
3395
|
-
return e === "A" ?
|
|
3398
|
+
const n = s.n.simplify().norm, l = r.n.simplify().norm, u = s.getEquation().multiply(l), f = r.getEquation().multiply(n), p = new D(u.clone().subtract(f).simplify()), g = new D(f.clone().subtract(u).simplify());
|
|
3399
|
+
return e === "A" ? p.hitSegment(this.B, this.C) ? { internal: p, external: g } : { internal: g, external: p } : e === "B" ? p.hitSegment(this.A, this.C) ? { internal: p, external: g } : { internal: g, external: p } : e === "C" ? p.hitSegment(this.B, this.A) ? { internal: p, external: g } : { internal: g, external: p } : { internal: p, external: g };
|
|
3396
3400
|
});
|
|
3397
3401
|
return e.length > 0 && this.parse(...e), this;
|
|
3398
3402
|
}
|
|
@@ -3448,8 +3452,8 @@ var z, W;
|
|
|
3448
3452
|
const nt = class nt {
|
|
3449
3453
|
constructor(e, t) {
|
|
3450
3454
|
// ax + by + c = 0
|
|
3451
|
-
|
|
3452
|
-
|
|
3455
|
+
d(this, z, new j());
|
|
3456
|
+
d(this, W, new x());
|
|
3453
3457
|
a(this, "clone", () => (h(this, W, i(this, W).clone()), h(this, z, i(this, z).clone()), this));
|
|
3454
3458
|
// ------------------------------------------
|
|
3455
3459
|
// Mathematical operations
|
|
@@ -3491,7 +3495,7 @@ const nt = class nt {
|
|
|
3491
3495
|
// }
|
|
3492
3496
|
a(this, "randomPoint", (e = 5) => {
|
|
3493
3497
|
const t = i(this, z).clone(), s = new c(X(e, !1));
|
|
3494
|
-
return new
|
|
3498
|
+
return new j(
|
|
3495
3499
|
t.x.clone().add(i(this, W).x.clone().multiply(s)),
|
|
3496
3500
|
t.y.clone().add(i(this, W).y.clone().multiply(s)),
|
|
3497
3501
|
t.z.clone().add(i(this, W).z.clone().multiply(s))
|
|
@@ -3557,8 +3561,8 @@ let wt = nt;
|
|
|
3557
3561
|
var Ae, Fe;
|
|
3558
3562
|
const ii = class ii {
|
|
3559
3563
|
constructor(e) {
|
|
3560
|
-
|
|
3561
|
-
|
|
3564
|
+
d(this, Ae, new x(0, 0, 1));
|
|
3565
|
+
d(this, Fe, new j(0, 0, 0));
|
|
3562
3566
|
return e && this.parse(e), this;
|
|
3563
3567
|
}
|
|
3564
3568
|
get normal() {
|
|
@@ -3604,18 +3608,18 @@ const ii = class ii {
|
|
|
3604
3608
|
return;
|
|
3605
3609
|
}
|
|
3606
3610
|
if (e.equation) {
|
|
3607
|
-
const n = e.equation.moveLeft().reduce().left, l = n.monomByLetter("x").coefficient, u = n.monomByLetter("y").coefficient,
|
|
3608
|
-
this.normal = new x(l, u,
|
|
3611
|
+
const n = e.equation.moveLeft().reduce().left, l = n.monomByLetter("x").coefficient, u = n.monomByLetter("y").coefficient, f = n.monomByLetter("z").coefficient, p = n.monomByDegree(0).coefficient;
|
|
3612
|
+
this.normal = new x(l, u, f), l.isNotZero() ? this.point = new j(p.clone().divide(l).opposite(), 0, 0) : u.isNotZero() ? this.point = new j(0, p.clone().divide(u).opposite(), 0) : this.point = new j(0, 0, p.clone().divide(f).opposite());
|
|
3609
3613
|
return;
|
|
3610
3614
|
}
|
|
3611
3615
|
if (((s = e.points) == null ? void 0 : s.length) === 3 && e.points.every((n) => n instanceof x)) {
|
|
3612
|
-
const n = e.points[0], l = e.points[1], u = e.points[2],
|
|
3613
|
-
this.normal =
|
|
3616
|
+
const n = e.points[0], l = e.points[1], u = e.points[2], f = new x(n, l), p = new x(n, u);
|
|
3617
|
+
this.normal = f.cross(p), this.point = n;
|
|
3614
3618
|
return;
|
|
3615
3619
|
}
|
|
3616
3620
|
if (((r = e.coefficients) == null ? void 0 : r.length) === 4) {
|
|
3617
|
-
const [n, l, u,
|
|
3618
|
-
this.normal = new x(n, l, u), this.point = new
|
|
3621
|
+
const [n, l, u, f] = e.coefficients;
|
|
3622
|
+
this.normal = new x(n, l, u), this.point = new j(0, 0, -f);
|
|
3619
3623
|
return;
|
|
3620
3624
|
}
|
|
3621
3625
|
}
|
|
@@ -3639,7 +3643,7 @@ const ii = class ii {
|
|
|
3639
3643
|
return t.clone().add(s.clone().multiplyByScalar(r));
|
|
3640
3644
|
}
|
|
3641
3645
|
intersectWithPlane(e) {
|
|
3642
|
-
throw this.normal.cross(e.normal), new
|
|
3646
|
+
throw this.normal.cross(e.normal), new j(0, 0, 0), new Error("Intersection with plane not yet implemented !");
|
|
3643
3647
|
}
|
|
3644
3648
|
isPointOnPlane(e) {
|
|
3645
3649
|
return this.normal.dot(e).add(this.d).isZero();
|
|
@@ -3650,7 +3654,7 @@ let Jt = ii;
|
|
|
3650
3654
|
var Me;
|
|
3651
3655
|
class Hi {
|
|
3652
3656
|
constructor(...e) {
|
|
3653
|
-
|
|
3657
|
+
d(this, Me, []);
|
|
3654
3658
|
return h(this, Me, e), this;
|
|
3655
3659
|
}
|
|
3656
3660
|
get values() {
|
|
@@ -3791,7 +3795,7 @@ function Oi(o) {
|
|
|
3791
3795
|
},
|
|
3792
3796
|
o
|
|
3793
3797
|
), t = e.axis === "x", s = e.axis === "y", r = e.fraction ? vt({ max: e.max, zero: t }) : new c(X(e.max, t)), n = e.fraction ? vt({ max: e.max, zero: s }) : new c(X(e.max, s));
|
|
3794
|
-
return Number(e.quadrant) === 1 && (r.abs(), n.abs()), Number(e.quadrant) === 2 && (r.isPositive() && r.opposite(), n.isNegative() && n.opposite()), Number(e.quadrant) === 3 && (r.isPositive() && r.opposite(), n.isPositive() && n.opposite()), Number(e.quadrant) === 4 && (r.isNegative() && r.opposite(), n.isPositive() && n.opposite()), new
|
|
3798
|
+
return Number(e.quadrant) === 1 && (r.abs(), n.abs()), Number(e.quadrant) === 2 && (r.isPositive() && r.opposite(), n.isNegative() && n.opposite()), Number(e.quadrant) === 3 && (r.isPositive() && r.opposite(), n.isPositive() && n.opposite()), Number(e.quadrant) === 4 && (r.isNegative() && r.opposite(), n.isPositive() && n.opposite()), new j(r, n);
|
|
3795
3799
|
}
|
|
3796
3800
|
function Qi(o) {
|
|
3797
3801
|
const e = Object.assign(
|
|
@@ -3822,7 +3826,7 @@ function Ki(o) {
|
|
|
3822
3826
|
);
|
|
3823
3827
|
for (; t.isNull; )
|
|
3824
3828
|
t.x = X(10), t.y = X(10);
|
|
3825
|
-
return e.slope === 1 ? t.x.sign() !== t.y.sign() && t.y.opposite() : e.slope === -1 && t.x.sign() !== t.y.sign() && t.y.opposite(), new
|
|
3829
|
+
return e.slope === 1 ? t.x.sign() !== t.y.sign() && t.y.opposite() : e.slope === -1 && t.x.sign() !== t.y.sign() && t.y.opposite(), new D(new x(e.A.x, e.A.y), t);
|
|
3826
3830
|
}
|
|
3827
3831
|
function Ji(o) {
|
|
3828
3832
|
const e = Object.assign(
|
|
@@ -3839,7 +3843,7 @@ function Ji(o) {
|
|
|
3839
3843
|
}
|
|
3840
3844
|
},
|
|
3841
3845
|
o
|
|
3842
|
-
), t = new
|
|
3846
|
+
), t = new j(e.A.x, e.A.y, e.A.z), s = new x(e.direction.x, e.direction.y, e.direction.z);
|
|
3843
3847
|
return new wt(t, s);
|
|
3844
3848
|
}
|
|
3845
3849
|
const _i = {
|
|
@@ -3860,8 +3864,8 @@ const _i = {
|
|
|
3860
3864
|
circle: (o) => Qi(o)
|
|
3861
3865
|
}, es = {
|
|
3862
3866
|
Vector: x,
|
|
3863
|
-
Point:
|
|
3864
|
-
Line:
|
|
3867
|
+
Point: j,
|
|
3868
|
+
Line: D,
|
|
3865
3869
|
Triangle: Kt,
|
|
3866
3870
|
Circle: yt,
|
|
3867
3871
|
Line3: wt,
|