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 +58 -38
- package/dist/pi.js.map +1 -1
- package/dist/pi.min.js +1 -1
- package/dist/pi.min.js.map +1 -1
- package/esm/maths/geometry/vector.d.ts +3 -0
- package/esm/maths/geometry/vector.js +9 -0
- package/esm/maths/geometry/vector.js.map +1 -1
- package/esm/maths/numeric.js +49 -38
- package/esm/maths/numeric.js.map +1 -1
- package/package.json +1 -1
- package/src/maths/geometry/vector.ts +12 -0
- package/src/maths/numeric.ts +49 -48
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 =
|
|
6993
|
-
|
|
6994
|
-
//
|
|
6995
|
-
//
|
|
6996
|
-
//
|
|
6997
|
-
//
|
|
6998
|
-
//
|
|
6999
|
-
|
|
7000
|
-
|
|
7001
|
-
|
|
7002
|
-
|
|
7003
|
-
|
|
7004
|
-
|
|
7005
|
-
|
|
7006
|
-
}
|
|
7007
|
-
|
|
7008
|
-
|
|
7009
|
-
|
|
7010
|
-
|
|
7011
|
-
|
|
7012
|
-
const
|
|
7013
|
-
const
|
|
7014
|
-
if
|
|
7015
|
-
|
|
7016
|
-
|
|
7017
|
-
|
|
7018
|
-
|
|
7019
|
-
|
|
7020
|
-
|
|
7021
|
-
|
|
7022
|
-
|
|
7023
|
-
|
|
7024
|
-
|
|
7025
|
-
|
|
7026
|
-
|
|
7027
|
-
|
|
7028
|
-
|
|
7029
|
-
|
|
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)) {
|