pimath 0.0.20 → 0.0.24
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/dev/index.html +45 -37
- package/dev/pi.js +45 -13
- package/dev/pi.js.map +1 -1
- package/dist/pi.js +1 -1
- package/dist/pi.js.map +1 -1
- package/esm/maths/geometry/line.d.ts +3 -2
- package/esm/maths/geometry/line.js +17 -4
- package/esm/maths/geometry/line.js.map +1 -1
- package/esm/maths/random/index.js +18 -6
- package/esm/maths/random/index.js.map +1 -1
- package/esm/maths/random/rndFraction.js +8 -2
- package/esm/maths/random/rndFraction.js.map +1 -1
- package/esm/maths/random/rndMonom.js +2 -1
- package/esm/maths/random/rndMonom.js.map +1 -1
- package/esm/maths/random/rndTypes.d.ts +1 -0
- package/package.json +1 -1
- package/src/maths/geometry/line.ts +29 -6
- package/src/maths/random/index.ts +24 -6
- package/src/maths/random/rndFraction.ts +7 -2
- package/src/maths/random/rndMonom.ts +2 -1
- package/src/maths/random/rndTypes.ts +2 -1
package/dev/index.html
CHANGED
|
@@ -18,43 +18,51 @@
|
|
|
18
18
|
|
|
19
19
|
<script>
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
console.log(
|
|
38
|
-
console.log(
|
|
39
|
-
|
|
40
|
-
let
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
21
|
+
let L = new Pi.Geometry.Line('6x-8y+12=0')
|
|
22
|
+
|
|
23
|
+
console.log(L.a.display, L.b.display, L.c.display)
|
|
24
|
+
L.simplify()
|
|
25
|
+
console.log(L.a.display, L.b.display, L.c.display)
|
|
26
|
+
|
|
27
|
+
console.log(L.tex.canonical)
|
|
28
|
+
|
|
29
|
+
// let C1 = new Pi.Geometry.Point(-5, 4),
|
|
30
|
+
// r1 = 36,
|
|
31
|
+
// C2 = new Pi.Geometry.Point(7, -2),
|
|
32
|
+
// T = new Pi.Geometry.Point(2, 3)
|
|
33
|
+
//
|
|
34
|
+
// let G1 = new Pi.Geometry.Circle(C1, r1, true),
|
|
35
|
+
// G2 = new Pi.Geometry.Circle(C2, T)
|
|
36
|
+
//
|
|
37
|
+
// console.log('G1', G1.tex)
|
|
38
|
+
// console.log('G2', G2.tex)
|
|
39
|
+
//
|
|
40
|
+
// let t = new Pi.Geometry.Line(
|
|
41
|
+
// new Pi.Geometry.Vector(C2, T),
|
|
42
|
+
// T
|
|
43
|
+
// )
|
|
44
|
+
//
|
|
45
|
+
// console.log(t.tex.canonical)
|
|
46
|
+
// console.log(G1.relativePosition(t))
|
|
47
|
+
//
|
|
48
|
+
// let d = new Pi.Geometry.Line(G1.center, G2.center)
|
|
49
|
+
// console.log(d.tex.canonical)
|
|
50
|
+
//
|
|
51
|
+
// let M = new Pi.Geometry.Point(
|
|
52
|
+
// G1.center.x.clone().add(G2.center.x).divide(2),
|
|
53
|
+
// G1.center.y.clone().add(G2.center.y).divide(2),
|
|
54
|
+
// )
|
|
55
|
+
//
|
|
56
|
+
// console.log(M.display)
|
|
57
|
+
//
|
|
58
|
+
// let k = new Pi.Geometry.Line().parseByPointAndLine(
|
|
59
|
+
// M, d,
|
|
60
|
+
// Pi.Geometry.Line.PERPENDICULAR
|
|
61
|
+
// )
|
|
62
|
+
//
|
|
63
|
+
// console.log(k.tex.canonical)
|
|
64
|
+
//
|
|
65
|
+
// console.log(G1.lineIntersection(d))
|
|
58
66
|
</script>
|
|
59
67
|
</body>
|
|
60
68
|
</html>
|
package/dev/pi.js
CHANGED
|
@@ -3220,6 +3220,14 @@ class Line {
|
|
|
3220
3220
|
(values[2] instanceof coefficients_1.Fraction || typeof values[2] === 'number')) {
|
|
3221
3221
|
return this.parseByCoefficient(values[0], values[1], values[2]);
|
|
3222
3222
|
}
|
|
3223
|
+
else if (values[0] instanceof point_1.Point && values[1] instanceof vector_1.Vector) {
|
|
3224
|
+
if (values[2] === LinePropriety.Perpendicular) {
|
|
3225
|
+
return this.parseByPointAndNormal(values[0], values[1]);
|
|
3226
|
+
}
|
|
3227
|
+
else if (values[2] === LinePropriety.Parallel) {
|
|
3228
|
+
return this.parseByPointAndVector(values[0], values[1]);
|
|
3229
|
+
}
|
|
3230
|
+
}
|
|
3223
3231
|
}
|
|
3224
3232
|
console.log('Someting wrong happend while creating the line');
|
|
3225
3233
|
return this;
|
|
@@ -3291,6 +3299,11 @@ class Line {
|
|
|
3291
3299
|
isSameAs = (line) => {
|
|
3292
3300
|
return this.slope.isEqual(line.slope) && this.height.isEqual(line.height);
|
|
3293
3301
|
};
|
|
3302
|
+
simplify = () => {
|
|
3303
|
+
let lcm = numeric_1.Numeric.lcm(this._a.denominator, this._b.denominator, this._c.denominator), gcd = numeric_1.Numeric.gcd(this._a.numerator, this._b.numerator, this._c.numerator);
|
|
3304
|
+
this.parseByCoefficient(this._a.clone().multiply(lcm).divide(gcd), this._b.clone().multiply(lcm).divide(gcd), this._c.clone().multiply(lcm).divide(gcd));
|
|
3305
|
+
return this;
|
|
3306
|
+
};
|
|
3294
3307
|
simplifyDirection = () => {
|
|
3295
3308
|
let lcm = numeric_1.Numeric.lcm(this._d.x.denominator, this._d.y.denominator), gcd = numeric_1.Numeric.gcd(this._d.x.numerator, this._d.y.numerator);
|
|
3296
3309
|
this._d.x.multiply(lcm).divide(gcd);
|
|
@@ -3360,16 +3373,16 @@ class Line {
|
|
|
3360
3373
|
return false;
|
|
3361
3374
|
}
|
|
3362
3375
|
getValueAtX = (value) => {
|
|
3363
|
-
const equ = this.equation.clone().isolate('y');
|
|
3376
|
+
const equ = this.equation.clone().isolate('y'), F = new coefficients_1.Fraction(value);
|
|
3364
3377
|
if (equ instanceof algebra_1.Equation) {
|
|
3365
|
-
return equ.right.evaluate({ x:
|
|
3378
|
+
return equ.right.evaluate({ x: F });
|
|
3366
3379
|
}
|
|
3367
3380
|
return;
|
|
3368
3381
|
};
|
|
3369
3382
|
getValueAtY = (value) => {
|
|
3370
|
-
const equ = this.equation.clone().isolate('x');
|
|
3383
|
+
const equ = this.equation.clone().isolate('x'), F = new coefficients_1.Fraction(value);
|
|
3371
3384
|
if (equ instanceof algebra_1.Equation) {
|
|
3372
|
-
return equ.right.evaluate({ y:
|
|
3385
|
+
return equ.right.evaluate({ y: F });
|
|
3373
3386
|
}
|
|
3374
3387
|
return;
|
|
3375
3388
|
};
|
|
@@ -4041,17 +4054,29 @@ var Random;
|
|
|
4041
4054
|
return (new rndFraction_1.rndFraction(config)).generate();
|
|
4042
4055
|
}
|
|
4043
4056
|
Random.fraction = fraction;
|
|
4044
|
-
function number(from, to) {
|
|
4057
|
+
function number(from, to) {
|
|
4058
|
+
return rndHelpers_1.rndHelpers.randomInt(from, to);
|
|
4059
|
+
}
|
|
4045
4060
|
Random.number = number;
|
|
4046
|
-
function numberSym(max, allowZero) {
|
|
4061
|
+
function numberSym(max, allowZero) {
|
|
4062
|
+
return rndHelpers_1.rndHelpers.randomIntSym(max, allowZero);
|
|
4063
|
+
}
|
|
4047
4064
|
Random.numberSym = numberSym;
|
|
4048
|
-
function bool(percent) {
|
|
4065
|
+
function bool(percent) {
|
|
4066
|
+
return rndHelpers_1.rndHelpers.randomBool(percent);
|
|
4067
|
+
}
|
|
4049
4068
|
Random.bool = bool;
|
|
4050
|
-
function array(arr, number) {
|
|
4069
|
+
function array(arr, number) {
|
|
4070
|
+
return rndHelpers_1.rndHelpers.randomArray(arr, number);
|
|
4071
|
+
}
|
|
4051
4072
|
Random.array = array;
|
|
4052
|
-
function item(arr) {
|
|
4073
|
+
function item(arr) {
|
|
4074
|
+
return rndHelpers_1.rndHelpers.randomItem(arr);
|
|
4075
|
+
}
|
|
4053
4076
|
Random.item = item;
|
|
4054
|
-
function shuffle(arr) {
|
|
4077
|
+
function shuffle(arr) {
|
|
4078
|
+
rndHelpers_1.rndHelpers.shuffleArray(arr);
|
|
4079
|
+
}
|
|
4055
4080
|
Random.shuffle = shuffle;
|
|
4056
4081
|
})(Random = exports.Random || (exports.Random = {}));
|
|
4057
4082
|
|
|
@@ -4107,7 +4132,8 @@ class rndFraction extends randomCore_1.randomCore {
|
|
|
4107
4132
|
this._defaultConfig = {
|
|
4108
4133
|
negative: true,
|
|
4109
4134
|
reduced: true,
|
|
4110
|
-
zero: true
|
|
4135
|
+
zero: true,
|
|
4136
|
+
natural: false
|
|
4111
4137
|
};
|
|
4112
4138
|
this._config = this.mergeConfig(userConfig, this._defaultConfig);
|
|
4113
4139
|
}
|
|
@@ -4119,7 +4145,12 @@ class rndFraction extends randomCore_1.randomCore {
|
|
|
4119
4145
|
else {
|
|
4120
4146
|
Q.numerator = index_1.Random.number(this._config.zero ? 0 : 1, 10);
|
|
4121
4147
|
}
|
|
4122
|
-
|
|
4148
|
+
if (this._config.natural) {
|
|
4149
|
+
Q.denominator = 1;
|
|
4150
|
+
}
|
|
4151
|
+
else {
|
|
4152
|
+
Q.denominator = index_1.Random.number(1, 10);
|
|
4153
|
+
}
|
|
4123
4154
|
return this._config.reduced ? Q.reduce() : Q;
|
|
4124
4155
|
};
|
|
4125
4156
|
}
|
|
@@ -4213,7 +4244,8 @@ class rndMonom extends randomCore_1.randomCore {
|
|
|
4213
4244
|
let M = new monom_1.Monom();
|
|
4214
4245
|
M.coefficient = index_1.Random.fraction({
|
|
4215
4246
|
zero: this._config.zero,
|
|
4216
|
-
reduced: true
|
|
4247
|
+
reduced: true,
|
|
4248
|
+
natural: !this._config.fraction
|
|
4217
4249
|
});
|
|
4218
4250
|
if (this._config.letters.length > 1) {
|
|
4219
4251
|
for (let L of this._config.letters.split('')) {
|