pimath 0.0.107 → 0.0.108
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 +65 -2
- 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 -2
- package/esm/maths/geometry/vector.js +5 -2
- package/esm/maths/geometry/vector.js.map +1 -1
- package/esm/maths/randomization/random.d.ts +5 -1
- package/esm/maths/randomization/random.js +8 -0
- package/esm/maths/randomization/random.js.map +1 -1
- package/esm/maths/randomization/rndGeometryLine.d.ts +12 -0
- package/esm/maths/randomization/rndGeometryLine.js +46 -0
- package/esm/maths/randomization/rndGeometryLine.js.map +1 -0
- package/esm/maths/randomization/rndTypes.d.ts +8 -0
- package/package.json +1 -1
- package/src/maths/geometry/vector.ts +8 -4
- package/src/maths/randomization/random.ts +9 -1
- package/src/maths/randomization/rndGeometryLine.ts +54 -0
- package/src/maths/randomization/rndTypes.ts +8 -1
- package/tests/custom.test.ts +6 -0
package/dist/pi.js
CHANGED
|
@@ -6781,13 +6781,13 @@ class Vector {
|
|
|
6781
6781
|
return this._x;
|
|
6782
6782
|
}
|
|
6783
6783
|
set x(value) {
|
|
6784
|
-
this._x = value;
|
|
6784
|
+
this._x = new fraction_1.Fraction(value);
|
|
6785
6785
|
}
|
|
6786
6786
|
get y() {
|
|
6787
6787
|
return this._y;
|
|
6788
6788
|
}
|
|
6789
6789
|
set y(value) {
|
|
6790
|
-
this._y = value;
|
|
6790
|
+
this._y = new fraction_1.Fraction(value);
|
|
6791
6791
|
}
|
|
6792
6792
|
get normSquare() {
|
|
6793
6793
|
return this._x.clone().pow(2).add(this._y.clone().pow(2));
|
|
@@ -6798,6 +6798,9 @@ class Vector {
|
|
|
6798
6798
|
get tex() {
|
|
6799
6799
|
return `\\begin{pmatrix}${this._x.tex} \\\\\ ${this._y.tex} \\end{pmatrix}`;
|
|
6800
6800
|
}
|
|
6801
|
+
get isNull() {
|
|
6802
|
+
return this.x.isZero() && this.y.isZero();
|
|
6803
|
+
}
|
|
6801
6804
|
}
|
|
6802
6805
|
exports.Vector = Vector;
|
|
6803
6806
|
Vector.scalarProduct = (v1, v2) => {
|
|
@@ -7008,6 +7011,7 @@ const rndPolynom_1 = __webpack_require__(22);
|
|
|
7008
7011
|
const rndMonom_1 = __webpack_require__(793);
|
|
7009
7012
|
const rndHelpers_1 = __webpack_require__(140);
|
|
7010
7013
|
const rndFraction_1 = __webpack_require__(754);
|
|
7014
|
+
const rndGeometryLine_1 = __webpack_require__(821);
|
|
7011
7015
|
__exportStar(__webpack_require__(230), exports);
|
|
7012
7016
|
var Random;
|
|
7013
7017
|
(function (Random) {
|
|
@@ -7051,6 +7055,13 @@ var Random;
|
|
|
7051
7055
|
return rndHelpers_1.rndHelpers.shuffleArray(arr);
|
|
7052
7056
|
}
|
|
7053
7057
|
Random.shuffle = shuffle;
|
|
7058
|
+
let Geometry;
|
|
7059
|
+
(function (Geometry) {
|
|
7060
|
+
function line(config) {
|
|
7061
|
+
return (new rndGeometryLine_1.rndGeometryLine(config).generate());
|
|
7062
|
+
}
|
|
7063
|
+
Geometry.line = line;
|
|
7064
|
+
})(Geometry = Random.Geometry || (Random.Geometry = {}));
|
|
7054
7065
|
})(Random = exports.Random || (exports.Random = {}));
|
|
7055
7066
|
|
|
7056
7067
|
|
|
@@ -7132,6 +7143,58 @@ class rndFraction extends randomCore_1.randomCore {
|
|
|
7132
7143
|
exports.rndFraction = rndFraction;
|
|
7133
7144
|
|
|
7134
7145
|
|
|
7146
|
+
/***/ }),
|
|
7147
|
+
|
|
7148
|
+
/***/ 821:
|
|
7149
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
7150
|
+
|
|
7151
|
+
|
|
7152
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
7153
|
+
exports.rndGeometryLine = void 0;
|
|
7154
|
+
const randomCore_1 = __webpack_require__(373);
|
|
7155
|
+
const random_1 = __webpack_require__(330);
|
|
7156
|
+
const line_1 = __webpack_require__(9);
|
|
7157
|
+
const vector_1 = __webpack_require__(586);
|
|
7158
|
+
const point_1 = __webpack_require__(557);
|
|
7159
|
+
/**
|
|
7160
|
+
* Create a random monom based on a based configuration
|
|
7161
|
+
*/
|
|
7162
|
+
class rndGeometryLine extends randomCore_1.randomCore {
|
|
7163
|
+
constructor(userConfig) {
|
|
7164
|
+
super();
|
|
7165
|
+
this.generate = () => {
|
|
7166
|
+
// The A point exists.
|
|
7167
|
+
const d = new vector_1.Vector(random_1.Random.numberSym(10), random_1.Random.numberSym(10));
|
|
7168
|
+
while (d.isNull) {
|
|
7169
|
+
d.x = random_1.Random.numberSym(10);
|
|
7170
|
+
d.y = random_1.Random.numberSym(10);
|
|
7171
|
+
}
|
|
7172
|
+
if (this._config.slope === 1) {
|
|
7173
|
+
if (d.x.sign() !== d.y.sign()) {
|
|
7174
|
+
d.y.opposed();
|
|
7175
|
+
}
|
|
7176
|
+
}
|
|
7177
|
+
else if (this._config.slope === -1) {
|
|
7178
|
+
if (d.x.sign() !== d.y.sign()) {
|
|
7179
|
+
d.y.opposed();
|
|
7180
|
+
}
|
|
7181
|
+
}
|
|
7182
|
+
return new line_1.Line(new point_1.Point(this._config.A.x, this._config.A.y), d);
|
|
7183
|
+
};
|
|
7184
|
+
this._defaultConfig = {
|
|
7185
|
+
A: {
|
|
7186
|
+
x: random_1.Random.numberSym(10),
|
|
7187
|
+
y: random_1.Random.numberSym(10)
|
|
7188
|
+
},
|
|
7189
|
+
};
|
|
7190
|
+
// TODO: Strange that it raise an error
|
|
7191
|
+
// @ts-ignore
|
|
7192
|
+
this._config = this.mergeConfig(userConfig, this._defaultConfig);
|
|
7193
|
+
}
|
|
7194
|
+
}
|
|
7195
|
+
exports.rndGeometryLine = rndGeometryLine;
|
|
7196
|
+
|
|
7197
|
+
|
|
7135
7198
|
/***/ }),
|
|
7136
7199
|
|
|
7137
7200
|
/***/ 140:
|