pimath 0.0.113 → 0.0.114

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.
Files changed (93) hide show
  1. package/dist/pi.js +144 -42
  2. package/dist/pi.js.map +1 -1
  3. package/dist/pi.min.js +1 -1
  4. package/dist/pi.min.js.map +1 -1
  5. package/docs/assets/highlight.css +3 -3
  6. package/docs/assets/main.js +58 -52
  7. package/docs/assets/search.js +1 -1
  8. package/docs/assets/style.css +488 -621
  9. package/docs/classes/Logicalset.Logicalset.html +212 -0
  10. package/docs/classes/Polynom.Rational.html +388 -4
  11. package/docs/classes/Vector-1.Vector.html +448 -0
  12. package/docs/classes/Vector.Point.html +342 -1
  13. package/docs/classes/algebra_equation.Equation.html +749 -22
  14. package/docs/classes/algebra_linearSystem.LinearSystem.html +397 -1
  15. package/docs/classes/algebra_monom.Monom.html +906 -110
  16. package/docs/classes/algebra_polynom.Polynom.html +1258 -28
  17. package/docs/classes/coefficients_fraction.Fraction.html +929 -17
  18. package/docs/classes/expressions_numexp.NumExp.html +236 -1
  19. package/docs/classes/expressions_polynomexp.PolynomExpFactor.html +317 -1
  20. package/docs/classes/expressions_polynomexp.PolynomExpProduct.html +285 -1
  21. package/docs/classes/geometry_circle.Circle.html +476 -3
  22. package/docs/classes/geometry_line.Line.html +719 -3
  23. package/docs/classes/geometry_triangle.Triangle.html +417 -14
  24. package/docs/classes/numeric.Numeric.html +263 -14
  25. package/docs/classes/shutingyard.Shutingyard.html +246 -16
  26. package/docs/enums/algebra_equation.PARTICULAR_SOLUTION.html +88 -1
  27. package/docs/enums/geometry_line.LinePropriety.html +102 -1
  28. package/docs/enums/shutingyard.ShutingyardMode.html +102 -1
  29. package/docs/enums/shutingyard.ShutingyardType.html +116 -1
  30. package/docs/index.html +56 -2
  31. package/docs/interfaces/algebra_equation.ISolution.html +109 -3
  32. package/docs/interfaces/algebra_polynom.IEuclidian.html +92 -1
  33. package/docs/interfaces/geometry_triangle.remarquableLines.html +150 -1
  34. package/docs/modules/Logicalset.html +74 -3
  35. package/docs/modules/Polynom.html +74 -3
  36. package/docs/modules/Vector-1.html +74 -0
  37. package/docs/modules/Vector.html +74 -3
  38. package/docs/modules/algebra_equation.html +81 -1
  39. package/docs/modules/algebra_linearSystem.html +71 -1
  40. package/docs/modules/algebra_monom.html +76 -1
  41. package/docs/modules/algebra_polynom.html +81 -1
  42. package/docs/modules/coefficients_fraction.html +76 -1
  43. package/docs/modules/expressions_numexp.html +71 -1
  44. package/docs/modules/expressions_polynomexp.html +73 -1
  45. package/docs/modules/geometry_circle.html +71 -1
  46. package/docs/modules/geometry_line.html +76 -1
  47. package/docs/modules/geometry_triangle.html +76 -1
  48. package/docs/modules/numeric.html +71 -1
  49. package/docs/modules/shutingyard.html +90 -1
  50. package/docs/modules.html +76 -1
  51. package/docs/types/algebra_monom.literalType.html +70 -0
  52. package/docs/types/algebra_polynom.PolynomParsingType.html +66 -0
  53. package/docs/types/coefficients_fraction.FractionParsingType.html +65 -0
  54. package/docs/types/shutingyard.Token.html +76 -0
  55. package/docs/types/shutingyard.tokenType.html +81 -0
  56. package/docs/variables/shutingyard.tokenConstant.html +74 -0
  57. package/esm/index.js.map +1 -1
  58. package/esm/maths/geometry/line.d.ts +19 -16
  59. package/esm/maths/geometry/line.js +63 -38
  60. package/esm/maths/geometry/line.js.map +1 -1
  61. package/esm/maths/geometry/point.d.ts +2 -0
  62. package/esm/maths/geometry/point.js +3 -0
  63. package/esm/maths/geometry/point.js.map +1 -1
  64. package/esm/maths/geometry/vector.d.ts +3 -1
  65. package/esm/maths/geometry/vector.js +6 -4
  66. package/esm/maths/geometry/vector.js.map +1 -1
  67. package/esm/maths/randomization/random.d.ts +3 -1
  68. package/esm/maths/randomization/random.js +5 -0
  69. package/esm/maths/randomization/random.js.map +1 -1
  70. package/esm/maths/randomization/rndGeometryLine.js.map +1 -1
  71. package/esm/maths/randomization/rndGeometryPoint.d.ts +12 -0
  72. package/esm/maths/randomization/rndGeometryPoint.js +61 -0
  73. package/esm/maths/randomization/rndGeometryPoint.js.map +1 -0
  74. package/esm/maths/randomization/rndTypes.d.ts +6 -0
  75. package/package.json +8 -8
  76. package/src/index.ts +1 -0
  77. package/src/maths/geometry/line.ts +111 -74
  78. package/src/maths/geometry/point.ts +4 -0
  79. package/src/maths/geometry/vector.ts +8 -5
  80. package/src/maths/randomization/random.ts +14 -1
  81. package/src/maths/randomization/rndGeometryLine.ts +5 -6
  82. package/src/maths/randomization/rndGeometryPoint.ts +69 -0
  83. package/src/maths/randomization/rndTypes.ts +8 -0
  84. package/tests/geometry/line.test.ts +13 -0
  85. package/docs/assets/icons.css +0 -1043
  86. package/docs/assets/icons.png +0 -0
  87. package/docs/assets/icons@2x.png +0 -0
  88. package/docs/assets/widgets.png +0 -0
  89. package/docs/assets/widgets@2x.png +0 -0
  90. package/docs/classes/Logicalset.Logicalset-1.html +0 -5
  91. package/docs/classes/Vector.Vector-1.html +0 -1
  92. package/docs/classes/coefficients_nthroot.NthRoot.html +0 -3
  93. package/docs/modules/coefficients_nthroot.html +0 -1
package/dist/pi.js CHANGED
@@ -5757,6 +5757,7 @@ const numeric_1 = __webpack_require__(956);
5757
5757
  const fraction_1 = __webpack_require__(506);
5758
5758
  const equation_1 = __webpack_require__(760);
5759
5759
  const polynom_1 = __webpack_require__(38);
5760
+ const random_1 = __webpack_require__(330);
5760
5761
  var LinePropriety;
5761
5762
  (function (LinePropriety) {
5762
5763
  LinePropriety[LinePropriety["None"] = 0] = "None";
@@ -5766,6 +5767,24 @@ var LinePropriety;
5766
5767
  })(LinePropriety = exports.LinePropriety || (exports.LinePropriety = {}));
5767
5768
  class Line {
5768
5769
  constructor(...values) {
5770
+ this.randomPoint = (k) => {
5771
+ // Return a random point on the line.
5772
+ return this._d
5773
+ .clone()
5774
+ .multiplyByScalar(random_1.Random.numberSym((k === undefined || k <= 1) ? 3 : k, false))
5775
+ .add(this._OA.asVector)
5776
+ .asPoint;
5777
+ };
5778
+ this.randomNearPoint = (k) => {
5779
+ let pt = this.randomPoint(k);
5780
+ let maxIterationTest = 10;
5781
+ while (this.isOnLine(pt) && maxIterationTest > 0) {
5782
+ pt.x.add(random_1.Random.numberSym(1, false));
5783
+ pt.y.add(random_1.Random.numberSym(1, false));
5784
+ maxIterationTest--;
5785
+ }
5786
+ return pt;
5787
+ };
5769
5788
  // ------------------------------------------
5770
5789
  // Creation / parsing functions
5771
5790
  // ------------------------------------------
@@ -5920,6 +5939,14 @@ class Line {
5920
5939
  // ------------------------------------------
5921
5940
  // Mathematical operations
5922
5941
  // ------------------------------------------
5942
+ this.isOnLine = (pt) => {
5943
+ return this._a.clone()
5944
+ .multiply(pt.x)
5945
+ .add(this._b.clone()
5946
+ .multiply(pt.y))
5947
+ .add(this._c)
5948
+ .isZero();
5949
+ };
5923
5950
  this.isParellelTo = (line) => {
5924
5951
  // Do they have the isSame direction ?
5925
5952
  return this.slope.isEqual(line.slope) && this.height.isNotEqual(line.height);
@@ -6001,11 +6028,44 @@ class Line {
6001
6028
  }
6002
6029
  return this;
6003
6030
  }
6004
- get exists() {
6005
- return this._exists;
6031
+ get a() {
6032
+ return this._a;
6033
+ }
6034
+ set a(value) {
6035
+ this._a = value;
6036
+ }
6037
+ get b() {
6038
+ return this._b;
6039
+ }
6040
+ set b(value) {
6041
+ this._b = value;
6042
+ }
6043
+ get c() {
6044
+ return this._c;
6006
6045
  }
6007
6046
  // ------------------------------------------
6008
6047
  // Getter and setter
6048
+ set c(value) {
6049
+ this._c = value;
6050
+ }
6051
+ get OA() {
6052
+ return this._OA;
6053
+ }
6054
+ set OA(value) {
6055
+ this._OA = value;
6056
+ }
6057
+ get d() {
6058
+ return this._d;
6059
+ }
6060
+ set d(value) {
6061
+ this._d = value;
6062
+ }
6063
+ get n() {
6064
+ return this._n;
6065
+ }
6066
+ get exists() {
6067
+ return this._exists;
6068
+ }
6009
6069
  // ------------------------------------------
6010
6070
  get equation() {
6011
6071
  return new equation_1.Equation(new polynom_1.Polynom().parse('xy', this._a, this._b, this._c), new polynom_1.Polynom('0')).simplify();
@@ -6015,14 +6075,11 @@ class Line {
6015
6075
  // mxh => y = -a/b x - c/b
6016
6076
  // parametric => (xy) = OA + k*d
6017
6077
  // equation => ax + by = -c
6018
- console.log('BEFORE', this.equation.tex);
6019
6078
  let canonical = this.equation.clone().reorder(true);
6020
- console.log('CANONCIAL', canonical.tex);
6021
6079
  // Make sur the first item is positive.
6022
6080
  if (this._a.isNegative()) {
6023
6081
  canonical.multiply(-1);
6024
6082
  }
6025
- console.log('CANONCIAL (multiply)', canonical.tex);
6026
6083
  const d = this._d.clone().simplifyDirection();
6027
6084
  return {
6028
6085
  canonical: canonical.tex,
@@ -6046,45 +6103,12 @@ class Line {
6046
6103
  parametric: ""
6047
6104
  };
6048
6105
  }
6049
- get a() {
6050
- return this._a;
6051
- }
6052
- set a(value) {
6053
- this._a = value;
6054
- }
6055
- get b() {
6056
- return this._b;
6057
- }
6058
- set b(value) {
6059
- this._b = value;
6060
- }
6061
- get c() {
6062
- return this._c;
6063
- }
6064
- set c(value) {
6065
- this._c = value;
6066
- }
6067
- get OA() {
6068
- return this._OA;
6069
- }
6070
- set OA(value) {
6071
- this._OA = value;
6072
- }
6073
- get d() {
6074
- return this._d;
6075
- }
6076
- get n() {
6077
- return this._n;
6078
- }
6079
6106
  get normal() {
6080
6107
  return new vector_1.Vector(this._a, this._b);
6081
6108
  }
6082
6109
  get director() {
6083
6110
  return this._d.clone();
6084
6111
  }
6085
- set d(value) {
6086
- this._d = value;
6087
- }
6088
6112
  get slope() {
6089
6113
  return this._a.clone().opposed().divide(this._b);
6090
6114
  }
@@ -6166,6 +6190,7 @@ class Line {
6166
6190
  }
6167
6191
  }
6168
6192
  exports.Line = Line;
6193
+ // A line is defined as the canonical form
6169
6194
  Line.PERPENDICULAR = LinePropriety.Perpendicular;
6170
6195
  Line.PARALLEL = LinePropriety.Parallel;
6171
6196
 
@@ -6316,6 +6341,9 @@ class Point {
6316
6341
  pts.push(this._y.tex);
6317
6342
  return `(${pts.join(';')})`;
6318
6343
  }
6344
+ get asVector() {
6345
+ return new vector_1.Vector(this.x, this.y);
6346
+ }
6319
6347
  get key() {
6320
6348
  return `${this.x.display};${this.y.display}`;
6321
6349
  }
@@ -6724,8 +6752,8 @@ class Vector {
6724
6752
  return this.add(V.clone().opposed());
6725
6753
  };
6726
6754
  this.scalarProductWithVector = (V) => {
6727
- // TODO: Add the scalar factor !!!!
6728
- return this._x.clone().multiply(V.x).add(this._y.clone().multiply(V.y));
6755
+ return Vector.scalarProduct(this, V);
6756
+ // return this._x.clone().multiply(V.x).add(this._y.clone().multiply(V.y));
6729
6757
  };
6730
6758
  this.normal = () => {
6731
6759
  let x = this.x.clone().opposed(), y = this.y.clone();
@@ -6797,14 +6825,16 @@ class Vector {
6797
6825
  get tex() {
6798
6826
  return `\\begin{pmatrix}${this._x.tex} \\\\\ ${this._y.tex} \\end{pmatrix}`;
6799
6827
  }
6828
+ get asPoint() {
6829
+ return new point_1.Point(this.x, this.y);
6830
+ }
6800
6831
  get isNull() {
6801
6832
  return this.x.isZero() && this.y.isZero();
6802
6833
  }
6803
6834
  }
6804
6835
  exports.Vector = Vector;
6805
6836
  Vector.scalarProduct = (v1, v2) => {
6806
- // TODO: Transform to fraction with nthroot.
6807
- return v1.x.value * v2.x.value + v1.y.value * v2.y.value;
6837
+ return v1.x.clone().multiply(v2.x).add(v1.y.clone().multiply(v2.y));
6808
6838
  };
6809
6839
 
6810
6840
 
@@ -7011,6 +7041,7 @@ const rndMonom_1 = __webpack_require__(793);
7011
7041
  const rndHelpers_1 = __webpack_require__(140);
7012
7042
  const rndFraction_1 = __webpack_require__(754);
7013
7043
  const rndGeometryLine_1 = __webpack_require__(821);
7044
+ const rndGeometryPoint_1 = __webpack_require__(246);
7014
7045
  __exportStar(__webpack_require__(230), exports);
7015
7046
  var Random;
7016
7047
  (function (Random) {
@@ -7060,6 +7091,10 @@ var Random;
7060
7091
  return (new rndGeometryLine_1.rndGeometryLine(config).generate());
7061
7092
  }
7062
7093
  Geometry.line = line;
7094
+ function point(config) {
7095
+ return (new rndGeometryPoint_1.rndGeometryPoint(config).generate());
7096
+ }
7097
+ Geometry.point = point;
7063
7098
  })(Geometry = Random.Geometry || (Random.Geometry = {}));
7064
7099
  })(Random = exports.Random || (exports.Random = {}));
7065
7100
 
@@ -7194,6 +7229,73 @@ class rndGeometryLine extends randomCore_1.randomCore {
7194
7229
  exports.rndGeometryLine = rndGeometryLine;
7195
7230
 
7196
7231
 
7232
+ /***/ }),
7233
+
7234
+ /***/ 246:
7235
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
7236
+
7237
+
7238
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
7239
+ exports.rndGeometryPoint = void 0;
7240
+ const randomCore_1 = __webpack_require__(373);
7241
+ const random_1 = __webpack_require__(330);
7242
+ const point_1 = __webpack_require__(557);
7243
+ const fraction_1 = __webpack_require__(506);
7244
+ /**
7245
+ * Create a random monom based on a based configuration
7246
+ */
7247
+ class rndGeometryPoint extends randomCore_1.randomCore {
7248
+ constructor(userConfig) {
7249
+ super();
7250
+ this.generate = () => {
7251
+ let x, y, zeroX = this._config.axis === true || this._config.axis === 'x', zeroY = this._config.axis === true || this._config.axis === 'y';
7252
+ x = this._config.fraction ?
7253
+ random_1.Random.fraction({ max: this._config.max, zero: zeroX }) :
7254
+ new fraction_1.Fraction(random_1.Random.numberSym(this._config.max, zeroX));
7255
+ y = this._config.fraction ?
7256
+ random_1.Random.fraction({ max: this._config.max, zero: zeroY }) :
7257
+ new fraction_1.Fraction(random_1.Random.numberSym(this._config.max, zeroY));
7258
+ if (+this._config.quadrant === 1) {
7259
+ x.abs();
7260
+ y.abs();
7261
+ }
7262
+ if (+this._config.quadrant === 2) {
7263
+ if (x.isPositive()) {
7264
+ x.opposed();
7265
+ }
7266
+ if (y.isNegative()) {
7267
+ y.opposed();
7268
+ }
7269
+ }
7270
+ if (+this._config.quadrant === 3) {
7271
+ if (x.isPositive()) {
7272
+ x.opposed();
7273
+ }
7274
+ if (y.isPositive()) {
7275
+ y.opposed();
7276
+ }
7277
+ }
7278
+ if (+this._config.quadrant === 4) {
7279
+ if (x.isNegative()) {
7280
+ x.opposed();
7281
+ }
7282
+ if (y.isPositive()) {
7283
+ y.opposed();
7284
+ }
7285
+ }
7286
+ return new point_1.Point(x, y);
7287
+ };
7288
+ this._defaultConfig = {
7289
+ axis: true,
7290
+ fraction: false,
7291
+ max: 10
7292
+ };
7293
+ this._config = this.mergeConfig(userConfig, this._defaultConfig);
7294
+ }
7295
+ }
7296
+ exports.rndGeometryPoint = rndGeometryPoint;
7297
+
7298
+
7197
7299
  /***/ }),
7198
7300
 
7199
7301
  /***/ 140: