pimath 0.0.113 → 0.0.115

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 +149 -44
  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 +21 -17
  59. package/esm/maths/geometry/line.js +68 -40
  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 +116 -76
  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,13 +5939,24 @@ class Line {
5920
5939
  // ------------------------------------------
5921
5940
  // Mathematical operations
5922
5941
  // ------------------------------------------
5923
- this.isParellelTo = (line) => {
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
+ };
5950
+ this.isParallelTo = (line) => {
5924
5951
  // Do they have the isSame direction ?
5925
5952
  return this.slope.isEqual(line.slope) && this.height.isNotEqual(line.height);
5926
5953
  };
5927
5954
  this.isSameAs = (line) => {
5928
5955
  return this.slope.isEqual(line.slope) && this.height.isEqual(line.height);
5929
5956
  };
5957
+ this.isPerpendicularTo = (line) => {
5958
+ return this.d.isNormalTo(line.d);
5959
+ };
5930
5960
  this.isVertical = () => {
5931
5961
  return this.slope.isInfinity();
5932
5962
  };
@@ -5958,7 +5988,7 @@ class Line {
5958
5988
  if (this._b.isZero() || line.b.isZero()) {
5959
5989
  // TODO : handle no y in the line canonical form
5960
5990
  }
5961
- if (this.isParellelTo(line)) {
5991
+ if (this.isParallelTo(line)) {
5962
5992
  Pt.x = null;
5963
5993
  Pt.y = null;
5964
5994
  isParallel = true;
@@ -6001,11 +6031,44 @@ class Line {
6001
6031
  }
6002
6032
  return this;
6003
6033
  }
6004
- get exists() {
6005
- return this._exists;
6034
+ get a() {
6035
+ return this._a;
6036
+ }
6037
+ set a(value) {
6038
+ this._a = value;
6039
+ }
6040
+ get b() {
6041
+ return this._b;
6042
+ }
6043
+ set b(value) {
6044
+ this._b = value;
6045
+ }
6046
+ get c() {
6047
+ return this._c;
6006
6048
  }
6007
6049
  // ------------------------------------------
6008
6050
  // Getter and setter
6051
+ set c(value) {
6052
+ this._c = value;
6053
+ }
6054
+ get OA() {
6055
+ return this._OA;
6056
+ }
6057
+ set OA(value) {
6058
+ this._OA = value;
6059
+ }
6060
+ get d() {
6061
+ return this._d;
6062
+ }
6063
+ set d(value) {
6064
+ this._d = value;
6065
+ }
6066
+ get n() {
6067
+ return this._n;
6068
+ }
6069
+ get exists() {
6070
+ return this._exists;
6071
+ }
6009
6072
  // ------------------------------------------
6010
6073
  get equation() {
6011
6074
  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 +6078,11 @@ class Line {
6015
6078
  // mxh => y = -a/b x - c/b
6016
6079
  // parametric => (xy) = OA + k*d
6017
6080
  // equation => ax + by = -c
6018
- console.log('BEFORE', this.equation.tex);
6019
6081
  let canonical = this.equation.clone().reorder(true);
6020
- console.log('CANONCIAL', canonical.tex);
6021
6082
  // Make sur the first item is positive.
6022
6083
  if (this._a.isNegative()) {
6023
6084
  canonical.multiply(-1);
6024
6085
  }
6025
- console.log('CANONCIAL (multiply)', canonical.tex);
6026
6086
  const d = this._d.clone().simplifyDirection();
6027
6087
  return {
6028
6088
  canonical: canonical.tex,
@@ -6046,45 +6106,12 @@ class Line {
6046
6106
  parametric: ""
6047
6107
  };
6048
6108
  }
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
6109
  get normal() {
6080
6110
  return new vector_1.Vector(this._a, this._b);
6081
6111
  }
6082
6112
  get director() {
6083
6113
  return this._d.clone();
6084
6114
  }
6085
- set d(value) {
6086
- this._d = value;
6087
- }
6088
6115
  get slope() {
6089
6116
  return this._a.clone().opposed().divide(this._b);
6090
6117
  }
@@ -6166,6 +6193,7 @@ class Line {
6166
6193
  }
6167
6194
  }
6168
6195
  exports.Line = Line;
6196
+ // A line is defined as the canonical form
6169
6197
  Line.PERPENDICULAR = LinePropriety.Perpendicular;
6170
6198
  Line.PARALLEL = LinePropriety.Parallel;
6171
6199
 
@@ -6316,6 +6344,9 @@ class Point {
6316
6344
  pts.push(this._y.tex);
6317
6345
  return `(${pts.join(';')})`;
6318
6346
  }
6347
+ get asVector() {
6348
+ return new vector_1.Vector(this.x, this.y);
6349
+ }
6319
6350
  get key() {
6320
6351
  return `${this.x.display};${this.y.display}`;
6321
6352
  }
@@ -6724,8 +6755,8 @@ class Vector {
6724
6755
  return this.add(V.clone().opposed());
6725
6756
  };
6726
6757
  this.scalarProductWithVector = (V) => {
6727
- // TODO: Add the scalar factor !!!!
6728
- return this._x.clone().multiply(V.x).add(this._y.clone().multiply(V.y));
6758
+ return Vector.scalarProduct(this, V);
6759
+ // return this._x.clone().multiply(V.x).add(this._y.clone().multiply(V.y));
6729
6760
  };
6730
6761
  this.normal = () => {
6731
6762
  let x = this.x.clone().opposed(), y = this.y.clone();
@@ -6797,14 +6828,16 @@ class Vector {
6797
6828
  get tex() {
6798
6829
  return `\\begin{pmatrix}${this._x.tex} \\\\\ ${this._y.tex} \\end{pmatrix}`;
6799
6830
  }
6831
+ get asPoint() {
6832
+ return new point_1.Point(this.x, this.y);
6833
+ }
6800
6834
  get isNull() {
6801
6835
  return this.x.isZero() && this.y.isZero();
6802
6836
  }
6803
6837
  }
6804
6838
  exports.Vector = Vector;
6805
6839
  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;
6840
+ return v1.x.clone().multiply(v2.x).add(v1.y.clone().multiply(v2.y));
6808
6841
  };
6809
6842
 
6810
6843
 
@@ -7011,6 +7044,7 @@ const rndMonom_1 = __webpack_require__(793);
7011
7044
  const rndHelpers_1 = __webpack_require__(140);
7012
7045
  const rndFraction_1 = __webpack_require__(754);
7013
7046
  const rndGeometryLine_1 = __webpack_require__(821);
7047
+ const rndGeometryPoint_1 = __webpack_require__(246);
7014
7048
  __exportStar(__webpack_require__(230), exports);
7015
7049
  var Random;
7016
7050
  (function (Random) {
@@ -7060,6 +7094,10 @@ var Random;
7060
7094
  return (new rndGeometryLine_1.rndGeometryLine(config).generate());
7061
7095
  }
7062
7096
  Geometry.line = line;
7097
+ function point(config) {
7098
+ return (new rndGeometryPoint_1.rndGeometryPoint(config).generate());
7099
+ }
7100
+ Geometry.point = point;
7063
7101
  })(Geometry = Random.Geometry || (Random.Geometry = {}));
7064
7102
  })(Random = exports.Random || (exports.Random = {}));
7065
7103
 
@@ -7194,6 +7232,73 @@ class rndGeometryLine extends randomCore_1.randomCore {
7194
7232
  exports.rndGeometryLine = rndGeometryLine;
7195
7233
 
7196
7234
 
7235
+ /***/ }),
7236
+
7237
+ /***/ 246:
7238
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
7239
+
7240
+
7241
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
7242
+ exports.rndGeometryPoint = void 0;
7243
+ const randomCore_1 = __webpack_require__(373);
7244
+ const random_1 = __webpack_require__(330);
7245
+ const point_1 = __webpack_require__(557);
7246
+ const fraction_1 = __webpack_require__(506);
7247
+ /**
7248
+ * Create a random monom based on a based configuration
7249
+ */
7250
+ class rndGeometryPoint extends randomCore_1.randomCore {
7251
+ constructor(userConfig) {
7252
+ super();
7253
+ this.generate = () => {
7254
+ let x, y, zeroX = this._config.axis === true || this._config.axis === 'x', zeroY = this._config.axis === true || this._config.axis === 'y';
7255
+ x = this._config.fraction ?
7256
+ random_1.Random.fraction({ max: this._config.max, zero: zeroX }) :
7257
+ new fraction_1.Fraction(random_1.Random.numberSym(this._config.max, zeroX));
7258
+ y = this._config.fraction ?
7259
+ random_1.Random.fraction({ max: this._config.max, zero: zeroY }) :
7260
+ new fraction_1.Fraction(random_1.Random.numberSym(this._config.max, zeroY));
7261
+ if (+this._config.quadrant === 1) {
7262
+ x.abs();
7263
+ y.abs();
7264
+ }
7265
+ if (+this._config.quadrant === 2) {
7266
+ if (x.isPositive()) {
7267
+ x.opposed();
7268
+ }
7269
+ if (y.isNegative()) {
7270
+ y.opposed();
7271
+ }
7272
+ }
7273
+ if (+this._config.quadrant === 3) {
7274
+ if (x.isPositive()) {
7275
+ x.opposed();
7276
+ }
7277
+ if (y.isPositive()) {
7278
+ y.opposed();
7279
+ }
7280
+ }
7281
+ if (+this._config.quadrant === 4) {
7282
+ if (x.isNegative()) {
7283
+ x.opposed();
7284
+ }
7285
+ if (y.isPositive()) {
7286
+ y.opposed();
7287
+ }
7288
+ }
7289
+ return new point_1.Point(x, y);
7290
+ };
7291
+ this._defaultConfig = {
7292
+ axis: true,
7293
+ fraction: false,
7294
+ max: 10
7295
+ };
7296
+ this._config = this.mergeConfig(userConfig, this._defaultConfig);
7297
+ }
7298
+ }
7299
+ exports.rndGeometryPoint = rndGeometryPoint;
7300
+
7301
+
7197
7302
  /***/ }),
7198
7303
 
7199
7304
  /***/ 140: