pimath 0.0.115 → 0.0.117

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 CHANGED
@@ -2741,21 +2741,24 @@ class Polynom {
2741
2741
  }
2742
2742
  return this.reorder();
2743
2743
  };
2744
- this.reorder = (letter = 'x') => {
2744
+ this.reorder = (letter = 'x', revert) => {
2745
+ if (revert === undefined) {
2746
+ revert = false;
2747
+ }
2745
2748
  // TODO: Must handle multiple setLetter reorder system
2746
2749
  let otherLetters = this.variables.filter(x => x !== letter);
2747
2750
  this._monoms.sort(function (a, b) {
2748
2751
  let da = a.degree(letter).value, db = b.degree(letter).value;
2749
2752
  // Values are different
2750
2753
  if (da !== db)
2751
- return db - da;
2752
- // if values are equals, check other letters.
2754
+ return revert ? da - db : db - da;
2755
+ // if values are equals, check other letters - it must be revert in that case !
2753
2756
  if (otherLetters.length > 0) {
2754
2757
  for (let L of otherLetters) {
2755
2758
  let da = a.degree(L).value, db = b.degree(L).value;
2756
2759
  // Values are different
2757
2760
  if (da !== db)
2758
- return db - da;
2761
+ return revert ? da - db : db - da;
2759
2762
  }
2760
2763
  }
2761
2764
  return 0;
@@ -5758,6 +5761,7 @@ const fraction_1 = __webpack_require__(506);
5758
5761
  const equation_1 = __webpack_require__(760);
5759
5762
  const polynom_1 = __webpack_require__(38);
5760
5763
  const random_1 = __webpack_require__(330);
5764
+ const monom_1 = __webpack_require__(937);
5761
5765
  var LinePropriety;
5762
5766
  (function (LinePropriety) {
5763
5767
  LinePropriety[LinePropriety["None"] = 0] = "None";
@@ -6026,6 +6030,7 @@ class Line {
6026
6030
  return;
6027
6031
  };
6028
6032
  this._exists = false;
6033
+ this._reduceBeforeDisplay = true;
6029
6034
  if (values.length > 0) {
6030
6035
  this.parse(...values);
6031
6036
  }
@@ -6071,7 +6076,19 @@ class Line {
6071
6076
  }
6072
6077
  // ------------------------------------------
6073
6078
  get equation() {
6074
- return new equation_1.Equation(new polynom_1.Polynom().parse('xy', this._a, this._b, this._c), new polynom_1.Polynom('0')).simplify();
6079
+ let equ = new equation_1.Equation(new polynom_1.Polynom().parse('xy', this._a, this._b, this._c), new polynom_1.Polynom('0'));
6080
+ if (this._reduceBeforeDisplay) {
6081
+ return equ.simplify();
6082
+ }
6083
+ else {
6084
+ return equ;
6085
+ }
6086
+ }
6087
+ get system() {
6088
+ let e1 = new equation_1.Equation(new polynom_1.Polynom('x'), new polynom_1.Polynom(this._OA.x)
6089
+ .add(new monom_1.Monom('k').multiplyByNumber(this._d.x))), e2 = new equation_1.Equation(new polynom_1.Polynom('y'), new polynom_1.Polynom(this._OA.y)
6090
+ .add(new monom_1.Monom('k').multiplyByNumber(this._d.y)));
6091
+ return { x: e1, y: e2 };
6075
6092
  }
6076
6093
  get tex() {
6077
6094
  // canonical => ax + by + c = 0
@@ -6083,13 +6100,32 @@ class Line {
6083
6100
  if (this._a.isNegative()) {
6084
6101
  canonical.multiply(-1);
6085
6102
  }
6086
- const d = this._d.clone().simplifyDirection();
6103
+ let d = this._d.clone();
6104
+ if (this._reduceBeforeDisplay) {
6105
+ d.simplifyDirection();
6106
+ }
6087
6107
  return {
6088
6108
  canonical: canonical.tex,
6089
6109
  equation: canonical.clone().reorder().tex,
6090
6110
  mxh: this.slope.isInfinity() ? 'x=' + this.OA.x.tex : 'y=' + new polynom_1.Polynom().parse('x', this.slope, this.height).tex,
6091
- 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)}`
6092
- };
6111
+ 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)}`,
6112
+ system: `\\left\\{\\begin{aligned}
6113
+ x &= ${(new polynom_1.Polynom(this._OA.x)
6114
+ .add(new monom_1.Monom(this._d.x).multiply(new monom_1.Monom('k'))))
6115
+ .reorder('k', true)
6116
+ .tex}\\
6117
+ y &= ${(new polynom_1.Polynom(this._OA.y)
6118
+ .add(new monom_1.Monom(this._d.y).multiply(new monom_1.Monom('k'))))
6119
+ .reorder('k', true)
6120
+ .tex}
6121
+ \\end{aligned}\\right.`
6122
+ };
6123
+ }
6124
+ get reduceBeforeDisplay() {
6125
+ return this._reduceBeforeDisplay;
6126
+ }
6127
+ set reduceBeforeDisplay(value) {
6128
+ this._reduceBeforeDisplay = value;
6093
6129
  }
6094
6130
  get display() {
6095
6131
  // canonical => ax + by + c = 0