pimath 0.0.110 → 0.0.111
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/pi.js +20 -5
- package/dist/pi.js.map +1 -1
- package/dist/pi.min.js +1 -1
- package/dist/pi.min.js.map +1 -1
- package/esm/maths/algebra/linearSystem.d.ts +6 -0
- package/esm/maths/algebra/linearSystem.js +8 -0
- package/esm/maths/algebra/linearSystem.js.map +1 -1
- package/esm/maths/geometry/line.d.ts +1 -0
- package/esm/maths/geometry/line.js +6 -5
- package/esm/maths/geometry/line.js.map +1 -1
- package/esm/maths/geometry/vector.d.ts +1 -0
- package/esm/maths/geometry/vector.js +6 -0
- package/esm/maths/geometry/vector.js.map +1 -1
- package/package.json +1 -1
- package/src/maths/algebra/linearSystem.ts +26 -14
- package/src/maths/geometry/line.ts +8 -8
- package/src/maths/geometry/vector.ts +9 -0
- package/tests/algebra/linear.test.ts +16 -6
package/dist/pi.js
CHANGED
|
@@ -857,6 +857,7 @@ exports.LinearSystem = void 0;
|
|
|
857
857
|
const equation_1 = __webpack_require__(760);
|
|
858
858
|
const fraction_1 = __webpack_require__(506);
|
|
859
859
|
const polynom_1 = __webpack_require__(38);
|
|
860
|
+
const numeric_1 = __webpack_require__(956);
|
|
860
861
|
// TODO: Must check and rework
|
|
861
862
|
class LinearSystem {
|
|
862
863
|
constructor(...equationStrings) {
|
|
@@ -1027,9 +1028,16 @@ class LinearSystem {
|
|
|
1027
1028
|
}
|
|
1028
1029
|
return `\\left(${tex.join(';')}\\right)`;
|
|
1029
1030
|
}
|
|
1031
|
+
get resolutionSteps() {
|
|
1032
|
+
return this._resolutionSteps;
|
|
1033
|
+
}
|
|
1030
1034
|
_linearReduction(eq1, eq2, letter) {
|
|
1031
1035
|
// Get the monom for the particular letter.
|
|
1032
1036
|
let c1 = eq1.left.monomByDegree(1, letter).coefficient.clone(), c2 = eq2.left.monomByDegree(1, letter).coefficient.clone().opposed();
|
|
1037
|
+
// Reduce c1 and c2 by the gcd
|
|
1038
|
+
const gcdN = numeric_1.Numeric.gcd(c1.numerator, c2.numerator), gcdD = numeric_1.Numeric.gcd(c1.denominator, c2.denominator);
|
|
1039
|
+
c1.divide(gcdN).multiply(gcdD);
|
|
1040
|
+
c2.divide(gcdN).multiply(gcdD);
|
|
1033
1041
|
// if one value is -1, use 1 and make the other one opposed
|
|
1034
1042
|
if (c2.isNegativeOne()) {
|
|
1035
1043
|
c1.opposed();
|
|
@@ -5928,9 +5936,7 @@ class Line {
|
|
|
5928
5936
|
return this;
|
|
5929
5937
|
};
|
|
5930
5938
|
this.simplifyDirection = () => {
|
|
5931
|
-
|
|
5932
|
-
this._d.x.multiply(lcm).divide(gcd);
|
|
5933
|
-
this._d.y.multiply(lcm).divide(gcd);
|
|
5939
|
+
this._d.simplifyDirection();
|
|
5934
5940
|
return this;
|
|
5935
5941
|
};
|
|
5936
5942
|
this.intersection = (line) => {
|
|
@@ -6008,15 +6014,18 @@ class Line {
|
|
|
6008
6014
|
// canonical => ax + by + c = 0
|
|
6009
6015
|
// mxh => y = -a/b x - c/b
|
|
6010
6016
|
// parametric => (xy) = OA + k*d
|
|
6011
|
-
|
|
6017
|
+
// equation => ax + by = -c
|
|
6018
|
+
let canonical = this.equation.clone().moveLeft();
|
|
6012
6019
|
// Make sur the first item is positive.
|
|
6013
6020
|
if (this._a.isNegative()) {
|
|
6014
6021
|
canonical.multiply(-1);
|
|
6015
6022
|
}
|
|
6023
|
+
const d = this._d.clone().simplifyDirection();
|
|
6016
6024
|
return {
|
|
6017
6025
|
canonical: canonical.tex,
|
|
6018
6026
|
mxh: this.slope.isInfinity() ? 'x=' + this.OA.x.tex : 'y=' + new polynom_1.Polynom().parse('x', this.slope, this.height).tex,
|
|
6019
|
-
parametric: `${point_1.Point.pmatrix('x', 'y')} = ${point_1.Point.pmatrix(this._OA.x, this._OA.y)} + k\\cdot ${point_1.Point.pmatrix(
|
|
6027
|
+
parametric: `${point_1.Point.pmatrix('x', 'y')} = ${point_1.Point.pmatrix(this._OA.x, this._OA.y)} + k\\cdot ${point_1.Point.pmatrix(d.x, d.y)}`,
|
|
6028
|
+
equation: canonical.clone().reorder().tex
|
|
6020
6029
|
};
|
|
6021
6030
|
}
|
|
6022
6031
|
get display() {
|
|
@@ -6741,6 +6750,12 @@ class Vector {
|
|
|
6741
6750
|
return this.multiplyByScalar(numeric_1.Numeric.lcm(this._x.denominator, this._y.denominator))
|
|
6742
6751
|
.divideByScalar(numeric_1.Numeric.gcd(this._x.numerator, this._y.numerator));
|
|
6743
6752
|
};
|
|
6753
|
+
this.simplifyDirection = () => {
|
|
6754
|
+
let lcm = numeric_1.Numeric.lcm(this.x.denominator, this.y.denominator), gcd = numeric_1.Numeric.gcd(this.x.numerator, this.y.numerator);
|
|
6755
|
+
this.x.multiply(lcm).divide(gcd);
|
|
6756
|
+
this.y.multiply(lcm).divide(gcd);
|
|
6757
|
+
return this;
|
|
6758
|
+
};
|
|
6744
6759
|
this.angleWith = (V, sharp, radian) => {
|
|
6745
6760
|
let scalar = this.scalarProductWithVector(V).value, toDegree = radian ? 1 : 180 / Math.PI;
|
|
6746
6761
|
if (sharp) {
|