pimath 0.0.19 → 0.0.23

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 CHANGED
@@ -18,43 +18,50 @@
18
18
 
19
19
  <script>
20
20
 
21
- let C1 = new Pi.Geometry.Point(-5, 4),
22
- r1 = 36,
23
- C2 = new Pi.Geometry.Point(7, -2),
24
- T = new Pi.Geometry.Point(2, 3)
25
-
26
- let G1 = new Pi.Geometry.Circle(C1, r1, true),
27
- G2 = new Pi.Geometry.Circle(C2, T)
28
-
29
- console.log('G1', G1.tex)
30
- console.log('G2', G2.tex)
31
-
32
- let t = new Pi.Geometry.Line(
33
- new Pi.Geometry.Vector(C2, T),
34
- T
35
- )
36
-
37
- console.log(t.tex.canonical)
38
- console.log(G1.relativePosition(t))
39
-
40
- let d = new Pi.Geometry.Line(G1.center, G2.center)
41
- console.log(d.tex.canonical)
42
-
43
- let M = new Pi.Geometry.Point(
44
- G1.center.x.clone().add(G2.center.x).divide(2),
45
- G1.center.y.clone().add(G2.center.y).divide(2),
46
- )
47
-
48
- console.log(M.display)
49
-
50
- let k = new Pi.Geometry.Line().parseByPointAndLine(
51
- M, d,
52
- Pi.Geometry.Line.PERPENDICULAR
53
- )
54
-
55
- console.log(k.tex.canonical)
56
-
57
- console.log(G1.lineIntersection(d))
21
+ let P = new Pi.Random.polynom({
22
+ degree: 4,
23
+ fraction: false
24
+ })
25
+
26
+ console.log(P.display)
27
+
28
+ // let C1 = new Pi.Geometry.Point(-5, 4),
29
+ // r1 = 36,
30
+ // C2 = new Pi.Geometry.Point(7, -2),
31
+ // T = new Pi.Geometry.Point(2, 3)
32
+ //
33
+ // let G1 = new Pi.Geometry.Circle(C1, r1, true),
34
+ // G2 = new Pi.Geometry.Circle(C2, T)
35
+ //
36
+ // console.log('G1', G1.tex)
37
+ // console.log('G2', G2.tex)
38
+ //
39
+ // let t = new Pi.Geometry.Line(
40
+ // new Pi.Geometry.Vector(C2, T),
41
+ // T
42
+ // )
43
+ //
44
+ // console.log(t.tex.canonical)
45
+ // console.log(G1.relativePosition(t))
46
+ //
47
+ // let d = new Pi.Geometry.Line(G1.center, G2.center)
48
+ // console.log(d.tex.canonical)
49
+ //
50
+ // let M = new Pi.Geometry.Point(
51
+ // G1.center.x.clone().add(G2.center.x).divide(2),
52
+ // G1.center.y.clone().add(G2.center.y).divide(2),
53
+ // )
54
+ //
55
+ // console.log(M.display)
56
+ //
57
+ // let k = new Pi.Geometry.Line().parseByPointAndLine(
58
+ // M, d,
59
+ // Pi.Geometry.Line.PERPENDICULAR
60
+ // )
61
+ //
62
+ // console.log(k.tex.canonical)
63
+ //
64
+ // console.log(G1.lineIntersection(d))
58
65
  </script>
59
66
  </body>
60
67
  </html>
package/dev/pi.js CHANGED
@@ -1984,9 +1984,9 @@ class Polynom {
1984
1984
  resultPolynom.add(m.clone());
1985
1985
  }
1986
1986
  else {
1987
- pow = +m.literal[letter];
1987
+ pow = m.literal[letter].clone();
1988
1988
  delete m.literal[letter];
1989
- resultPolynom.add(P.clone().pow(pow).multiply(m));
1989
+ resultPolynom.add(P.clone().pow(Math.abs(pow.numerator)).multiply(m));
1990
1990
  }
1991
1991
  }
1992
1992
  this._monoms = resultPolynom.reduce().reorder().monoms;
@@ -4041,17 +4041,29 @@ var Random;
4041
4041
  return (new rndFraction_1.rndFraction(config)).generate();
4042
4042
  }
4043
4043
  Random.fraction = fraction;
4044
- function number(from, to) { return rndHelpers_1.rndHelpers.randomInt(from, to); }
4044
+ function number(from, to) {
4045
+ return rndHelpers_1.rndHelpers.randomInt(from, to);
4046
+ }
4045
4047
  Random.number = number;
4046
- function numberSym(max, allowZero) { return rndHelpers_1.rndHelpers.randomIntSym(max, allowZero); }
4048
+ function numberSym(max, allowZero) {
4049
+ return rndHelpers_1.rndHelpers.randomIntSym(max, allowZero);
4050
+ }
4047
4051
  Random.numberSym = numberSym;
4048
- function bool(percent) { return rndHelpers_1.rndHelpers.randomBool(percent); }
4052
+ function bool(percent) {
4053
+ return rndHelpers_1.rndHelpers.randomBool(percent);
4054
+ }
4049
4055
  Random.bool = bool;
4050
- function array(arr, number) { return rndHelpers_1.rndHelpers.randomArray(arr, number); }
4056
+ function array(arr, number) {
4057
+ return rndHelpers_1.rndHelpers.randomArray(arr, number);
4058
+ }
4051
4059
  Random.array = array;
4052
- function item(arr) { return rndHelpers_1.rndHelpers.randomItem(arr); }
4060
+ function item(arr) {
4061
+ return rndHelpers_1.rndHelpers.randomItem(arr);
4062
+ }
4053
4063
  Random.item = item;
4054
- function shuffle(arr) { rndHelpers_1.rndHelpers.shuffleArray(arr); }
4064
+ function shuffle(arr) {
4065
+ rndHelpers_1.rndHelpers.shuffleArray(arr);
4066
+ }
4055
4067
  Random.shuffle = shuffle;
4056
4068
  })(Random = exports.Random || (exports.Random = {}));
4057
4069
 
@@ -4107,7 +4119,8 @@ class rndFraction extends randomCore_1.randomCore {
4107
4119
  this._defaultConfig = {
4108
4120
  negative: true,
4109
4121
  reduced: true,
4110
- zero: true
4122
+ zero: true,
4123
+ natural: false
4111
4124
  };
4112
4125
  this._config = this.mergeConfig(userConfig, this._defaultConfig);
4113
4126
  }
@@ -4119,7 +4132,12 @@ class rndFraction extends randomCore_1.randomCore {
4119
4132
  else {
4120
4133
  Q.numerator = index_1.Random.number(this._config.zero ? 0 : 1, 10);
4121
4134
  }
4122
- Q.denominator = index_1.Random.number(1, 10);
4135
+ if (this._config.natural) {
4136
+ Q.denominator = 1;
4137
+ }
4138
+ else {
4139
+ Q.denominator = index_1.Random.number(1, 10);
4140
+ }
4123
4141
  return this._config.reduced ? Q.reduce() : Q;
4124
4142
  };
4125
4143
  }
@@ -4213,7 +4231,8 @@ class rndMonom extends randomCore_1.randomCore {
4213
4231
  let M = new monom_1.Monom();
4214
4232
  M.coefficient = index_1.Random.fraction({
4215
4233
  zero: this._config.zero,
4216
- reduced: true
4234
+ reduced: true,
4235
+ natural: !this._config.fraction
4217
4236
  });
4218
4237
  if (this._config.letters.length > 1) {
4219
4238
  for (let L of this._config.letters.split('')) {