pimath 0.0.21 → 0.0.25
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/demo.css +3 -0
- package/dev/index.html +216 -53
- package/dev/pi.js +374 -132
- package/dev/pi.js.map +1 -1
- package/dist/pi.js +1 -1
- package/dist/pi.js.map +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/algebra.Equation.html +11 -13
- package/docs/classes/algebra.LinearSystem.html +1 -1
- package/docs/classes/algebra.Logicalset.html +3 -3
- package/docs/classes/algebra.Monom.html +42 -42
- package/docs/classes/algebra.Polynom.html +12 -25
- package/docs/classes/algebra.Rational.html +3 -3
- package/docs/classes/coefficients.Fraction.html +10 -6
- package/docs/classes/coefficients.Nthroot.html +3 -1
- package/docs/classes/geometry.Circle.html +3 -1
- package/docs/classes/geometry.Line.html +3 -1
- package/docs/classes/geometry.Point.html +1 -1
- package/docs/classes/geometry.Triangle.html +6 -6
- package/docs/classes/geometry.Vector.html +1 -1
- package/docs/classes/numeric.Numeric.html +5 -5
- package/docs/classes/shutingyard.Shutingyard.html +5 -5
- package/docs/index.html +1 -1
- package/docs/interfaces/geometry.remarquableLines.html +1 -1
- package/docs/modules/algebra.html +1 -1
- package/docs/modules/coefficients.html +1 -1
- package/docs/modules/geometry.html +1 -1
- package/docs/modules/numeric.html +1 -1
- package/docs/modules/random.Random.html +1 -1
- package/docs/modules/random.html +1 -1
- package/docs/modules/shutingyard.html +1 -1
- package/docs/modules.html +1 -1
- package/esm/maths/algebra/equation.d.ts +11 -5
- package/esm/maths/algebra/equation.js +159 -52
- package/esm/maths/algebra/equation.js.map +1 -1
- package/esm/maths/algebra/linearSystem.d.ts +3 -4
- package/esm/maths/algebra/linearSystem.js +2 -5
- package/esm/maths/algebra/linearSystem.js.map +1 -1
- package/esm/maths/algebra/logicalset.d.ts +2 -2
- package/esm/maths/algebra/logicalset.js.map +1 -1
- package/esm/maths/algebra/monom.d.ts +3 -2
- package/esm/maths/algebra/monom.js +22 -1
- package/esm/maths/algebra/monom.js.map +1 -1
- package/esm/maths/algebra/polynom.d.ts +6 -6
- package/esm/maths/algebra/polynom.js +3 -3
- package/esm/maths/algebra/polynom.js.map +1 -1
- package/esm/maths/coefficients/fraction.d.ts +2 -2
- package/esm/maths/coefficients/fraction.js +1 -1
- package/esm/maths/coefficients/fraction.js.map +1 -1
- package/esm/maths/coefficients/nthroot.d.ts +1 -1
- package/esm/maths/coefficients/nthroot.js +4 -1
- package/esm/maths/coefficients/nthroot.js.map +1 -1
- package/esm/maths/geometry/circle.d.ts +12 -3
- package/esm/maths/geometry/circle.js +125 -39
- package/esm/maths/geometry/circle.js.map +1 -1
- package/esm/maths/geometry/line.d.ts +4 -4
- package/esm/maths/geometry/line.js +17 -7
- package/esm/maths/geometry/line.js.map +1 -1
- package/esm/maths/geometry/point.d.ts +3 -4
- package/esm/maths/geometry/point.js +18 -15
- package/esm/maths/geometry/point.js.map +1 -1
- package/esm/maths/geometry/triangle.d.ts +0 -1
- package/esm/maths/geometry/triangle.js +3 -4
- package/esm/maths/geometry/triangle.js.map +1 -1
- package/esm/maths/geometry/vector.js +2 -1
- package/esm/maths/geometry/vector.js.map +1 -1
- package/esm/maths/random/index.js +18 -6
- package/esm/maths/random/index.js.map +1 -1
- package/esm/maths/random/rndFraction.js +4 -3
- package/esm/maths/random/rndFraction.js.map +1 -1
- package/esm/maths/random/rndMonom.d.ts +1 -1
- package/esm/maths/random/rndMonom.js +12 -7
- package/esm/maths/random/rndMonom.js.map +1 -1
- package/esm/maths/random/rndPolynom.js +8 -2
- package/esm/maths/random/rndPolynom.js.map +1 -1
- package/esm/maths/random/rndTypes.d.ts +3 -1
- package/package.json +3 -5
- package/src/maths/algebra/equation.ts +183 -73
- package/src/maths/algebra/linearSystem.ts +262 -265
- package/src/maths/algebra/logicalset.ts +1 -1
- package/src/maths/algebra/monom.ts +24 -18
- package/src/maths/algebra/polynom.ts +9 -9
- package/src/maths/coefficients/fraction.ts +11 -7
- package/src/maths/coefficients/nthroot.ts +8 -1
- package/src/maths/geometry/circle.ts +160 -45
- package/src/maths/geometry/line.ts +30 -11
- package/src/maths/geometry/point.ts +25 -18
- package/src/maths/geometry/triangle.ts +3 -5
- package/src/maths/geometry/vector.ts +4 -3
- package/src/maths/random/index.ts +24 -6
- package/src/maths/random/rndFraction.ts +4 -3
- package/src/maths/random/rndMonom.ts +39 -35
- package/src/maths/random/rndPolynom.ts +13 -3
- package/src/maths/random/rndTypes.ts +4 -2
- package/tests/algebra/monom.test.ts +18 -4
- package/tests/algebra/polynom.test.ts +10 -4
- package/tests/geometry/circle.test.ts +28 -0
- package/tsconfig.json +4 -1
- package/typedoc.katex.js +11 -0
- package/docs/classes/algebra.Algebra.Equation.html +0 -26
- package/docs/classes/algebra.Algebra.LinearSystem.html +0 -1
- package/docs/classes/algebra.Algebra.LogicalSet.html +0 -3
- package/docs/classes/algebra.Algebra.Monom.html +0 -111
- package/docs/classes/algebra.Algebra.Polynom.html +0 -36
- package/docs/classes/algebra.Algebra.Rational.html +0 -2
- package/docs/classes/geometry.Geometry.Circle.html +0 -1
- package/docs/classes/geometry.Geometry.Line.html +0 -1
- package/docs/classes/geometry.Geometry.Point.html +0 -1
- package/docs/classes/geometry.Geometry.Triangle.html +0 -9
- package/docs/classes/geometry.Geometry.Vector.html +0 -1
- package/docs/modules/algebra.Algebra.html +0 -1
- package/docs/modules/geometry.Geometry.html +0 -1
- package/src/maths/algebra/monom_bck.backup +0 -746
package/dev/pi.js
CHANGED
|
@@ -14,7 +14,6 @@ exports.Equation = void 0;
|
|
|
14
14
|
const polynom_1 = __webpack_require__(/*! ./polynom */ "./src/maths/algebra/polynom.ts");
|
|
15
15
|
const numeric_1 = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
16
16
|
const coefficients_1 = __webpack_require__(/*! ../coefficients */ "./src/maths/coefficients/index.ts");
|
|
17
|
-
const coefficients_2 = __webpack_require__(/*! ../coefficients */ "./src/maths/coefficients/index.ts");
|
|
18
17
|
class Equation {
|
|
19
18
|
_left;
|
|
20
19
|
_right;
|
|
@@ -28,16 +27,26 @@ class Equation {
|
|
|
28
27
|
this._right = new polynom_1.Polynom().zero();
|
|
29
28
|
this._sign = '=';
|
|
30
29
|
if (equations.length === 1) {
|
|
31
|
-
if (equations[0]
|
|
30
|
+
if (equations[0] instanceof Equation) {
|
|
32
31
|
return equations[0].clone();
|
|
33
32
|
}
|
|
34
|
-
else {
|
|
33
|
+
else if (typeof equations[0] === 'string') {
|
|
35
34
|
this.parse(equations[0]);
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
37
|
else if (equations.length === 2) {
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
if (equations[0] instanceof polynom_1.Polynom) {
|
|
39
|
+
this.left = equations[0].clone();
|
|
40
|
+
}
|
|
41
|
+
else if (typeof equations[0] === 'string') {
|
|
42
|
+
this.left = new polynom_1.Polynom(equations[0]);
|
|
43
|
+
}
|
|
44
|
+
if (equations[1] instanceof polynom_1.Polynom) {
|
|
45
|
+
this.right = equations[1].clone();
|
|
46
|
+
}
|
|
47
|
+
else if (typeof equations[1] === 'string') {
|
|
48
|
+
this.right = new polynom_1.Polynom(equations[1]);
|
|
49
|
+
}
|
|
41
50
|
}
|
|
42
51
|
else {
|
|
43
52
|
return this;
|
|
@@ -53,24 +62,24 @@ class Equation {
|
|
|
53
62
|
get solution() {
|
|
54
63
|
if (this._solutions.length === 1
|
|
55
64
|
&&
|
|
56
|
-
(this._solutions[0] === this._real
|
|
57
|
-
|| this._solutions[0] === this._varnothing
|
|
58
|
-
|| this._solutions[0].includes('\\left'))) {
|
|
65
|
+
(this._solutions[0].tex === this._real
|
|
66
|
+
|| this._solutions[0].tex === this._varnothing
|
|
67
|
+
|| this._solutions[0].tex.includes('\\left'))) {
|
|
59
68
|
return `S = ${this._solutions[0]}`;
|
|
60
69
|
}
|
|
61
|
-
return `S = \\left{ ${this._solutions.join(';')} \\right}`;
|
|
70
|
+
return `S = \\left{ ${this._solutions.map(x => x.tex).join(';')} \\right}`;
|
|
62
71
|
}
|
|
63
72
|
get isReal() {
|
|
64
73
|
if (this._solutions === undefined) {
|
|
65
74
|
this.solve();
|
|
66
75
|
}
|
|
67
|
-
return this._solutions[0] === this._real;
|
|
76
|
+
return this._solutions[0].tex === this._real;
|
|
68
77
|
}
|
|
69
78
|
get isVarnothing() {
|
|
70
79
|
if (this._solutions === undefined) {
|
|
71
80
|
this.solve();
|
|
72
81
|
}
|
|
73
|
-
return this._solutions[0] === this._varnothing;
|
|
82
|
+
return this._solutions[0].tex === this._varnothing;
|
|
74
83
|
}
|
|
75
84
|
get signAsTex() {
|
|
76
85
|
if (this._sign === '>=' || this._sign === '=>' || this._sign === 'geq') {
|
|
@@ -310,19 +319,19 @@ class Equation {
|
|
|
310
319
|
letters = () => {
|
|
311
320
|
return [...new Set([...this._left.letters(), ...this._right.letters()])];
|
|
312
321
|
};
|
|
313
|
-
solve = (
|
|
322
|
+
solve = () => {
|
|
314
323
|
this._solutions = [];
|
|
315
324
|
this._polynom = this._left.clone().subtract(this._right);
|
|
316
|
-
switch (this._polynom.degree(
|
|
325
|
+
switch (this._polynom.degree().value) {
|
|
317
326
|
case 0:
|
|
318
327
|
case 1:
|
|
319
|
-
this._solveDegree1(
|
|
328
|
+
this._solveDegree1();
|
|
320
329
|
break;
|
|
321
330
|
case 2:
|
|
322
|
-
this._solveDegree2(
|
|
331
|
+
this._solveDegree2();
|
|
323
332
|
break;
|
|
324
333
|
default:
|
|
325
|
-
this._solveDegree3plus(
|
|
334
|
+
this._solveDegree3plus();
|
|
326
335
|
}
|
|
327
336
|
return this;
|
|
328
337
|
};
|
|
@@ -347,19 +356,31 @@ class Equation {
|
|
|
347
356
|
}
|
|
348
357
|
};
|
|
349
358
|
_solveDegree1 = (letter) => {
|
|
350
|
-
const m1 = this._polynom.monomByDegree(1, letter).coefficient, m0 = this._polynom.monomByDegree(0, letter).coefficient, v = m0.clone().opposed().divide(m1)
|
|
359
|
+
const m1 = this._polynom.monomByDegree(1, letter).coefficient, m0 = this._polynom.monomByDegree(0, letter).coefficient, v = m0.clone().opposed().divide(m1);
|
|
351
360
|
let s;
|
|
352
361
|
if (this.isStrictEqual()) {
|
|
353
362
|
if (m1.value === 0) {
|
|
354
363
|
if (m0.value === 0) {
|
|
355
|
-
this._solutions = [
|
|
364
|
+
this._solutions = [{
|
|
365
|
+
tex: this._real,
|
|
366
|
+
value: NaN,
|
|
367
|
+
exact: false
|
|
368
|
+
}];
|
|
356
369
|
}
|
|
357
370
|
else {
|
|
358
|
-
this._solutions = [
|
|
371
|
+
this._solutions = [{
|
|
372
|
+
tex: this._varnothing,
|
|
373
|
+
value: NaN,
|
|
374
|
+
exact: false
|
|
375
|
+
}];
|
|
359
376
|
}
|
|
360
377
|
}
|
|
361
378
|
else {
|
|
362
|
-
this._solutions = [
|
|
379
|
+
this._solutions = [{
|
|
380
|
+
tex: v.display,
|
|
381
|
+
value: v.value,
|
|
382
|
+
exact: v
|
|
383
|
+
}];
|
|
363
384
|
}
|
|
364
385
|
}
|
|
365
386
|
else {
|
|
@@ -384,7 +405,11 @@ class Equation {
|
|
|
384
405
|
s = `\\left\\]-\\infty;${v} \\right\\${this.isAlsoEqual() ? '\\]' : '\\['}`;
|
|
385
406
|
}
|
|
386
407
|
}
|
|
387
|
-
this._solutions = [
|
|
408
|
+
this._solutions = [{
|
|
409
|
+
tex: s,
|
|
410
|
+
value: NaN,
|
|
411
|
+
exact: false
|
|
412
|
+
}];
|
|
388
413
|
}
|
|
389
414
|
return this._solutions;
|
|
390
415
|
};
|
|
@@ -396,87 +421,161 @@ class Equation {
|
|
|
396
421
|
realX2 = (-b + Math.sqrt(delta)) / (2 * a);
|
|
397
422
|
if (delta > 1.0e5) {
|
|
398
423
|
this._solutions = [
|
|
399
|
-
|
|
400
|
-
|
|
424
|
+
{
|
|
425
|
+
tex: ((-b - Math.sqrt(delta)) / (2 * a)).toFixed(5),
|
|
426
|
+
value: realX1,
|
|
427
|
+
exact: false
|
|
428
|
+
},
|
|
429
|
+
{
|
|
430
|
+
tex: ((-b + Math.sqrt(delta)) / (2 * a)).toFixed(5),
|
|
431
|
+
value: realX2,
|
|
432
|
+
exact: false
|
|
433
|
+
}
|
|
401
434
|
];
|
|
402
435
|
}
|
|
403
436
|
else {
|
|
404
|
-
nthDelta = new
|
|
437
|
+
nthDelta = new coefficients_1.Nthroot(delta).reduce();
|
|
405
438
|
if (nthDelta.hasRadical()) {
|
|
406
439
|
let gcd = numeric_1.Numeric.gcd(b, 2 * a, nthDelta.coefficient);
|
|
407
440
|
nthDelta.coefficient = nthDelta.coefficient / gcd;
|
|
408
441
|
if (b !== 0) {
|
|
409
442
|
if (2 * a / gcd === 1) {
|
|
410
443
|
this._solutions = [
|
|
411
|
-
|
|
412
|
-
|
|
444
|
+
{
|
|
445
|
+
tex: `${-b / gcd} - ${nthDelta.tex}`,
|
|
446
|
+
value: realX1,
|
|
447
|
+
exact: false
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
tex: `${-b / gcd} + ${nthDelta.tex}`,
|
|
451
|
+
value: realX2,
|
|
452
|
+
exact: false
|
|
453
|
+
},
|
|
413
454
|
];
|
|
414
455
|
}
|
|
415
456
|
else {
|
|
416
457
|
this._solutions = [
|
|
417
|
-
|
|
418
|
-
|
|
458
|
+
{
|
|
459
|
+
tex: `\\dfrac{${-b / gcd} - ${nthDelta.tex} }{ ${2 * a / gcd} }`,
|
|
460
|
+
value: realX1,
|
|
461
|
+
exact: false
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
tex: `\\dfrac{${-b / gcd} + ${nthDelta.tex} }{ ${2 * a / gcd} }`,
|
|
465
|
+
value: realX2,
|
|
466
|
+
exact: false
|
|
467
|
+
},
|
|
419
468
|
];
|
|
420
469
|
}
|
|
421
470
|
}
|
|
422
471
|
else {
|
|
423
472
|
if (2 * a / gcd === 1) {
|
|
424
473
|
this._solutions = [
|
|
425
|
-
|
|
426
|
-
|
|
474
|
+
{
|
|
475
|
+
tex: `- ${nthDelta.tex}`,
|
|
476
|
+
value: realX1,
|
|
477
|
+
exact: false
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
tex: `${nthDelta.tex}`,
|
|
481
|
+
value: realX2,
|
|
482
|
+
exact: false
|
|
483
|
+
},
|
|
427
484
|
];
|
|
428
485
|
}
|
|
429
486
|
else {
|
|
430
487
|
this._solutions = [
|
|
431
|
-
|
|
432
|
-
|
|
488
|
+
{
|
|
489
|
+
tex: `\\dfrac{- ${nthDelta.tex} }{ ${2 * a / gcd} }`,
|
|
490
|
+
value: realX1,
|
|
491
|
+
exact: false
|
|
492
|
+
},
|
|
493
|
+
{
|
|
494
|
+
tex: `\\dfrac{${nthDelta.tex} }{ ${2 * a / gcd} }`,
|
|
495
|
+
value: realX2,
|
|
496
|
+
exact: false
|
|
497
|
+
},
|
|
433
498
|
];
|
|
434
499
|
}
|
|
435
500
|
}
|
|
436
501
|
}
|
|
437
502
|
else {
|
|
503
|
+
const S1 = new coefficients_1.Fraction(-b - nthDelta.coefficient, 2 * a).reduce(), S2 = new coefficients_1.Fraction(-b + nthDelta.coefficient, 2 * a).reduce();
|
|
438
504
|
this._solutions = [
|
|
439
|
-
|
|
440
|
-
|
|
505
|
+
{
|
|
506
|
+
tex: S1.dfrac,
|
|
507
|
+
value: realX1,
|
|
508
|
+
exact: S1
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
tex: S2.dfrac,
|
|
512
|
+
value: realX2,
|
|
513
|
+
exact: S2
|
|
514
|
+
}
|
|
441
515
|
];
|
|
442
516
|
}
|
|
443
517
|
}
|
|
444
518
|
}
|
|
445
519
|
else if (delta === 0) {
|
|
446
|
-
|
|
520
|
+
const sol = new coefficients_1.Fraction(-b, 2 * a).reduce();
|
|
521
|
+
this._solutions = [{
|
|
522
|
+
tex: sol.dfrac,
|
|
523
|
+
value: sol.value,
|
|
524
|
+
exact: sol
|
|
525
|
+
}];
|
|
447
526
|
}
|
|
448
527
|
else {
|
|
449
|
-
this._solutions = [
|
|
528
|
+
this._solutions = [{
|
|
529
|
+
tex: this._varnothing,
|
|
530
|
+
value: NaN,
|
|
531
|
+
exact: false
|
|
532
|
+
}];
|
|
450
533
|
}
|
|
451
534
|
if (!this.isStrictEqual()) {
|
|
452
535
|
if (this._solutions.length === 2) {
|
|
453
|
-
sX1 = (realX1 < realX2) ? this._solutions[0] : this._solutions[1];
|
|
454
|
-
sX2 = (realX1 < realX2) ? this._solutions[1] : this._solutions[0];
|
|
536
|
+
sX1 = (realX1 < realX2) ? this._solutions[0].tex : this._solutions[1].tex;
|
|
537
|
+
sX2 = (realX1 < realX2) ? this._solutions[1].tex : this._solutions[0].tex;
|
|
455
538
|
if ((this.isGreater() && aF.sign() === 1) || (!this.isGreater() && aF.sign() === -1)) {
|
|
456
|
-
this._solutions = [
|
|
457
|
-
|
|
539
|
+
this._solutions = [{
|
|
540
|
+
tex: `\\left]-\\infty ; ${sX1}\\right${this.isAlsoEqual() ? ']' : '['} \\cup \\left${this.isAlsoEqual() ? '[' : ']'}${sX2};+\\infty\\right[`,
|
|
541
|
+
value: NaN,
|
|
542
|
+
exact: false
|
|
543
|
+
}
|
|
458
544
|
];
|
|
459
545
|
}
|
|
460
546
|
else {
|
|
461
|
-
this._solutions = [
|
|
462
|
-
|
|
463
|
-
|
|
547
|
+
this._solutions = [{
|
|
548
|
+
tex: `\\left${this.isAlsoEqual() ? '[' : ']'}${sX1} ; ${sX2}\\right${this.isAlsoEqual() ? ']' : '['}`,
|
|
549
|
+
value: NaN,
|
|
550
|
+
exact: false
|
|
551
|
+
}];
|
|
464
552
|
}
|
|
465
553
|
}
|
|
466
|
-
else if (this._solutions.length === 1 && this._solutions[0] !== this._varnothing) {
|
|
554
|
+
else if (this._solutions.length === 1 && this._solutions[0].tex !== this._varnothing) {
|
|
467
555
|
if (!this.isAlsoEqual()) {
|
|
468
556
|
if ((this.isGreater() && aF.sign() === 1) || (!this.isGreater() && aF.sign() === -1)) {
|
|
469
|
-
this._solutions = [
|
|
470
|
-
|
|
557
|
+
this._solutions = [{
|
|
558
|
+
tex: `\\left]-\\infty ; ${this._solutions[0].tex}\\right[ \\cup \\left]${this._solutions[0].tex};+\\infty\\right[`,
|
|
559
|
+
value: NaN,
|
|
560
|
+
exact: false
|
|
561
|
+
}
|
|
471
562
|
];
|
|
472
563
|
}
|
|
473
564
|
else {
|
|
474
|
-
this._solutions = [
|
|
565
|
+
this._solutions = [{
|
|
566
|
+
tex: this._varnothing,
|
|
567
|
+
value: NaN,
|
|
568
|
+
exact: false
|
|
569
|
+
}];
|
|
475
570
|
}
|
|
476
571
|
}
|
|
477
572
|
else {
|
|
478
573
|
if ((this.isGreater() && aF.sign() === 1) || (!this.isGreater() && aF.sign() === -1)) {
|
|
479
|
-
this._solutions = [
|
|
574
|
+
this._solutions = [{
|
|
575
|
+
tex: this._real,
|
|
576
|
+
value: NaN,
|
|
577
|
+
exact: false
|
|
578
|
+
}];
|
|
480
579
|
}
|
|
481
580
|
else {
|
|
482
581
|
}
|
|
@@ -484,17 +583,25 @@ class Equation {
|
|
|
484
583
|
}
|
|
485
584
|
else {
|
|
486
585
|
if (this.isGreater()) {
|
|
487
|
-
this._solutions = [
|
|
586
|
+
this._solutions = [{
|
|
587
|
+
tex: aF.sign() === 1 ? this._real : this._varnothing,
|
|
588
|
+
value: NaN,
|
|
589
|
+
exact: false
|
|
590
|
+
}];
|
|
488
591
|
}
|
|
489
592
|
else {
|
|
490
|
-
this._solutions = [
|
|
593
|
+
this._solutions = [{
|
|
594
|
+
tex: aF.sign() === -1 ? this._real : this._varnothing,
|
|
595
|
+
value: NaN,
|
|
596
|
+
exact: false
|
|
597
|
+
}];
|
|
491
598
|
}
|
|
492
599
|
}
|
|
493
600
|
}
|
|
494
601
|
return this._solutions;
|
|
495
602
|
};
|
|
496
|
-
_solveDegree3plus = (
|
|
497
|
-
this._solutions = [
|
|
603
|
+
_solveDegree3plus = () => {
|
|
604
|
+
this._solutions = [{ tex: 'solve x - not yet handled', value: NaN, exact: false }];
|
|
498
605
|
return this._solutions;
|
|
499
606
|
};
|
|
500
607
|
}
|
|
@@ -605,7 +712,7 @@ class LinearSystem {
|
|
|
605
712
|
}
|
|
606
713
|
return `\\left\\{\\begin{array}{${"r".repeat(letters.length)}cl}${equArray.join('\\\\\ ')}\\end{array}\\right.`;
|
|
607
714
|
}
|
|
608
|
-
get
|
|
715
|
+
get solution() {
|
|
609
716
|
let tex = [];
|
|
610
717
|
if (this._solutions === undefined) {
|
|
611
718
|
this.solve();
|
|
@@ -732,7 +839,7 @@ class LinearSystem {
|
|
|
732
839
|
let E = this._resolutionSteps[this._resolutionSteps.length - 1].equations[0];
|
|
733
840
|
E.solve();
|
|
734
841
|
return {
|
|
735
|
-
value: new coefficients_1.Fraction(E.solutions[0]),
|
|
842
|
+
value: new coefficients_1.Fraction(E.solutions[0].value),
|
|
736
843
|
isReal: E.isReal,
|
|
737
844
|
isVarnothing: E.isVarnothing
|
|
738
845
|
};
|
|
@@ -1105,7 +1212,21 @@ class Monom {
|
|
|
1105
1212
|
}
|
|
1106
1213
|
}
|
|
1107
1214
|
parse = (inputStr) => {
|
|
1108
|
-
|
|
1215
|
+
if (typeof inputStr === 'string') {
|
|
1216
|
+
this._shutingYardToReducedMonom(inputStr);
|
|
1217
|
+
}
|
|
1218
|
+
else if (typeof inputStr === 'number') {
|
|
1219
|
+
this._coefficient = new coefficients_1.Fraction(inputStr);
|
|
1220
|
+
this._literal = {};
|
|
1221
|
+
}
|
|
1222
|
+
else if (inputStr instanceof coefficients_1.Fraction) {
|
|
1223
|
+
this._coefficient = inputStr.clone();
|
|
1224
|
+
this._literal = {};
|
|
1225
|
+
}
|
|
1226
|
+
else if (inputStr instanceof Monom) {
|
|
1227
|
+
this._coefficient = inputStr._coefficient.clone();
|
|
1228
|
+
this._literal = this.copyLiterals(inputStr.literal);
|
|
1229
|
+
}
|
|
1109
1230
|
return this;
|
|
1110
1231
|
};
|
|
1111
1232
|
_shutingYardToReducedMonom = (inputStr) => {
|
|
@@ -1176,6 +1297,13 @@ class Monom {
|
|
|
1176
1297
|
}
|
|
1177
1298
|
return F;
|
|
1178
1299
|
};
|
|
1300
|
+
copyLiterals = (literal) => {
|
|
1301
|
+
let L = {};
|
|
1302
|
+
for (let k in literal) {
|
|
1303
|
+
L[k] = literal[k].clone();
|
|
1304
|
+
}
|
|
1305
|
+
return L;
|
|
1306
|
+
};
|
|
1179
1307
|
makeSame = (M) => {
|
|
1180
1308
|
for (let k in M._literal) {
|
|
1181
1309
|
this.setLetter(k, M._literal[k].clone());
|
|
@@ -1737,7 +1865,7 @@ class Polynom {
|
|
|
1737
1865
|
else if (value instanceof monom_1.Monom) {
|
|
1738
1866
|
return this.multiplyByMonom(value);
|
|
1739
1867
|
}
|
|
1740
|
-
else if (Number.isSafeInteger(value)) {
|
|
1868
|
+
else if (Number.isSafeInteger(value) && typeof value === 'number') {
|
|
1741
1869
|
return this.multiplyByInteger(value);
|
|
1742
1870
|
}
|
|
1743
1871
|
return this;
|
|
@@ -1790,10 +1918,10 @@ class Polynom {
|
|
|
1790
1918
|
return { quotient, reminder };
|
|
1791
1919
|
};
|
|
1792
1920
|
divide = (value) => {
|
|
1793
|
-
if (value.
|
|
1921
|
+
if (value instanceof coefficients_1.Fraction) {
|
|
1794
1922
|
this.divideByFraction(value);
|
|
1795
1923
|
}
|
|
1796
|
-
else if (Number.isSafeInteger(value)) {
|
|
1924
|
+
else if (typeof value === 'number' && Number.isSafeInteger(value)) {
|
|
1797
1925
|
return this.divideByInteger(value);
|
|
1798
1926
|
}
|
|
1799
1927
|
};
|
|
@@ -2516,7 +2644,7 @@ class Fraction {
|
|
|
2516
2644
|
}
|
|
2517
2645
|
break;
|
|
2518
2646
|
case "object":
|
|
2519
|
-
if (value
|
|
2647
|
+
if (value instanceof Fraction) {
|
|
2520
2648
|
this._numerator = +value.numerator;
|
|
2521
2649
|
this._denominator = +value.denominator;
|
|
2522
2650
|
}
|
|
@@ -2825,11 +2953,14 @@ class Nthroot {
|
|
|
2825
2953
|
_nth;
|
|
2826
2954
|
_coefficient;
|
|
2827
2955
|
_isValid;
|
|
2828
|
-
constructor() {
|
|
2956
|
+
constructor(...values) {
|
|
2829
2957
|
this._radical = 1;
|
|
2830
2958
|
this._coefficient = 1;
|
|
2831
2959
|
this._nth = 2;
|
|
2832
2960
|
this._isValid = true;
|
|
2961
|
+
if (values !== undefined) {
|
|
2962
|
+
this.parse(values[0], values[1], values[2]);
|
|
2963
|
+
}
|
|
2833
2964
|
}
|
|
2834
2965
|
get radical() {
|
|
2835
2966
|
return this._radical;
|
|
@@ -2929,9 +3060,9 @@ const point_1 = __webpack_require__(/*! ./point */ "./src/maths/geometry/point.t
|
|
|
2929
3060
|
const coefficients_1 = __webpack_require__(/*! ../coefficients */ "./src/maths/coefficients/index.ts");
|
|
2930
3061
|
const algebra_1 = __webpack_require__(/*! ../algebra */ "./src/maths/algebra/index.ts");
|
|
2931
3062
|
const vector_1 = __webpack_require__(/*! ./vector */ "./src/maths/geometry/vector.ts");
|
|
3063
|
+
const triangle_1 = __webpack_require__(/*! ./triangle */ "./src/maths/geometry/triangle.ts");
|
|
2932
3064
|
class Circle {
|
|
2933
3065
|
_center;
|
|
2934
|
-
_radius;
|
|
2935
3066
|
_squareRadius;
|
|
2936
3067
|
_cartesian;
|
|
2937
3068
|
_exists;
|
|
@@ -2944,6 +3075,12 @@ class Circle {
|
|
|
2944
3075
|
get center() {
|
|
2945
3076
|
return this._center;
|
|
2946
3077
|
}
|
|
3078
|
+
get exists() {
|
|
3079
|
+
return this._exists;
|
|
3080
|
+
}
|
|
3081
|
+
get squareRadius() {
|
|
3082
|
+
return this._squareRadius;
|
|
3083
|
+
}
|
|
2947
3084
|
get radius() {
|
|
2948
3085
|
if (this._squareRadius.isSquare()) {
|
|
2949
3086
|
return {
|
|
@@ -2960,20 +3097,25 @@ class Circle {
|
|
|
2960
3097
|
return this._squareRadius;
|
|
2961
3098
|
}
|
|
2962
3099
|
get tex() {
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
3100
|
+
if (this._exists) {
|
|
3101
|
+
let cx, cy;
|
|
3102
|
+
if (this._center.x.isZero()) {
|
|
3103
|
+
cx = 'x^2';
|
|
3104
|
+
}
|
|
3105
|
+
else {
|
|
3106
|
+
cx = `\\left(x${this._center.x.isNegative() ? '+' : '-'}${this._center.x.clone().abs().tex}\\right)^2`;
|
|
3107
|
+
}
|
|
3108
|
+
if (this._center.y.isZero()) {
|
|
3109
|
+
cy = 'y^2';
|
|
3110
|
+
}
|
|
3111
|
+
else {
|
|
3112
|
+
cy = `\\left(y${this._center.y.isNegative() ? '+' : '-'}${this._center.y.clone().abs().tex}\\right)^2`;
|
|
3113
|
+
}
|
|
3114
|
+
return `${cx}+${cy}=${this._squareRadius.tex}`;
|
|
2972
3115
|
}
|
|
2973
3116
|
else {
|
|
2974
|
-
|
|
3117
|
+
return `\\text{le cercle n'existe pas.}`;
|
|
2975
3118
|
}
|
|
2976
|
-
return `${cx}+${cy}=${this._squareRadius.tex}`;
|
|
2977
3119
|
}
|
|
2978
3120
|
get developed() {
|
|
2979
3121
|
return this._cartesian.tex;
|
|
@@ -2984,43 +3126,108 @@ class Circle {
|
|
|
2984
3126
|
get cartesian() {
|
|
2985
3127
|
return this._cartesian;
|
|
2986
3128
|
}
|
|
3129
|
+
clone() {
|
|
3130
|
+
this._center = this._center.clone();
|
|
3131
|
+
this._squareRadius = this._squareRadius.clone();
|
|
3132
|
+
this._calculateCartesian();
|
|
3133
|
+
return this;
|
|
3134
|
+
}
|
|
3135
|
+
_reset() {
|
|
3136
|
+
this._center = null;
|
|
3137
|
+
this._squareRadius = null;
|
|
3138
|
+
this._cartesian = null;
|
|
3139
|
+
this._exists = false;
|
|
3140
|
+
return this;
|
|
3141
|
+
}
|
|
2987
3142
|
parse(...values) {
|
|
2988
|
-
|
|
2989
|
-
|
|
3143
|
+
this._reset();
|
|
3144
|
+
if (typeof values[0] === 'string') {
|
|
3145
|
+
this._parseEquation(new algebra_1.Equation(values[0]));
|
|
3146
|
+
}
|
|
3147
|
+
else if (values[0] instanceof algebra_1.Equation) {
|
|
3148
|
+
this._parseEquation(values[0]);
|
|
3149
|
+
}
|
|
3150
|
+
else if (values[0] instanceof Circle) {
|
|
3151
|
+
this._parseCopyCircle(values[0]);
|
|
2990
3152
|
}
|
|
2991
|
-
else if (values.length
|
|
2992
|
-
this._center = new point_1.Point(values[0]);
|
|
3153
|
+
else if (values[0] instanceof point_1.Point && values.length > 1) {
|
|
2993
3154
|
if (values[1] instanceof point_1.Point) {
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
else {
|
|
2997
|
-
if (values[2] === true) {
|
|
2998
|
-
this._squareRadius = new coefficients_1.Fraction(values[1]);
|
|
3155
|
+
if (values[2] instanceof point_1.Point) {
|
|
3156
|
+
this._parseThroughtThreePoints(values[0], values[1], values[2]);
|
|
2999
3157
|
}
|
|
3000
3158
|
else {
|
|
3001
|
-
this.
|
|
3002
|
-
this._squareRadius = this._radius.clone().pow(2);
|
|
3159
|
+
this._parseCenterAndPointThrough(values[0], values[1]);
|
|
3003
3160
|
}
|
|
3004
3161
|
}
|
|
3005
|
-
|
|
3162
|
+
else if (values[1] instanceof coefficients_1.Fraction || typeof values[1] === 'number') {
|
|
3163
|
+
this._parseCenterAndRadius(values[0], values[1], (typeof values[2] === "boolean") ? values[2] : false);
|
|
3164
|
+
}
|
|
3165
|
+
}
|
|
3166
|
+
if (this._exists) {
|
|
3167
|
+
this._calculateCartesian();
|
|
3168
|
+
if (this._squareRadius !== undefined && this._squareRadius.isNegative()) {
|
|
3169
|
+
this._exists = false;
|
|
3170
|
+
}
|
|
3171
|
+
}
|
|
3172
|
+
return this;
|
|
3173
|
+
}
|
|
3174
|
+
_calculateCartesian() {
|
|
3175
|
+
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();
|
|
3176
|
+
}
|
|
3177
|
+
_parseCopyCircle(circle) {
|
|
3178
|
+
this._center = circle.center.clone();
|
|
3179
|
+
this._squareRadius = circle.squareRadius.clone();
|
|
3180
|
+
this._calculateCartesian();
|
|
3181
|
+
this._exists = circle.exists;
|
|
3182
|
+
return this;
|
|
3183
|
+
}
|
|
3184
|
+
_parseCenterAndRadius(center, radius, square) {
|
|
3185
|
+
this._center = center.clone();
|
|
3186
|
+
if (square) {
|
|
3187
|
+
this._squareRadius = (new coefficients_1.Fraction(radius));
|
|
3188
|
+
}
|
|
3189
|
+
else {
|
|
3190
|
+
this._squareRadius = new coefficients_1.Fraction(radius).pow(2);
|
|
3006
3191
|
}
|
|
3192
|
+
this._exists = true;
|
|
3193
|
+
return this;
|
|
3194
|
+
}
|
|
3195
|
+
_parseCenterAndPointThrough(center, pointThrough) {
|
|
3196
|
+
this._center = center.clone();
|
|
3197
|
+
this._squareRadius = new vector_1.Vector(this._center, pointThrough).normSquare;
|
|
3198
|
+
this._exists = true;
|
|
3199
|
+
return this;
|
|
3007
3200
|
}
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3201
|
+
_parseEquation(equ) {
|
|
3202
|
+
this._exists = false;
|
|
3203
|
+
equ.moveLeft();
|
|
3204
|
+
if (equ.degree('x').value === 2 && equ.degree('y').value === 2) {
|
|
3205
|
+
let x2 = equ.left.monomByDegree(2, 'x'), y2 = equ.left.monomByDegree(2, 'y'), x1, y1, c;
|
|
3011
3206
|
if (x2.coefficient.isEqual(y2.coefficient)) {
|
|
3012
|
-
|
|
3013
|
-
x1 =
|
|
3014
|
-
y1 =
|
|
3015
|
-
c =
|
|
3207
|
+
equ.divide(x2.coefficient);
|
|
3208
|
+
x1 = equ.left.monomByDegree(1, 'x');
|
|
3209
|
+
y1 = equ.left.monomByDegree(1, 'y');
|
|
3210
|
+
c = equ.left.monomByDegree(0);
|
|
3016
3211
|
this._center = new point_1.Point(x1.coefficient.clone().divide(2).opposed(), y1.coefficient.clone().divide(2).opposed());
|
|
3017
3212
|
this._squareRadius = c.coefficient.clone().opposed()
|
|
3018
3213
|
.add(this._center.x.clone().pow(2))
|
|
3019
3214
|
.add(this._center.y.clone().pow(2));
|
|
3215
|
+
this._calculateCartesian();
|
|
3216
|
+
this._exists = true;
|
|
3217
|
+
}
|
|
3218
|
+
else {
|
|
3219
|
+
this._center = null;
|
|
3220
|
+
this._squareRadius = null;
|
|
3221
|
+
this._exists = false;
|
|
3020
3222
|
}
|
|
3021
3223
|
}
|
|
3022
|
-
return
|
|
3023
|
-
}
|
|
3224
|
+
return this;
|
|
3225
|
+
}
|
|
3226
|
+
_parseThroughtThreePoints(A, B, C) {
|
|
3227
|
+
let T = new triangle_1.Triangle(A, B, C), mAB = T.remarquables.mediators.AB.clone(), mAC = T.remarquables.mediators.AC.clone();
|
|
3228
|
+
this.parse(mAB.intersection(mAC).point, A);
|
|
3229
|
+
return this;
|
|
3230
|
+
}
|
|
3024
3231
|
relativePosition = (L) => {
|
|
3025
3232
|
let distance = L.distanceTo(this.center), radius = Math.sqrt(this._squareRadius.value);
|
|
3026
3233
|
if (distance.value - radius > 0.0000000001) {
|
|
@@ -3034,13 +3241,23 @@ class Circle {
|
|
|
3034
3241
|
}
|
|
3035
3242
|
};
|
|
3036
3243
|
lineIntersection = (L) => {
|
|
3037
|
-
let
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3244
|
+
let intersectionPoints = [], solX;
|
|
3245
|
+
if (this._cartesian === null) {
|
|
3246
|
+
return [];
|
|
3247
|
+
}
|
|
3248
|
+
const equX = this._cartesian.clone(), lineX = L.equation.clone().isolate('x'), lineY = L.equation.clone().isolate('y');
|
|
3249
|
+
if (lineX instanceof algebra_1.Equation && lineY instanceof algebra_1.Equation) {
|
|
3250
|
+
equX.replaceBy('y', lineY.right).simplify();
|
|
3251
|
+
equX.solve();
|
|
3252
|
+
for (let x of equX.solutions) {
|
|
3253
|
+
if (x.exact === false && isNaN(x.value)) {
|
|
3254
|
+
continue;
|
|
3255
|
+
}
|
|
3256
|
+
solX = new coefficients_1.Fraction(x.exact === false ? x.value : x.exact);
|
|
3257
|
+
intersectionPoints.push(new point_1.Point(solX.clone(), lineY.right.evaluate(solX)));
|
|
3258
|
+
}
|
|
3042
3259
|
}
|
|
3043
|
-
return
|
|
3260
|
+
return intersectionPoints;
|
|
3044
3261
|
};
|
|
3045
3262
|
}
|
|
3046
3263
|
exports.Circle = Circle;
|
|
@@ -3114,9 +3331,6 @@ class Line {
|
|
|
3114
3331
|
}
|
|
3115
3332
|
return this;
|
|
3116
3333
|
}
|
|
3117
|
-
get isLine() {
|
|
3118
|
-
return true;
|
|
3119
|
-
}
|
|
3120
3334
|
get exists() {
|
|
3121
3335
|
return this._exists;
|
|
3122
3336
|
}
|
|
@@ -3220,6 +3434,14 @@ class Line {
|
|
|
3220
3434
|
(values[2] instanceof coefficients_1.Fraction || typeof values[2] === 'number')) {
|
|
3221
3435
|
return this.parseByCoefficient(values[0], values[1], values[2]);
|
|
3222
3436
|
}
|
|
3437
|
+
else if (values[0] instanceof point_1.Point && values[1] instanceof vector_1.Vector) {
|
|
3438
|
+
if (values[2] === LinePropriety.Perpendicular) {
|
|
3439
|
+
return this.parseByPointAndNormal(values[0], values[1]);
|
|
3440
|
+
}
|
|
3441
|
+
else if (values[2] === LinePropriety.Parallel) {
|
|
3442
|
+
return this.parseByPointAndVector(values[0], values[1]);
|
|
3443
|
+
}
|
|
3444
|
+
}
|
|
3223
3445
|
}
|
|
3224
3446
|
console.log('Someting wrong happend while creating the line');
|
|
3225
3447
|
return this;
|
|
@@ -3291,6 +3513,11 @@ class Line {
|
|
|
3291
3513
|
isSameAs = (line) => {
|
|
3292
3514
|
return this.slope.isEqual(line.slope) && this.height.isEqual(line.height);
|
|
3293
3515
|
};
|
|
3516
|
+
simplify = () => {
|
|
3517
|
+
let lcm = numeric_1.Numeric.lcm(this._a.denominator, this._b.denominator, this._c.denominator), gcd = numeric_1.Numeric.gcd(this._a.numerator, this._b.numerator, this._c.numerator);
|
|
3518
|
+
this.parseByCoefficient(this._a.clone().multiply(lcm).divide(gcd), this._b.clone().multiply(lcm).divide(gcd), this._c.clone().multiply(lcm).divide(gcd));
|
|
3519
|
+
return this;
|
|
3520
|
+
};
|
|
3294
3521
|
simplifyDirection = () => {
|
|
3295
3522
|
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);
|
|
3296
3523
|
this._d.x.multiply(lcm).divide(gcd);
|
|
@@ -3360,16 +3587,16 @@ class Line {
|
|
|
3360
3587
|
return false;
|
|
3361
3588
|
}
|
|
3362
3589
|
getValueAtX = (value) => {
|
|
3363
|
-
const equ = this.equation.clone().isolate('y');
|
|
3590
|
+
const equ = this.equation.clone().isolate('y'), F = new coefficients_1.Fraction(value);
|
|
3364
3591
|
if (equ instanceof algebra_1.Equation) {
|
|
3365
|
-
return equ.right.evaluate({ x:
|
|
3592
|
+
return equ.right.evaluate({ x: F });
|
|
3366
3593
|
}
|
|
3367
3594
|
return;
|
|
3368
3595
|
};
|
|
3369
3596
|
getValueAtY = (value) => {
|
|
3370
|
-
const equ = this.equation.clone().isolate('x');
|
|
3597
|
+
const equ = this.equation.clone().isolate('x'), F = new coefficients_1.Fraction(value);
|
|
3371
3598
|
if (equ instanceof algebra_1.Equation) {
|
|
3372
|
-
return equ.right.evaluate({ y:
|
|
3599
|
+
return equ.right.evaluate({ y: F });
|
|
3373
3600
|
}
|
|
3374
3601
|
return;
|
|
3375
3602
|
};
|
|
@@ -3418,23 +3645,24 @@ exports.Line = Line;
|
|
|
3418
3645
|
|
|
3419
3646
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3420
3647
|
exports.Point = void 0;
|
|
3421
|
-
const
|
|
3648
|
+
const coefficients_1 = __webpack_require__(/*! ../coefficients */ "./src/maths/coefficients/index.ts");
|
|
3649
|
+
class PointXY {
|
|
3650
|
+
x;
|
|
3651
|
+
y;
|
|
3652
|
+
}
|
|
3422
3653
|
class Point {
|
|
3423
3654
|
_x;
|
|
3424
3655
|
_y;
|
|
3425
3656
|
_exist;
|
|
3426
3657
|
constructor(...values) {
|
|
3427
|
-
this._x = new
|
|
3428
|
-
this._y = new
|
|
3658
|
+
this._x = new coefficients_1.Fraction().zero();
|
|
3659
|
+
this._y = new coefficients_1.Fraction().zero();
|
|
3429
3660
|
if (values !== undefined) {
|
|
3430
3661
|
this.parse(...values);
|
|
3431
3662
|
}
|
|
3432
3663
|
return this;
|
|
3433
3664
|
}
|
|
3434
3665
|
;
|
|
3435
|
-
get isPoint() {
|
|
3436
|
-
return true;
|
|
3437
|
-
}
|
|
3438
3666
|
get x() {
|
|
3439
3667
|
return this._x;
|
|
3440
3668
|
}
|
|
@@ -3473,22 +3701,24 @@ class Point {
|
|
|
3473
3701
|
if (typeof values[0] === 'string') {
|
|
3474
3702
|
let xy = values[0].split(',');
|
|
3475
3703
|
if (xy.length === 2) {
|
|
3476
|
-
this._x = new
|
|
3477
|
-
this._y = new
|
|
3704
|
+
this._x = new coefficients_1.Fraction(xy[0]).reduce();
|
|
3705
|
+
this._y = new coefficients_1.Fraction(xy[1]).reduce();
|
|
3478
3706
|
return this;
|
|
3479
3707
|
}
|
|
3480
3708
|
}
|
|
3481
|
-
if (values[0]
|
|
3482
|
-
this._x = new
|
|
3483
|
-
this._y = new
|
|
3709
|
+
if (values[0] instanceof PointXY) {
|
|
3710
|
+
this._x = new coefficients_1.Fraction(values[0].x).reduce();
|
|
3711
|
+
this._y = new coefficients_1.Fraction(values[0].y).reduce();
|
|
3712
|
+
return this;
|
|
3484
3713
|
}
|
|
3485
3714
|
else {
|
|
3486
3715
|
return this.zero();
|
|
3487
3716
|
}
|
|
3488
3717
|
}
|
|
3489
3718
|
if (values.length === 2) {
|
|
3490
|
-
this._x = new
|
|
3491
|
-
this._y = new
|
|
3719
|
+
this._x = new coefficients_1.Fraction(values[0]).reduce();
|
|
3720
|
+
this._y = new coefficients_1.Fraction(values[1]).reduce();
|
|
3721
|
+
return this;
|
|
3492
3722
|
}
|
|
3493
3723
|
return this;
|
|
3494
3724
|
};
|
|
@@ -3498,8 +3728,8 @@ class Point {
|
|
|
3498
3728
|
return this;
|
|
3499
3729
|
};
|
|
3500
3730
|
zero = () => {
|
|
3501
|
-
this._x = new
|
|
3502
|
-
this._y = new
|
|
3731
|
+
this._x = new coefficients_1.Fraction(null);
|
|
3732
|
+
this._y = new coefficients_1.Fraction(null);
|
|
3503
3733
|
return this;
|
|
3504
3734
|
};
|
|
3505
3735
|
origin = () => {
|
|
@@ -3558,7 +3788,6 @@ class Triangle {
|
|
|
3558
3788
|
}
|
|
3559
3789
|
return this;
|
|
3560
3790
|
}
|
|
3561
|
-
get isTriangle() { return true; }
|
|
3562
3791
|
get A() {
|
|
3563
3792
|
return this._A;
|
|
3564
3793
|
}
|
|
@@ -3622,7 +3851,7 @@ class Triangle {
|
|
|
3622
3851
|
if (values.filter((x) => typeof x === 'string').length === 3) {
|
|
3623
3852
|
return this.parse(...values.map((x) => new line_1.Line(x)));
|
|
3624
3853
|
}
|
|
3625
|
-
else if (values.filter((x) => x
|
|
3854
|
+
else if (values.filter((x) => x instanceof line_1.Line).length === 3) {
|
|
3626
3855
|
this._lines = {
|
|
3627
3856
|
'AB': values[0],
|
|
3628
3857
|
'BC': values[1],
|
|
@@ -3651,7 +3880,7 @@ class Triangle {
|
|
|
3651
3880
|
}
|
|
3652
3881
|
}
|
|
3653
3882
|
else {
|
|
3654
|
-
if (values.filter((x) => x
|
|
3883
|
+
if (values.filter((x) => (x instanceof point_1.Point)).length < 3) {
|
|
3655
3884
|
return this.parse(new point_1.Point(values[0]), new point_1.Point(values[1]), new point_1.Point(values[2]));
|
|
3656
3885
|
}
|
|
3657
3886
|
this._A = values[0].clone();
|
|
@@ -3665,7 +3894,7 @@ class Triangle {
|
|
|
3665
3894
|
}
|
|
3666
3895
|
}
|
|
3667
3896
|
else if (values.length === 1) {
|
|
3668
|
-
if (values[0]
|
|
3897
|
+
if (values[0] instanceof Triangle) {
|
|
3669
3898
|
return values[0].clone();
|
|
3670
3899
|
}
|
|
3671
3900
|
}
|
|
@@ -3782,6 +4011,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
3782
4011
|
exports.Vector = void 0;
|
|
3783
4012
|
const fraction_1 = __webpack_require__(/*! ../coefficients/fraction */ "./src/maths/coefficients/fraction.ts");
|
|
3784
4013
|
const numeric_1 = __webpack_require__(/*! ../numeric */ "./src/maths/numeric.ts");
|
|
4014
|
+
const point_1 = __webpack_require__(/*! ./point */ "./src/maths/geometry/point.ts");
|
|
3785
4015
|
class Vector {
|
|
3786
4016
|
_x;
|
|
3787
4017
|
_y;
|
|
@@ -3828,7 +4058,7 @@ class Vector {
|
|
|
3828
4058
|
}
|
|
3829
4059
|
}
|
|
3830
4060
|
if (values.length >= 2) {
|
|
3831
|
-
if (values[0].
|
|
4061
|
+
if (values[0] instanceof point_1.Point && values[1] instanceof point_1.Point) {
|
|
3832
4062
|
this._x = values[1].x.clone().subtract(values[0].x);
|
|
3833
4063
|
this._y = values[1].y.clone().subtract(values[0].y);
|
|
3834
4064
|
return this;
|
|
@@ -4041,17 +4271,29 @@ var Random;
|
|
|
4041
4271
|
return (new rndFraction_1.rndFraction(config)).generate();
|
|
4042
4272
|
}
|
|
4043
4273
|
Random.fraction = fraction;
|
|
4044
|
-
function number(from, to) {
|
|
4274
|
+
function number(from, to) {
|
|
4275
|
+
return rndHelpers_1.rndHelpers.randomInt(from, to);
|
|
4276
|
+
}
|
|
4045
4277
|
Random.number = number;
|
|
4046
|
-
function numberSym(max, allowZero) {
|
|
4278
|
+
function numberSym(max, allowZero) {
|
|
4279
|
+
return rndHelpers_1.rndHelpers.randomIntSym(max, allowZero);
|
|
4280
|
+
}
|
|
4047
4281
|
Random.numberSym = numberSym;
|
|
4048
|
-
function bool(percent) {
|
|
4282
|
+
function bool(percent) {
|
|
4283
|
+
return rndHelpers_1.rndHelpers.randomBool(percent);
|
|
4284
|
+
}
|
|
4049
4285
|
Random.bool = bool;
|
|
4050
|
-
function array(arr, number) {
|
|
4286
|
+
function array(arr, number) {
|
|
4287
|
+
return rndHelpers_1.rndHelpers.randomArray(arr, number);
|
|
4288
|
+
}
|
|
4051
4289
|
Random.array = array;
|
|
4052
|
-
function item(arr) {
|
|
4290
|
+
function item(arr) {
|
|
4291
|
+
return rndHelpers_1.rndHelpers.randomItem(arr);
|
|
4292
|
+
}
|
|
4053
4293
|
Random.item = item;
|
|
4054
|
-
function shuffle(arr) {
|
|
4294
|
+
function shuffle(arr) {
|
|
4295
|
+
rndHelpers_1.rndHelpers.shuffleArray(arr);
|
|
4296
|
+
}
|
|
4055
4297
|
Random.shuffle = shuffle;
|
|
4056
4298
|
})(Random = exports.Random || (exports.Random = {}));
|
|
4057
4299
|
|