pimath 0.0.122 → 0.0.124
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/pimath.js +7930 -7924
- package/dev/pimath.js.map +1 -1
- package/dist/pimath.js +43 -20
- package/dist/pimath.js.map +1 -1
- package/dist/pimath.min.js +1 -1
- package/dist/pimath.min.js.map +1 -1
- package/esm/maths/algebra/polynom.js +13 -8
- package/esm/maths/algebra/polynom.js.map +1 -1
- package/esm/maths/algebra/rational.d.ts +1 -0
- package/esm/maths/algebra/rational.js +12 -1
- package/esm/maths/algebra/rational.js.map +1 -1
- package/esm/maths/geometry/triangle.d.ts +6 -0
- package/esm/maths/geometry/triangle.js +14 -7
- package/esm/maths/geometry/triangle.js.map +1 -1
- package/esm/maths/numexp.d.ts +1 -1
- package/esm/maths/numexp.js.map +1 -1
- package/esm/maths/shutingyard.js +4 -4
- package/esm/maths/shutingyard.js.map +1 -1
- package/package.json +8 -8
- package/src/maths/algebra/polynom.ts +16 -11
- package/src/maths/algebra/rational.ts +13 -1
- package/src/maths/geometry/triangle.ts +24 -8
- package/src/maths/numexp.ts +1 -1
- package/src/maths/shutingyard.ts +6 -4
- package/tests/algebra/polynom.test.ts +8 -0
- package/tests/algebra/rationnal.test.ts +5 -0
- package/tests/numexp.test.ts +7 -2
- package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31_[Default_Changelist]1/shelved.patch +0 -107
- package/.idea/shelf/Uncommitted_changes_before_Update_at_24_07_2023_15_31__Default_Changelist_1.xml +0 -4
package/dist/pimath.js
CHANGED
|
@@ -2702,8 +2702,10 @@ class Polynom {
|
|
|
2702
2702
|
};
|
|
2703
2703
|
this.isDeveloped = (polynomString) => {
|
|
2704
2704
|
let P;
|
|
2705
|
+
// Start by removing the parenthis after a "power"
|
|
2706
|
+
let pString = polynomString.replaceAll(/\^\(([-0-9/]+)\)/g, '$1');
|
|
2705
2707
|
// There is at least one parenthese - it is not developed.
|
|
2706
|
-
if (
|
|
2708
|
+
if (pString.includes('(') || pString.includes(')')) {
|
|
2707
2709
|
return false;
|
|
2708
2710
|
}
|
|
2709
2711
|
// Try to build the polynom
|
|
@@ -2719,13 +2721,16 @@ class Polynom {
|
|
|
2719
2721
|
return false;
|
|
2720
2722
|
}
|
|
2721
2723
|
// Check that everything is completely developed. Actually, there are no parentheses... so it is fully developed
|
|
2722
|
-
|
|
2723
|
-
//
|
|
2724
|
-
//
|
|
2725
|
-
|
|
2726
|
-
//
|
|
2727
|
-
//
|
|
2728
|
-
|
|
2724
|
+
return true;
|
|
2725
|
+
// // maybe it wasn't reduced and not ordered...
|
|
2726
|
+
// // compare polynom string.
|
|
2727
|
+
//
|
|
2728
|
+
// // normalize the string
|
|
2729
|
+
// let polynomStringNormalized = polynomString.replaceAll('[*\s]', '')
|
|
2730
|
+
//
|
|
2731
|
+
// // Determine if it's the exact same string.
|
|
2732
|
+
// // TODO: Maybe it's enough to just make this test !a
|
|
2733
|
+
// return polynomStringNormalized === P.reduce().reorder().display
|
|
2729
2734
|
};
|
|
2730
2735
|
// -------------------------------------
|
|
2731
2736
|
this.reduce = () => {
|
|
@@ -3576,7 +3581,15 @@ class Rational {
|
|
|
3576
3581
|
this.reduce = () => {
|
|
3577
3582
|
this._numerator.factorize();
|
|
3578
3583
|
for (let f of this._numerator.factors) {
|
|
3579
|
-
|
|
3584
|
+
if (f.degree().isZero()) {
|
|
3585
|
+
// Do the simplify only if the factor can divide the denominator
|
|
3586
|
+
if (this._denominator.commonMonom().coefficient.clone().divide(f.monomByDegree().coefficient).isNatural()) {
|
|
3587
|
+
this.simplify(f);
|
|
3588
|
+
}
|
|
3589
|
+
}
|
|
3590
|
+
else {
|
|
3591
|
+
this.simplify(f);
|
|
3592
|
+
}
|
|
3580
3593
|
}
|
|
3581
3594
|
return this;
|
|
3582
3595
|
};
|
|
@@ -3682,6 +3695,9 @@ class Rational {
|
|
|
3682
3695
|
get tex() {
|
|
3683
3696
|
return `\\frac{ ${this._numerator.tex} }{ ${this._denominator.tex} }`;
|
|
3684
3697
|
}
|
|
3698
|
+
get display() {
|
|
3699
|
+
return `(${this._numerator.display})/(${this._denominator.display})`;
|
|
3700
|
+
}
|
|
3685
3701
|
get texFactors() {
|
|
3686
3702
|
return `\\frac{ ${this._numerator.texFactors} }{ ${this._denominator.texFactors} }`;
|
|
3687
3703
|
}
|
|
@@ -6135,6 +6151,7 @@ class Triangle {
|
|
|
6135
6151
|
return new vector_1.Vector(this.getPointByName(ptName1), this.getPointByName(ptName2));
|
|
6136
6152
|
};
|
|
6137
6153
|
this._calculateRemarquableLines = () => {
|
|
6154
|
+
const bA = this._calculateBisectors('A'), bB = this._calculateBisectors('B'), bC = this._calculateBisectors('C');
|
|
6138
6155
|
let remarquables = {
|
|
6139
6156
|
'medians': {
|
|
6140
6157
|
'A': new line_1.Line(this._A, this._middles.BC),
|
|
@@ -6155,9 +6172,15 @@ class Triangle {
|
|
|
6155
6172
|
'intersection': null
|
|
6156
6173
|
},
|
|
6157
6174
|
'bisectors': {
|
|
6158
|
-
'A':
|
|
6159
|
-
'B':
|
|
6160
|
-
'C':
|
|
6175
|
+
'A': bA.internal,
|
|
6176
|
+
'B': bB.internal,
|
|
6177
|
+
'C': bB.internal,
|
|
6178
|
+
'intersection': null
|
|
6179
|
+
},
|
|
6180
|
+
externalBisectors: {
|
|
6181
|
+
'A': bA.external,
|
|
6182
|
+
'B': bB.external,
|
|
6183
|
+
'C': bC.external,
|
|
6161
6184
|
'intersection': null
|
|
6162
6185
|
}
|
|
6163
6186
|
};
|
|
@@ -6186,16 +6209,16 @@ class Triangle {
|
|
|
6186
6209
|
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());
|
|
6187
6210
|
// Must determine which bisectors is in the triangle
|
|
6188
6211
|
if (pt === 'A') {
|
|
6189
|
-
return b1.hitSegment(this.B, this.C) ? b1 : b2;
|
|
6212
|
+
return b1.hitSegment(this.B, this.C) ? { internal: b1, external: b2 } : { internal: b2, external: b1 };
|
|
6190
6213
|
}
|
|
6191
6214
|
if (pt === 'B') {
|
|
6192
|
-
return b1.hitSegment(this.A, this.C) ? b1 : b2;
|
|
6215
|
+
return b1.hitSegment(this.A, this.C) ? { internal: b1, external: b2 } : { internal: b2, external: b1 };
|
|
6193
6216
|
}
|
|
6194
6217
|
if (pt === 'C') {
|
|
6195
|
-
return b1.hitSegment(this.B, this.A) ? b1 : b2;
|
|
6218
|
+
return b1.hitSegment(this.B, this.A) ? { internal: b1, external: b2 } : { internal: b2, external: b1 };
|
|
6196
6219
|
}
|
|
6197
6220
|
// Default returns the first bisector
|
|
6198
|
-
return b1;
|
|
6221
|
+
return { internal: b1, external: b2 };
|
|
6199
6222
|
};
|
|
6200
6223
|
if (values.length > 0) {
|
|
6201
6224
|
this.parse(...values);
|
|
@@ -7595,21 +7618,21 @@ class Shutingyard {
|
|
|
7595
7618
|
if (crtToken.match(/[a-zA-Z]/g)) {
|
|
7596
7619
|
// Current element is a letter.
|
|
7597
7620
|
// if the next element is a letter, a number or an opening parentheses, add the multiplication sign.
|
|
7598
|
-
if (nextToken
|
|
7621
|
+
if (nextToken?.match(/[a-zA-Z\d(]/)) {
|
|
7599
7622
|
normalizedExpr += '*';
|
|
7600
7623
|
}
|
|
7601
7624
|
}
|
|
7602
7625
|
else if (crtToken.match(/\d/)) {
|
|
7603
7626
|
// Current element is a number.
|
|
7604
7627
|
// if the next element is a letter or a parentheses, add the multiplication sign.
|
|
7605
|
-
if (nextToken
|
|
7628
|
+
if (nextToken?.match(/[a-zA-Z(]/)) {
|
|
7606
7629
|
normalizedExpr += '*';
|
|
7607
7630
|
}
|
|
7608
7631
|
}
|
|
7609
7632
|
else if (crtToken === ')') {
|
|
7610
7633
|
// Current element is a closing parentheses.
|
|
7611
7634
|
// if the next element is a letter, a number or an opening parentheses, add the multiplication sign
|
|
7612
|
-
if (nextToken
|
|
7635
|
+
if (nextToken?.match(/[a-zA-Z\d(]/)) {
|
|
7613
7636
|
normalizedExpr += '*';
|
|
7614
7637
|
}
|
|
7615
7638
|
}
|
|
@@ -7617,7 +7640,7 @@ class Shutingyard {
|
|
|
7617
7640
|
i++;
|
|
7618
7641
|
}
|
|
7619
7642
|
// add the last token
|
|
7620
|
-
return normalizedExpr + nextToken;
|
|
7643
|
+
return normalizedExpr + (nextToken === undefined ? '' : nextToken);
|
|
7621
7644
|
}
|
|
7622
7645
|
// /**
|
|
7623
7646
|
// * Sanitize an expression by adding missing common operation (multiplication between parentheseses)
|