pimath 0.0.118 → 0.0.120

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
@@ -6794,12 +6794,18 @@ class Vector {
6794
6794
  return Vector.scalarProduct(this, V);
6795
6795
  // return this._x.clone().multiply(V.x).add(this._y.clone().multiply(V.y));
6796
6796
  };
6797
+ this.determinantWithVector = (V) => {
6798
+ return Vector.determinant(this, V);
6799
+ };
6797
6800
  this.normal = () => {
6798
6801
  let x = this.x.clone().opposed(), y = this.y.clone();
6799
6802
  this._x = y;
6800
6803
  this._y = x;
6801
6804
  return this;
6802
6805
  };
6806
+ this.isColinearTo = (v) => {
6807
+ return this.determinantWithVector(v).isZero();
6808
+ };
6803
6809
  this.isNormalTo = (v) => {
6804
6810
  return this.scalarProductWithVector(v).isZero();
6805
6811
  };
@@ -6875,6 +6881,9 @@ exports.Vector = Vector;
6875
6881
  Vector.scalarProduct = (v1, v2) => {
6876
6882
  return v1.x.clone().multiply(v2.x).add(v1.y.clone().multiply(v2.y));
6877
6883
  };
6884
+ Vector.determinant = (v1, v2) => {
6885
+ return v1.x.clone().multiply(v2.y).subtract(v1.y.clone().multiply(v2.x));
6886
+ };
6878
6887
 
6879
6888
 
6880
6889
  /***/ }),
@@ -6989,44 +6998,55 @@ class Numeric {
6989
6998
  }
6990
6999
  return triplets;
6991
7000
  }
6992
- static numberCorrection(value, epsilonDigit = 1, epsilonNumberOfDigits = 10, number_of_digits = 6) {
6993
- // Must modify the number if it's like:
6994
- // a: 3.0000000000000003
6995
- // b: 3.9999999999999994
6996
- // remove the last character
6997
- // check if around n last characters are either 0 or 9
6998
- // if it is, 'round' the number.
6999
- function extractDecimalPart(valueToExtract, decimalLength) {
7000
- let decimal = valueToExtract.toString();
7001
- if (!decimal.includes('.')) {
7002
- return '';
7003
- }
7004
- decimal = decimal.split('.')[1];
7005
- return decimal.substring(0, decimalLength);
7006
- }
7007
- const epsilon = Number(`0.${"0".repeat(epsilonNumberOfDigits - 1)}${epsilonDigit}`);
7008
- const decimal = extractDecimalPart(value, epsilonNumberOfDigits);
7009
- if (decimal === '') {
7010
- return value;
7011
- }
7012
- const n9 = decimal.match(/9+$/g);
7013
- const n0 = decimal.match(/0+$/g);
7014
- if (n9 && n9[0].length >= number_of_digits) {
7015
- // New tested values.
7016
- const mod = extractDecimalPart(value + epsilon, epsilonNumberOfDigits), mod0 = mod.match(/0+$/g);
7017
- if (mod0 && mod0[0].length >= number_of_digits) {
7018
- return +((value + epsilon).toString().split(mod0[0])[0]);
7019
- }
7020
- }
7021
- if (n0 && n0[0].length >= number_of_digits) {
7022
- // New tested values.
7023
- const mod = extractDecimalPart(value - epsilon, epsilonNumberOfDigits), mod9 = mod.match(/9+$/g);
7024
- if (mod9 && mod9[0].length >= number_of_digits) {
7025
- // The value can be changed. Remove all nines!
7026
- return +(value.toString().split(n0[0])[0]);
7027
- }
7028
- }
7029
- return value;
7001
+ static numberCorrection(value, epsilonDigit = 1, epsilonNumberOfDigits = 10, number_of_digits = 8) {
7002
+ return +value.toFixed(number_of_digits);
7003
+ //
7004
+ // // Must modify the number if it's like:
7005
+ // // a: 3.0000000000000003
7006
+ // // b: 3.9999999999999994
7007
+ // // remove the last character
7008
+ // // check if around n last characters are either 0 or 9
7009
+ // // if it is, 'round' the number.
7010
+ // function extractDecimalPart(valueToExtract: number, decimalLength: number){
7011
+ // let decimal = valueToExtract.toString()
7012
+ //
7013
+ // if (!decimal.includes('.')) {
7014
+ // return ''
7015
+ // }
7016
+ //
7017
+ // decimal = decimal.split('.')[1]
7018
+ // return decimal.substring(0, decimalLength)
7019
+ // }
7020
+ //
7021
+ // const epsilon = Number(`0.${"0".repeat(epsilonNumberOfDigits-1)}${epsilonDigit}`)
7022
+ // const decimal = extractDecimalPart(value, epsilonNumberOfDigits)
7023
+ // if(decimal===''){return value}
7024
+ //
7025
+ // const n9 = decimal.match(/9+$/g)
7026
+ // const n0 = decimal.match(/0+$/g)
7027
+ //
7028
+ // if (n9 && n9[0].length >= number_of_digits) {
7029
+ // // New tested values.
7030
+ // const mod = extractDecimalPart(value + epsilon, epsilonNumberOfDigits),
7031
+ // mod0 = mod.match(/0+$/g)
7032
+ //
7033
+ // if(mod0 && mod0[0].length>= number_of_digits){
7034
+ // return +((value+epsilon).toString().split(mod0[0])[0])
7035
+ // }
7036
+ // }
7037
+ //
7038
+ // if (n0 && n0[0].length >= number_of_digits) {
7039
+ // // New tested values.
7040
+ // const mod = extractDecimalPart(value - epsilon, epsilonNumberOfDigits),
7041
+ // mod9 = mod.match(/9+$/g)
7042
+ //
7043
+ // if(mod9 && mod9[0].length>= number_of_digits){
7044
+ // // The value can be changed. Remove all nines!
7045
+ // return +(value.toString().split(n0[0])[0])
7046
+ // }
7047
+ // }
7048
+ //
7049
+ // return value
7030
7050
  }
7031
7051
  static periodic(value) {
7032
7052
  if (Number.isSafeInteger(value)) {