pimath 0.0.114 → 0.0.116

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
@@ -2749,13 +2749,13 @@ class Polynom {
2749
2749
  // Values are different
2750
2750
  if (da !== db)
2751
2751
  return db - da;
2752
- // if values are equals, check other letters.
2752
+ // if values are equals, check other letters - it must be revert in that case !
2753
2753
  if (otherLetters.length > 0) {
2754
2754
  for (let L of otherLetters) {
2755
2755
  let da = a.degree(L).value, db = b.degree(L).value;
2756
2756
  // Values are different
2757
2757
  if (da !== db)
2758
- return db - da;
2758
+ return da - db;
2759
2759
  }
2760
2760
  }
2761
2761
  return 0;
@@ -5758,6 +5758,7 @@ const fraction_1 = __webpack_require__(506);
5758
5758
  const equation_1 = __webpack_require__(760);
5759
5759
  const polynom_1 = __webpack_require__(38);
5760
5760
  const random_1 = __webpack_require__(330);
5761
+ const monom_1 = __webpack_require__(937);
5761
5762
  var LinePropriety;
5762
5763
  (function (LinePropriety) {
5763
5764
  LinePropriety[LinePropriety["None"] = 0] = "None";
@@ -5947,13 +5948,16 @@ class Line {
5947
5948
  .add(this._c)
5948
5949
  .isZero();
5949
5950
  };
5950
- this.isParellelTo = (line) => {
5951
+ this.isParallelTo = (line) => {
5951
5952
  // Do they have the isSame direction ?
5952
5953
  return this.slope.isEqual(line.slope) && this.height.isNotEqual(line.height);
5953
5954
  };
5954
5955
  this.isSameAs = (line) => {
5955
5956
  return this.slope.isEqual(line.slope) && this.height.isEqual(line.height);
5956
5957
  };
5958
+ this.isPerpendicularTo = (line) => {
5959
+ return this.d.isNormalTo(line.d);
5960
+ };
5957
5961
  this.isVertical = () => {
5958
5962
  return this.slope.isInfinity();
5959
5963
  };
@@ -5985,7 +5989,7 @@ class Line {
5985
5989
  if (this._b.isZero() || line.b.isZero()) {
5986
5990
  // TODO : handle no y in the line canonical form
5987
5991
  }
5988
- if (this.isParellelTo(line)) {
5992
+ if (this.isParallelTo(line)) {
5989
5993
  Pt.x = null;
5990
5994
  Pt.y = null;
5991
5995
  isParallel = true;
@@ -6023,6 +6027,7 @@ class Line {
6023
6027
  return;
6024
6028
  };
6025
6029
  this._exists = false;
6030
+ this._reduceBeforeDisplay = true;
6026
6031
  if (values.length > 0) {
6027
6032
  this.parse(...values);
6028
6033
  }
@@ -6068,7 +6073,19 @@ class Line {
6068
6073
  }
6069
6074
  // ------------------------------------------
6070
6075
  get equation() {
6071
- return new equation_1.Equation(new polynom_1.Polynom().parse('xy', this._a, this._b, this._c), new polynom_1.Polynom('0')).simplify();
6076
+ let equ = new equation_1.Equation(new polynom_1.Polynom().parse('xy', this._a, this._b, this._c), new polynom_1.Polynom('0'));
6077
+ if (this._reduceBeforeDisplay) {
6078
+ return equ.simplify();
6079
+ }
6080
+ else {
6081
+ return equ;
6082
+ }
6083
+ }
6084
+ get system() {
6085
+ let e1 = new equation_1.Equation(new polynom_1.Polynom('x'), new polynom_1.Polynom(this._OA.x)
6086
+ .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)
6087
+ .add(new monom_1.Monom('k').multiplyByNumber(this._d.y)));
6088
+ return { x: e1, y: e2 };
6072
6089
  }
6073
6090
  get tex() {
6074
6091
  // canonical => ax + by + c = 0
@@ -6080,13 +6097,30 @@ class Line {
6080
6097
  if (this._a.isNegative()) {
6081
6098
  canonical.multiply(-1);
6082
6099
  }
6083
- const d = this._d.clone().simplifyDirection();
6100
+ let d = this._d.clone();
6101
+ if (this._reduceBeforeDisplay) {
6102
+ d.simplifyDirection();
6103
+ }
6084
6104
  return {
6085
6105
  canonical: canonical.tex,
6086
6106
  equation: canonical.clone().reorder().tex,
6087
6107
  mxh: this.slope.isInfinity() ? 'x=' + this.OA.x.tex : 'y=' + new polynom_1.Polynom().parse('x', this.slope, this.height).tex,
6088
- 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)}`
6089
- };
6108
+ 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)}`,
6109
+ system: `\\left\\{\\begin{aligned}
6110
+ x &= ${(new polynom_1.Polynom(this._OA.x)
6111
+ .add(new monom_1.Monom(this._d.x).multiply(new monom_1.Monom('k'))))
6112
+ .tex}\\
6113
+ y &= ${(new polynom_1.Polynom(this._OA.y)
6114
+ .add(new monom_1.Monom(this._d.y).multiply(new monom_1.Monom('k'))))
6115
+ .tex}
6116
+ \\end{aligned}\\right.`
6117
+ };
6118
+ }
6119
+ get reduceBeforeDisplay() {
6120
+ return this._reduceBeforeDisplay;
6121
+ }
6122
+ set reduceBeforeDisplay(value) {
6123
+ this._reduceBeforeDisplay = value;
6090
6124
  }
6091
6125
  get display() {
6092
6126
  // canonical => ax + by + c = 0