pimath 0.0.17 → 0.0.21
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/dev/index.html +46 -9
- package/dev/pi.js +890 -806
- package/dev/pi.js.map +1 -1
- package/dist/pi.js +1 -1
- package/dist/pi.js.map +1 -1
- package/esm/maths/algebra/equation.d.ts +1 -0
- package/esm/maths/algebra/equation.js +5 -2
- package/esm/maths/algebra/equation.js.map +1 -1
- package/esm/maths/algebra/monom.d.ts +1 -1
- package/esm/maths/algebra/monom.js +27 -18
- package/esm/maths/algebra/monom.js.map +1 -1
- package/esm/maths/algebra/polynom.d.ts +0 -1
- package/esm/maths/algebra/polynom.js +7 -11
- package/esm/maths/algebra/polynom.js.map +1 -1
- package/esm/maths/geometry/circle.d.ts +16 -1
- package/esm/maths/geometry/circle.js +89 -12
- package/esm/maths/geometry/circle.js.map +1 -1
- package/esm/maths/geometry/line.d.ts +20 -4
- package/esm/maths/geometry/line.js +109 -39
- package/esm/maths/geometry/line.js.map +1 -1
- package/esm/maths/geometry/point.d.ts +1 -0
- package/esm/maths/geometry/point.js +6 -0
- package/esm/maths/geometry/point.js.map +1 -1
- package/esm/maths/geometry/vector.d.ts +0 -1
- package/esm/maths/geometry/vector.js +1 -4
- package/esm/maths/geometry/vector.js.map +1 -1
- package/esm/maths/random/rndFraction.js +8 -2
- package/esm/maths/random/rndFraction.js.map +1 -1
- package/esm/maths/random/rndMonom.js +2 -1
- package/esm/maths/random/rndMonom.js.map +1 -1
- package/esm/maths/random/rndTypes.d.ts +1 -0
- package/package.json +1 -1
- package/src/maths/algebra/equation.ts +7 -2
- package/src/maths/algebra/monom.ts +40 -25
- package/src/maths/algebra/polynom.ts +9 -13
- package/src/maths/geometry/circle.ts +133 -21
- package/src/maths/geometry/line.ts +161 -57
- package/src/maths/geometry/point.ts +9 -0
- package/src/maths/geometry/vector.ts +1 -5
- package/src/maths/random/rndFraction.ts +7 -2
- package/src/maths/random/rndMonom.ts +2 -1
- package/src/maths/random/rndTypes.ts +2 -1
- package/tests/algebra/monom.test.ts +25 -7
- package/tsconfig.json +1 -1
package/dev/pi.js
CHANGED
|
@@ -6,19 +6,15 @@
|
|
|
6
6
|
/*!***************************************!*\
|
|
7
7
|
!*** ./src/maths/algebra/equation.ts ***!
|
|
8
8
|
\***************************************/
|
|
9
|
-
/***/ ((__unused_webpack_module,
|
|
9
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
10
10
|
|
|
11
|
-
__webpack_require__.r(__webpack_exports__);
|
|
12
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
13
|
-
/* harmony export */ "Equation": () => (/* binding */ Equation)
|
|
14
|
-
/* harmony export */ });
|
|
15
|
-
/* harmony import */ var _polynom__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./polynom */ "./src/maths/algebra/polynom.ts");
|
|
16
|
-
/* harmony import */ var _numeric__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
17
|
-
/* harmony import */ var _coefficients__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../coefficients */ "./src/maths/coefficients/index.ts");
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
11
|
|
|
12
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
13
|
+
exports.Equation = void 0;
|
|
14
|
+
const polynom_1 = __webpack_require__(/*! ./polynom */ "./src/maths/algebra/polynom.ts");
|
|
15
|
+
const numeric_1 = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
16
|
+
const coefficients_1 = __webpack_require__(/*! ../coefficients */ "./src/maths/coefficients/index.ts");
|
|
17
|
+
const coefficients_2 = __webpack_require__(/*! ../coefficients */ "./src/maths/coefficients/index.ts");
|
|
22
18
|
class Equation {
|
|
23
19
|
_left;
|
|
24
20
|
_right;
|
|
@@ -28,8 +24,8 @@ class Equation {
|
|
|
28
24
|
_varnothing = '\\varnothing';
|
|
29
25
|
_real = '\\mathbb{R}';
|
|
30
26
|
constructor(...equations) {
|
|
31
|
-
this._left = new
|
|
32
|
-
this._right = new
|
|
27
|
+
this._left = new polynom_1.Polynom().zero();
|
|
28
|
+
this._right = new polynom_1.Polynom().zero();
|
|
33
29
|
this._sign = '=';
|
|
34
30
|
if (equations.length === 1) {
|
|
35
31
|
if (equations[0].isEquation === true) {
|
|
@@ -40,8 +36,8 @@ class Equation {
|
|
|
40
36
|
}
|
|
41
37
|
}
|
|
42
38
|
else if (equations.length === 2) {
|
|
43
|
-
this.left = equations[0].
|
|
44
|
-
this.right = equations[1].
|
|
39
|
+
this.left = (equations[0] instanceof polynom_1.Polynom) ? equations[0].clone() : new polynom_1.Polynom(equations[0]);
|
|
40
|
+
this.right = (equations[1] instanceof polynom_1.Polynom) ? equations[1].clone() : new polynom_1.Polynom(equations[1]);
|
|
45
41
|
}
|
|
46
42
|
else {
|
|
47
43
|
return this;
|
|
@@ -88,6 +84,9 @@ class Equation {
|
|
|
88
84
|
get tex() {
|
|
89
85
|
return `${this._left.tex}${this.signAsTex}${this._right.tex}`;
|
|
90
86
|
}
|
|
87
|
+
get display() {
|
|
88
|
+
return `${this._left.display}${this.signAsTex}${this._right.display}`;
|
|
89
|
+
}
|
|
91
90
|
get raw() {
|
|
92
91
|
return `${this._left.raw}${this.signAsTex}${this._right.raw}`;
|
|
93
92
|
}
|
|
@@ -123,7 +122,7 @@ class Equation {
|
|
|
123
122
|
return;
|
|
124
123
|
}
|
|
125
124
|
pStr = equationString.split(strSign);
|
|
126
|
-
return this.create(new
|
|
125
|
+
return this.create(new polynom_1.Polynom(pStr[0]), new polynom_1.Polynom(pStr[1]), this._formatSign(strSign));
|
|
127
126
|
};
|
|
128
127
|
_findSign = (equationString) => {
|
|
129
128
|
let strSign = '';
|
|
@@ -224,7 +223,7 @@ class Equation {
|
|
|
224
223
|
this._randomizeDefaults = value;
|
|
225
224
|
}
|
|
226
225
|
randomize = (opts, sign) => {
|
|
227
|
-
return new Equation().create(new
|
|
226
|
+
return new Equation().create(new polynom_1.Polynom(), new polynom_1.Polynom(), sign);
|
|
228
227
|
};
|
|
229
228
|
moveLeft = () => {
|
|
230
229
|
this._left = this._left.clone().subtract(this._right);
|
|
@@ -239,7 +238,7 @@ class Equation {
|
|
|
239
238
|
}
|
|
240
239
|
let mMove;
|
|
241
240
|
for (let m of this._left.monoms) {
|
|
242
|
-
if (m.degree()
|
|
241
|
+
if (m.degree().isZero()) {
|
|
243
242
|
mMove = m.clone();
|
|
244
243
|
this._left.subtract(mMove);
|
|
245
244
|
this._right.subtract(mMove);
|
|
@@ -250,12 +249,12 @@ class Equation {
|
|
|
250
249
|
return this;
|
|
251
250
|
};
|
|
252
251
|
simplify = () => {
|
|
253
|
-
this.multiply(
|
|
254
|
-
this.divide(
|
|
252
|
+
this.multiply(numeric_1.Numeric.lcm(...this._left.getDenominators(), ...this._right.getDenominators()));
|
|
253
|
+
this.divide(numeric_1.Numeric.gcd(...this._left.getNumerators(), ...this._right.getNumerators()));
|
|
255
254
|
return this;
|
|
256
255
|
};
|
|
257
256
|
isolate = (letter) => {
|
|
258
|
-
if (this.degree(letter)
|
|
257
|
+
if (!this.degree(letter).isOne()) {
|
|
259
258
|
return false;
|
|
260
259
|
}
|
|
261
260
|
if (this.isMultiVariable()) {
|
|
@@ -285,7 +284,7 @@ class Equation {
|
|
|
285
284
|
return this;
|
|
286
285
|
};
|
|
287
286
|
multiply = (value) => {
|
|
288
|
-
let F = new
|
|
287
|
+
let F = new coefficients_1.Fraction(value);
|
|
289
288
|
this._left.multiply(F);
|
|
290
289
|
this._right.multiply(F);
|
|
291
290
|
if (this._sign !== '=' && F.sign() === -1) {
|
|
@@ -294,7 +293,7 @@ class Equation {
|
|
|
294
293
|
return this;
|
|
295
294
|
};
|
|
296
295
|
divide = (value) => {
|
|
297
|
-
let F = new
|
|
296
|
+
let F = new coefficients_1.Fraction(value);
|
|
298
297
|
if (F.isZero()) {
|
|
299
298
|
return this;
|
|
300
299
|
}
|
|
@@ -303,7 +302,7 @@ class Equation {
|
|
|
303
302
|
}
|
|
304
303
|
};
|
|
305
304
|
degree = (letter) => {
|
|
306
|
-
return
|
|
305
|
+
return coefficients_1.Fraction.max(this._left.degree(letter), this._right.degree(letter));
|
|
307
306
|
};
|
|
308
307
|
isMultiVariable = () => {
|
|
309
308
|
return this._left.isMultiVariable || this._right.isMultiVariable;
|
|
@@ -314,7 +313,7 @@ class Equation {
|
|
|
314
313
|
solve = (letter) => {
|
|
315
314
|
this._solutions = [];
|
|
316
315
|
this._polynom = this._left.clone().subtract(this._right);
|
|
317
|
-
switch (this._polynom.degree(letter)) {
|
|
316
|
+
switch (this._polynom.degree(letter).value) {
|
|
318
317
|
case 0:
|
|
319
318
|
case 1:
|
|
320
319
|
this._solveDegree1(letter);
|
|
@@ -390,7 +389,7 @@ class Equation {
|
|
|
390
389
|
return this._solutions;
|
|
391
390
|
};
|
|
392
391
|
_solveDegree2 = (letter) => {
|
|
393
|
-
let aF = this._polynom.monomByDegree(2, letter).coefficient, bF = this._polynom.monomByDegree(1, letter).coefficient, cF = this._polynom.monomByDegree(0, letter).coefficient, delta, nthDelta, lcm =
|
|
392
|
+
let aF = this._polynom.monomByDegree(2, letter).coefficient, bF = this._polynom.monomByDegree(1, letter).coefficient, cF = this._polynom.monomByDegree(0, letter).coefficient, delta, nthDelta, lcm = numeric_1.Numeric.lcm(aF.denominator, bF.denominator, cF.denominator), a = aF.multiply(lcm).value, b = bF.multiply(lcm).value, c = cF.multiply(lcm).value, realX1, realX2, sX1, sX2;
|
|
394
393
|
delta = b * b - 4 * a * c;
|
|
395
394
|
if (delta > 0) {
|
|
396
395
|
realX1 = (-b - Math.sqrt(delta)) / (2 * a);
|
|
@@ -402,9 +401,9 @@ class Equation {
|
|
|
402
401
|
];
|
|
403
402
|
}
|
|
404
403
|
else {
|
|
405
|
-
nthDelta = new
|
|
404
|
+
nthDelta = new coefficients_2.Nthroot().parse(delta).reduce();
|
|
406
405
|
if (nthDelta.hasRadical()) {
|
|
407
|
-
let gcd =
|
|
406
|
+
let gcd = numeric_1.Numeric.gcd(b, 2 * a, nthDelta.coefficient);
|
|
408
407
|
nthDelta.coefficient = nthDelta.coefficient / gcd;
|
|
409
408
|
if (b !== 0) {
|
|
410
409
|
if (2 * a / gcd === 1) {
|
|
@@ -437,14 +436,14 @@ class Equation {
|
|
|
437
436
|
}
|
|
438
437
|
else {
|
|
439
438
|
this._solutions = [
|
|
440
|
-
new
|
|
441
|
-
new
|
|
439
|
+
new coefficients_1.Fraction(-b - nthDelta.coefficient, 2 * a).reduce().dfrac,
|
|
440
|
+
new coefficients_1.Fraction(-b + nthDelta.coefficient, 2 * a).reduce().dfrac
|
|
442
441
|
];
|
|
443
442
|
}
|
|
444
443
|
}
|
|
445
444
|
}
|
|
446
445
|
else if (delta === 0) {
|
|
447
|
-
this._solutions = [new
|
|
446
|
+
this._solutions = [new coefficients_1.Fraction(-b, 2 * a).reduce().dfrac];
|
|
448
447
|
}
|
|
449
448
|
else {
|
|
450
449
|
this._solutions = [this._varnothing];
|
|
@@ -499,6 +498,7 @@ class Equation {
|
|
|
499
498
|
return this._solutions;
|
|
500
499
|
};
|
|
501
500
|
}
|
|
501
|
+
exports.Equation = Equation;
|
|
502
502
|
|
|
503
503
|
|
|
504
504
|
/***/ }),
|
|
@@ -507,57 +507,26 @@ class Equation {
|
|
|
507
507
|
/*!************************************!*\
|
|
508
508
|
!*** ./src/maths/algebra/index.ts ***!
|
|
509
509
|
\************************************/
|
|
510
|
-
/***/ ((__unused_webpack_module,
|
|
510
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
511
511
|
|
|
512
|
-
__webpack_require__.r(__webpack_exports__);
|
|
513
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
514
|
-
/* harmony export */ "Equation": () => (/* reexport safe */ _equation__WEBPACK_IMPORTED_MODULE_0__.Equation),
|
|
515
|
-
/* harmony export */ "LinearSystem": () => (/* reexport safe */ _linearSystem__WEBPACK_IMPORTED_MODULE_1__.LinearSystem),
|
|
516
|
-
/* harmony export */ "Logicalset": () => (/* reexport safe */ _logicalset__WEBPACK_IMPORTED_MODULE_2__.Logicalset),
|
|
517
|
-
/* harmony export */ "Monom": () => (/* reexport safe */ _monom__WEBPACK_IMPORTED_MODULE_3__.Monom),
|
|
518
|
-
/* harmony export */ "Polynom": () => (/* reexport safe */ _polynom__WEBPACK_IMPORTED_MODULE_4__.Polynom),
|
|
519
|
-
/* harmony export */ "Rational": () => (/* reexport safe */ _rational__WEBPACK_IMPORTED_MODULE_5__.Rational),
|
|
520
|
-
/* harmony export */ "Algebra": () => (/* binding */ Algebra)
|
|
521
|
-
/* harmony export */ });
|
|
522
|
-
/* harmony import */ var _equation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./equation */ "./src/maths/algebra/equation.ts");
|
|
523
|
-
/* harmony import */ var _linearSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./linearSystem */ "./src/maths/algebra/linearSystem.ts");
|
|
524
|
-
/* harmony import */ var _logicalset__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./logicalset */ "./src/maths/algebra/logicalset.ts");
|
|
525
|
-
/* harmony import */ var _monom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./monom */ "./src/maths/algebra/monom.ts");
|
|
526
|
-
/* harmony import */ var _polynom__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./polynom */ "./src/maths/algebra/polynom.ts");
|
|
527
|
-
/* harmony import */ var _rational__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./rational */ "./src/maths/algebra/rational.ts");
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
512
|
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
}
|
|
553
|
-
Algebra.Equation = Equation;
|
|
554
|
-
class LogicalSet extends _logicalset__WEBPACK_IMPORTED_MODULE_2__.Logicalset {
|
|
555
|
-
}
|
|
556
|
-
Algebra.LogicalSet = LogicalSet;
|
|
557
|
-
class Rational extends _rational__WEBPACK_IMPORTED_MODULE_5__.Rational {
|
|
558
|
-
}
|
|
559
|
-
Algebra.Rational = Rational;
|
|
560
|
-
})(Algebra || (Algebra = {}));
|
|
513
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
514
|
+
if (k2 === undefined) k2 = k;
|
|
515
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
516
|
+
}) : (function(o, m, k, k2) {
|
|
517
|
+
if (k2 === undefined) k2 = k;
|
|
518
|
+
o[k2] = m[k];
|
|
519
|
+
}));
|
|
520
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
521
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
522
|
+
};
|
|
523
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
524
|
+
__exportStar(__webpack_require__(/*! ./equation */ "./src/maths/algebra/equation.ts"), exports);
|
|
525
|
+
__exportStar(__webpack_require__(/*! ./linearSystem */ "./src/maths/algebra/linearSystem.ts"), exports);
|
|
526
|
+
__exportStar(__webpack_require__(/*! ./logicalset */ "./src/maths/algebra/logicalset.ts"), exports);
|
|
527
|
+
__exportStar(__webpack_require__(/*! ./monom */ "./src/maths/algebra/monom.ts"), exports);
|
|
528
|
+
__exportStar(__webpack_require__(/*! ./polynom */ "./src/maths/algebra/polynom.ts"), exports);
|
|
529
|
+
__exportStar(__webpack_require__(/*! ./rational */ "./src/maths/algebra/rational.ts"), exports);
|
|
561
530
|
|
|
562
531
|
|
|
563
532
|
/***/ }),
|
|
@@ -566,20 +535,15 @@ var Algebra;
|
|
|
566
535
|
/*!*******************************************!*\
|
|
567
536
|
!*** ./src/maths/algebra/linearSystem.ts ***!
|
|
568
537
|
\*******************************************/
|
|
569
|
-
/***/ ((__unused_webpack_module,
|
|
538
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
570
539
|
|
|
571
|
-
__webpack_require__.r(__webpack_exports__);
|
|
572
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
573
|
-
/* harmony export */ "LinearSystem": () => (/* binding */ LinearSystem)
|
|
574
|
-
/* harmony export */ });
|
|
575
|
-
/* harmony import */ var _coefficients__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../coefficients */ "./src/maths/coefficients/index.ts");
|
|
576
|
-
/* harmony import */ var _equation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./equation */ "./src/maths/algebra/equation.ts");
|
|
577
|
-
/* harmony import */ var _polynom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./polynom */ "./src/maths/algebra/polynom.ts");
|
|
578
|
-
/* harmony import */ var _random__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../random */ "./src/maths/random/index.ts");
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
540
|
|
|
541
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
542
|
+
exports.LinearSystem = void 0;
|
|
543
|
+
const coefficients_1 = __webpack_require__(/*! ../coefficients */ "./src/maths/coefficients/index.ts");
|
|
544
|
+
const equation_1 = __webpack_require__(/*! ./equation */ "./src/maths/algebra/equation.ts");
|
|
545
|
+
const polynom_1 = __webpack_require__(/*! ./polynom */ "./src/maths/algebra/polynom.ts");
|
|
546
|
+
const random_1 = __webpack_require__(/*! ../random */ "./src/maths/random/index.ts");
|
|
583
547
|
class LinearSystem {
|
|
584
548
|
_solutions;
|
|
585
549
|
_resolutionSteps;
|
|
@@ -593,7 +557,7 @@ class LinearSystem {
|
|
|
593
557
|
}
|
|
594
558
|
return this;
|
|
595
559
|
}
|
|
596
|
-
get
|
|
560
|
+
get isLinearSystem() {
|
|
597
561
|
return true;
|
|
598
562
|
}
|
|
599
563
|
get equations() {
|
|
@@ -660,7 +624,7 @@ class LinearSystem {
|
|
|
660
624
|
return `(${tex.join(';')})`;
|
|
661
625
|
}
|
|
662
626
|
parse = (...equations) => {
|
|
663
|
-
this._equations = equations.map(value => new
|
|
627
|
+
this._equations = equations.map(value => new equation_1.Equation(value));
|
|
664
628
|
this._findLetters();
|
|
665
629
|
return this;
|
|
666
630
|
};
|
|
@@ -668,7 +632,7 @@ class LinearSystem {
|
|
|
668
632
|
this._equations = [];
|
|
669
633
|
let i = 0;
|
|
670
634
|
while (i < coefficients.length - this._letters.length) {
|
|
671
|
-
let left = new
|
|
635
|
+
let left = new polynom_1.Polynom().parse(this._letters.join(''), ...coefficients.slice(i, i + this._letters.length)), right = new polynom_1.Polynom(coefficients[i + this._letters.length].toString()), equ = new equation_1.Equation().create(left, right);
|
|
672
636
|
this._equations.push(equ.clone());
|
|
673
637
|
i = i + this._letters.length + 1;
|
|
674
638
|
}
|
|
@@ -693,7 +657,7 @@ class LinearSystem {
|
|
|
693
657
|
let solutionsF = [];
|
|
694
658
|
for (let s of solutions) {
|
|
695
659
|
if (typeof s === "number") {
|
|
696
|
-
solutionsF.push(new
|
|
660
|
+
solutionsF.push(new coefficients_1.Fraction(s.toString()));
|
|
697
661
|
}
|
|
698
662
|
else {
|
|
699
663
|
solutionsF.push(s.clone());
|
|
@@ -706,15 +670,15 @@ class LinearSystem {
|
|
|
706
670
|
return this;
|
|
707
671
|
};
|
|
708
672
|
_generateOneEquation = (...solutions) => {
|
|
709
|
-
let coeff = [], leftValue = new
|
|
673
|
+
let coeff = [], leftValue = new coefficients_1.Fraction().zero(), letters = ['x', 'y', 'z', 't', 'u', 'v', 'w', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'], equString = '', equ;
|
|
710
674
|
for (let i = 0; i < solutions.length; i++) {
|
|
711
|
-
coeff.push(
|
|
675
|
+
coeff.push(random_1.Random.numberSym(5));
|
|
712
676
|
leftValue.add(solutions[i].clone().multiply(coeff[i]));
|
|
713
677
|
equString += `${(coeff[i] < 0) ? coeff[i] : '+' + coeff[i]}${letters[i]}`;
|
|
714
678
|
}
|
|
715
|
-
equ = new
|
|
679
|
+
equ = new equation_1.Equation(`${equString}=${leftValue.display}`);
|
|
716
680
|
if (equ.right.monoms[0].coefficient.denominator != 1) {
|
|
717
|
-
equ.multiply(new
|
|
681
|
+
equ.multiply(new coefficients_1.Fraction(equ.right.monoms[0].coefficient.denominator, 1));
|
|
718
682
|
}
|
|
719
683
|
if (this._checkIfLinerCombination(equ)) {
|
|
720
684
|
return equ;
|
|
@@ -728,7 +692,7 @@ class LinearSystem {
|
|
|
728
692
|
return this.mergeEquations(eq1, eq2, c2, c1);
|
|
729
693
|
}
|
|
730
694
|
mergeEquations = (eq1, eq2, factor1, factor2) => {
|
|
731
|
-
let eq1multiplied = eq1.clone().multiply(new
|
|
695
|
+
let eq1multiplied = eq1.clone().multiply(new coefficients_1.Fraction(factor1)), eq2multiplied = eq2.clone().multiply(new coefficients_1.Fraction(factor2));
|
|
732
696
|
eq1multiplied.left.add(eq2multiplied.left);
|
|
733
697
|
eq1multiplied.right.add(eq2multiplied.right);
|
|
734
698
|
return eq1multiplied;
|
|
@@ -768,7 +732,7 @@ class LinearSystem {
|
|
|
768
732
|
let E = this._resolutionSteps[this._resolutionSteps.length - 1].equations[0];
|
|
769
733
|
E.solve();
|
|
770
734
|
return {
|
|
771
|
-
value: new
|
|
735
|
+
value: new coefficients_1.Fraction(E.solutions[0]),
|
|
772
736
|
isReal: E.isReal,
|
|
773
737
|
isVarnothing: E.isVarnothing
|
|
774
738
|
};
|
|
@@ -782,6 +746,7 @@ class LinearSystem {
|
|
|
782
746
|
return str;
|
|
783
747
|
};
|
|
784
748
|
}
|
|
749
|
+
exports.LinearSystem = LinearSystem;
|
|
785
750
|
|
|
786
751
|
|
|
787
752
|
/***/ }),
|
|
@@ -790,14 +755,12 @@ class LinearSystem {
|
|
|
790
755
|
/*!*****************************************!*\
|
|
791
756
|
!*** ./src/maths/algebra/logicalset.ts ***!
|
|
792
757
|
\*****************************************/
|
|
793
|
-
/***/ ((__unused_webpack_module,
|
|
758
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
794
759
|
|
|
795
|
-
__webpack_require__.r(__webpack_exports__);
|
|
796
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
797
|
-
/* harmony export */ "Logicalset": () => (/* binding */ Logicalset)
|
|
798
|
-
/* harmony export */ });
|
|
799
|
-
/* harmony import */ var _shutingyard__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../shutingyard */ "./src/maths/shutingyard.ts");
|
|
800
760
|
|
|
761
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
762
|
+
exports.Logicalset = void 0;
|
|
763
|
+
const shutingyard_1 = __webpack_require__(/*! ../shutingyard */ "./src/maths/shutingyard.ts");
|
|
801
764
|
class Logicalset {
|
|
802
765
|
_rawString;
|
|
803
766
|
_rpn;
|
|
@@ -811,7 +774,7 @@ class Logicalset {
|
|
|
811
774
|
}
|
|
812
775
|
;
|
|
813
776
|
parse = (value) => {
|
|
814
|
-
this._rpn = new
|
|
777
|
+
this._rpn = new shutingyard_1.Shutingyard('set').parse(value).rpn;
|
|
815
778
|
return this;
|
|
816
779
|
};
|
|
817
780
|
evaluate(tokenSets, reference) {
|
|
@@ -938,6 +901,7 @@ class Logicalset {
|
|
|
938
901
|
return varStack[0].token;
|
|
939
902
|
}
|
|
940
903
|
}
|
|
904
|
+
exports.Logicalset = Logicalset;
|
|
941
905
|
|
|
942
906
|
|
|
943
907
|
/***/ }),
|
|
@@ -946,16 +910,14 @@ class Logicalset {
|
|
|
946
910
|
/*!************************************!*\
|
|
947
911
|
!*** ./src/maths/algebra/monom.ts ***!
|
|
948
912
|
\************************************/
|
|
949
|
-
/***/ ((__unused_webpack_module,
|
|
913
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
950
914
|
|
|
951
|
-
__webpack_require__.r(__webpack_exports__);
|
|
952
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
953
|
-
/* harmony export */ "Monom": () => (/* binding */ Monom)
|
|
954
|
-
/* harmony export */ });
|
|
955
|
-
/* harmony import */ var _coefficients_fraction__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
956
|
-
/* harmony import */ var _numeric__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
957
|
-
|
|
958
915
|
|
|
916
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
917
|
+
exports.Monom = void 0;
|
|
918
|
+
const coefficients_1 = __webpack_require__(/*! ../coefficients */ "./src/maths/coefficients/index.ts");
|
|
919
|
+
const numeric_1 = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
920
|
+
const shutingyard_1 = __webpack_require__(/*! ../shutingyard */ "./src/maths/shutingyard.ts");
|
|
959
921
|
class Monom {
|
|
960
922
|
_coefficient;
|
|
961
923
|
_literal;
|
|
@@ -966,9 +928,6 @@ class Monom {
|
|
|
966
928
|
}
|
|
967
929
|
return this;
|
|
968
930
|
}
|
|
969
|
-
get isMonom() {
|
|
970
|
-
return true;
|
|
971
|
-
}
|
|
972
931
|
get coefficient() {
|
|
973
932
|
return this._coefficient;
|
|
974
933
|
}
|
|
@@ -979,10 +938,10 @@ class Monom {
|
|
|
979
938
|
return this._literal;
|
|
980
939
|
}
|
|
981
940
|
get literalSqrt() {
|
|
982
|
-
if (this.
|
|
941
|
+
if (this.isLiteralSquare()) {
|
|
983
942
|
let L = {};
|
|
984
943
|
for (let key in this._literal) {
|
|
985
|
-
L[key] = this._literal[key]
|
|
944
|
+
L[key] = this._literal[key].clone().sqrt();
|
|
986
945
|
}
|
|
987
946
|
return L;
|
|
988
947
|
}
|
|
@@ -996,15 +955,15 @@ class Monom {
|
|
|
996
955
|
set literalStr(inputStr) {
|
|
997
956
|
for (const v of [...inputStr.matchAll(/([a-z])\^([+-]?[0-9]+)/g)]) {
|
|
998
957
|
if (!(v[1] in this._literal)) {
|
|
999
|
-
this._literal[v[1]] =
|
|
958
|
+
this._literal[v[1]] = new coefficients_1.Fraction().zero();
|
|
1000
959
|
}
|
|
1001
|
-
this._literal[v[1]]
|
|
960
|
+
this._literal[v[1]].add(+v[2]);
|
|
1002
961
|
}
|
|
1003
962
|
for (const v of [...inputStr.matchAll(/([a-z](?!\^))/g)]) {
|
|
1004
963
|
if (!(v[1] in this._literal)) {
|
|
1005
|
-
this._literal[v[1]] =
|
|
964
|
+
this._literal[v[1]] = new coefficients_1.Fraction().zero();
|
|
1006
965
|
}
|
|
1007
|
-
this._literal[v[1]]
|
|
966
|
+
this._literal[v[1]].add(1);
|
|
1008
967
|
}
|
|
1009
968
|
}
|
|
1010
969
|
get variables() {
|
|
@@ -1012,12 +971,12 @@ class Monom {
|
|
|
1012
971
|
return Object.keys(this._literal);
|
|
1013
972
|
}
|
|
1014
973
|
get display() {
|
|
1015
|
-
let L = '';
|
|
1016
|
-
for (let letter
|
|
1017
|
-
if (this._literal[letter]
|
|
974
|
+
let L = '', letters = Object.keys(this._literal).sort();
|
|
975
|
+
for (let letter of letters) {
|
|
976
|
+
if (this._literal[letter].isNotZero()) {
|
|
1018
977
|
L += `${letter}`;
|
|
1019
|
-
if (this._literal[letter]
|
|
1020
|
-
L += `^${this._literal[letter]}`;
|
|
978
|
+
if (this._literal[letter].isNotEqual(1)) {
|
|
979
|
+
L += `^${this._literal[letter].display}`;
|
|
1021
980
|
}
|
|
1022
981
|
}
|
|
1023
982
|
}
|
|
@@ -1048,29 +1007,32 @@ class Monom {
|
|
|
1048
1007
|
if (this.coefficient.denominator !== 1) {
|
|
1049
1008
|
return [this.clone()];
|
|
1050
1009
|
}
|
|
1010
|
+
if (this.hasFractionCoefficient) {
|
|
1011
|
+
return [this.clone()];
|
|
1012
|
+
}
|
|
1051
1013
|
if (this.coefficient.numerator > 10000) {
|
|
1052
1014
|
return [this.clone()];
|
|
1053
1015
|
}
|
|
1054
|
-
const dividers =
|
|
1055
|
-
let
|
|
1016
|
+
const dividers = numeric_1.Numeric.dividers(Math.abs(this.coefficient.numerator));
|
|
1017
|
+
let literals = [];
|
|
1056
1018
|
for (let L in this.literal) {
|
|
1057
|
-
|
|
1019
|
+
literals = this._getLiteralDividers(literals, L);
|
|
1058
1020
|
}
|
|
1059
1021
|
const monomDividers = [];
|
|
1060
|
-
if (
|
|
1022
|
+
if (literals.length > 0 && dividers.length > 0) {
|
|
1061
1023
|
for (let N of dividers) {
|
|
1062
|
-
for (let L of
|
|
1024
|
+
for (let L of literals) {
|
|
1063
1025
|
let M = new Monom();
|
|
1064
|
-
M.coefficient = new
|
|
1026
|
+
M.coefficient = new coefficients_1.Fraction(N);
|
|
1065
1027
|
M.literal = L;
|
|
1066
1028
|
monomDividers.push(M);
|
|
1067
1029
|
}
|
|
1068
1030
|
}
|
|
1069
1031
|
}
|
|
1070
1032
|
else if (dividers.length === 0) {
|
|
1071
|
-
for (let L of
|
|
1033
|
+
for (let L of literals) {
|
|
1072
1034
|
let M = new Monom();
|
|
1073
|
-
M.coefficient = new
|
|
1035
|
+
M.coefficient = new coefficients_1.Fraction().one();
|
|
1074
1036
|
M.literal = L;
|
|
1075
1037
|
monomDividers.push(M);
|
|
1076
1038
|
}
|
|
@@ -1078,18 +1040,18 @@ class Monom {
|
|
|
1078
1040
|
else {
|
|
1079
1041
|
for (let N of dividers) {
|
|
1080
1042
|
let M = new Monom();
|
|
1081
|
-
M.coefficient = new
|
|
1043
|
+
M.coefficient = new coefficients_1.Fraction(N);
|
|
1082
1044
|
monomDividers.push(M);
|
|
1083
1045
|
}
|
|
1084
1046
|
}
|
|
1085
1047
|
return monomDividers.length === 0 ? [new Monom().one()] : monomDividers;
|
|
1086
1048
|
}
|
|
1087
|
-
|
|
1049
|
+
_getLiteralDividers(arr, letter) {
|
|
1088
1050
|
let tmpList = [];
|
|
1089
|
-
for (let d = 0; d <= this.literal[letter]; d++) {
|
|
1051
|
+
for (let d = 0; d <= this.literal[letter].value; d++) {
|
|
1090
1052
|
if (arr.length === 0) {
|
|
1091
1053
|
let litt = {};
|
|
1092
|
-
litt[letter] = d;
|
|
1054
|
+
litt[letter] = new coefficients_1.Fraction(d);
|
|
1093
1055
|
tmpList.push(litt);
|
|
1094
1056
|
}
|
|
1095
1057
|
else {
|
|
@@ -1098,7 +1060,7 @@ class Monom {
|
|
|
1098
1060
|
for (let currentLetter in item) {
|
|
1099
1061
|
litt[currentLetter] = item[currentLetter];
|
|
1100
1062
|
}
|
|
1101
|
-
litt[letter] = d;
|
|
1063
|
+
litt[letter] = new coefficients_1.Fraction(d);
|
|
1102
1064
|
tmpList.push(litt);
|
|
1103
1065
|
}
|
|
1104
1066
|
}
|
|
@@ -1110,12 +1072,12 @@ class Monom {
|
|
|
1110
1072
|
return (d[0] !== '-' ? '+' : '') + d;
|
|
1111
1073
|
}
|
|
1112
1074
|
get tex() {
|
|
1113
|
-
let L = '';
|
|
1114
|
-
for (let letter
|
|
1115
|
-
if (this._literal[letter]
|
|
1075
|
+
let L = '', letters = Object.keys(this._literal).sort();
|
|
1076
|
+
for (let letter of letters) {
|
|
1077
|
+
if (this._literal[letter].isNotZero()) {
|
|
1116
1078
|
L += `${letter}`;
|
|
1117
|
-
if (this._literal[letter]
|
|
1118
|
-
L +=
|
|
1079
|
+
if (this._literal[letter].isNotEqual(1)) {
|
|
1080
|
+
L += `^{${this._literal[letter].display}}`;
|
|
1119
1081
|
}
|
|
1120
1082
|
}
|
|
1121
1083
|
}
|
|
@@ -1143,37 +1105,96 @@ class Monom {
|
|
|
1143
1105
|
}
|
|
1144
1106
|
}
|
|
1145
1107
|
parse = (inputStr) => {
|
|
1146
|
-
this.
|
|
1147
|
-
this
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1108
|
+
this._shutingYardToReducedMonom(inputStr);
|
|
1109
|
+
return this;
|
|
1110
|
+
};
|
|
1111
|
+
_shutingYardToReducedMonom = (inputStr) => {
|
|
1112
|
+
const SY = new shutingyard_1.Shutingyard().parse(inputStr);
|
|
1113
|
+
const rpn = SY.rpn;
|
|
1114
|
+
let stack = [], m, pow, letter, q1, q2;
|
|
1115
|
+
if (rpn.length === 0) {
|
|
1116
|
+
this.zero();
|
|
1117
|
+
return this;
|
|
1118
|
+
}
|
|
1119
|
+
else if (rpn.length === 1) {
|
|
1120
|
+
const element = rpn[0];
|
|
1121
|
+
this.one();
|
|
1122
|
+
if (element.tokenType === 'coefficient') {
|
|
1123
|
+
this.coefficient = new coefficients_1.Fraction(element.token);
|
|
1124
|
+
}
|
|
1125
|
+
else if (element.tokenType === 'variable') {
|
|
1126
|
+
this.setLetter(element.token, 1);
|
|
1127
|
+
}
|
|
1128
|
+
return this;
|
|
1129
|
+
}
|
|
1130
|
+
else {
|
|
1131
|
+
for (const element of rpn) {
|
|
1132
|
+
if (element.tokenType === 'coefficient') {
|
|
1133
|
+
let M = new Monom().one();
|
|
1134
|
+
M.coefficient = new coefficients_1.Fraction(element.token);
|
|
1135
|
+
stack.push(M.clone());
|
|
1136
|
+
}
|
|
1137
|
+
else if (element.tokenType === 'variable') {
|
|
1138
|
+
let M = new Monom().one();
|
|
1139
|
+
M.setLetter(element.token, 1);
|
|
1140
|
+
stack.push(M.clone());
|
|
1141
|
+
}
|
|
1142
|
+
else if (element.tokenType === 'operation') {
|
|
1143
|
+
switch (element.token) {
|
|
1144
|
+
case '-':
|
|
1145
|
+
q2 = (stack.pop()) || new Monom().zero();
|
|
1146
|
+
q1 = (stack.pop()) || new Monom().zero();
|
|
1147
|
+
stack.push(q1.subtract(q2));
|
|
1148
|
+
break;
|
|
1149
|
+
case '*':
|
|
1150
|
+
q2 = (stack.pop()) || new Monom().one();
|
|
1151
|
+
q1 = (stack.pop()) || new Monom().one();
|
|
1152
|
+
stack.push(q1.multiply(q2));
|
|
1153
|
+
break;
|
|
1154
|
+
case '^':
|
|
1155
|
+
pow = (stack.pop().coefficient) || new coefficients_1.Fraction().one();
|
|
1156
|
+
m = (stack.pop()) || new Monom().one();
|
|
1157
|
+
letter = m.variables[0];
|
|
1158
|
+
if (letter !== undefined) {
|
|
1159
|
+
m.setLetter(letter, pow);
|
|
1160
|
+
}
|
|
1161
|
+
stack.push(m);
|
|
1162
|
+
break;
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1151
1165
|
}
|
|
1152
|
-
this._coefficient.multiply(new _coefficients_fraction__WEBPACK_IMPORTED_MODULE_0__.Fraction(v.trim()));
|
|
1153
1166
|
}
|
|
1167
|
+
this.one();
|
|
1168
|
+
this.multiply(stack[0]);
|
|
1154
1169
|
return this;
|
|
1155
1170
|
};
|
|
1156
1171
|
clone = () => {
|
|
1157
1172
|
let F = new Monom();
|
|
1158
1173
|
F.coefficient = this._coefficient.clone();
|
|
1159
1174
|
for (let k in this._literal) {
|
|
1160
|
-
F.setLetter(k, this._literal[k]);
|
|
1175
|
+
F.setLetter(k, this._literal[k].clone());
|
|
1161
1176
|
}
|
|
1162
1177
|
return F;
|
|
1163
1178
|
};
|
|
1179
|
+
makeSame = (M) => {
|
|
1180
|
+
for (let k in M._literal) {
|
|
1181
|
+
this.setLetter(k, M._literal[k].clone());
|
|
1182
|
+
}
|
|
1183
|
+
return this;
|
|
1184
|
+
};
|
|
1164
1185
|
zero = () => {
|
|
1165
|
-
this._coefficient = new
|
|
1186
|
+
this._coefficient = new coefficients_1.Fraction().zero();
|
|
1166
1187
|
this._literal = {};
|
|
1167
1188
|
return this;
|
|
1168
1189
|
};
|
|
1169
1190
|
one = () => {
|
|
1170
|
-
this._coefficient = new
|
|
1191
|
+
this._coefficient = new coefficients_1.Fraction().one();
|
|
1171
1192
|
this._literal = {};
|
|
1172
1193
|
return this;
|
|
1173
1194
|
};
|
|
1174
1195
|
clean = () => {
|
|
1175
1196
|
for (let letter in this._literal) {
|
|
1176
|
-
if (this._literal[letter]
|
|
1197
|
+
if (this._literal[letter].isZero()) {
|
|
1177
1198
|
delete this._literal[letter];
|
|
1178
1199
|
}
|
|
1179
1200
|
}
|
|
@@ -1186,6 +1207,9 @@ class Monom {
|
|
|
1186
1207
|
add = (...M) => {
|
|
1187
1208
|
for (let m of M) {
|
|
1188
1209
|
if (this.isSameAs(m)) {
|
|
1210
|
+
if (this.isZero()) {
|
|
1211
|
+
this.makeSame(m);
|
|
1212
|
+
}
|
|
1189
1213
|
this._coefficient.add(m.coefficient);
|
|
1190
1214
|
}
|
|
1191
1215
|
else {
|
|
@@ -1197,7 +1221,10 @@ class Monom {
|
|
|
1197
1221
|
subtract = (...M) => {
|
|
1198
1222
|
for (let m of M) {
|
|
1199
1223
|
if (this.isSameAs(m)) {
|
|
1200
|
-
this.
|
|
1224
|
+
if (this.isZero()) {
|
|
1225
|
+
this.makeSame(m);
|
|
1226
|
+
}
|
|
1227
|
+
this._coefficient.add(m.clone().coefficient.opposed());
|
|
1201
1228
|
}
|
|
1202
1229
|
else {
|
|
1203
1230
|
console.log('Subtract: Is not similar: ', m.display);
|
|
@@ -1209,7 +1236,12 @@ class Monom {
|
|
|
1209
1236
|
for (let m of M) {
|
|
1210
1237
|
this._coefficient.multiply(m.coefficient);
|
|
1211
1238
|
for (let letter in m.literal) {
|
|
1212
|
-
|
|
1239
|
+
if (this._literal[letter] === undefined) {
|
|
1240
|
+
this._literal[letter] = m.literal[letter].clone();
|
|
1241
|
+
}
|
|
1242
|
+
else {
|
|
1243
|
+
this._literal[letter].add(m.literal[letter]);
|
|
1244
|
+
}
|
|
1213
1245
|
}
|
|
1214
1246
|
}
|
|
1215
1247
|
return this;
|
|
@@ -1222,8 +1254,8 @@ class Monom {
|
|
|
1222
1254
|
for (let v of M) {
|
|
1223
1255
|
this._coefficient.divide(v.coefficient);
|
|
1224
1256
|
for (let letter in v.literal) {
|
|
1225
|
-
this._literal[letter] = (this._literal[letter] === undefined) ?
|
|
1226
|
-
if (this._literal[letter]
|
|
1257
|
+
this._literal[letter] = (this._literal[letter] === undefined) ? v.literal[letter].clone().opposed() : this._literal[letter].subtract(v.literal[letter]);
|
|
1258
|
+
if (this._literal[letter].isZero()) {
|
|
1227
1259
|
delete this._literal[letter];
|
|
1228
1260
|
}
|
|
1229
1261
|
}
|
|
@@ -1233,7 +1265,7 @@ class Monom {
|
|
|
1233
1265
|
pow = (nb) => {
|
|
1234
1266
|
this._coefficient.pow(nb);
|
|
1235
1267
|
for (let letter in this._literal) {
|
|
1236
|
-
this._literal[letter]
|
|
1268
|
+
this._literal[letter].pow(nb);
|
|
1237
1269
|
}
|
|
1238
1270
|
return this;
|
|
1239
1271
|
};
|
|
@@ -1244,7 +1276,7 @@ class Monom {
|
|
|
1244
1276
|
if (this.isSquare()) {
|
|
1245
1277
|
this._coefficient.sqrt();
|
|
1246
1278
|
for (let letter in this._literal) {
|
|
1247
|
-
this._literal[letter]
|
|
1279
|
+
this._literal[letter].clone().divide(2);
|
|
1248
1280
|
}
|
|
1249
1281
|
}
|
|
1250
1282
|
return this.root(2);
|
|
@@ -1261,12 +1293,14 @@ class Monom {
|
|
|
1261
1293
|
return this._coefficient.isEqual(M.coefficient);
|
|
1262
1294
|
case 'same':
|
|
1263
1295
|
let M1 = this.variables, M2 = M.variables, K = M1.concat(M2.filter((item) => M1.indexOf(item) < 0));
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1296
|
+
if (!this.isZero() && !M.isZero()) {
|
|
1297
|
+
for (let key of K) {
|
|
1298
|
+
if (this._literal[key] === undefined || M.literal[key] === undefined) {
|
|
1299
|
+
return false;
|
|
1300
|
+
}
|
|
1301
|
+
if (!this._literal[key].isEqual(M.literal[key])) {
|
|
1302
|
+
return false;
|
|
1303
|
+
}
|
|
1270
1304
|
}
|
|
1271
1305
|
}
|
|
1272
1306
|
return true;
|
|
@@ -1290,53 +1324,68 @@ class Monom {
|
|
|
1290
1324
|
if (!this.coefficient.isSquare()) {
|
|
1291
1325
|
return false;
|
|
1292
1326
|
}
|
|
1293
|
-
return this.
|
|
1327
|
+
return this.isLiteralSquare();
|
|
1294
1328
|
};
|
|
1295
|
-
|
|
1329
|
+
isLiteralSquare = () => {
|
|
1296
1330
|
for (let letter in this.literal) {
|
|
1297
|
-
if (this.literal[letter]
|
|
1331
|
+
if (this.literal[letter].isRational()) {
|
|
1332
|
+
return false;
|
|
1333
|
+
}
|
|
1334
|
+
if (this.literal[letter].isEven()) {
|
|
1298
1335
|
return false;
|
|
1299
1336
|
}
|
|
1300
1337
|
}
|
|
1301
1338
|
return true;
|
|
1302
1339
|
};
|
|
1340
|
+
hasFractionCoefficient = () => {
|
|
1341
|
+
for (let letter in this._literal) {
|
|
1342
|
+
if (this._literal[letter].isRational()) {
|
|
1343
|
+
return true;
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
return false;
|
|
1347
|
+
};
|
|
1303
1348
|
hasLetter = (letter) => {
|
|
1304
|
-
|
|
1349
|
+
if (this._literal[letter === undefined ? 'x' : letter] === undefined) {
|
|
1350
|
+
return false;
|
|
1351
|
+
}
|
|
1352
|
+
return this._literal[letter === undefined ? 'x' : letter].isNotZero();
|
|
1305
1353
|
};
|
|
1306
1354
|
setLetter = (letter, pow) => {
|
|
1307
|
-
if (pow
|
|
1308
|
-
if (this.
|
|
1355
|
+
if (pow instanceof coefficients_1.Fraction) {
|
|
1356
|
+
if (this.hasLetter(letter) && pow.isZero()) {
|
|
1309
1357
|
delete this._literal[letter];
|
|
1310
1358
|
}
|
|
1359
|
+
this._literal[letter] = pow.clone();
|
|
1311
1360
|
}
|
|
1312
1361
|
else {
|
|
1313
|
-
this.
|
|
1362
|
+
this.setLetter(letter, new coefficients_1.Fraction(pow));
|
|
1314
1363
|
}
|
|
1315
1364
|
};
|
|
1316
1365
|
degree = (letter) => {
|
|
1317
1366
|
if (this.variables.length === 0) {
|
|
1318
|
-
return
|
|
1367
|
+
return new coefficients_1.Fraction().zero();
|
|
1319
1368
|
}
|
|
1320
1369
|
if (letter === undefined) {
|
|
1321
|
-
return Object.values(this._literal).reduce((t, n) => t
|
|
1370
|
+
return Object.values(this._literal).reduce((t, n) => t.clone().add(n));
|
|
1322
1371
|
}
|
|
1323
1372
|
else {
|
|
1324
|
-
return this._literal[letter] === undefined ?
|
|
1373
|
+
return this._literal[letter] === undefined ? new coefficients_1.Fraction().zero() : this._literal[letter].clone();
|
|
1325
1374
|
}
|
|
1326
1375
|
};
|
|
1327
1376
|
evaluate = (values) => {
|
|
1328
1377
|
let r = this.coefficient.clone();
|
|
1329
|
-
if (typeof values === 'number' || values instanceof
|
|
1378
|
+
if (typeof values === 'number' || values instanceof coefficients_1.Fraction) {
|
|
1330
1379
|
let tmpValues = {};
|
|
1331
|
-
tmpValues[this.variables[0]] = new
|
|
1380
|
+
tmpValues[this.variables[0]] = new coefficients_1.Fraction(values);
|
|
1332
1381
|
return this.evaluate(tmpValues);
|
|
1333
1382
|
}
|
|
1334
1383
|
if (typeof values === 'object') {
|
|
1335
1384
|
for (let L in this._literal) {
|
|
1336
1385
|
if (values[L] === undefined) {
|
|
1337
|
-
return new
|
|
1386
|
+
return new coefficients_1.Fraction().zero();
|
|
1338
1387
|
}
|
|
1339
|
-
let value = new
|
|
1388
|
+
let value = new coefficients_1.Fraction(values[L]);
|
|
1340
1389
|
r.multiply(value.pow(this._literal[L]));
|
|
1341
1390
|
}
|
|
1342
1391
|
}
|
|
@@ -1347,9 +1396,9 @@ class Monom {
|
|
|
1347
1396
|
letter = 'x';
|
|
1348
1397
|
}
|
|
1349
1398
|
if (this.hasLetter(letter)) {
|
|
1350
|
-
let d =
|
|
1351
|
-
dM._literal[letter]
|
|
1352
|
-
dM._coefficient.multiply(new
|
|
1399
|
+
let d = this._literal[letter].clone(), dM = this.clone();
|
|
1400
|
+
dM._literal[letter].subtract(1);
|
|
1401
|
+
dM._coefficient.multiply(new coefficients_1.Fraction(d.clone()));
|
|
1353
1402
|
return dM;
|
|
1354
1403
|
}
|
|
1355
1404
|
else {
|
|
@@ -1360,34 +1409,40 @@ class Monom {
|
|
|
1360
1409
|
if (letter === undefined) {
|
|
1361
1410
|
letter = 'x';
|
|
1362
1411
|
}
|
|
1363
|
-
let M = this.clone();
|
|
1412
|
+
let M = this.clone(), degree;
|
|
1364
1413
|
if (M.hasLetter(letter)) {
|
|
1365
|
-
|
|
1366
|
-
M.
|
|
1414
|
+
degree = M.degree(letter).clone().add(1);
|
|
1415
|
+
M.coefficient = M.coefficient.clone().divide(degree);
|
|
1416
|
+
M.setLetter(letter, degree);
|
|
1367
1417
|
}
|
|
1368
1418
|
else {
|
|
1369
1419
|
if (M.coefficient.isZero()) {
|
|
1370
|
-
M.coefficient = new
|
|
1420
|
+
M.coefficient = new coefficients_1.Fraction().one();
|
|
1371
1421
|
}
|
|
1372
1422
|
M.setLetter(letter, 1);
|
|
1373
1423
|
}
|
|
1374
1424
|
return M;
|
|
1375
1425
|
};
|
|
1376
1426
|
static lcm = (...monoms) => {
|
|
1377
|
-
|
|
1378
|
-
|
|
1427
|
+
for (let m of monoms) {
|
|
1428
|
+
if (m.hasFractionCoefficient()) {
|
|
1429
|
+
return new Monom().zero();
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
let M = new Monom(), coeffN = monoms.map(value => value.coefficient.numerator), coeffD = monoms.map(value => value.coefficient.denominator), n = numeric_1.Numeric.gcd(...coeffN), d = numeric_1.Numeric.lcm(...coeffD);
|
|
1433
|
+
M.coefficient = new coefficients_1.Fraction(n, d).reduce();
|
|
1379
1434
|
for (let m of monoms) {
|
|
1380
1435
|
for (let letter in M.literal) {
|
|
1381
1436
|
if (!(letter in m.literal)) {
|
|
1382
|
-
M.literal[letter]
|
|
1437
|
+
M.literal[letter].zero();
|
|
1383
1438
|
}
|
|
1384
1439
|
}
|
|
1385
1440
|
for (let letter in m.literal) {
|
|
1386
|
-
if (M.literal[letter] === undefined && m.literal[letter]
|
|
1387
|
-
M.literal[letter] = m.literal[letter];
|
|
1441
|
+
if (M.literal[letter] === undefined && m.literal[letter].isStrictlyPositive()) {
|
|
1442
|
+
M.literal[letter] = m.literal[letter].clone();
|
|
1388
1443
|
}
|
|
1389
1444
|
else {
|
|
1390
|
-
M.literal[letter] = Math.min(m.literal[letter], M.literal[letter]);
|
|
1445
|
+
M.literal[letter] = new coefficients_1.Fraction(Math.min(m.literal[letter].value, M.literal[letter].value));
|
|
1391
1446
|
}
|
|
1392
1447
|
}
|
|
1393
1448
|
}
|
|
@@ -1421,6 +1476,7 @@ class Monom {
|
|
|
1421
1476
|
return true;
|
|
1422
1477
|
};
|
|
1423
1478
|
}
|
|
1479
|
+
exports.Monom = Monom;
|
|
1424
1480
|
|
|
1425
1481
|
|
|
1426
1482
|
/***/ }),
|
|
@@ -1429,22 +1485,15 @@ class Monom {
|
|
|
1429
1485
|
/*!**************************************!*\
|
|
1430
1486
|
!*** ./src/maths/algebra/polynom.ts ***!
|
|
1431
1487
|
\**************************************/
|
|
1432
|
-
/***/ ((__unused_webpack_module,
|
|
1488
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1433
1489
|
|
|
1434
|
-
__webpack_require__.r(__webpack_exports__);
|
|
1435
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1436
|
-
/* harmony export */ "Polynom": () => (/* binding */ Polynom)
|
|
1437
|
-
/* harmony export */ });
|
|
1438
|
-
/* harmony import */ var _monom__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./monom */ "./src/maths/algebra/monom.ts");
|
|
1439
|
-
/* harmony import */ var _shutingyard__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../shutingyard */ "./src/maths/shutingyard.ts");
|
|
1440
|
-
/* harmony import */ var _numeric__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
1441
|
-
/* harmony import */ var _random__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../random */ "./src/maths/random/index.ts");
|
|
1442
|
-
/* harmony import */ var _coefficients_fraction__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
1490
|
|
|
1491
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1492
|
+
exports.Polynom = void 0;
|
|
1493
|
+
const monom_1 = __webpack_require__(/*! ./monom */ "./src/maths/algebra/monom.ts");
|
|
1494
|
+
const shutingyard_1 = __webpack_require__(/*! ../shutingyard */ "./src/maths/shutingyard.ts");
|
|
1495
|
+
const numeric_1 = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
1496
|
+
const coefficients_1 = __webpack_require__(/*! ../coefficients */ "./src/maths/coefficients/index.ts");
|
|
1448
1497
|
class Polynom {
|
|
1449
1498
|
_rawString;
|
|
1450
1499
|
_monoms;
|
|
@@ -1458,10 +1507,6 @@ class Polynom {
|
|
|
1458
1507
|
}
|
|
1459
1508
|
return this;
|
|
1460
1509
|
}
|
|
1461
|
-
get isPolynom() {
|
|
1462
|
-
return true;
|
|
1463
|
-
}
|
|
1464
|
-
;
|
|
1465
1510
|
get monoms() {
|
|
1466
1511
|
return this._monoms;
|
|
1467
1512
|
}
|
|
@@ -1549,9 +1594,7 @@ class Polynom {
|
|
|
1549
1594
|
this._rawString = inputStr;
|
|
1550
1595
|
if (inputStr !== '' && !isNaN(Number(inputStr))) {
|
|
1551
1596
|
this.empty();
|
|
1552
|
-
let m = new
|
|
1553
|
-
m.coefficient = new _coefficients_fraction__WEBPACK_IMPORTED_MODULE_4__.Fraction(inputStr);
|
|
1554
|
-
m.literalStr = '';
|
|
1597
|
+
let m = new monom_1.Monom(inputStr);
|
|
1555
1598
|
this.add(m);
|
|
1556
1599
|
return this;
|
|
1557
1600
|
}
|
|
@@ -1559,11 +1602,11 @@ class Polynom {
|
|
|
1559
1602
|
}
|
|
1560
1603
|
else if (/^[a-z]/.test(inputStr)) {
|
|
1561
1604
|
this.empty();
|
|
1562
|
-
let fractions = values.map(x => new
|
|
1605
|
+
let fractions = values.map(x => new coefficients_1.Fraction(x));
|
|
1563
1606
|
if (inputStr.length > 1) {
|
|
1564
1607
|
let letters = inputStr.split(''), i = 0;
|
|
1565
1608
|
for (let F of fractions) {
|
|
1566
|
-
let m = new
|
|
1609
|
+
let m = new monom_1.Monom();
|
|
1567
1610
|
m.coefficient = F.clone();
|
|
1568
1611
|
m.literalStr = letters[i] || '';
|
|
1569
1612
|
this.add(m);
|
|
@@ -1573,7 +1616,7 @@ class Polynom {
|
|
|
1573
1616
|
else {
|
|
1574
1617
|
let n = fractions.length - 1;
|
|
1575
1618
|
for (let F of fractions) {
|
|
1576
|
-
let m = new
|
|
1619
|
+
let m = new monom_1.Monom();
|
|
1577
1620
|
m.coefficient = F.clone();
|
|
1578
1621
|
m.literalStr = `${inputStr}^${n}`;
|
|
1579
1622
|
this.add(m);
|
|
@@ -1587,7 +1630,7 @@ class Polynom {
|
|
|
1587
1630
|
}
|
|
1588
1631
|
};
|
|
1589
1632
|
shutingYardToReducedPolynom = (inputStr) => {
|
|
1590
|
-
const SY = new
|
|
1633
|
+
const SY = new shutingyard_1.Shutingyard().parse(inputStr);
|
|
1591
1634
|
const rpn = SY.rpn;
|
|
1592
1635
|
let m1;
|
|
1593
1636
|
let m2;
|
|
@@ -1595,7 +1638,7 @@ class Polynom {
|
|
|
1595
1638
|
for (const element of rpn) {
|
|
1596
1639
|
if (element.tokenType === 'coefficient' || element.tokenType === 'variable') {
|
|
1597
1640
|
tempPolynom = new Polynom().zero();
|
|
1598
|
-
tempPolynom.monoms = [new
|
|
1641
|
+
tempPolynom.monoms = [new monom_1.Monom(element.token)];
|
|
1599
1642
|
stack.push(tempPolynom.clone());
|
|
1600
1643
|
}
|
|
1601
1644
|
else if (element.tokenType === 'operation') {
|
|
@@ -1631,13 +1674,13 @@ class Polynom {
|
|
|
1631
1674
|
};
|
|
1632
1675
|
zero = () => {
|
|
1633
1676
|
this._monoms = [];
|
|
1634
|
-
this._monoms.push(new
|
|
1677
|
+
this._monoms.push(new monom_1.Monom().zero());
|
|
1635
1678
|
this._rawString = '0';
|
|
1636
1679
|
return this;
|
|
1637
1680
|
};
|
|
1638
1681
|
one = () => {
|
|
1639
1682
|
this._monoms = [];
|
|
1640
|
-
this._monoms.push(new
|
|
1683
|
+
this._monoms.push(new monom_1.Monom().one());
|
|
1641
1684
|
this._rawString = '1';
|
|
1642
1685
|
return this;
|
|
1643
1686
|
};
|
|
@@ -1646,99 +1689,52 @@ class Polynom {
|
|
|
1646
1689
|
this._rawString = '';
|
|
1647
1690
|
return this;
|
|
1648
1691
|
};
|
|
1649
|
-
random(config) {
|
|
1650
|
-
return _random__WEBPACK_IMPORTED_MODULE_3__.Random.polynom(config);
|
|
1651
|
-
}
|
|
1652
|
-
_randomizeDefaults = {
|
|
1653
|
-
degree: 2,
|
|
1654
|
-
unit: true,
|
|
1655
|
-
fractions: false,
|
|
1656
|
-
factorable: false,
|
|
1657
|
-
letters: 'x',
|
|
1658
|
-
allowNullMonom: false,
|
|
1659
|
-
numberOfMonoms: false
|
|
1660
|
-
};
|
|
1661
|
-
get randomizeDefaults() {
|
|
1662
|
-
return this._randomizeDefaults;
|
|
1663
|
-
}
|
|
1664
|
-
set randomizeDefaults(value) {
|
|
1665
|
-
this._randomizeDefaults = value;
|
|
1666
|
-
}
|
|
1667
|
-
randomize = (config) => {
|
|
1668
|
-
let P = new Polynom();
|
|
1669
|
-
if (config === undefined) {
|
|
1670
|
-
config = {};
|
|
1671
|
-
}
|
|
1672
|
-
for (let k in this._randomizeDefaults) {
|
|
1673
|
-
if (config[k] === undefined) {
|
|
1674
|
-
config[k] = this._randomizeDefaults[k];
|
|
1675
|
-
}
|
|
1676
|
-
}
|
|
1677
|
-
return P;
|
|
1678
|
-
};
|
|
1679
|
-
rndFactorable = (degree = 2, unit = false, letters = 'x') => {
|
|
1680
|
-
this._factors = [];
|
|
1681
|
-
for (let i = 0; i < degree; i++) {
|
|
1682
|
-
let factorUnit = unit === true || i >= unit, p = _random__WEBPACK_IMPORTED_MODULE_3__.Random.polynom({
|
|
1683
|
-
degree: 1,
|
|
1684
|
-
unit: factorUnit,
|
|
1685
|
-
fraction: false,
|
|
1686
|
-
letters
|
|
1687
|
-
});
|
|
1688
|
-
this._factors.push(p);
|
|
1689
|
-
}
|
|
1690
|
-
this.empty().monoms = this._factors[0].monoms;
|
|
1691
|
-
for (let i = 1; i < this._factors.length; i++) {
|
|
1692
|
-
this.multiply(this._factors[i]);
|
|
1693
|
-
}
|
|
1694
|
-
return this;
|
|
1695
|
-
};
|
|
1696
1692
|
opposed = () => {
|
|
1697
1693
|
this._monoms = this._monoms.map(m => m.opposed());
|
|
1698
1694
|
return this;
|
|
1699
1695
|
};
|
|
1700
1696
|
add = (...values) => {
|
|
1701
1697
|
for (let value of values) {
|
|
1702
|
-
if (value
|
|
1698
|
+
if (value instanceof Polynom) {
|
|
1703
1699
|
this._monoms = this._monoms.concat(value.monoms);
|
|
1704
1700
|
}
|
|
1705
|
-
else if (value.
|
|
1701
|
+
else if (value instanceof monom_1.Monom) {
|
|
1706
1702
|
this._monoms.push(value.clone());
|
|
1707
1703
|
}
|
|
1708
1704
|
else if (Number.isSafeInteger(value)) {
|
|
1709
|
-
this._monoms.push(new
|
|
1705
|
+
this._monoms.push(new monom_1.Monom(value.toString()));
|
|
1710
1706
|
}
|
|
1711
1707
|
else {
|
|
1712
|
-
this._monoms.push(new
|
|
1708
|
+
this._monoms.push(new monom_1.Monom(value));
|
|
1713
1709
|
}
|
|
1714
1710
|
}
|
|
1715
1711
|
return this.reduce();
|
|
1716
1712
|
};
|
|
1717
1713
|
subtract = (...values) => {
|
|
1718
1714
|
for (let value of values) {
|
|
1719
|
-
if (value
|
|
1715
|
+
if (value instanceof Polynom) {
|
|
1720
1716
|
this._monoms = this._monoms.concat(value.clone().opposed().monoms);
|
|
1721
1717
|
}
|
|
1722
|
-
else if (value.
|
|
1718
|
+
else if (value instanceof monom_1.Monom) {
|
|
1723
1719
|
this._monoms.push(value.clone().opposed());
|
|
1724
1720
|
}
|
|
1725
1721
|
else if (Number.isSafeInteger(value)) {
|
|
1726
|
-
this._monoms.push(new
|
|
1722
|
+
this._monoms.push(new monom_1.Monom(value.toString()).opposed());
|
|
1727
1723
|
}
|
|
1728
1724
|
else {
|
|
1729
|
-
this._monoms.push(new
|
|
1725
|
+
this._monoms.push(new monom_1.Monom(value).opposed());
|
|
1730
1726
|
}
|
|
1731
1727
|
}
|
|
1732
1728
|
return this.reduce();
|
|
1733
1729
|
};
|
|
1734
1730
|
multiply = (value) => {
|
|
1735
|
-
if (value
|
|
1731
|
+
if (value instanceof Polynom) {
|
|
1736
1732
|
return this.multiplyByPolynom(value);
|
|
1737
1733
|
}
|
|
1738
|
-
else if (value.
|
|
1734
|
+
else if (value instanceof coefficients_1.Fraction) {
|
|
1739
1735
|
return this.multiplyByFraction(value);
|
|
1740
1736
|
}
|
|
1741
|
-
else if (value.
|
|
1737
|
+
else if (value instanceof monom_1.Monom) {
|
|
1742
1738
|
return this.multiplyByMonom(value);
|
|
1743
1739
|
}
|
|
1744
1740
|
else if (Number.isSafeInteger(value)) {
|
|
@@ -1750,7 +1746,7 @@ class Polynom {
|
|
|
1750
1746
|
const M = [];
|
|
1751
1747
|
for (const m1 of this._monoms) {
|
|
1752
1748
|
for (const m2 of P.monoms) {
|
|
1753
|
-
M.push(
|
|
1749
|
+
M.push(monom_1.Monom.xmultiply(m1, m2));
|
|
1754
1750
|
}
|
|
1755
1751
|
}
|
|
1756
1752
|
this._monoms = M;
|
|
@@ -1763,7 +1759,7 @@ class Polynom {
|
|
|
1763
1759
|
return this.reduce();
|
|
1764
1760
|
};
|
|
1765
1761
|
multiplyByInteger = (nb) => {
|
|
1766
|
-
return this.multiplyByFraction(new
|
|
1762
|
+
return this.multiplyByFraction(new coefficients_1.Fraction(nb));
|
|
1767
1763
|
};
|
|
1768
1764
|
multiplyByMonom = (M) => {
|
|
1769
1765
|
for (const m of this._monoms) {
|
|
@@ -1781,9 +1777,9 @@ class Polynom {
|
|
|
1781
1777
|
const maxMP = P.monomByDegree(undefined, letter);
|
|
1782
1778
|
const degreeP = P.degree(letter);
|
|
1783
1779
|
let newM;
|
|
1784
|
-
let MaxIteration = this.degree(letter)
|
|
1785
|
-
while (reminder.degree(letter) >= degreeP && MaxIteration
|
|
1786
|
-
MaxIteration
|
|
1780
|
+
let MaxIteration = this.degree(letter).clone().multiply(2);
|
|
1781
|
+
while (reminder.degree(letter) >= degreeP && MaxIteration.isPositive()) {
|
|
1782
|
+
MaxIteration.subtract(1);
|
|
1787
1783
|
newM = reminder.monomByDegree(undefined, letter).clone().divide(maxMP);
|
|
1788
1784
|
if (newM.isZero()) {
|
|
1789
1785
|
break;
|
|
@@ -1802,7 +1798,7 @@ class Polynom {
|
|
|
1802
1798
|
}
|
|
1803
1799
|
};
|
|
1804
1800
|
divideByInteger = (nb) => {
|
|
1805
|
-
const nbF = new
|
|
1801
|
+
const nbF = new coefficients_1.Fraction(nb);
|
|
1806
1802
|
for (const m of this._monoms) {
|
|
1807
1803
|
m.coefficient.divide(nbF);
|
|
1808
1804
|
}
|
|
@@ -1838,7 +1834,7 @@ class Polynom {
|
|
|
1838
1834
|
const cP2 = P.clone().reduce().reorder();
|
|
1839
1835
|
switch (sign) {
|
|
1840
1836
|
case '=':
|
|
1841
|
-
if (cP1.length !== cP2.length || cP1.degree()
|
|
1837
|
+
if (cP1.length !== cP2.length || cP1.degree().isNotEqual(cP2.degree())) {
|
|
1842
1838
|
return false;
|
|
1843
1839
|
}
|
|
1844
1840
|
for (const i in cP1.monoms) {
|
|
@@ -1962,14 +1958,14 @@ class Polynom {
|
|
|
1962
1958
|
};
|
|
1963
1959
|
reorder = (letter = 'x') => {
|
|
1964
1960
|
this._monoms.sort(function (a, b) {
|
|
1965
|
-
return b.degree(letter)
|
|
1961
|
+
return b.degree(letter).clone().subtract(a.degree(letter)).value;
|
|
1966
1962
|
});
|
|
1967
1963
|
return this.reduce();
|
|
1968
1964
|
};
|
|
1969
1965
|
degree = (letter) => {
|
|
1970
|
-
let d =
|
|
1966
|
+
let d = new coefficients_1.Fraction().zero();
|
|
1971
1967
|
for (const m of this._monoms) {
|
|
1972
|
-
d =
|
|
1968
|
+
d = coefficients_1.Fraction.max(m.degree(letter).value, d);
|
|
1973
1969
|
}
|
|
1974
1970
|
return d;
|
|
1975
1971
|
};
|
|
@@ -1984,20 +1980,20 @@ class Polynom {
|
|
|
1984
1980
|
let pow;
|
|
1985
1981
|
const resultPolynom = new Polynom().zero();
|
|
1986
1982
|
for (const m of this.monoms) {
|
|
1987
|
-
if (m.literal[letter] === undefined || m.literal[letter]
|
|
1983
|
+
if (m.literal[letter] === undefined || m.literal[letter].isZero()) {
|
|
1988
1984
|
resultPolynom.add(m.clone());
|
|
1989
1985
|
}
|
|
1990
1986
|
else {
|
|
1991
|
-
pow =
|
|
1987
|
+
pow = m.literal[letter].clone();
|
|
1992
1988
|
delete m.literal[letter];
|
|
1993
|
-
resultPolynom.add(P.clone().pow(pow).multiply(m));
|
|
1989
|
+
resultPolynom.add(P.clone().pow(Math.abs(pow.numerator)).multiply(m));
|
|
1994
1990
|
}
|
|
1995
1991
|
}
|
|
1996
1992
|
this._monoms = resultPolynom.reduce().reorder().monoms;
|
|
1997
1993
|
return this;
|
|
1998
1994
|
};
|
|
1999
1995
|
evaluate = (values) => {
|
|
2000
|
-
const r = new
|
|
1996
|
+
const r = new coefficients_1.Fraction().zero();
|
|
2001
1997
|
this._monoms.forEach(monom => {
|
|
2002
1998
|
r.add(monom.evaluate(values));
|
|
2003
1999
|
});
|
|
@@ -2023,59 +2019,10 @@ class Polynom {
|
|
|
2023
2019
|
letter = 'x';
|
|
2024
2020
|
}
|
|
2025
2021
|
let valuesA = {}, valuesB = {};
|
|
2026
|
-
valuesA[letter] = a;
|
|
2027
|
-
valuesB[letter] = b;
|
|
2022
|
+
valuesA[letter] = new coefficients_1.Fraction(a);
|
|
2023
|
+
valuesB[letter] = new coefficients_1.Fraction(b);
|
|
2028
2024
|
return primitive.evaluate(valuesB).subtract(primitive.evaluate(valuesA));
|
|
2029
2025
|
};
|
|
2030
|
-
factorize_OLD = (maxValue) => {
|
|
2031
|
-
this._factors = [];
|
|
2032
|
-
let P = this.clone(), nbFactorsFound = 0;
|
|
2033
|
-
if (P.monomByDegree().coefficient.numerator < 0) {
|
|
2034
|
-
this._factors.push(new Polynom('-1'));
|
|
2035
|
-
}
|
|
2036
|
-
let M = P.commonMonom();
|
|
2037
|
-
if (!M.isOne()) {
|
|
2038
|
-
let commonPolynom = new Polynom();
|
|
2039
|
-
commonPolynom.monoms = [M];
|
|
2040
|
-
if (this._factors.length === 0) {
|
|
2041
|
-
this._factors.push(commonPolynom);
|
|
2042
|
-
}
|
|
2043
|
-
else {
|
|
2044
|
-
this._factors = [];
|
|
2045
|
-
this._factors.push(commonPolynom.opposed());
|
|
2046
|
-
}
|
|
2047
|
-
P = P.euclidian(commonPolynom).quotient;
|
|
2048
|
-
nbFactorsFound = commonPolynom.degree();
|
|
2049
|
-
}
|
|
2050
|
-
if (P.degree() <= 1) {
|
|
2051
|
-
this._factors.push(P.clone());
|
|
2052
|
-
}
|
|
2053
|
-
else {
|
|
2054
|
-
let Q = new _coefficients_fraction__WEBPACK_IMPORTED_MODULE_4__.Fraction(), F, degree = P.degree();
|
|
2055
|
-
maxValue = maxValue === undefined ? 20 : maxValue;
|
|
2056
|
-
for (let a = 1; a <= maxValue; a++) {
|
|
2057
|
-
for (let b = -maxValue; b <= maxValue; b++) {
|
|
2058
|
-
Q.parse(-b, a);
|
|
2059
|
-
if (P.evaluate({ x: Q })) {
|
|
2060
|
-
F = new Polynom(`${a}x+${b}`);
|
|
2061
|
-
while (P.evaluate({ x: Q }).value === 0) {
|
|
2062
|
-
this._factors.push(F.clone());
|
|
2063
|
-
nbFactorsFound++;
|
|
2064
|
-
P = P.euclidian(F).quotient;
|
|
2065
|
-
}
|
|
2066
|
-
}
|
|
2067
|
-
if (nbFactorsFound > degree) {
|
|
2068
|
-
return this;
|
|
2069
|
-
}
|
|
2070
|
-
}
|
|
2071
|
-
}
|
|
2072
|
-
if (P.degree() > 1) {
|
|
2073
|
-
this._factors.push(P.clone());
|
|
2074
|
-
return this;
|
|
2075
|
-
}
|
|
2076
|
-
}
|
|
2077
|
-
return this;
|
|
2078
|
-
};
|
|
2079
2026
|
factorize = (letter) => {
|
|
2080
2027
|
let factors = [];
|
|
2081
2028
|
let P = this.clone().reorder(), M = P.commonMonom(), tempPolynom;
|
|
@@ -2085,7 +2032,7 @@ class Polynom {
|
|
|
2085
2032
|
factors = [tempPolynom.clone()];
|
|
2086
2033
|
P = P.euclidian(tempPolynom).quotient;
|
|
2087
2034
|
}
|
|
2088
|
-
let securityLoop = P.degree()
|
|
2035
|
+
let securityLoop = P.degree().clone().multiply(2).value;
|
|
2089
2036
|
while (securityLoop >= 0) {
|
|
2090
2037
|
securityLoop--;
|
|
2091
2038
|
if (P.monoms.length < 2) {
|
|
@@ -2168,14 +2115,14 @@ class Polynom {
|
|
|
2168
2115
|
a = this.monomByDegree(2, letter);
|
|
2169
2116
|
b = this.monomByDegree(1, letter);
|
|
2170
2117
|
c = this.monomByDegree(0, letter);
|
|
2171
|
-
if (a.
|
|
2118
|
+
if (a.isLiteralSquare() && c.isLiteralSquare()) {
|
|
2172
2119
|
if (b.clone().pow(2).isSameAs(a.clone().multiply(c))) {
|
|
2173
2120
|
let xPolynom = new Polynom('x', a.coefficient, b.coefficient, c.coefficient);
|
|
2174
2121
|
let xFactors = xPolynom._factorize2ndDegree('x');
|
|
2175
2122
|
let factors = [], xyzPolynom;
|
|
2176
2123
|
if (xFactors.length >= 2) {
|
|
2177
2124
|
for (let p of xFactors) {
|
|
2178
|
-
if (p.degree()
|
|
2125
|
+
if (p.degree().isZero()) {
|
|
2179
2126
|
factors.push(p.clone());
|
|
2180
2127
|
}
|
|
2181
2128
|
else {
|
|
@@ -2197,7 +2144,7 @@ class Polynom {
|
|
|
2197
2144
|
};
|
|
2198
2145
|
getZeroes = () => {
|
|
2199
2146
|
const Z = [];
|
|
2200
|
-
switch (this.degree()) {
|
|
2147
|
+
switch (this.degree().value) {
|
|
2201
2148
|
case 0:
|
|
2202
2149
|
if (this._monoms[0].coefficient.value === 0) {
|
|
2203
2150
|
return [true];
|
|
@@ -2207,7 +2154,7 @@ class Polynom {
|
|
|
2207
2154
|
}
|
|
2208
2155
|
case 1:
|
|
2209
2156
|
if (this._monoms.length === 1) {
|
|
2210
|
-
return [new
|
|
2157
|
+
return [new coefficients_1.Fraction().zero()];
|
|
2211
2158
|
}
|
|
2212
2159
|
else {
|
|
2213
2160
|
const P = this.clone().reduce().reorder();
|
|
@@ -2219,14 +2166,14 @@ class Polynom {
|
|
|
2219
2166
|
}
|
|
2220
2167
|
let zeroes = [], zeroesAsTex = [];
|
|
2221
2168
|
for (let P of this._factors) {
|
|
2222
|
-
if (P.degree()
|
|
2169
|
+
if (P.degree().greater(2)) {
|
|
2223
2170
|
}
|
|
2224
|
-
else if (P.degree() === 2) {
|
|
2171
|
+
else if (P.degree().value === 2) {
|
|
2225
2172
|
let A = P.monomByDegree(2).coefficient, B = P.monomByDegree(1).coefficient, C = P.monomByDegree(0).coefficient, D = B.clone().pow(2).subtract(A.clone().multiply(C).multiply(4));
|
|
2226
2173
|
if (D.value > 0) {
|
|
2227
2174
|
let x1 = (-(B.value) + Math.sqrt(D.value)) / (2 * A.value), x2 = (-(B.value) - Math.sqrt(D.value)) / (2 * A.value);
|
|
2228
|
-
zeroes.push(new
|
|
2229
|
-
zeroes.push(new
|
|
2175
|
+
zeroes.push(new coefficients_1.Fraction(x1.toFixed(3)).reduce());
|
|
2176
|
+
zeroes.push(new coefficients_1.Fraction(x2.toFixed(3)).reduce());
|
|
2230
2177
|
}
|
|
2231
2178
|
else if (D.value === 0) {
|
|
2232
2179
|
}
|
|
@@ -2256,11 +2203,11 @@ class Polynom {
|
|
|
2256
2203
|
}
|
|
2257
2204
|
const M = this.clone().reduce();
|
|
2258
2205
|
for (const m of M._monoms) {
|
|
2259
|
-
if (m.degree(letter)
|
|
2206
|
+
if (m.degree(letter).isEqual(degree)) {
|
|
2260
2207
|
return m.clone();
|
|
2261
2208
|
}
|
|
2262
2209
|
}
|
|
2263
|
-
return new
|
|
2210
|
+
return new monom_1.Monom().zero();
|
|
2264
2211
|
};
|
|
2265
2212
|
monomsByDegree = (degree, letter) => {
|
|
2266
2213
|
if (degree === undefined) {
|
|
@@ -2282,7 +2229,7 @@ class Polynom {
|
|
|
2282
2229
|
return m.clone();
|
|
2283
2230
|
}
|
|
2284
2231
|
}
|
|
2285
|
-
return new
|
|
2232
|
+
return new monom_1.Monom().zero();
|
|
2286
2233
|
};
|
|
2287
2234
|
getDenominators = () => {
|
|
2288
2235
|
const denominators = [];
|
|
@@ -2299,91 +2246,35 @@ class Polynom {
|
|
|
2299
2246
|
return numerators;
|
|
2300
2247
|
};
|
|
2301
2248
|
lcmDenominator = () => {
|
|
2302
|
-
return
|
|
2249
|
+
return numeric_1.Numeric.lcm(...this.getDenominators());
|
|
2303
2250
|
};
|
|
2304
2251
|
gcdDenominator = () => {
|
|
2305
|
-
return
|
|
2252
|
+
return numeric_1.Numeric.gcd(...this.getDenominators());
|
|
2306
2253
|
};
|
|
2307
2254
|
lcmNumerator = () => {
|
|
2308
|
-
return
|
|
2255
|
+
return numeric_1.Numeric.lcm(...this.getNumerators());
|
|
2309
2256
|
};
|
|
2310
2257
|
gcdNumerator = () => {
|
|
2311
|
-
return
|
|
2258
|
+
return numeric_1.Numeric.gcd(...this.getNumerators());
|
|
2312
2259
|
};
|
|
2313
2260
|
commonMonom = () => {
|
|
2314
|
-
let M = new
|
|
2261
|
+
let M = new monom_1.Monom().one(), numerator, denominator, degree = this.degree();
|
|
2315
2262
|
numerator = this.gcdNumerator();
|
|
2316
2263
|
denominator = this.gcdDenominator();
|
|
2317
|
-
M.coefficient = new
|
|
2264
|
+
M.coefficient = new coefficients_1.Fraction(numerator, denominator);
|
|
2318
2265
|
for (let L of this.variables) {
|
|
2319
2266
|
M.setLetter(L, degree);
|
|
2320
2267
|
for (let m of this._monoms) {
|
|
2321
|
-
M.setLetter(L,
|
|
2322
|
-
if (M.degree(L)
|
|
2268
|
+
M.setLetter(L, coefficients_1.Fraction.min(m.degree(L), M.degree(L)));
|
|
2269
|
+
if (M.degree(L).isZero()) {
|
|
2323
2270
|
break;
|
|
2324
2271
|
}
|
|
2325
2272
|
}
|
|
2326
2273
|
}
|
|
2327
2274
|
return M;
|
|
2328
2275
|
};
|
|
2329
|
-
makeItComplicate = (complexity = 1) => {
|
|
2330
|
-
this._texString = '';
|
|
2331
|
-
if (this.degree() < 1) {
|
|
2332
|
-
return this;
|
|
2333
|
-
}
|
|
2334
|
-
const mDegree = _random__WEBPACK_IMPORTED_MODULE_3__.Random.number(0, this.degree() - 1);
|
|
2335
|
-
return this;
|
|
2336
|
-
};
|
|
2337
|
-
factorizePartial = (forceSign) => {
|
|
2338
|
-
this._texString = '';
|
|
2339
|
-
if (this.length <= 1) {
|
|
2340
|
-
return this;
|
|
2341
|
-
}
|
|
2342
|
-
let mMain, mCheck, mFactor, pFactor, g, sign;
|
|
2343
|
-
for (let i = 0; i < this.length; i++) {
|
|
2344
|
-
mMain = this._monoms[i].clone();
|
|
2345
|
-
for (let j = i + 1; j < this.length; j++) {
|
|
2346
|
-
mCheck = this._monoms[j].clone();
|
|
2347
|
-
g = _numeric__WEBPACK_IMPORTED_MODULE_2__.Numeric.gcd(mMain.coefficient.numerator, mCheck.coefficient.numerator);
|
|
2348
|
-
if (g !== 1) {
|
|
2349
|
-
mFactor = _monom__WEBPACK_IMPORTED_MODULE_0__.Monom.lcm(mMain, mCheck);
|
|
2350
|
-
sign = mMain.coefficient.sign() === 1 ? '+' : '-';
|
|
2351
|
-
this._texString = `${forceSign === true ? sign : (sign === '+' ? '' : sign)}${mFactor.tex}`;
|
|
2352
|
-
pFactor = new Polynom().add(mMain.divide(mFactor)).add(mCheck.divide(mFactor));
|
|
2353
|
-
this._texString += pFactor.genDisplay('tex', false, true);
|
|
2354
|
-
this._texString += this.clone().subtract(pFactor.clone().multiply(mFactor)).genDisplay('tex', true, false);
|
|
2355
|
-
return this;
|
|
2356
|
-
}
|
|
2357
|
-
}
|
|
2358
|
-
}
|
|
2359
|
-
this._texString = this.genDisplay('tex', forceSign);
|
|
2360
|
-
return this;
|
|
2361
|
-
};
|
|
2362
|
-
minify = () => {
|
|
2363
|
-
this.multiply(this.lcmDenominator()).divide(this.gcdNumerator()).reduce();
|
|
2364
|
-
return this.reduce();
|
|
2365
|
-
};
|
|
2366
|
-
canDivide = (P, letter = 'x') => {
|
|
2367
|
-
const d = P.degree();
|
|
2368
|
-
const evalValue = {};
|
|
2369
|
-
if (d === 0) {
|
|
2370
|
-
return !P.isZero;
|
|
2371
|
-
}
|
|
2372
|
-
if (d === 1) {
|
|
2373
|
-
const z = P.getZeroes();
|
|
2374
|
-
if (z[0] === true || z[0] === false) {
|
|
2375
|
-
return false;
|
|
2376
|
-
}
|
|
2377
|
-
evalValue[letter] = z[0];
|
|
2378
|
-
return this.evaluate(evalValue).value === 0;
|
|
2379
|
-
}
|
|
2380
|
-
if (d > 1) {
|
|
2381
|
-
console.log('Currently, only first degree polynom are supported');
|
|
2382
|
-
return false;
|
|
2383
|
-
}
|
|
2384
|
-
return false;
|
|
2385
|
-
};
|
|
2386
2276
|
}
|
|
2277
|
+
exports.Polynom = Polynom;
|
|
2387
2278
|
|
|
2388
2279
|
|
|
2389
2280
|
/***/ }),
|
|
@@ -2392,21 +2283,20 @@ class Polynom {
|
|
|
2392
2283
|
/*!***************************************!*\
|
|
2393
2284
|
!*** ./src/maths/algebra/rational.ts ***!
|
|
2394
2285
|
\***************************************/
|
|
2395
|
-
/***/ ((__unused_webpack_module,
|
|
2286
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
2396
2287
|
|
|
2397
|
-
__webpack_require__.r(__webpack_exports__);
|
|
2398
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2399
|
-
/* harmony export */ "Rational": () => (/* binding */ Rational)
|
|
2400
|
-
/* harmony export */ });
|
|
2401
|
-
/* harmony import */ var _polynom__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./polynom */ "./src/maths/algebra/polynom.ts");
|
|
2402
2288
|
|
|
2289
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2290
|
+
exports.Rational = void 0;
|
|
2291
|
+
const polynom_1 = __webpack_require__(/*! ./polynom */ "./src/maths/algebra/polynom.ts");
|
|
2292
|
+
const fraction_1 = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
2403
2293
|
class Rational {
|
|
2404
2294
|
_rawString;
|
|
2405
2295
|
_numerator;
|
|
2406
2296
|
_denominator;
|
|
2407
2297
|
constructor(numerator, denominator) {
|
|
2408
|
-
this._numerator = numerator ? numerator.clone() : new
|
|
2409
|
-
this._denominator = denominator ? denominator.clone() : new
|
|
2298
|
+
this._numerator = numerator ? numerator.clone() : new polynom_1.Polynom();
|
|
2299
|
+
this._denominator = denominator ? denominator.clone() : new polynom_1.Polynom();
|
|
2410
2300
|
}
|
|
2411
2301
|
clone = () => {
|
|
2412
2302
|
this._numerator = this._numerator.clone();
|
|
@@ -2487,21 +2377,22 @@ class Rational {
|
|
|
2487
2377
|
if (value === Infinity || value === -Infinity) {
|
|
2488
2378
|
let N = this._numerator.monomByDegree(this._numerator.degree(letter), letter), D = this._denominator.monomByDegree(this._denominator.degree(letter), letter);
|
|
2489
2379
|
N.divide(D);
|
|
2490
|
-
if (N.degree(letter)
|
|
2491
|
-
return N.coefficient.sign() * (Math.pow((value > 0 ? 1 : -1), N.degree(letter) % 2)) === 1 ? Infinity : -Infinity;
|
|
2380
|
+
if (N.degree(letter).isStrictlyPositive()) {
|
|
2381
|
+
return N.coefficient.sign() * (Math.pow((value > 0 ? 1 : -1), N.degree(letter).value % 2)) === 1 ? Infinity : -Infinity;
|
|
2492
2382
|
}
|
|
2493
|
-
if (N.degree(letter)
|
|
2383
|
+
if (N.degree(letter).isZero()) {
|
|
2494
2384
|
return N.coefficient;
|
|
2495
2385
|
}
|
|
2496
|
-
if (N.degree(letter)
|
|
2497
|
-
return N.coefficient.sign() * (Math.pow(-1, N.degree(letter) % 2)) === 1 ? 0 : -0;
|
|
2386
|
+
if (N.degree(letter).isStrictlyPositive()) {
|
|
2387
|
+
return N.coefficient.sign() * (Math.pow(-1, N.degree(letter).value % 2)) === 1 ? 0 : -0;
|
|
2498
2388
|
}
|
|
2499
2389
|
}
|
|
2500
2390
|
else {
|
|
2501
|
-
return this._numerator.evaluate({ letter: value }).divide(this._denominator.evaluate({ letter: value }));
|
|
2391
|
+
return this._numerator.evaluate({ letter: new fraction_1.Fraction(value) }).divide(this._denominator.evaluate({ letter: new fraction_1.Fraction(value) }));
|
|
2502
2392
|
}
|
|
2503
2393
|
};
|
|
2504
2394
|
}
|
|
2395
|
+
exports.Rational = Rational;
|
|
2505
2396
|
|
|
2506
2397
|
|
|
2507
2398
|
/***/ }),
|
|
@@ -2510,14 +2401,12 @@ class Rational {
|
|
|
2510
2401
|
/*!********************************************!*\
|
|
2511
2402
|
!*** ./src/maths/coefficients/fraction.ts ***!
|
|
2512
2403
|
\********************************************/
|
|
2513
|
-
/***/ ((__unused_webpack_module,
|
|
2404
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
2514
2405
|
|
|
2515
|
-
__webpack_require__.r(__webpack_exports__);
|
|
2516
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2517
|
-
/* harmony export */ "Fraction": () => (/* binding */ Fraction)
|
|
2518
|
-
/* harmony export */ });
|
|
2519
|
-
/* harmony import */ var _numeric__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
2520
2406
|
|
|
2407
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2408
|
+
exports.Fraction = void 0;
|
|
2409
|
+
const numeric_1 = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
2521
2410
|
class Fraction {
|
|
2522
2411
|
_numerator;
|
|
2523
2412
|
_denominator;
|
|
@@ -2666,13 +2555,23 @@ class Fraction {
|
|
|
2666
2555
|
return this;
|
|
2667
2556
|
};
|
|
2668
2557
|
add = (F) => {
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2558
|
+
if (F instanceof Fraction) {
|
|
2559
|
+
let N = this._numerator, D = this._denominator;
|
|
2560
|
+
this._numerator = N * F.denominator + F.numerator * D;
|
|
2561
|
+
this._denominator = D * F.denominator;
|
|
2562
|
+
}
|
|
2563
|
+
else {
|
|
2564
|
+
return this.add(new Fraction(F));
|
|
2565
|
+
}
|
|
2672
2566
|
return this.reduce();
|
|
2673
2567
|
};
|
|
2674
2568
|
subtract = (F) => {
|
|
2675
|
-
|
|
2569
|
+
if (F instanceof Fraction) {
|
|
2570
|
+
return this.add(F.clone().opposed());
|
|
2571
|
+
}
|
|
2572
|
+
else {
|
|
2573
|
+
return this.add(-F);
|
|
2574
|
+
}
|
|
2676
2575
|
};
|
|
2677
2576
|
multiply = (F) => {
|
|
2678
2577
|
let Q = new Fraction(F);
|
|
@@ -2697,6 +2596,9 @@ class Fraction {
|
|
|
2697
2596
|
return this;
|
|
2698
2597
|
};
|
|
2699
2598
|
pow = (p) => {
|
|
2599
|
+
if (p instanceof Fraction) {
|
|
2600
|
+
return this.pow(p.value);
|
|
2601
|
+
}
|
|
2700
2602
|
if (!Number.isSafeInteger(p)) {
|
|
2701
2603
|
return this.invalid();
|
|
2702
2604
|
}
|
|
@@ -2728,8 +2630,28 @@ class Fraction {
|
|
|
2728
2630
|
this._denominator = Math.abs(this._denominator);
|
|
2729
2631
|
return this;
|
|
2730
2632
|
};
|
|
2633
|
+
static max = (...fractions) => {
|
|
2634
|
+
let M = new Fraction(fractions[0]);
|
|
2635
|
+
for (let m of fractions) {
|
|
2636
|
+
let compare = new Fraction(m);
|
|
2637
|
+
if (compare.greater(M)) {
|
|
2638
|
+
M = compare.clone();
|
|
2639
|
+
}
|
|
2640
|
+
}
|
|
2641
|
+
return M;
|
|
2642
|
+
};
|
|
2643
|
+
static min = (...fractions) => {
|
|
2644
|
+
let M = new Fraction(fractions[0]);
|
|
2645
|
+
for (let m of fractions) {
|
|
2646
|
+
let compare = new Fraction(m);
|
|
2647
|
+
if (compare.lesser(M)) {
|
|
2648
|
+
M = compare.clone();
|
|
2649
|
+
}
|
|
2650
|
+
}
|
|
2651
|
+
return M;
|
|
2652
|
+
};
|
|
2731
2653
|
reduce = () => {
|
|
2732
|
-
let g =
|
|
2654
|
+
let g = numeric_1.Numeric.gcd(this._numerator, this._denominator);
|
|
2733
2655
|
this._numerator = this._numerator / g;
|
|
2734
2656
|
this._denominator = this._denominator / g;
|
|
2735
2657
|
if (this._denominator < 0) {
|
|
@@ -2749,19 +2671,26 @@ class Fraction {
|
|
|
2749
2671
|
if (sign === undefined) {
|
|
2750
2672
|
sign = '=';
|
|
2751
2673
|
}
|
|
2674
|
+
let compareFraction;
|
|
2675
|
+
if (F instanceof Fraction) {
|
|
2676
|
+
compareFraction = F.clone();
|
|
2677
|
+
}
|
|
2678
|
+
else {
|
|
2679
|
+
compareFraction = new Fraction(F);
|
|
2680
|
+
}
|
|
2752
2681
|
switch (sign) {
|
|
2753
2682
|
case '>':
|
|
2754
|
-
return this.value >
|
|
2683
|
+
return this.value > compareFraction.value;
|
|
2755
2684
|
case ">=" || 0 || 0:
|
|
2756
|
-
return this.value >=
|
|
2685
|
+
return this.value >= compareFraction.value;
|
|
2757
2686
|
case "<":
|
|
2758
|
-
return this.value <
|
|
2687
|
+
return this.value < compareFraction.value;
|
|
2759
2688
|
case "<=" || 0 || 0:
|
|
2760
|
-
return this.value <=
|
|
2689
|
+
return this.value <= compareFraction.value;
|
|
2761
2690
|
case "=":
|
|
2762
|
-
return this.value ===
|
|
2691
|
+
return this.value === compareFraction.value;
|
|
2763
2692
|
case "<>":
|
|
2764
|
-
return this.value !==
|
|
2693
|
+
return this.value !== compareFraction.value;
|
|
2765
2694
|
default:
|
|
2766
2695
|
return false;
|
|
2767
2696
|
}
|
|
@@ -2781,7 +2710,7 @@ class Fraction {
|
|
|
2781
2710
|
isEqual = (than) => {
|
|
2782
2711
|
return this.compare(than, '=');
|
|
2783
2712
|
};
|
|
2784
|
-
|
|
2713
|
+
isNotEqual = (than) => {
|
|
2785
2714
|
return this.compare(than, '<>');
|
|
2786
2715
|
};
|
|
2787
2716
|
isOpposed = (p) => {
|
|
@@ -2793,15 +2722,27 @@ class Fraction {
|
|
|
2793
2722
|
isZero = () => {
|
|
2794
2723
|
return this._numerator === 0;
|
|
2795
2724
|
};
|
|
2725
|
+
isNotZero = () => {
|
|
2726
|
+
return this._numerator !== 0;
|
|
2727
|
+
};
|
|
2796
2728
|
isOne = () => {
|
|
2797
2729
|
return this._numerator === 1 && this._denominator === 1;
|
|
2798
2730
|
};
|
|
2731
|
+
isNegativeOne = () => {
|
|
2732
|
+
return this._numerator === -1 && this._denominator === 1;
|
|
2733
|
+
};
|
|
2799
2734
|
isPositive = () => {
|
|
2800
2735
|
return this.sign() === 1;
|
|
2801
2736
|
};
|
|
2802
2737
|
isNegative = () => {
|
|
2803
2738
|
return this.sign() === -1;
|
|
2804
2739
|
};
|
|
2740
|
+
isStrictlyPositive = () => {
|
|
2741
|
+
return this.value > 0;
|
|
2742
|
+
};
|
|
2743
|
+
isStrictlyNegative = () => {
|
|
2744
|
+
return this.value < 0;
|
|
2745
|
+
};
|
|
2805
2746
|
isNaN = () => {
|
|
2806
2747
|
return isNaN(this._numerator);
|
|
2807
2748
|
};
|
|
@@ -2815,7 +2756,19 @@ class Fraction {
|
|
|
2815
2756
|
return Math.sqrt(this._numerator) % 1 === 0 && Math.sqrt(this._denominator) % 1 === 0;
|
|
2816
2757
|
};
|
|
2817
2758
|
isReduced = () => {
|
|
2818
|
-
return Math.abs(
|
|
2759
|
+
return Math.abs(numeric_1.Numeric.gcd(this._numerator, this._denominator)) === 1;
|
|
2760
|
+
};
|
|
2761
|
+
isNatural = () => {
|
|
2762
|
+
return this.clone().reduce().denominator === 1;
|
|
2763
|
+
};
|
|
2764
|
+
isRational = () => {
|
|
2765
|
+
return !this.isNatural();
|
|
2766
|
+
};
|
|
2767
|
+
isEven = () => {
|
|
2768
|
+
return this.isNatural() && this.value % 2 === 0;
|
|
2769
|
+
};
|
|
2770
|
+
isOdd = () => {
|
|
2771
|
+
return this.isNatural() && this.value % 2 === 1;
|
|
2819
2772
|
};
|
|
2820
2773
|
sign = () => {
|
|
2821
2774
|
return (this._numerator * this._denominator >= 0) ? 1 : -1;
|
|
@@ -2829,6 +2782,7 @@ class Fraction {
|
|
|
2829
2782
|
return true;
|
|
2830
2783
|
};
|
|
2831
2784
|
}
|
|
2785
|
+
exports.Fraction = Fraction;
|
|
2832
2786
|
|
|
2833
2787
|
|
|
2834
2788
|
/***/ }),
|
|
@@ -2837,17 +2791,22 @@ class Fraction {
|
|
|
2837
2791
|
/*!*****************************************!*\
|
|
2838
2792
|
!*** ./src/maths/coefficients/index.ts ***!
|
|
2839
2793
|
\*****************************************/
|
|
2840
|
-
/***/ ((__unused_webpack_module,
|
|
2794
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
2841
2795
|
|
|
2842
|
-
__webpack_require__.r(__webpack_exports__);
|
|
2843
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2844
|
-
/* harmony export */ "Fraction": () => (/* reexport safe */ _fraction__WEBPACK_IMPORTED_MODULE_0__.Fraction),
|
|
2845
|
-
/* harmony export */ "Nthroot": () => (/* reexport safe */ _nthroot__WEBPACK_IMPORTED_MODULE_1__.Nthroot)
|
|
2846
|
-
/* harmony export */ });
|
|
2847
|
-
/* harmony import */ var _fraction__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fraction */ "./src/maths/coefficients/fraction.ts");
|
|
2848
|
-
/* harmony import */ var _nthroot__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./nthroot */ "./src/maths/coefficients/nthroot.ts");
|
|
2849
|
-
|
|
2850
2796
|
|
|
2797
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2798
|
+
if (k2 === undefined) k2 = k;
|
|
2799
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
2800
|
+
}) : (function(o, m, k, k2) {
|
|
2801
|
+
if (k2 === undefined) k2 = k;
|
|
2802
|
+
o[k2] = m[k];
|
|
2803
|
+
}));
|
|
2804
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
2805
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
2806
|
+
};
|
|
2807
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2808
|
+
__exportStar(__webpack_require__(/*! ./fraction */ "./src/maths/coefficients/fraction.ts"), exports);
|
|
2809
|
+
__exportStar(__webpack_require__(/*! ./nthroot */ "./src/maths/coefficients/nthroot.ts"), exports);
|
|
2851
2810
|
|
|
2852
2811
|
|
|
2853
2812
|
/***/ }),
|
|
@@ -2856,12 +2815,11 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2856
2815
|
/*!*******************************************!*\
|
|
2857
2816
|
!*** ./src/maths/coefficients/nthroot.ts ***!
|
|
2858
2817
|
\*******************************************/
|
|
2859
|
-
/***/ ((__unused_webpack_module,
|
|
2818
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
2860
2819
|
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
/* harmony export */ });
|
|
2820
|
+
|
|
2821
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2822
|
+
exports.Nthroot = void 0;
|
|
2865
2823
|
class Nthroot {
|
|
2866
2824
|
_radical;
|
|
2867
2825
|
_nth;
|
|
@@ -2953,6 +2911,7 @@ class Nthroot {
|
|
|
2953
2911
|
return !(this._radical === 1 || this._radical === 0 || this._isValid === false);
|
|
2954
2912
|
};
|
|
2955
2913
|
}
|
|
2914
|
+
exports.Nthroot = Nthroot;
|
|
2956
2915
|
|
|
2957
2916
|
|
|
2958
2917
|
/***/ }),
|
|
@@ -2961,23 +2920,20 @@ class Nthroot {
|
|
|
2961
2920
|
/*!**************************************!*\
|
|
2962
2921
|
!*** ./src/maths/geometry/circle.ts ***!
|
|
2963
2922
|
\**************************************/
|
|
2964
|
-
/***/ ((__unused_webpack_module,
|
|
2923
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
2965
2924
|
|
|
2966
|
-
__webpack_require__.r(__webpack_exports__);
|
|
2967
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2968
|
-
/* harmony export */ "Circle": () => (/* binding */ Circle)
|
|
2969
|
-
/* harmony export */ });
|
|
2970
|
-
/* harmony import */ var _point__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./point */ "./src/maths/geometry/point.ts");
|
|
2971
|
-
/* harmony import */ var _coefficients_fraction__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
2972
|
-
/* harmony import */ var _algebra_equation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../algebra/equation */ "./src/maths/algebra/equation.ts");
|
|
2973
|
-
/* harmony import */ var _algebra_polynom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../algebra/polynom */ "./src/maths/algebra/polynom.ts");
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
2925
|
|
|
2926
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2927
|
+
exports.Circle = void 0;
|
|
2928
|
+
const point_1 = __webpack_require__(/*! ./point */ "./src/maths/geometry/point.ts");
|
|
2929
|
+
const coefficients_1 = __webpack_require__(/*! ../coefficients */ "./src/maths/coefficients/index.ts");
|
|
2930
|
+
const algebra_1 = __webpack_require__(/*! ../algebra */ "./src/maths/algebra/index.ts");
|
|
2931
|
+
const vector_1 = __webpack_require__(/*! ./vector */ "./src/maths/geometry/vector.ts");
|
|
2978
2932
|
class Circle {
|
|
2979
2933
|
_center;
|
|
2980
2934
|
_radius;
|
|
2935
|
+
_squareRadius;
|
|
2936
|
+
_cartesian;
|
|
2981
2937
|
_exists;
|
|
2982
2938
|
constructor(...values) {
|
|
2983
2939
|
this._exists = false;
|
|
@@ -2985,11 +2941,23 @@ class Circle {
|
|
|
2985
2941
|
this.parse(...values);
|
|
2986
2942
|
}
|
|
2987
2943
|
}
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2944
|
+
get center() {
|
|
2945
|
+
return this._center;
|
|
2946
|
+
}
|
|
2947
|
+
get radius() {
|
|
2948
|
+
if (this._squareRadius.isSquare()) {
|
|
2949
|
+
return {
|
|
2950
|
+
tex: this._squareRadius.clone().sqrt().tex,
|
|
2951
|
+
display: this._squareRadius.clone().sqrt().display,
|
|
2952
|
+
};
|
|
2953
|
+
}
|
|
2954
|
+
else {
|
|
2955
|
+
return {
|
|
2956
|
+
tex: `\\sqrt{${this._squareRadius.tex}}`,
|
|
2957
|
+
display: `sqrt(${this._squareRadius.display})`
|
|
2958
|
+
};
|
|
2992
2959
|
}
|
|
2960
|
+
return this._squareRadius;
|
|
2993
2961
|
}
|
|
2994
2962
|
get tex() {
|
|
2995
2963
|
let cx, cy;
|
|
@@ -2997,21 +2965,85 @@ class Circle {
|
|
|
2997
2965
|
cx = 'x^2';
|
|
2998
2966
|
}
|
|
2999
2967
|
else {
|
|
3000
|
-
cx = `\\left(x
|
|
2968
|
+
cx = `\\left(x${this._center.x.isNegative() ? '+' : '-'}${this._center.x.clone().abs().tex}\\right)^2`;
|
|
3001
2969
|
}
|
|
3002
2970
|
if (this._center.y.isZero()) {
|
|
3003
2971
|
cy = 'y^2';
|
|
3004
2972
|
}
|
|
3005
2973
|
else {
|
|
3006
|
-
cy = `\\left(y
|
|
2974
|
+
cy = `\\left(y${this._center.y.isNegative() ? '+' : '-'}${this._center.y.clone().abs().tex}\\right)^2`;
|
|
3007
2975
|
}
|
|
3008
|
-
return `${cx}+${cy}=${this.
|
|
2976
|
+
return `${cx}+${cy}=${this._squareRadius.tex}`;
|
|
3009
2977
|
}
|
|
3010
2978
|
get developed() {
|
|
3011
|
-
|
|
3012
|
-
return equ.moveLeft().tex;
|
|
2979
|
+
return this._cartesian.tex;
|
|
3013
2980
|
}
|
|
2981
|
+
get display() {
|
|
2982
|
+
return this._cartesian.display;
|
|
2983
|
+
}
|
|
2984
|
+
get cartesian() {
|
|
2985
|
+
return this._cartesian;
|
|
2986
|
+
}
|
|
2987
|
+
parse(...values) {
|
|
2988
|
+
if (values.length === 1 && typeof values[0] === 'string') {
|
|
2989
|
+
this.checkCircle(new algebra_1.Equation(values[0]));
|
|
2990
|
+
}
|
|
2991
|
+
else if (values.length >= 2) {
|
|
2992
|
+
this._center = new point_1.Point(values[0]);
|
|
2993
|
+
if (values[1] instanceof point_1.Point) {
|
|
2994
|
+
this._squareRadius = new vector_1.Vector(this._center, values[1]).normSquare;
|
|
2995
|
+
}
|
|
2996
|
+
else {
|
|
2997
|
+
if (values[2] === true) {
|
|
2998
|
+
this._squareRadius = new coefficients_1.Fraction(values[1]);
|
|
2999
|
+
}
|
|
3000
|
+
else {
|
|
3001
|
+
this._radius = new coefficients_1.Fraction(values[1]);
|
|
3002
|
+
this._squareRadius = this._radius.clone().pow(2);
|
|
3003
|
+
}
|
|
3004
|
+
}
|
|
3005
|
+
this._cartesian = (new algebra_1.Equation(new algebra_1.Polynom(`(x-(${this._center.x.display}))^2+(y-(${this._center.y.display}))^2`), new algebra_1.Polynom(`${this._squareRadius.display}`))).moveLeft();
|
|
3006
|
+
}
|
|
3007
|
+
}
|
|
3008
|
+
checkCircle = (P) => {
|
|
3009
|
+
if (P.degree('x').value === 2 && P.degree('y').value === 2) {
|
|
3010
|
+
let x2 = P.left.monomByDegree(2, 'x'), y2 = P.left.monomByDegree(2, 'y'), x1, y1, c;
|
|
3011
|
+
if (x2.coefficient.isEqual(y2.coefficient)) {
|
|
3012
|
+
P.divide(x2.coefficient);
|
|
3013
|
+
x1 = P.left.monomByDegree(1, 'x');
|
|
3014
|
+
y1 = P.left.monomByDegree(1, 'y');
|
|
3015
|
+
c = P.left.monomByDegree(0);
|
|
3016
|
+
this._center = new point_1.Point(x1.coefficient.clone().divide(2).opposed(), y1.coefficient.clone().divide(2).opposed());
|
|
3017
|
+
this._squareRadius = c.coefficient.clone().opposed()
|
|
3018
|
+
.add(this._center.x.clone().pow(2))
|
|
3019
|
+
.add(this._center.y.clone().pow(2));
|
|
3020
|
+
}
|
|
3021
|
+
}
|
|
3022
|
+
return false;
|
|
3023
|
+
};
|
|
3024
|
+
relativePosition = (L) => {
|
|
3025
|
+
let distance = L.distanceTo(this.center), radius = Math.sqrt(this._squareRadius.value);
|
|
3026
|
+
if (distance.value - radius > 0.0000000001) {
|
|
3027
|
+
return 0;
|
|
3028
|
+
}
|
|
3029
|
+
else if (Math.abs(distance.value - radius) < 0.0000000001) {
|
|
3030
|
+
return 1;
|
|
3031
|
+
}
|
|
3032
|
+
else {
|
|
3033
|
+
return 2;
|
|
3034
|
+
}
|
|
3035
|
+
};
|
|
3036
|
+
lineIntersection = (L) => {
|
|
3037
|
+
let P1, P2;
|
|
3038
|
+
const equ = this._cartesian.clone(), yLine = L.equation.clone().isolate('y');
|
|
3039
|
+
if (yLine instanceof algebra_1.Equation) {
|
|
3040
|
+
equ.replaceBy('y', yLine.right);
|
|
3041
|
+
equ.solve();
|
|
3042
|
+
}
|
|
3043
|
+
return [];
|
|
3044
|
+
};
|
|
3014
3045
|
}
|
|
3046
|
+
exports.Circle = Circle;
|
|
3015
3047
|
|
|
3016
3048
|
|
|
3017
3049
|
/***/ }),
|
|
@@ -3020,50 +3052,25 @@ class Circle {
|
|
|
3020
3052
|
/*!*************************************!*\
|
|
3021
3053
|
!*** ./src/maths/geometry/index.ts ***!
|
|
3022
3054
|
\*************************************/
|
|
3023
|
-
/***/ ((__unused_webpack_module,
|
|
3055
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
3024
3056
|
|
|
3025
|
-
__webpack_require__.r(__webpack_exports__);
|
|
3026
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3027
|
-
/* harmony export */ "Vector": () => (/* reexport safe */ _vector__WEBPACK_IMPORTED_MODULE_0__.Vector),
|
|
3028
|
-
/* harmony export */ "Triangle": () => (/* reexport safe */ _triangle__WEBPACK_IMPORTED_MODULE_1__.Triangle),
|
|
3029
|
-
/* harmony export */ "Point": () => (/* reexport safe */ _point__WEBPACK_IMPORTED_MODULE_2__.Point),
|
|
3030
|
-
/* harmony export */ "Circle": () => (/* reexport safe */ _circle__WEBPACK_IMPORTED_MODULE_3__.Circle),
|
|
3031
|
-
/* harmony export */ "Line": () => (/* reexport safe */ _line__WEBPACK_IMPORTED_MODULE_4__.Line),
|
|
3032
|
-
/* harmony export */ "Geometry": () => (/* binding */ Geometry)
|
|
3033
|
-
/* harmony export */ });
|
|
3034
|
-
/* harmony import */ var _vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vector */ "./src/maths/geometry/vector.ts");
|
|
3035
|
-
/* harmony import */ var _triangle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./triangle */ "./src/maths/geometry/triangle.ts");
|
|
3036
|
-
/* harmony import */ var _point__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./point */ "./src/maths/geometry/point.ts");
|
|
3037
|
-
/* harmony import */ var _circle__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./circle */ "./src/maths/geometry/circle.ts");
|
|
3038
|
-
/* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./line */ "./src/maths/geometry/line.ts");
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
3057
|
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
}
|
|
3062
|
-
Geometry.Triangle = Triangle;
|
|
3063
|
-
class Vector extends _vector__WEBPACK_IMPORTED_MODULE_0__.Vector {
|
|
3064
|
-
}
|
|
3065
|
-
Geometry.Vector = Vector;
|
|
3066
|
-
})(Geometry || (Geometry = {}));
|
|
3058
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3059
|
+
if (k2 === undefined) k2 = k;
|
|
3060
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
3061
|
+
}) : (function(o, m, k, k2) {
|
|
3062
|
+
if (k2 === undefined) k2 = k;
|
|
3063
|
+
o[k2] = m[k];
|
|
3064
|
+
}));
|
|
3065
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
3066
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
3067
|
+
};
|
|
3068
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3069
|
+
__exportStar(__webpack_require__(/*! ./vector */ "./src/maths/geometry/vector.ts"), exports);
|
|
3070
|
+
__exportStar(__webpack_require__(/*! ./triangle */ "./src/maths/geometry/triangle.ts"), exports);
|
|
3071
|
+
__exportStar(__webpack_require__(/*! ./point */ "./src/maths/geometry/point.ts"), exports);
|
|
3072
|
+
__exportStar(__webpack_require__(/*! ./circle */ "./src/maths/geometry/circle.ts"), exports);
|
|
3073
|
+
__exportStar(__webpack_require__(/*! ./line */ "./src/maths/geometry/line.ts"), exports);
|
|
3067
3074
|
|
|
3068
3075
|
|
|
3069
3076
|
/***/ }),
|
|
@@ -3072,24 +3079,22 @@ var Geometry;
|
|
|
3072
3079
|
/*!************************************!*\
|
|
3073
3080
|
!*** ./src/maths/geometry/line.ts ***!
|
|
3074
3081
|
\************************************/
|
|
3075
|
-
/***/ ((__unused_webpack_module,
|
|
3082
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
3076
3083
|
|
|
3077
|
-
__webpack_require__.r(__webpack_exports__);
|
|
3078
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3079
|
-
/* harmony export */ "Line": () => (/* binding */ Line)
|
|
3080
|
-
/* harmony export */ });
|
|
3081
|
-
/* harmony import */ var _coefficients_fraction__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
3082
|
-
/* harmony import */ var _vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vector */ "./src/maths/geometry/vector.ts");
|
|
3083
|
-
/* harmony import */ var _point__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./point */ "./src/maths/geometry/point.ts");
|
|
3084
|
-
/* harmony import */ var _algebra_polynom__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../algebra/polynom */ "./src/maths/algebra/polynom.ts");
|
|
3085
|
-
/* harmony import */ var _numeric__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
3086
|
-
/* harmony import */ var _algebra_equation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../algebra/equation */ "./src/maths/algebra/equation.ts");
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
3084
|
|
|
3085
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3086
|
+
exports.Line = void 0;
|
|
3087
|
+
const coefficients_1 = __webpack_require__(/*! ../coefficients */ "./src/maths/coefficients/index.ts");
|
|
3088
|
+
const vector_1 = __webpack_require__(/*! ./vector */ "./src/maths/geometry/vector.ts");
|
|
3089
|
+
const point_1 = __webpack_require__(/*! ./point */ "./src/maths/geometry/point.ts");
|
|
3090
|
+
const algebra_1 = __webpack_require__(/*! ../algebra */ "./src/maths/algebra/index.ts");
|
|
3091
|
+
const numeric_1 = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
3092
|
+
var LinePropriety;
|
|
3093
|
+
(function (LinePropriety) {
|
|
3094
|
+
LinePropriety[LinePropriety["None"] = 0] = "None";
|
|
3095
|
+
LinePropriety[LinePropriety["Parallel"] = 1] = "Parallel";
|
|
3096
|
+
LinePropriety[LinePropriety["Perpendicular"] = 2] = "Perpendicular";
|
|
3097
|
+
})(LinePropriety || (LinePropriety = {}));
|
|
3093
3098
|
class Line {
|
|
3094
3099
|
_a;
|
|
3095
3100
|
_b;
|
|
@@ -3098,17 +3103,25 @@ class Line {
|
|
|
3098
3103
|
_d;
|
|
3099
3104
|
_n;
|
|
3100
3105
|
_exists;
|
|
3106
|
+
_referencePropriety;
|
|
3107
|
+
_referenceLine;
|
|
3108
|
+
static PERPENDICULAR = LinePropriety.Perpendicular;
|
|
3109
|
+
static PARALLEL = LinePropriety.Parallel;
|
|
3101
3110
|
constructor(...values) {
|
|
3102
3111
|
this._exists = false;
|
|
3103
|
-
if (values
|
|
3112
|
+
if (values.length > 0) {
|
|
3104
3113
|
this.parse(...values);
|
|
3105
3114
|
}
|
|
3106
3115
|
return this;
|
|
3107
3116
|
}
|
|
3108
|
-
get isLine() {
|
|
3109
|
-
|
|
3117
|
+
get isLine() {
|
|
3118
|
+
return true;
|
|
3119
|
+
}
|
|
3120
|
+
get exists() {
|
|
3121
|
+
return this._exists;
|
|
3122
|
+
}
|
|
3110
3123
|
get equation() {
|
|
3111
|
-
return new
|
|
3124
|
+
return new algebra_1.Equation(new algebra_1.Polynom().parse('xy', this._a, this._b, this._c), new algebra_1.Polynom('0')).simplify();
|
|
3112
3125
|
}
|
|
3113
3126
|
get tex() {
|
|
3114
3127
|
let canonical = this.equation;
|
|
@@ -3117,8 +3130,8 @@ class Line {
|
|
|
3117
3130
|
}
|
|
3118
3131
|
return {
|
|
3119
3132
|
canonical: canonical.tex,
|
|
3120
|
-
mxh: this.slope.isInfinity() ? 'x=' + this.OA.x.tex : 'y=' + new
|
|
3121
|
-
parametric: `${
|
|
3133
|
+
mxh: this.slope.isInfinity() ? 'x=' + this.OA.x.tex : 'y=' + new algebra_1.Polynom().parse('x', this.slope, this.height).tex,
|
|
3134
|
+
parametric: `${point_1.Point.pmatrix('x', 'y')} = ${point_1.Point.pmatrix(this._OA.x, this._OA.y)} + k\\cdot ${point_1.Point.pmatrix(this._d.x, this._d.y)}`
|
|
3122
3135
|
};
|
|
3123
3136
|
}
|
|
3124
3137
|
get a() {
|
|
@@ -3152,7 +3165,10 @@ class Line {
|
|
|
3152
3165
|
return this._n;
|
|
3153
3166
|
}
|
|
3154
3167
|
get normal() {
|
|
3155
|
-
return new
|
|
3168
|
+
return new vector_1.Vector(this._a, this._b);
|
|
3169
|
+
}
|
|
3170
|
+
get director() {
|
|
3171
|
+
return this._d.clone();
|
|
3156
3172
|
}
|
|
3157
3173
|
set d(value) {
|
|
3158
3174
|
this._d = value;
|
|
@@ -3165,49 +3181,71 @@ class Line {
|
|
|
3165
3181
|
}
|
|
3166
3182
|
parse = (...values) => {
|
|
3167
3183
|
this._exists = false;
|
|
3168
|
-
if (values.length ===
|
|
3169
|
-
return this
|
|
3170
|
-
}
|
|
3171
|
-
else if (values.length === 2) {
|
|
3172
|
-
if (values[0].isPoint && values[1].isVector) {
|
|
3173
|
-
return this.parseByPointAndVector(values[0], values[1]);
|
|
3174
|
-
}
|
|
3175
|
-
else if (values[0].isPoint && values[1].isPoint) {
|
|
3176
|
-
return this.parseByPointAndVector(values[0], new _vector__WEBPACK_IMPORTED_MODULE_1__.Vector(values[0], values[1]));
|
|
3177
|
-
}
|
|
3184
|
+
if (values.length === 0) {
|
|
3185
|
+
return this;
|
|
3178
3186
|
}
|
|
3179
|
-
|
|
3180
|
-
if (values[0]
|
|
3187
|
+
if (values.length === 1) {
|
|
3188
|
+
if (values[0] instanceof Line) {
|
|
3181
3189
|
return values[0].clone();
|
|
3182
3190
|
}
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
for (let elem of ['x', 'y']) {
|
|
3191
|
-
if (letters.has(elem)) {
|
|
3192
|
-
letters.delete(elem);
|
|
3193
|
-
}
|
|
3191
|
+
else if (values[0] instanceof algebra_1.Equation) {
|
|
3192
|
+
return this.parseEquation(values[0]);
|
|
3193
|
+
}
|
|
3194
|
+
else if (typeof values[0] === "string") {
|
|
3195
|
+
try {
|
|
3196
|
+
let E = new algebra_1.Equation(values[0]);
|
|
3197
|
+
return this.parse(E);
|
|
3194
3198
|
}
|
|
3195
|
-
|
|
3196
|
-
console.log('Extra variable in the equation.');
|
|
3199
|
+
catch (e) {
|
|
3197
3200
|
return this;
|
|
3198
3201
|
}
|
|
3199
|
-
|
|
3202
|
+
}
|
|
3203
|
+
}
|
|
3204
|
+
if (values.length === 2) {
|
|
3205
|
+
if (values[0] instanceof point_1.Point && values[1] instanceof vector_1.Vector) {
|
|
3206
|
+
return this.parseByPointAndVector(values[0], values[1]);
|
|
3207
|
+
}
|
|
3208
|
+
else if (values[0] instanceof point_1.Point && values[1] instanceof point_1.Point) {
|
|
3209
|
+
return this.parseByPointAndVector(values[0], new vector_1.Vector(values[0], values[1]));
|
|
3210
|
+
}
|
|
3211
|
+
else if (values[0] instanceof vector_1.Vector && values[1] instanceof point_1.Point) {
|
|
3212
|
+
return this.parseByPointAndNormal(values[1], values[0]);
|
|
3213
|
+
}
|
|
3214
|
+
}
|
|
3215
|
+
if (values.length === 3) {
|
|
3216
|
+
if ((values[0] instanceof coefficients_1.Fraction || typeof values[0] === 'number')
|
|
3217
|
+
&&
|
|
3218
|
+
(values[1] instanceof coefficients_1.Fraction || typeof values[1] === 'number')
|
|
3219
|
+
&&
|
|
3220
|
+
(values[2] instanceof coefficients_1.Fraction || typeof values[2] === 'number')) {
|
|
3221
|
+
return this.parseByCoefficient(values[0], values[1], values[2]);
|
|
3200
3222
|
}
|
|
3201
3223
|
}
|
|
3202
3224
|
console.log('Someting wrong happend while creating the line');
|
|
3203
3225
|
return this;
|
|
3204
3226
|
};
|
|
3227
|
+
parseEquation = (equ) => {
|
|
3228
|
+
equ.reorder(true);
|
|
3229
|
+
let letters = new Set(equ.letters());
|
|
3230
|
+
if (!(letters.has('x') || letters.has('y'))) {
|
|
3231
|
+
return this;
|
|
3232
|
+
}
|
|
3233
|
+
for (let elem of ['x', 'y']) {
|
|
3234
|
+
if (letters.has(elem)) {
|
|
3235
|
+
letters.delete(elem);
|
|
3236
|
+
}
|
|
3237
|
+
}
|
|
3238
|
+
if (letters.size > 0) {
|
|
3239
|
+
return this;
|
|
3240
|
+
}
|
|
3241
|
+
return this.parseByCoefficient(equ.left.monomByLetter('x').coefficient, equ.left.monomByLetter('y').coefficient, equ.left.monomByDegree(0).coefficient);
|
|
3242
|
+
};
|
|
3205
3243
|
parseByCoefficient = (a, b, c) => {
|
|
3206
|
-
this._a = new
|
|
3207
|
-
this._b = new
|
|
3208
|
-
this._c = new
|
|
3209
|
-
this._d = new
|
|
3210
|
-
this._OA = new
|
|
3244
|
+
this._a = new coefficients_1.Fraction(a);
|
|
3245
|
+
this._b = new coefficients_1.Fraction(b);
|
|
3246
|
+
this._c = new coefficients_1.Fraction(c);
|
|
3247
|
+
this._d = new vector_1.Vector(this._b.clone(), this._a.clone().opposed());
|
|
3248
|
+
this._OA = new point_1.Point(new coefficients_1.Fraction().zero(), this._c.clone());
|
|
3211
3249
|
this._n = this._d.clone().normal();
|
|
3212
3250
|
this._exists = true;
|
|
3213
3251
|
return this;
|
|
@@ -3220,6 +3258,23 @@ class Line {
|
|
|
3220
3258
|
this._exists = true;
|
|
3221
3259
|
return this;
|
|
3222
3260
|
};
|
|
3261
|
+
parseByPointAndNormal = (P, n) => {
|
|
3262
|
+
return this.parseByCoefficient(n.x, n.y, P.x.clone().multiply(n.x)
|
|
3263
|
+
.add(P.y.clone().multiply(n.y)).opposed());
|
|
3264
|
+
};
|
|
3265
|
+
parseByPointAndLine = (P, L, orientation) => {
|
|
3266
|
+
if (orientation === undefined) {
|
|
3267
|
+
orientation = LinePropriety.Parallel;
|
|
3268
|
+
}
|
|
3269
|
+
if (orientation === LinePropriety.Parallel) {
|
|
3270
|
+
return this.parseByPointAndNormal(P, L.normal);
|
|
3271
|
+
}
|
|
3272
|
+
else if (orientation === LinePropriety.Perpendicular) {
|
|
3273
|
+
return this.parseByPointAndNormal(P, L.director);
|
|
3274
|
+
}
|
|
3275
|
+
this._exists = false;
|
|
3276
|
+
return this;
|
|
3277
|
+
};
|
|
3223
3278
|
clone = () => {
|
|
3224
3279
|
this._a = this._a.clone();
|
|
3225
3280
|
this._b = this._b.clone();
|
|
@@ -3227,22 +3282,23 @@ class Line {
|
|
|
3227
3282
|
this._d = this._d.clone();
|
|
3228
3283
|
this._OA = this._OA.clone();
|
|
3229
3284
|
this._n = this._n.clone();
|
|
3285
|
+
this._exists = this.exists;
|
|
3230
3286
|
return this;
|
|
3231
3287
|
};
|
|
3232
3288
|
isParellelTo = (line) => {
|
|
3233
|
-
return this.slope.isEqual(line.slope) && this.height.
|
|
3289
|
+
return this.slope.isEqual(line.slope) && this.height.isNotEqual(line.height);
|
|
3234
3290
|
};
|
|
3235
3291
|
isSameAs = (line) => {
|
|
3236
3292
|
return this.slope.isEqual(line.slope) && this.height.isEqual(line.height);
|
|
3237
3293
|
};
|
|
3238
3294
|
simplifyDirection = () => {
|
|
3239
|
-
let lcm =
|
|
3295
|
+
let lcm = numeric_1.Numeric.lcm(this._d.x.denominator, this._d.y.denominator), gcd = numeric_1.Numeric.gcd(this._d.x.numerator, this._d.y.numerator);
|
|
3240
3296
|
this._d.x.multiply(lcm).divide(gcd);
|
|
3241
3297
|
this._d.y.multiply(lcm).divide(gcd);
|
|
3242
3298
|
return this;
|
|
3243
3299
|
};
|
|
3244
3300
|
intersection = (line) => {
|
|
3245
|
-
let Pt = new
|
|
3301
|
+
let Pt = new point_1.Point(), isParallel = false, isSame = false, hasIntersection = true;
|
|
3246
3302
|
if (this._b.isZero() || line.b.isZero()) {
|
|
3247
3303
|
}
|
|
3248
3304
|
if (this.isParellelTo(line)) {
|
|
@@ -3276,7 +3332,7 @@ class Line {
|
|
|
3276
3332
|
return {
|
|
3277
3333
|
value: NaN,
|
|
3278
3334
|
tex: 'Not a line',
|
|
3279
|
-
fraction: new
|
|
3335
|
+
fraction: new coefficients_1.Fraction().infinite()
|
|
3280
3336
|
};
|
|
3281
3337
|
}
|
|
3282
3338
|
let value = numerator.value / Math.sqrt(d2.value), F = numerator.clone().divide(d2.clone().sqrt());
|
|
@@ -3303,6 +3359,20 @@ class Line {
|
|
|
3303
3359
|
}
|
|
3304
3360
|
return false;
|
|
3305
3361
|
}
|
|
3362
|
+
getValueAtX = (value) => {
|
|
3363
|
+
const equ = this.equation.clone().isolate('y');
|
|
3364
|
+
if (equ instanceof algebra_1.Equation) {
|
|
3365
|
+
return equ.right.evaluate({ x: value });
|
|
3366
|
+
}
|
|
3367
|
+
return;
|
|
3368
|
+
};
|
|
3369
|
+
getValueAtY = (value) => {
|
|
3370
|
+
const equ = this.equation.clone().isolate('x');
|
|
3371
|
+
if (equ instanceof algebra_1.Equation) {
|
|
3372
|
+
return equ.right.evaluate({ y: value });
|
|
3373
|
+
}
|
|
3374
|
+
return;
|
|
3375
|
+
};
|
|
3306
3376
|
canonicalAsFloatCoefficient(decimals) {
|
|
3307
3377
|
if (decimals === undefined) {
|
|
3308
3378
|
decimals = 2;
|
|
@@ -3334,6 +3404,7 @@ class Line {
|
|
|
3334
3404
|
return canonical + '=0';
|
|
3335
3405
|
}
|
|
3336
3406
|
}
|
|
3407
|
+
exports.Line = Line;
|
|
3337
3408
|
|
|
3338
3409
|
|
|
3339
3410
|
/***/ }),
|
|
@@ -3342,21 +3413,19 @@ class Line {
|
|
|
3342
3413
|
/*!*************************************!*\
|
|
3343
3414
|
!*** ./src/maths/geometry/point.ts ***!
|
|
3344
3415
|
\*************************************/
|
|
3345
|
-
/***/ ((__unused_webpack_module,
|
|
3416
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
3346
3417
|
|
|
3347
|
-
__webpack_require__.r(__webpack_exports__);
|
|
3348
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3349
|
-
/* harmony export */ "Point": () => (/* binding */ Point)
|
|
3350
|
-
/* harmony export */ });
|
|
3351
|
-
/* harmony import */ var _coefficients_fraction__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
3352
3418
|
|
|
3419
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3420
|
+
exports.Point = void 0;
|
|
3421
|
+
const fraction_1 = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
3353
3422
|
class Point {
|
|
3354
3423
|
_x;
|
|
3355
3424
|
_y;
|
|
3356
3425
|
_exist;
|
|
3357
3426
|
constructor(...values) {
|
|
3358
|
-
this._x = new
|
|
3359
|
-
this._y = new
|
|
3427
|
+
this._x = new fraction_1.Fraction().zero();
|
|
3428
|
+
this._y = new fraction_1.Fraction().zero();
|
|
3360
3429
|
if (values !== undefined) {
|
|
3361
3430
|
this.parse(...values);
|
|
3362
3431
|
}
|
|
@@ -3384,6 +3453,12 @@ class Point {
|
|
|
3384
3453
|
pts.push(this._y.tex);
|
|
3385
3454
|
return `\\left(${pts.join(';')}\\right)`;
|
|
3386
3455
|
}
|
|
3456
|
+
get display() {
|
|
3457
|
+
let pts = [];
|
|
3458
|
+
pts.push(this._x.tex);
|
|
3459
|
+
pts.push(this._y.tex);
|
|
3460
|
+
return `(${pts.join(';')})`;
|
|
3461
|
+
}
|
|
3387
3462
|
parse = (...values) => {
|
|
3388
3463
|
this.zero();
|
|
3389
3464
|
if (values.length === 0) {
|
|
@@ -3398,22 +3473,22 @@ class Point {
|
|
|
3398
3473
|
if (typeof values[0] === 'string') {
|
|
3399
3474
|
let xy = values[0].split(',');
|
|
3400
3475
|
if (xy.length === 2) {
|
|
3401
|
-
this._x = new
|
|
3402
|
-
this._y = new
|
|
3476
|
+
this._x = new fraction_1.Fraction(xy[0]).reduce();
|
|
3477
|
+
this._y = new fraction_1.Fraction(xy[1]).reduce();
|
|
3403
3478
|
return this;
|
|
3404
3479
|
}
|
|
3405
3480
|
}
|
|
3406
3481
|
if (values[0].x !== undefined && values[0].y !== undefined) {
|
|
3407
|
-
this._x = new
|
|
3408
|
-
this._y = new
|
|
3482
|
+
this._x = new fraction_1.Fraction(values[0].x).reduce();
|
|
3483
|
+
this._y = new fraction_1.Fraction(values[0].y).reduce();
|
|
3409
3484
|
}
|
|
3410
3485
|
else {
|
|
3411
3486
|
return this.zero();
|
|
3412
3487
|
}
|
|
3413
3488
|
}
|
|
3414
3489
|
if (values.length === 2) {
|
|
3415
|
-
this._x = new
|
|
3416
|
-
this._y = new
|
|
3490
|
+
this._x = new fraction_1.Fraction(values[0]).reduce();
|
|
3491
|
+
this._y = new fraction_1.Fraction(values[1]).reduce();
|
|
3417
3492
|
}
|
|
3418
3493
|
return this;
|
|
3419
3494
|
};
|
|
@@ -3423,8 +3498,8 @@ class Point {
|
|
|
3423
3498
|
return this;
|
|
3424
3499
|
};
|
|
3425
3500
|
zero = () => {
|
|
3426
|
-
this._x = new
|
|
3427
|
-
this._y = new
|
|
3501
|
+
this._x = new fraction_1.Fraction(null);
|
|
3502
|
+
this._y = new fraction_1.Fraction(null);
|
|
3428
3503
|
return this;
|
|
3429
3504
|
};
|
|
3430
3505
|
origin = () => {
|
|
@@ -3451,6 +3526,7 @@ class Point {
|
|
|
3451
3526
|
}
|
|
3452
3527
|
};
|
|
3453
3528
|
}
|
|
3529
|
+
exports.Point = Point;
|
|
3454
3530
|
|
|
3455
3531
|
|
|
3456
3532
|
/***/ }),
|
|
@@ -3459,22 +3535,16 @@ class Point {
|
|
|
3459
3535
|
/*!****************************************!*\
|
|
3460
3536
|
!*** ./src/maths/geometry/triangle.ts ***!
|
|
3461
3537
|
\****************************************/
|
|
3462
|
-
/***/ ((__unused_webpack_module,
|
|
3538
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
3463
3539
|
|
|
3464
|
-
__webpack_require__.r(__webpack_exports__);
|
|
3465
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3466
|
-
/* harmony export */ "Triangle": () => (/* binding */ Triangle)
|
|
3467
|
-
/* harmony export */ });
|
|
3468
|
-
/* harmony import */ var _point__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./point */ "./src/maths/geometry/point.ts");
|
|
3469
|
-
/* harmony import */ var _coefficients_fraction__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
3470
|
-
/* harmony import */ var _vector__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vector */ "./src/maths/geometry/vector.ts");
|
|
3471
|
-
/* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./line */ "./src/maths/geometry/line.ts");
|
|
3472
|
-
/* harmony import */ var _algebra_equation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../algebra/equation */ "./src/maths/algebra/equation.ts");
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
3540
|
|
|
3541
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3542
|
+
exports.Triangle = void 0;
|
|
3543
|
+
const point_1 = __webpack_require__(/*! ./point */ "./src/maths/geometry/point.ts");
|
|
3544
|
+
const fraction_1 = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
3545
|
+
const vector_1 = __webpack_require__(/*! ./vector */ "./src/maths/geometry/vector.ts");
|
|
3546
|
+
const line_1 = __webpack_require__(/*! ./line */ "./src/maths/geometry/line.ts");
|
|
3547
|
+
const equation_1 = __webpack_require__(/*! ../algebra/equation */ "./src/maths/algebra/equation.ts");
|
|
3478
3548
|
class Triangle {
|
|
3479
3549
|
_A;
|
|
3480
3550
|
_B;
|
|
@@ -3545,12 +3615,12 @@ class Triangle {
|
|
|
3545
3615
|
}
|
|
3546
3616
|
parse = (...values) => {
|
|
3547
3617
|
if (values.length === 6) {
|
|
3548
|
-
let v = values.map((x) => new
|
|
3549
|
-
return this.parse(new
|
|
3618
|
+
let v = values.map((x) => new fraction_1.Fraction(x));
|
|
3619
|
+
return this.parse(new point_1.Point(v[0], v[1]), new point_1.Point(v[2], v[3]), new point_1.Point(v[4], v[5]));
|
|
3550
3620
|
}
|
|
3551
3621
|
else if (values.length === 3) {
|
|
3552
3622
|
if (values.filter((x) => typeof x === 'string').length === 3) {
|
|
3553
|
-
return this.parse(...values.map((x) => new
|
|
3623
|
+
return this.parse(...values.map((x) => new line_1.Line(x)));
|
|
3554
3624
|
}
|
|
3555
3625
|
else if (values.filter((x) => x.isLine === true).length === 3) {
|
|
3556
3626
|
this._lines = {
|
|
@@ -3582,15 +3652,15 @@ class Triangle {
|
|
|
3582
3652
|
}
|
|
3583
3653
|
else {
|
|
3584
3654
|
if (values.filter((x) => x.isPoint === true).length < 3) {
|
|
3585
|
-
return this.parse(new
|
|
3655
|
+
return this.parse(new point_1.Point(values[0]), new point_1.Point(values[1]), new point_1.Point(values[2]));
|
|
3586
3656
|
}
|
|
3587
3657
|
this._A = values[0].clone();
|
|
3588
3658
|
this._B = values[1].clone();
|
|
3589
3659
|
this._C = values[2].clone();
|
|
3590
3660
|
this._lines = {
|
|
3591
|
-
'AB': new
|
|
3592
|
-
'BC': new
|
|
3593
|
-
'AC': new
|
|
3661
|
+
'AB': new line_1.Line(this._A, this._B),
|
|
3662
|
+
'BC': new line_1.Line(this._B, this._C),
|
|
3663
|
+
'AC': new line_1.Line(this._A, this._C)
|
|
3594
3664
|
};
|
|
3595
3665
|
}
|
|
3596
3666
|
}
|
|
@@ -3616,9 +3686,9 @@ class Triangle {
|
|
|
3616
3686
|
};
|
|
3617
3687
|
_updateTriangle = () => {
|
|
3618
3688
|
this._middles = {
|
|
3619
|
-
'AB': new
|
|
3620
|
-
'AC': new
|
|
3621
|
-
'BC': new
|
|
3689
|
+
'AB': new point_1.Point().middleOf(this._A, this._B),
|
|
3690
|
+
'AC': new point_1.Point().middleOf(this._A, this._C),
|
|
3691
|
+
'BC': new point_1.Point().middleOf(this._B, this._C)
|
|
3622
3692
|
};
|
|
3623
3693
|
this._remarquables = this._calculateRemarquableLines();
|
|
3624
3694
|
};
|
|
@@ -3634,26 +3704,26 @@ class Triangle {
|
|
|
3634
3704
|
return this._A;
|
|
3635
3705
|
};
|
|
3636
3706
|
getSegment = (ptName1, ptName2) => {
|
|
3637
|
-
return new
|
|
3707
|
+
return new vector_1.Vector(this.getPointByName(ptName1), this.getPointByName(ptName2));
|
|
3638
3708
|
};
|
|
3639
3709
|
_calculateRemarquableLines = () => {
|
|
3640
3710
|
let remarquables = {
|
|
3641
3711
|
'medians': {
|
|
3642
|
-
'A': new
|
|
3643
|
-
'B': new
|
|
3644
|
-
'C': new
|
|
3712
|
+
'A': new line_1.Line(this._A, this._middles.BC),
|
|
3713
|
+
'B': new line_1.Line(this._B, this._middles.AC),
|
|
3714
|
+
'C': new line_1.Line(this._C, this._middles.AB),
|
|
3645
3715
|
'intersection': null
|
|
3646
3716
|
},
|
|
3647
3717
|
'mediators': {
|
|
3648
|
-
'AB': new
|
|
3649
|
-
'AC': new
|
|
3650
|
-
'BC': new
|
|
3718
|
+
'AB': new line_1.Line(this._middles.AB, new vector_1.Vector(this._A, this._B).normal()),
|
|
3719
|
+
'AC': new line_1.Line(this._middles.AC, new vector_1.Vector(this._A, this._C).normal()),
|
|
3720
|
+
'BC': new line_1.Line(this._middles.BC, new vector_1.Vector(this._B, this._C).normal()),
|
|
3651
3721
|
'intersection': null
|
|
3652
3722
|
},
|
|
3653
3723
|
'heights': {
|
|
3654
|
-
'A': new
|
|
3655
|
-
'B': new
|
|
3656
|
-
'C': new
|
|
3724
|
+
'A': new line_1.Line(this._A, new vector_1.Vector(this._B, this._C).normal()),
|
|
3725
|
+
'B': new line_1.Line(this._B, new vector_1.Vector(this._A, this._C).normal()),
|
|
3726
|
+
'C': new line_1.Line(this._C, new vector_1.Vector(this._A, this._B).normal()),
|
|
3657
3727
|
'intersection': null
|
|
3658
3728
|
},
|
|
3659
3729
|
'bisectors': {
|
|
@@ -3683,7 +3753,7 @@ class Triangle {
|
|
|
3683
3753
|
d1 = tlines.BC;
|
|
3684
3754
|
d2 = tlines.AC;
|
|
3685
3755
|
}
|
|
3686
|
-
let b1 = new
|
|
3756
|
+
let b1 = new line_1.Line(new equation_1.Equation(d1.equation.left.clone().multiply(d2.n.simplify().norm), d2.equation.left.clone().multiply(d1.n.simplify().norm)).reorder(true).simplify()), b2 = new line_1.Line(new equation_1.Equation(d1.equation.left.clone().multiply(d2.n.simplify().norm), d2.equation.left.clone().multiply(d1.n.simplify().norm).opposed()).reorder(true).simplify());
|
|
3687
3757
|
if (pt === 'A') {
|
|
3688
3758
|
return b1.hitSegment(this.B, this.C) ? b1 : b2;
|
|
3689
3759
|
}
|
|
@@ -3696,6 +3766,7 @@ class Triangle {
|
|
|
3696
3766
|
return b1;
|
|
3697
3767
|
};
|
|
3698
3768
|
}
|
|
3769
|
+
exports.Triangle = Triangle;
|
|
3699
3770
|
|
|
3700
3771
|
|
|
3701
3772
|
/***/ }),
|
|
@@ -3704,30 +3775,24 @@ class Triangle {
|
|
|
3704
3775
|
/*!**************************************!*\
|
|
3705
3776
|
!*** ./src/maths/geometry/vector.ts ***!
|
|
3706
3777
|
\**************************************/
|
|
3707
|
-
/***/ ((__unused_webpack_module,
|
|
3778
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
3708
3779
|
|
|
3709
|
-
__webpack_require__.r(__webpack_exports__);
|
|
3710
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3711
|
-
/* harmony export */ "Vector": () => (/* binding */ Vector)
|
|
3712
|
-
/* harmony export */ });
|
|
3713
|
-
/* harmony import */ var _coefficients_fraction__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
3714
|
-
/* harmony import */ var _numeric__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
3715
|
-
|
|
3716
3780
|
|
|
3781
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3782
|
+
exports.Vector = void 0;
|
|
3783
|
+
const fraction_1 = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
3784
|
+
const numeric_1 = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
3717
3785
|
class Vector {
|
|
3718
3786
|
_x;
|
|
3719
3787
|
_y;
|
|
3720
3788
|
constructor(...values) {
|
|
3721
|
-
this._x = new
|
|
3722
|
-
this._y = new
|
|
3789
|
+
this._x = new fraction_1.Fraction().zero();
|
|
3790
|
+
this._y = new fraction_1.Fraction().zero();
|
|
3723
3791
|
if (values !== undefined) {
|
|
3724
3792
|
this.parse(...values);
|
|
3725
3793
|
}
|
|
3726
3794
|
}
|
|
3727
3795
|
;
|
|
3728
|
-
get isVector() {
|
|
3729
|
-
return true;
|
|
3730
|
-
}
|
|
3731
3796
|
get x() {
|
|
3732
3797
|
return this._x;
|
|
3733
3798
|
}
|
|
@@ -3755,7 +3820,7 @@ class Vector {
|
|
|
3755
3820
|
return this;
|
|
3756
3821
|
}
|
|
3757
3822
|
if (values.length === 1) {
|
|
3758
|
-
if (values[0]
|
|
3823
|
+
if (values[0] instanceof Vector) {
|
|
3759
3824
|
return values[0].clone();
|
|
3760
3825
|
}
|
|
3761
3826
|
else {
|
|
@@ -3769,10 +3834,10 @@ class Vector {
|
|
|
3769
3834
|
return this;
|
|
3770
3835
|
}
|
|
3771
3836
|
if (values[0].isFraction || !isNaN(values[0])) {
|
|
3772
|
-
this._x = new
|
|
3837
|
+
this._x = new fraction_1.Fraction(values[0]);
|
|
3773
3838
|
}
|
|
3774
3839
|
if (values[1].isFraction || !isNaN(values[1])) {
|
|
3775
|
-
this._y = new
|
|
3840
|
+
this._y = new fraction_1.Fraction(values[1]);
|
|
3776
3841
|
}
|
|
3777
3842
|
}
|
|
3778
3843
|
return this;
|
|
@@ -3794,19 +3859,19 @@ class Vector {
|
|
|
3794
3859
|
};
|
|
3795
3860
|
zero = () => {
|
|
3796
3861
|
this.reset();
|
|
3797
|
-
this._x = new
|
|
3798
|
-
this._y = new
|
|
3862
|
+
this._x = new fraction_1.Fraction(null);
|
|
3863
|
+
this._y = new fraction_1.Fraction(null);
|
|
3799
3864
|
return this;
|
|
3800
3865
|
};
|
|
3801
3866
|
one = () => {
|
|
3802
|
-
this._x = new
|
|
3803
|
-
this._y = new
|
|
3867
|
+
this._x = new fraction_1.Fraction();
|
|
3868
|
+
this._y = new fraction_1.Fraction();
|
|
3804
3869
|
return this;
|
|
3805
3870
|
};
|
|
3806
3871
|
_parseString = (value) => {
|
|
3807
3872
|
let components = value.split(/[,;\s]/g);
|
|
3808
|
-
this.x = new
|
|
3809
|
-
this.y = new
|
|
3873
|
+
this.x = new fraction_1.Fraction(components[0] || null);
|
|
3874
|
+
this.y = new fraction_1.Fraction(components[1] || null);
|
|
3810
3875
|
return this;
|
|
3811
3876
|
};
|
|
3812
3877
|
opposed = () => {
|
|
@@ -3838,17 +3903,17 @@ class Vector {
|
|
|
3838
3903
|
return this.scalarProductWithVector(v).isZero();
|
|
3839
3904
|
};
|
|
3840
3905
|
multiplyByScalar = (k) => {
|
|
3841
|
-
let scalar = new
|
|
3906
|
+
let scalar = new fraction_1.Fraction(k);
|
|
3842
3907
|
this._x.multiply(scalar);
|
|
3843
3908
|
this._y.multiply(scalar);
|
|
3844
3909
|
return this;
|
|
3845
3910
|
};
|
|
3846
3911
|
divideByScalar = (k) => {
|
|
3847
|
-
return this.multiplyByScalar(new
|
|
3912
|
+
return this.multiplyByScalar(new fraction_1.Fraction(k).invert());
|
|
3848
3913
|
};
|
|
3849
3914
|
simplify = () => {
|
|
3850
|
-
return this.multiplyByScalar(
|
|
3851
|
-
.divideByScalar(
|
|
3915
|
+
return this.multiplyByScalar(numeric_1.Numeric.lcm(this._x.denominator, this._y.denominator))
|
|
3916
|
+
.divideByScalar(numeric_1.Numeric.gcd(this._x.numerator, this._y.numerator));
|
|
3852
3917
|
};
|
|
3853
3918
|
angleWith = (V, sharp, radian) => {
|
|
3854
3919
|
let scalar = this.scalarProductWithVector(V).value, toDegree = radian ? 1 : 180 / Math.PI;
|
|
@@ -3858,6 +3923,7 @@ class Vector {
|
|
|
3858
3923
|
return toDegree * Math.acos(scalar / (this.norm * V.norm));
|
|
3859
3924
|
};
|
|
3860
3925
|
}
|
|
3926
|
+
exports.Vector = Vector;
|
|
3861
3927
|
|
|
3862
3928
|
|
|
3863
3929
|
/***/ }),
|
|
@@ -3866,12 +3932,11 @@ class Vector {
|
|
|
3866
3932
|
/*!******************************!*\
|
|
3867
3933
|
!*** ./src/maths/numeric.ts ***!
|
|
3868
3934
|
\******************************/
|
|
3869
|
-
/***/ ((__unused_webpack_module,
|
|
3935
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
3870
3936
|
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
/* harmony export */ });
|
|
3937
|
+
|
|
3938
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3939
|
+
exports.Numeric = void 0;
|
|
3875
3940
|
class Numeric {
|
|
3876
3941
|
static round(value, decimals = 2) {
|
|
3877
3942
|
return Number(Math.round(Number(value + 'e' + decimals)) + 'e-' + decimals);
|
|
@@ -3933,6 +3998,7 @@ class Numeric {
|
|
|
3933
3998
|
});
|
|
3934
3999
|
}
|
|
3935
4000
|
}
|
|
4001
|
+
exports.Numeric = Numeric;
|
|
3936
4002
|
|
|
3937
4003
|
|
|
3938
4004
|
/***/ }),
|
|
@@ -3941,43 +4007,53 @@ class Numeric {
|
|
|
3941
4007
|
/*!***********************************!*\
|
|
3942
4008
|
!*** ./src/maths/random/index.ts ***!
|
|
3943
4009
|
\***********************************/
|
|
3944
|
-
/***/ ((__unused_webpack_module,
|
|
4010
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
3945
4011
|
|
|
3946
|
-
__webpack_require__.r(__webpack_exports__);
|
|
3947
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3948
|
-
/* harmony export */ "Random": () => (/* binding */ Random)
|
|
3949
|
-
/* harmony export */ });
|
|
3950
|
-
/* harmony import */ var _rndPolynom__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./rndPolynom */ "./src/maths/random/rndPolynom.ts");
|
|
3951
|
-
/* harmony import */ var _rndMonom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rndMonom */ "./src/maths/random/rndMonom.ts");
|
|
3952
|
-
/* harmony import */ var _rndHelpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./rndHelpers */ "./src/maths/random/rndHelpers.ts");
|
|
3953
|
-
/* harmony import */ var _rndTypes__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./rndTypes */ "./src/maths/random/rndTypes.ts");
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
4012
|
|
|
4013
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4014
|
+
if (k2 === undefined) k2 = k;
|
|
4015
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
4016
|
+
}) : (function(o, m, k, k2) {
|
|
4017
|
+
if (k2 === undefined) k2 = k;
|
|
4018
|
+
o[k2] = m[k];
|
|
4019
|
+
}));
|
|
4020
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
4021
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
4022
|
+
};
|
|
4023
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4024
|
+
exports.Random = void 0;
|
|
4025
|
+
const rndPolynom_1 = __webpack_require__(/*! ./rndPolynom */ "./src/maths/random/rndPolynom.ts");
|
|
4026
|
+
const rndMonom_1 = __webpack_require__(/*! ./rndMonom */ "./src/maths/random/rndMonom.ts");
|
|
4027
|
+
const rndHelpers_1 = __webpack_require__(/*! ./rndHelpers */ "./src/maths/random/rndHelpers.ts");
|
|
4028
|
+
const rndFraction_1 = __webpack_require__(/*! ./rndFraction */ "./src/maths/random/rndFraction.ts");
|
|
4029
|
+
__exportStar(__webpack_require__(/*! ./rndTypes */ "./src/maths/random/rndTypes.ts"), exports);
|
|
3958
4030
|
var Random;
|
|
3959
4031
|
(function (Random) {
|
|
3960
4032
|
function polynom(config) {
|
|
3961
|
-
return (new
|
|
4033
|
+
return (new rndPolynom_1.rndPolynom(config)).generate();
|
|
3962
4034
|
}
|
|
3963
4035
|
Random.polynom = polynom;
|
|
3964
4036
|
function monom(config) {
|
|
3965
|
-
return (new
|
|
4037
|
+
return (new rndMonom_1.rndMonom(config)).generate();
|
|
3966
4038
|
}
|
|
3967
4039
|
Random.monom = monom;
|
|
3968
|
-
function
|
|
4040
|
+
function fraction(config) {
|
|
4041
|
+
return (new rndFraction_1.rndFraction(config)).generate();
|
|
4042
|
+
}
|
|
4043
|
+
Random.fraction = fraction;
|
|
4044
|
+
function number(from, to) { return rndHelpers_1.rndHelpers.randomInt(from, to); }
|
|
3969
4045
|
Random.number = number;
|
|
3970
|
-
function numberSym(max, allowZero) { return
|
|
4046
|
+
function numberSym(max, allowZero) { return rndHelpers_1.rndHelpers.randomIntSym(max, allowZero); }
|
|
3971
4047
|
Random.numberSym = numberSym;
|
|
3972
|
-
function bool(percent) { return
|
|
4048
|
+
function bool(percent) { return rndHelpers_1.rndHelpers.randomBool(percent); }
|
|
3973
4049
|
Random.bool = bool;
|
|
3974
|
-
function array(arr, number) { return
|
|
4050
|
+
function array(arr, number) { return rndHelpers_1.rndHelpers.randomArray(arr, number); }
|
|
3975
4051
|
Random.array = array;
|
|
3976
|
-
function item(arr) { return
|
|
4052
|
+
function item(arr) { return rndHelpers_1.rndHelpers.randomItem(arr); }
|
|
3977
4053
|
Random.item = item;
|
|
3978
|
-
function shuffle(arr) {
|
|
4054
|
+
function shuffle(arr) { rndHelpers_1.rndHelpers.shuffleArray(arr); }
|
|
3979
4055
|
Random.shuffle = shuffle;
|
|
3980
|
-
})(Random || (Random = {}));
|
|
4056
|
+
})(Random = exports.Random || (exports.Random = {}));
|
|
3981
4057
|
|
|
3982
4058
|
|
|
3983
4059
|
/***/ }),
|
|
@@ -3986,12 +4062,11 @@ var Random;
|
|
|
3986
4062
|
/*!****************************************!*\
|
|
3987
4063
|
!*** ./src/maths/random/randomCore.ts ***!
|
|
3988
4064
|
\****************************************/
|
|
3989
|
-
/***/ ((__unused_webpack_module,
|
|
4065
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
3990
4066
|
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
/* harmony export */ });
|
|
4067
|
+
|
|
4068
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4069
|
+
exports.randomCore = void 0;
|
|
3995
4070
|
class randomCore {
|
|
3996
4071
|
_config;
|
|
3997
4072
|
_defaultConfig;
|
|
@@ -4009,6 +4084,52 @@ class randomCore {
|
|
|
4009
4084
|
return this;
|
|
4010
4085
|
};
|
|
4011
4086
|
}
|
|
4087
|
+
exports.randomCore = randomCore;
|
|
4088
|
+
|
|
4089
|
+
|
|
4090
|
+
/***/ }),
|
|
4091
|
+
|
|
4092
|
+
/***/ "./src/maths/random/rndFraction.ts":
|
|
4093
|
+
/*!*****************************************!*\
|
|
4094
|
+
!*** ./src/maths/random/rndFraction.ts ***!
|
|
4095
|
+
\*****************************************/
|
|
4096
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
4097
|
+
|
|
4098
|
+
|
|
4099
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4100
|
+
exports.rndFraction = void 0;
|
|
4101
|
+
const randomCore_1 = __webpack_require__(/*! ./randomCore */ "./src/maths/random/randomCore.ts");
|
|
4102
|
+
const coefficients_1 = __webpack_require__(/*! ../coefficients */ "./src/maths/coefficients/index.ts");
|
|
4103
|
+
const index_1 = __webpack_require__(/*! ./index */ "./src/maths/random/index.ts");
|
|
4104
|
+
class rndFraction extends randomCore_1.randomCore {
|
|
4105
|
+
constructor(userConfig) {
|
|
4106
|
+
super();
|
|
4107
|
+
this._defaultConfig = {
|
|
4108
|
+
negative: true,
|
|
4109
|
+
reduced: true,
|
|
4110
|
+
zero: true,
|
|
4111
|
+
natural: false
|
|
4112
|
+
};
|
|
4113
|
+
this._config = this.mergeConfig(userConfig, this._defaultConfig);
|
|
4114
|
+
}
|
|
4115
|
+
generate = () => {
|
|
4116
|
+
let Q = new coefficients_1.Fraction();
|
|
4117
|
+
if (this._config.negative) {
|
|
4118
|
+
Q.numerator = index_1.Random.numberSym(10, this._config.zero);
|
|
4119
|
+
}
|
|
4120
|
+
else {
|
|
4121
|
+
Q.numerator = index_1.Random.number(this._config.zero ? 0 : 1, 10);
|
|
4122
|
+
}
|
|
4123
|
+
if (this._config.natural) {
|
|
4124
|
+
Q.denominator = 1;
|
|
4125
|
+
}
|
|
4126
|
+
else {
|
|
4127
|
+
Q.denominator = index_1.Random.number(1, 10);
|
|
4128
|
+
}
|
|
4129
|
+
return this._config.reduced ? Q.reduce() : Q;
|
|
4130
|
+
};
|
|
4131
|
+
}
|
|
4132
|
+
exports.rndFraction = rndFraction;
|
|
4012
4133
|
|
|
4013
4134
|
|
|
4014
4135
|
/***/ }),
|
|
@@ -4017,12 +4138,11 @@ class randomCore {
|
|
|
4017
4138
|
/*!****************************************!*\
|
|
4018
4139
|
!*** ./src/maths/random/rndHelpers.ts ***!
|
|
4019
4140
|
\****************************************/
|
|
4020
|
-
/***/ ((__unused_webpack_module,
|
|
4141
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
4021
4142
|
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
/* harmony export */ });
|
|
4143
|
+
|
|
4144
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4145
|
+
exports.rndHelpers = void 0;
|
|
4026
4146
|
class rndHelpers {
|
|
4027
4147
|
static randomBool(percent = 0.5) {
|
|
4028
4148
|
return Math.random() < percent;
|
|
@@ -4067,6 +4187,7 @@ class rndHelpers {
|
|
|
4067
4187
|
return shuffleArray;
|
|
4068
4188
|
}
|
|
4069
4189
|
}
|
|
4190
|
+
exports.rndHelpers = rndHelpers;
|
|
4070
4191
|
|
|
4071
4192
|
|
|
4072
4193
|
/***/ }),
|
|
@@ -4075,19 +4196,15 @@ class rndHelpers {
|
|
|
4075
4196
|
/*!**************************************!*\
|
|
4076
4197
|
!*** ./src/maths/random/rndMonom.ts ***!
|
|
4077
4198
|
\**************************************/
|
|
4078
|
-
/***/ ((__unused_webpack_module,
|
|
4199
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
4079
4200
|
|
|
4080
|
-
__webpack_require__.r(__webpack_exports__);
|
|
4081
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
4082
|
-
/* harmony export */ "rndMonom": () => (/* binding */ rndMonom)
|
|
4083
|
-
/* harmony export */ });
|
|
4084
|
-
/* harmony import */ var _randomCore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./randomCore */ "./src/maths/random/randomCore.ts");
|
|
4085
|
-
/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./index */ "./src/maths/random/index.ts");
|
|
4086
|
-
/* harmony import */ var _algebra_monom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../algebra/monom */ "./src/maths/algebra/monom.ts");
|
|
4087
4201
|
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4202
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4203
|
+
exports.rndMonom = void 0;
|
|
4204
|
+
const randomCore_1 = __webpack_require__(/*! ./randomCore */ "./src/maths/random/randomCore.ts");
|
|
4205
|
+
const index_1 = __webpack_require__(/*! ./index */ "./src/maths/random/index.ts");
|
|
4206
|
+
const monom_1 = __webpack_require__(/*! ../algebra/monom */ "./src/maths/algebra/monom.ts");
|
|
4207
|
+
class rndMonom extends randomCore_1.randomCore {
|
|
4091
4208
|
constructor(userConfig) {
|
|
4092
4209
|
super();
|
|
4093
4210
|
this._defaultConfig = {
|
|
@@ -4099,15 +4216,19 @@ class rndMonom extends _randomCore__WEBPACK_IMPORTED_MODULE_0__.randomCore {
|
|
|
4099
4216
|
this._config = this.mergeConfig(userConfig, this._defaultConfig);
|
|
4100
4217
|
}
|
|
4101
4218
|
generate = () => {
|
|
4102
|
-
let M = new
|
|
4103
|
-
M.coefficient
|
|
4219
|
+
let M = new monom_1.Monom();
|
|
4220
|
+
M.coefficient = index_1.Random.fraction({
|
|
4221
|
+
zero: this._config.zero,
|
|
4222
|
+
reduced: true,
|
|
4223
|
+
natural: !this._config.fraction
|
|
4224
|
+
});
|
|
4104
4225
|
if (this._config.letters.length > 1) {
|
|
4105
4226
|
for (let L of this._config.letters.split('')) {
|
|
4106
4227
|
M.setLetter(L, 0);
|
|
4107
4228
|
}
|
|
4108
4229
|
for (let i = 0; i < this._config.degree; i++) {
|
|
4109
|
-
const L =
|
|
4110
|
-
M.setLetter(L, M.degree(L)
|
|
4230
|
+
const L = index_1.Random.item(this._config.letters.split(""));
|
|
4231
|
+
M.setLetter(L, M.degree(L).clone().add(1));
|
|
4111
4232
|
}
|
|
4112
4233
|
}
|
|
4113
4234
|
else {
|
|
@@ -4116,6 +4237,7 @@ class rndMonom extends _randomCore__WEBPACK_IMPORTED_MODULE_0__.randomCore {
|
|
|
4116
4237
|
return M;
|
|
4117
4238
|
};
|
|
4118
4239
|
}
|
|
4240
|
+
exports.rndMonom = rndMonom;
|
|
4119
4241
|
|
|
4120
4242
|
|
|
4121
4243
|
/***/ }),
|
|
@@ -4124,21 +4246,16 @@ class rndMonom extends _randomCore__WEBPACK_IMPORTED_MODULE_0__.randomCore {
|
|
|
4124
4246
|
/*!****************************************!*\
|
|
4125
4247
|
!*** ./src/maths/random/rndPolynom.ts ***!
|
|
4126
4248
|
\****************************************/
|
|
4127
|
-
/***/ ((__unused_webpack_module,
|
|
4249
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
4128
4250
|
|
|
4129
|
-
__webpack_require__.r(__webpack_exports__);
|
|
4130
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
4131
|
-
/* harmony export */ "rndPolynom": () => (/* binding */ rndPolynom)
|
|
4132
|
-
/* harmony export */ });
|
|
4133
|
-
/* harmony import */ var _randomCore__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./randomCore */ "./src/maths/random/randomCore.ts");
|
|
4134
|
-
/* harmony import */ var _rndMonom__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./rndMonom */ "./src/maths/random/rndMonom.ts");
|
|
4135
|
-
/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./index */ "./src/maths/random/index.ts");
|
|
4136
|
-
/* harmony import */ var _algebra__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../algebra */ "./src/maths/algebra/index.ts");
|
|
4137
4251
|
|
|
4138
|
-
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4252
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4253
|
+
exports.rndPolynom = void 0;
|
|
4254
|
+
const randomCore_1 = __webpack_require__(/*! ./randomCore */ "./src/maths/random/randomCore.ts");
|
|
4255
|
+
const rndMonom_1 = __webpack_require__(/*! ./rndMonom */ "./src/maths/random/rndMonom.ts");
|
|
4256
|
+
const index_1 = __webpack_require__(/*! ./index */ "./src/maths/random/index.ts");
|
|
4257
|
+
const algebra_1 = __webpack_require__(/*! ../algebra */ "./src/maths/algebra/index.ts");
|
|
4258
|
+
class rndPolynom extends randomCore_1.randomCore {
|
|
4142
4259
|
constructor(userConfig) {
|
|
4143
4260
|
super();
|
|
4144
4261
|
this._defaultConfig = {
|
|
@@ -4157,9 +4274,9 @@ class rndPolynom extends _randomCore__WEBPACK_IMPORTED_MODULE_0__.randomCore {
|
|
|
4157
4274
|
if (this._config.factorable && this._config.degree > 1) {
|
|
4158
4275
|
return this.factorable();
|
|
4159
4276
|
}
|
|
4160
|
-
let P = new
|
|
4277
|
+
let P = new algebra_1.Polynom().empty(), M;
|
|
4161
4278
|
for (let i = this._config.degree; i >= 0; i--) {
|
|
4162
|
-
M = new
|
|
4279
|
+
M = new rndMonom_1.rndMonom({
|
|
4163
4280
|
letters: this._config.letters,
|
|
4164
4281
|
degree: i,
|
|
4165
4282
|
fraction: this._config.fraction,
|
|
@@ -4171,22 +4288,22 @@ class rndPolynom extends _randomCore__WEBPACK_IMPORTED_MODULE_0__.randomCore {
|
|
|
4171
4288
|
P.add(M);
|
|
4172
4289
|
}
|
|
4173
4290
|
if (this._config.numberOfMonoms > 0 && this._config.numberOfMonoms < P.length) {
|
|
4174
|
-
|
|
4175
|
-
P.monoms = _index__WEBPACK_IMPORTED_MODULE_2__.Random.array(P.monoms, this._config.numberOfMonoms);
|
|
4291
|
+
P.monoms = index_1.Random.array(P.monoms, this._config.numberOfMonoms);
|
|
4176
4292
|
}
|
|
4177
4293
|
return P;
|
|
4178
4294
|
};
|
|
4179
4295
|
factorable = () => {
|
|
4180
|
-
let P = new
|
|
4296
|
+
let P = new algebra_1.Polynom().one();
|
|
4181
4297
|
let _factorableConfig = { ...this._config };
|
|
4182
4298
|
_factorableConfig.degree = 1;
|
|
4183
4299
|
_factorableConfig.factorable = false;
|
|
4184
4300
|
for (let i = 0; i < this._config.degree; i++) {
|
|
4185
|
-
P.multiply(
|
|
4301
|
+
P.multiply(index_1.Random.polynom(_factorableConfig));
|
|
4186
4302
|
}
|
|
4187
4303
|
return P;
|
|
4188
4304
|
};
|
|
4189
4305
|
}
|
|
4306
|
+
exports.rndPolynom = rndPolynom;
|
|
4190
4307
|
|
|
4191
4308
|
|
|
4192
4309
|
/***/ }),
|
|
@@ -4195,10 +4312,10 @@ class rndPolynom extends _randomCore__WEBPACK_IMPORTED_MODULE_0__.randomCore {
|
|
|
4195
4312
|
/*!**************************************!*\
|
|
4196
4313
|
!*** ./src/maths/random/rndTypes.ts ***!
|
|
4197
4314
|
\**************************************/
|
|
4198
|
-
/***/ ((__unused_webpack_module,
|
|
4315
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
4199
4316
|
|
|
4200
|
-
__webpack_require__.r(__webpack_exports__);
|
|
4201
4317
|
|
|
4318
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4202
4319
|
|
|
4203
4320
|
|
|
4204
4321
|
/***/ }),
|
|
@@ -4207,12 +4324,11 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
4207
4324
|
/*!**********************************!*\
|
|
4208
4325
|
!*** ./src/maths/shutingyard.ts ***!
|
|
4209
4326
|
\**********************************/
|
|
4210
|
-
/***/ ((__unused_webpack_module,
|
|
4327
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
4211
4328
|
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
|
|
4215
|
-
/* harmony export */ });
|
|
4329
|
+
|
|
4330
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4331
|
+
exports.Shutingyard = void 0;
|
|
4216
4332
|
class Shutingyard {
|
|
4217
4333
|
_rpn = [];
|
|
4218
4334
|
_mode;
|
|
@@ -4442,6 +4558,7 @@ class Shutingyard {
|
|
|
4442
4558
|
return this._rpn;
|
|
4443
4559
|
}
|
|
4444
4560
|
}
|
|
4561
|
+
exports.Shutingyard = Shutingyard;
|
|
4445
4562
|
|
|
4446
4563
|
|
|
4447
4564
|
/***/ })
|
|
@@ -4466,79 +4583,46 @@ class Shutingyard {
|
|
|
4466
4583
|
/******/ };
|
|
4467
4584
|
/******/
|
|
4468
4585
|
/******/ // Execute the module function
|
|
4469
|
-
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
4586
|
+
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
4470
4587
|
/******/
|
|
4471
4588
|
/******/ // Return the exports of the module
|
|
4472
4589
|
/******/ return module.exports;
|
|
4473
4590
|
/******/ }
|
|
4474
4591
|
/******/
|
|
4475
4592
|
/************************************************************************/
|
|
4476
|
-
/******/ /* webpack/runtime/define property getters */
|
|
4477
|
-
/******/ (() => {
|
|
4478
|
-
/******/ // define getter functions for harmony exports
|
|
4479
|
-
/******/ __webpack_require__.d = (exports, definition) => {
|
|
4480
|
-
/******/ for(var key in definition) {
|
|
4481
|
-
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
4482
|
-
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
4483
|
-
/******/ }
|
|
4484
|
-
/******/ }
|
|
4485
|
-
/******/ };
|
|
4486
|
-
/******/ })();
|
|
4487
|
-
/******/
|
|
4488
|
-
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
4489
|
-
/******/ (() => {
|
|
4490
|
-
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
4491
|
-
/******/ })();
|
|
4492
|
-
/******/
|
|
4493
|
-
/******/ /* webpack/runtime/make namespace object */
|
|
4494
|
-
/******/ (() => {
|
|
4495
|
-
/******/ // define __esModule on exports
|
|
4496
|
-
/******/ __webpack_require__.r = (exports) => {
|
|
4497
|
-
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
4498
|
-
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4499
|
-
/******/ }
|
|
4500
|
-
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
4501
|
-
/******/ };
|
|
4502
|
-
/******/ })();
|
|
4503
|
-
/******/
|
|
4504
|
-
/************************************************************************/
|
|
4505
4593
|
var __webpack_exports__ = {};
|
|
4506
4594
|
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
|
4507
4595
|
(() => {
|
|
4596
|
+
var exports = __webpack_exports__;
|
|
4508
4597
|
/*!*********************!*\
|
|
4509
4598
|
!*** ./src/main.ts ***!
|
|
4510
4599
|
\*********************/
|
|
4511
|
-
__webpack_require__.r(__webpack_exports__);
|
|
4512
|
-
/* harmony import */ var _maths_numeric__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./maths/numeric */ "./src/maths/numeric.ts");
|
|
4513
|
-
/* harmony import */ var _maths_shutingyard__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./maths/shutingyard */ "./src/maths/shutingyard.ts");
|
|
4514
|
-
/* harmony import */ var _maths_random__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./maths/random */ "./src/maths/random/index.ts");
|
|
4515
|
-
/* harmony import */ var _maths_coefficients__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./maths/coefficients */ "./src/maths/coefficients/index.ts");
|
|
4516
|
-
/* harmony import */ var _maths_algebra__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./maths/algebra */ "./src/maths/algebra/index.ts");
|
|
4517
|
-
/* harmony import */ var _maths_geometry__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./maths/geometry */ "./src/maths/geometry/index.ts");
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
4600
|
|
|
4601
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
4602
|
+
const numeric_1 = __webpack_require__(/*! ./maths/numeric */ "./src/maths/numeric.ts");
|
|
4603
|
+
const shutingyard_1 = __webpack_require__(/*! ./maths/shutingyard */ "./src/maths/shutingyard.ts");
|
|
4604
|
+
const random_1 = __webpack_require__(/*! ./maths/random */ "./src/maths/random/index.ts");
|
|
4605
|
+
const coefficients_1 = __webpack_require__(/*! ./maths/coefficients */ "./src/maths/coefficients/index.ts");
|
|
4606
|
+
const algebra_1 = __webpack_require__(/*! ./maths/algebra */ "./src/maths/algebra/index.ts");
|
|
4607
|
+
const geometry_1 = __webpack_require__(/*! ./maths/geometry */ "./src/maths/geometry/index.ts");
|
|
4524
4608
|
window.Pi = {
|
|
4525
|
-
ShutingYard:
|
|
4526
|
-
Numeric:
|
|
4527
|
-
Fraction:
|
|
4528
|
-
Root:
|
|
4529
|
-
Monom:
|
|
4530
|
-
Polynom:
|
|
4531
|
-
Equation:
|
|
4532
|
-
LinearSystem:
|
|
4533
|
-
Rational:
|
|
4534
|
-
Logicalset:
|
|
4535
|
-
Random:
|
|
4609
|
+
ShutingYard: shutingyard_1.Shutingyard,
|
|
4610
|
+
Numeric: numeric_1.Numeric,
|
|
4611
|
+
Fraction: coefficients_1.Fraction,
|
|
4612
|
+
Root: coefficients_1.Nthroot,
|
|
4613
|
+
Monom: algebra_1.Monom,
|
|
4614
|
+
Polynom: algebra_1.Polynom,
|
|
4615
|
+
Equation: algebra_1.Equation,
|
|
4616
|
+
LinearSystem: algebra_1.LinearSystem,
|
|
4617
|
+
Rational: algebra_1.Rational,
|
|
4618
|
+
Logicalset: algebra_1.Logicalset,
|
|
4619
|
+
Random: random_1.Random,
|
|
4536
4620
|
Geometry: {
|
|
4537
|
-
Vector:
|
|
4538
|
-
Point:
|
|
4539
|
-
Line:
|
|
4540
|
-
Triangle:
|
|
4541
|
-
Circle:
|
|
4621
|
+
Vector: geometry_1.Vector,
|
|
4622
|
+
Point: geometry_1.Point,
|
|
4623
|
+
Line: geometry_1.Line,
|
|
4624
|
+
Triangle: geometry_1.Triangle,
|
|
4625
|
+
Circle: geometry_1.Circle
|
|
4542
4626
|
}
|
|
4543
4627
|
};
|
|
4544
4628
|
|