pimath 0.0.124 → 0.0.125
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/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30_[Default_Changelist]/shelved.patch +192 -0
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30_[Default_Changelist]1/shelved.patch +0 -0
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_07_11_2023_08_30__Default_Changelist_.xml +4 -0
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_10_43_[Default_Changelist]/shelved.patch +2404 -0
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_10_43__Default_Changelist_.xml +4 -0
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_11_01_[Default_Changelist]/shelved.patch +1362 -0
- package/.idea/shelf/Uncommitted_changes_before_Checkout_at_09_11_2023_11_01__Default_Changelist_.xml +4 -0
- package/dist/pimath.js +27 -6
- package/dist/pimath.js.map +1 -1
- package/dist/pimath.min.js +1 -1
- package/dist/pimath.min.js.map +1 -1
- package/esm/maths/randomization/random.d.ts +1 -1
- package/esm/maths/randomization/random.js +2 -2
- package/esm/maths/randomization/random.js.map +1 -1
- package/esm/maths/randomization/rndHelpers.d.ts +1 -1
- package/esm/maths/randomization/rndHelpers.js +25 -4
- package/esm/maths/randomization/rndHelpers.js.map +1 -1
- package/package.json +1 -1
- package/src/maths/randomization/random.ts +2 -2
- package/src/maths/randomization/rndHelpers.ts +49 -18
- package/tests/geometry/circle.test.ts +125 -10
- package/tests/numexp.test.ts +10 -2
- package/dev/pimath.js +0 -7935
- package/dev/pimath.js.map +0 -1
- package/docs/.nojekyll +0 -1
- package/docs/assets/highlight.css +0 -78
- package/docs/assets/main.js +0 -58
- package/docs/assets/search.js +0 -1
- package/docs/assets/style.css +0 -1367
- package/docs/classes/Logicalset.Logicalset.html +0 -221
- package/docs/classes/Polynom.Rational.html +0 -391
- package/docs/classes/Vector-1.Vector.html +0 -494
- package/docs/classes/Vector.Point.html +0 -341
- package/docs/classes/algebra_equation.Equation.html +0 -796
- package/docs/classes/algebra_linearSystem.LinearSystem.html +0 -408
- package/docs/classes/algebra_monom.Monom.html +0 -967
- package/docs/classes/algebra_polynom.Polynom.html +0 -1281
- package/docs/classes/coefficients_fraction.Fraction.html +0 -939
- package/docs/classes/geometry_circle.Circle.html +0 -476
- package/docs/classes/geometry_line.Line.html +0 -779
- package/docs/classes/geometry_triangle.Triangle.html +0 -429
- package/docs/classes/numeric.Numeric.html +0 -269
- package/docs/classes/shutingyard.Shutingyard.html +0 -259
- package/docs/enums/algebra_equation.PARTICULAR_SOLUTION.html +0 -89
- package/docs/enums/geometry_line.LinePropriety.html +0 -102
- package/docs/enums/shutingyard.ShutingyardMode.html +0 -106
- package/docs/enums/shutingyard.ShutingyardType.html +0 -120
- package/docs/index.html +0 -63
- package/docs/interfaces/algebra_equation.ISolution.html +0 -111
- package/docs/interfaces/algebra_polynom.IEuclidian.html +0 -93
- package/docs/interfaces/geometry_triangle.remarquableLines.html +0 -150
- package/docs/modules/Logicalset.html +0 -69
- package/docs/modules/Polynom.html +0 -69
- package/docs/modules/Vector-1.html +0 -69
- package/docs/modules/Vector.html +0 -69
- package/docs/modules/algebra_equation.html +0 -75
- package/docs/modules/algebra_linearSystem.html +0 -65
- package/docs/modules/algebra_monom.html +0 -70
- package/docs/modules/algebra_polynom.html +0 -75
- package/docs/modules/coefficients_fraction.html +0 -70
- package/docs/modules/geometry_circle.html +0 -65
- package/docs/modules/geometry_line.html +0 -70
- package/docs/modules/geometry_triangle.html +0 -70
- package/docs/modules/numeric.html +0 -65
- package/docs/modules/shutingyard.html +0 -84
- package/docs/types/algebra_monom.literalType.html +0 -66
- package/docs/types/algebra_polynom.PolynomParsingType.html +0 -62
- package/docs/types/coefficients_fraction.FractionParsingType.html +0 -61
- package/docs/types/shutingyard.Token.html +0 -72
- package/docs/types/shutingyard.tokenType.html +0 -77
- package/docs/variables/shutingyard.tokenConstant.html +0 -70
- package/esm/maths/expressions/ExpressionTree.d.ts +0 -17
- package/esm/maths/expressions/ExpressionTree.js +0 -150
- package/esm/maths/expressions/ExpressionTree.js.map +0 -1
- package/esm/maths/expressions/expression.d.ts +0 -27
- package/esm/maths/expressions/expression.js +0 -239
- package/esm/maths/expressions/expression.js.map +0 -1
- package/esm/maths/expressions/expressionFactor.d.ts +0 -36
- package/esm/maths/expressions/expressionFactor.js +0 -156
- package/esm/maths/expressions/expressionFactor.js.map +0 -1
- package/esm/maths/expressions/expressionMember.d.ts +0 -27
- package/esm/maths/expressions/expressionMember.js +0 -199
- package/esm/maths/expressions/expressionMember.js.map +0 -1
- package/esm/maths/expressions/expressionOperators.d.ts +0 -8
- package/esm/maths/expressions/expressionOperators.js +0 -42
- package/esm/maths/expressions/expressionOperators.js.map +0 -1
- package/esm/maths/expressions/expressionParser.d.ts +0 -14
- package/esm/maths/expressions/expressionParser.js +0 -259
- package/esm/maths/expressions/expressionParser.js.map +0 -1
- package/esm/maths/expressions/factors/ExpFactor.d.ts +0 -7
- package/esm/maths/expressions/factors/ExpFactor.js +0 -34
- package/esm/maths/expressions/factors/ExpFactor.js.map +0 -1
- package/esm/maths/expressions/factors/ExpFactorConstant.d.ts +0 -14
- package/esm/maths/expressions/factors/ExpFactorConstant.js +0 -52
- package/esm/maths/expressions/factors/ExpFactorConstant.js.map +0 -1
- package/esm/maths/expressions/factors/ExpFactorExponential.d.ts +0 -8
- package/esm/maths/expressions/factors/ExpFactorExponential.js +0 -22
- package/esm/maths/expressions/factors/ExpFactorExponential.js.map +0 -1
- package/esm/maths/expressions/factors/ExpFactorNumber.d.ts +0 -14
- package/esm/maths/expressions/factors/ExpFactorNumber.js +0 -59
- package/esm/maths/expressions/factors/ExpFactorNumber.js.map +0 -1
- package/esm/maths/expressions/factors/ExpFactorPower.d.ts +0 -13
- package/esm/maths/expressions/factors/ExpFactorPower.js +0 -35
- package/esm/maths/expressions/factors/ExpFactorPower.js.map +0 -1
- package/esm/maths/expressions/factors/ExpFactorTrigo.d.ts +0 -20
- package/esm/maths/expressions/factors/ExpFactorTrigo.js +0 -48
- package/esm/maths/expressions/factors/ExpFactorTrigo.js.map +0 -1
- package/esm/maths/expressions/factors/ExpFactorVariable.d.ts +0 -13
- package/esm/maths/expressions/factors/ExpFactorVariable.js +0 -36
- package/esm/maths/expressions/factors/ExpFactorVariable.js.map +0 -1
- package/esm/maths/expressions/internals.d.ts +0 -12
- package/esm/maths/expressions/internals.js +0 -29
- package/esm/maths/expressions/internals.js.map +0 -1
- package/esm/maths/expressions/numexp.d.ts +0 -19
- package/esm/maths/expressions/numexp.js +0 -186
- package/esm/maths/expressions/numexp.js.map +0 -1
- package/esm/maths/expressions/polynomexp.bkp.d.ts +0 -33
- package/esm/maths/expressions/polynomexp.bkp.js +0 -184
- package/esm/maths/expressions/polynomexp.bkp.js.map +0 -1
- package/esm/maths/expressions/polynomexp.d.ts +0 -52
- package/esm/maths/expressions/polynomexp.js +0 -246
- package/esm/maths/expressions/polynomexp.js.map +0 -1
|
@@ -9,7 +9,7 @@ export declare namespace Random {
|
|
|
9
9
|
function polynom(config?: randomPolynomConfig): Polynom;
|
|
10
10
|
function monom(config?: randomMonomConfig): Monom;
|
|
11
11
|
function fraction(config?: randomCoefficientConfig): Fraction;
|
|
12
|
-
function number(from: number, to: number): number;
|
|
12
|
+
function number(from: number, to: number, exclude?: number[]): number;
|
|
13
13
|
function numberSym(max: number, allowZero?: boolean): number;
|
|
14
14
|
function prime(max: number): number;
|
|
15
15
|
function bool(percent?: number): boolean;
|
|
@@ -36,8 +36,8 @@ var Random;
|
|
|
36
36
|
return (new rndFraction_1.rndFraction(config)).generate();
|
|
37
37
|
}
|
|
38
38
|
Random.fraction = fraction;
|
|
39
|
-
function number(from, to) {
|
|
40
|
-
return rndHelpers_1.rndHelpers.randomInt(from, to);
|
|
39
|
+
function number(from, to, exclude) {
|
|
40
|
+
return rndHelpers_1.rndHelpers.randomInt(from, to, exclude);
|
|
41
41
|
}
|
|
42
42
|
Random.number = number;
|
|
43
43
|
function numberSym(max, allowZero) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"random.js","sourceRoot":"","sources":["../../../src/maths/randomization/random.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,6CAAwC;AACxC,yCAAoC;AACpC,6CAAwC;AAQxC,+CAA0C;AAK1C,uDAAkD;AAElD,yDAAoD;AAEpD,6CAA0B;AAE1B,IAAiB,MAAM,CAmDtB;AAnDD,WAAiB,MAAM;IACnB,SAAgB,OAAO,CAAC,MAA4B;QAChD,OAAO,CAAC,IAAI,uBAAU,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA;IAC9C,CAAC;IAFe,cAAO,UAEtB,CAAA;IAED,SAAgB,KAAK,CAAC,MAA0B;QAC5C,OAAO,CAAC,IAAI,mBAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA;IAC5C,CAAC;IAFe,YAAK,QAEpB,CAAA;IAED,SAAgB,QAAQ,CAAC,MAAgC;QACrD,OAAO,CAAC,IAAI,yBAAW,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAA;IAC/C,CAAC;IAFe,eAAQ,WAEvB,CAAA;IAED,SAAgB,MAAM,CAAC,IAAY,EAAE,EAAU;
|
|
1
|
+
{"version":3,"file":"random.js","sourceRoot":"","sources":["../../../src/maths/randomization/random.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,6CAAwC;AACxC,yCAAoC;AACpC,6CAAwC;AAQxC,+CAA0C;AAK1C,uDAAkD;AAElD,yDAAoD;AAEpD,6CAA0B;AAE1B,IAAiB,MAAM,CAmDtB;AAnDD,WAAiB,MAAM;IACnB,SAAgB,OAAO,CAAC,MAA4B;QAChD,OAAO,CAAC,IAAI,uBAAU,CAAC,M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SAAgB,OAAO,CAAC,GAAU;QAC9B,OAAO,uBAAU,CAAC,YAAY,CAAC,GAAG,CAAC,CAAA;IACvC,CAAC;IAFe,cAAO,UAEtB,CAAA;IAED,IAAiB,QAAQ,CASxB;IATD,WAAiB,QAAQ;QACrB,SAAgB,IAAI,CAAC,MAAiC;YAClD,OAAO,CAAC,IAAI,iCAAe,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAA;QACnD,CAAC;QAFe,aAAI,OAEnB,CAAA;QAED,SAAgB,KAAK,CAAC,MAAkC;YACpD,OAAO,CAAC,IAAI,mCAAgB,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAA;QACpD,CAAC;QAFe,cAAK,QAEpB,CAAA;IAEL,CAAC,EATgB,QAAQ,GAAR,eAAQ,KAAR,eAAQ,QASxB;AACL,CAAC,EAnDgB,MAAM,sBAAN,MAAM,QAmDtB"}
|
|
@@ -9,7 +9,7 @@ export declare class rndHelpers {
|
|
|
9
9
|
* @param a (number) : From this value to the second value. If the second is ommited, this value is the max value.
|
|
10
10
|
* @param b (number) : To this value. If this is ommited.
|
|
11
11
|
*/
|
|
12
|
-
static randomInt(a: number, b?: number): number;
|
|
12
|
+
static randomInt(a: number, b?: number, exclude?: number[]): number;
|
|
13
13
|
/**
|
|
14
14
|
* Random integer between -max and max value.
|
|
15
15
|
* @param max (number) : determine the limits.
|
|
@@ -18,11 +18,32 @@ class rndHelpers {
|
|
|
18
18
|
* @param a (number) : From this value to the second value. If the second is ommited, this value is the max value.
|
|
19
19
|
* @param b (number) : To this value. If this is ommited.
|
|
20
20
|
*/
|
|
21
|
-
static randomInt(a, b) {
|
|
21
|
+
static randomInt(a, b, exclude) {
|
|
22
22
|
if (b === undefined) {
|
|
23
|
-
|
|
23
|
+
if (a >= 0) {
|
|
24
|
+
return this.randomInt(0, a);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
return this.randomInt(a, 0);
|
|
28
|
+
}
|
|
24
29
|
}
|
|
25
|
-
|
|
30
|
+
// Same start and end values
|
|
31
|
+
if (a === b) {
|
|
32
|
+
return a;
|
|
33
|
+
}
|
|
34
|
+
// No exclusion
|
|
35
|
+
if (exclude === undefined) {
|
|
36
|
+
return Math.floor(Math.random() * (b - a + 1) + a);
|
|
37
|
+
}
|
|
38
|
+
// With exclusion
|
|
39
|
+
if (Math.abs(b - a) <= exclude.length) {
|
|
40
|
+
throw new Error('The number of excluded values is too high.');
|
|
41
|
+
}
|
|
42
|
+
let r = this.randomInt(a, b);
|
|
43
|
+
while (exclude.includes(r)) {
|
|
44
|
+
r = this.randomInt(a, b);
|
|
45
|
+
}
|
|
46
|
+
return r;
|
|
26
47
|
}
|
|
27
48
|
/**
|
|
28
49
|
* Random integer between -max and max value.
|
|
@@ -59,7 +80,7 @@ class rndHelpers {
|
|
|
59
80
|
if (arr.length === 0) {
|
|
60
81
|
return '';
|
|
61
82
|
}
|
|
62
|
-
return this.
|
|
83
|
+
return arr[this.randomInt(0, arr.length - 1)];
|
|
63
84
|
}
|
|
64
85
|
static shuffleArray(arr) {
|
|
65
86
|
// The Fisher-Yates algorithm
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rndHelpers.js","sourceRoot":"","sources":["../../../src/maths/randomization/rndHelpers.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,wCAAmC;AAEnC,MAAa,UAAU;IAEnB;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"rndHelpers.js","sourceRoot":"","sources":["../../../src/maths/randomization/rndHelpers.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,wCAAmC;AAEnC,MAAa,UAAU;IAEnB;;;OAGG;IACH,MAAM,CAAC,UAAU,CAAC,UAAkB,GAAG;QACnC,OAAO,IAAI,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,SAAS,CAAC,CAAS,EAAE,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AAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YAC9C,MAAM,IAAI,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;YAC7B,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;YAClC,YAAY,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;SAC1B;QAED,OAAO,YAAY,CAAC;IACxB,CAAC;CAEJ;AArGD,gCAqGC"}
|
package/package.json
CHANGED
|
@@ -32,8 +32,8 @@ export namespace Random {
|
|
|
32
32
|
return (new rndFraction(config)).generate()
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
export function number(from: number, to: number): number {
|
|
36
|
-
return rndHelpers.randomInt(from, to)
|
|
35
|
+
export function number(from: number, to: number, exclude?: number[]): number {
|
|
36
|
+
return rndHelpers.randomInt(from, to, exclude)
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
export function numberSym(max: number, allowZero?: boolean): number {
|
|
@@ -9,8 +9,8 @@ export class rndHelpers {
|
|
|
9
9
|
* Random boolean with a percent ratio
|
|
10
10
|
* @param percent
|
|
11
11
|
*/
|
|
12
|
-
static randomBool(percent:number=0.5):boolean{
|
|
13
|
-
return Math.random()<percent;
|
|
12
|
+
static randomBool(percent: number = 0.5): boolean {
|
|
13
|
+
return Math.random() < percent;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -18,10 +18,35 @@ export class rndHelpers {
|
|
|
18
18
|
* @param a (number) : From this value to the second value. If the second is ommited, this value is the max value.
|
|
19
19
|
* @param b (number) : To this value. If this is ommited.
|
|
20
20
|
*/
|
|
21
|
-
static randomInt(a:number, b?:number):number{
|
|
22
|
-
if(b===undefined){
|
|
21
|
+
static randomInt(a: number, b?: number, exclude?: number[]): number {
|
|
22
|
+
if (b === undefined) {
|
|
23
|
+
if (a >= 0) {
|
|
24
|
+
return this.randomInt(0, a);
|
|
25
|
+
} else {
|
|
26
|
+
return this.randomInt(a, 0);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Same start and end values
|
|
31
|
+
if (a === b) {
|
|
32
|
+
return a
|
|
33
|
+
}
|
|
23
34
|
|
|
24
|
-
|
|
35
|
+
// No exclusion
|
|
36
|
+
if (exclude === undefined) {
|
|
37
|
+
return Math.floor(Math.random() * (b - a + 1) + a);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// With exclusion
|
|
41
|
+
if (Math.abs(b - a) <= exclude.length) {
|
|
42
|
+
throw new Error('The number of excluded values is too high.')
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
let r = this.randomInt(a, b)
|
|
46
|
+
while (exclude.includes(r)) {
|
|
47
|
+
r = this.randomInt(a, b)
|
|
48
|
+
}
|
|
49
|
+
return r
|
|
25
50
|
}
|
|
26
51
|
|
|
27
52
|
/**
|
|
@@ -29,35 +54,41 @@ export class rndHelpers {
|
|
|
29
54
|
* @param max (number) : determine the limits.
|
|
30
55
|
* @param zero (bool) : determine if zero is allowed or not.
|
|
31
56
|
*/
|
|
32
|
-
static randomIntSym(max:number, zero?:boolean):number{
|
|
33
|
-
if(zero===false){
|
|
34
|
-
return this.randomBool()?this.randomInt(1,max)
|
|
35
|
-
}else{
|
|
57
|
+
static randomIntSym(max: number, zero?: boolean): number {
|
|
58
|
+
if (zero === false) {
|
|
59
|
+
return this.randomBool() ? this.randomInt(1, max) : -this.randomInt(1, max);
|
|
60
|
+
} else {
|
|
36
61
|
return this.randomInt(-max, max);
|
|
37
62
|
}
|
|
38
63
|
}
|
|
39
64
|
|
|
40
65
|
static randomPrime(max: number): number {
|
|
41
66
|
let primes = Numeric.primes()
|
|
42
|
-
if(max!==undefined){
|
|
43
|
-
primes = primes.filter(x=>x<max)
|
|
67
|
+
if (max !== undefined) {
|
|
68
|
+
primes = primes.filter(x => x < max)
|
|
44
69
|
}
|
|
45
70
|
return this.randomItem(primes)
|
|
46
71
|
}
|
|
47
72
|
|
|
48
|
-
static randomArray(arr: any[], number?:number):any[]{
|
|
49
|
-
if(number===undefined){
|
|
73
|
+
static randomArray(arr: any[], number?: number): any[] {
|
|
74
|
+
if (number === undefined) {
|
|
75
|
+
number = 1
|
|
76
|
+
}
|
|
50
77
|
|
|
51
78
|
// Return a clone array
|
|
52
|
-
if(arr.length<=0){
|
|
79
|
+
if (arr.length <= 0) {
|
|
80
|
+
return Object.values(arr)
|
|
81
|
+
}
|
|
53
82
|
|
|
54
83
|
// Randomize the array and return the n first elements.
|
|
55
|
-
return rndHelpers.shuffleArray(arr).slice(0,number);
|
|
84
|
+
return rndHelpers.shuffleArray(arr).slice(0, number);
|
|
56
85
|
}
|
|
57
86
|
|
|
58
|
-
static randomItem(arr: any[]): any{
|
|
59
|
-
if(arr.length===0){
|
|
60
|
-
|
|
87
|
+
static randomItem(arr: any[]): any {
|
|
88
|
+
if (arr.length === 0) {
|
|
89
|
+
return ''
|
|
90
|
+
}
|
|
91
|
+
return arr[this.randomInt(0, arr.length - 1)]
|
|
61
92
|
}
|
|
62
93
|
|
|
63
94
|
static shuffleArray(arr: any[]): any[] {
|
|
@@ -4,14 +4,16 @@ import {Circle} from "../../src/maths/geometry/circle";
|
|
|
4
4
|
import {Line} from "../../src/maths/geometry/line";
|
|
5
5
|
import {Point} from "../../src/maths/geometry/point";
|
|
6
6
|
import {Fraction} from "../../src/maths/coefficients/fraction";
|
|
7
|
+
import {Random} from "../../src/maths/randomization/random";
|
|
8
|
+
import {Numeric} from "../../src/maths/numeric";
|
|
7
9
|
|
|
8
10
|
describe('Circle', function () {
|
|
9
11
|
it('should calculate the intersection of a circle and a line', function () {
|
|
10
12
|
let C = new Circle(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
new Point(8, 6),
|
|
14
|
+
20,
|
|
15
|
+
true
|
|
16
|
+
),
|
|
15
17
|
LT = new Line('2x+y-32=0'),
|
|
16
18
|
LS = new Line('3x-y-8=0'),
|
|
17
19
|
IPT = C.lineIntersection(LT),
|
|
@@ -28,7 +30,7 @@ describe('Circle', function () {
|
|
|
28
30
|
expect(IPS[1].y.value).to.be.equal(10)
|
|
29
31
|
});
|
|
30
32
|
|
|
31
|
-
it('should calculate tangents', function(){
|
|
33
|
+
it('should calculate tangents', function () {
|
|
32
34
|
|
|
33
35
|
// Through one point on the circle
|
|
34
36
|
const C = new Circle(
|
|
@@ -37,18 +39,18 @@ describe('Circle', function () {
|
|
|
37
39
|
true
|
|
38
40
|
), P = new Point(-5, 7);
|
|
39
41
|
|
|
40
|
-
expect(C.tangents(P).map(x=>x.tex.canonical)).to.have.all.members(['3x-4y+43=0'])
|
|
42
|
+
expect(C.tangents(P).map(x => x.tex.canonical)).to.have.all.members(['3x-4y+43=0'])
|
|
41
43
|
|
|
42
44
|
// With a slope
|
|
43
45
|
const D = new Circle('x^2+y^2+10x=2y-6'),
|
|
44
46
|
slope = new Fraction(-2, 1)
|
|
45
47
|
|
|
46
|
-
expect(D.tangents(slope).map(x=>x.tex.canonical)).to.have.all.members(['2x+y-1=0', '2x+y+19=0'])
|
|
48
|
+
expect(D.tangents(slope).map(x => x.tex.canonical)).to.have.all.members(['2x+y-1=0', '2x+y+19=0'])
|
|
47
49
|
|
|
48
50
|
const E = new Circle('(x-2)^2+(y-1)^2=5'),
|
|
49
51
|
P2 = new Point(6, -2)
|
|
50
52
|
|
|
51
|
-
expect(E.tangents(P2).map(x=>x.tex.canonical)).to.have.all.members(['2x+y-10=0','2x+11y+10=0'])
|
|
53
|
+
expect(E.tangents(P2).map(x => x.tex.canonical)).to.have.all.members(['2x+y-10=0', '2x+11y+10=0'])
|
|
52
54
|
|
|
53
55
|
let P3 = new Point(2, 2)
|
|
54
56
|
expect(E.tangents(P3)).to.be.empty
|
|
@@ -58,10 +60,10 @@ describe('Circle', function () {
|
|
|
58
60
|
const C = new Circle('(x-3)^2+(y+4)^2=16'),
|
|
59
61
|
pts = C.getPointsOnCircle()
|
|
60
62
|
|
|
61
|
-
expect(pts.map(x=>x.x.display + ',' + x.y.display)).to.have.all.members([
|
|
63
|
+
expect(pts.map(x => x.x.display + ',' + x.y.display)).to.have.all.members(['3,0', '3,-8', '7,-4', '-1,-4'])
|
|
62
64
|
});
|
|
63
65
|
|
|
64
|
-
it('should calculate the circle from center and radius', function(){
|
|
66
|
+
it('should calculate the circle from center and radius', function () {
|
|
65
67
|
let circle = new Circle("x^2+6x+y^2-8y+12=0")
|
|
66
68
|
|
|
67
69
|
console.log(circle.tex)
|
|
@@ -81,4 +83,117 @@ describe('Circle', function () {
|
|
|
81
83
|
let L = new Line(A, B)
|
|
82
84
|
console.log(L.tex.canonical)
|
|
83
85
|
});
|
|
86
|
+
|
|
87
|
+
it('temp tests', () => {
|
|
88
|
+
for (let i = 0; i < 30; i++) {
|
|
89
|
+
let A = Random.Geometry.point({axis: false}),
|
|
90
|
+
B = Random.Geometry.point({axis: false})
|
|
91
|
+
|
|
92
|
+
if (Random.bool()) {
|
|
93
|
+
B.x = new Fraction().zero()
|
|
94
|
+
} else {
|
|
95
|
+
B.y = new Fraction().zero()
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const c1 = new Circle(A, Random.number(1, 10)),
|
|
99
|
+
c2 = new Circle(B, Random.number(1, 10))
|
|
100
|
+
|
|
101
|
+
console.log(`(exercice ${i + 1}): déterminer la forme \\textbf{centre-rayon} des équations cartésiennes suivantes. En déduire le centre et le rayon du cercle.
|
|
102
|
+
\\begin{enumerate}[label=\\Alph*]
|
|
103
|
+
\\item \\( (\\Gamma_1): ${c1.developed}\\) \\iftoggle{master}{\\(${c1.tex}\\)}{}
|
|
104
|
+
\\item \\( (\\Gamma_2): ${c2.developed}\\) \\iftoggle{master}{\\(${c2.tex}\\)}{}
|
|
105
|
+
\\end{enumerate}
|
|
106
|
+
\\vfill
|
|
107
|
+
${i % 2 === 1 ? '\\newpage' : ''}
|
|
108
|
+
`)
|
|
109
|
+
}
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
it('temp tests 2', () => {
|
|
113
|
+
const q = `(I): Soit \\(\\Gamma_1\\) et \\(\\Gamma_2\\) deux cercles. Déterminer leur position relative à l'aide des informations ci-dessous.
|
|
114
|
+
|
|
115
|
+
\\[(\\Gamma_1): @G1 \\qquad (\\Gamma_2): @G2 \\]
|
|
116
|
+
\\[\\trou{@R1} \\]
|
|
117
|
+
|
|
118
|
+
\\vspace{3cm}
|
|
119
|
+
(II): Soit \\((\\Gamma_3): @G3\\) un cercle. Déterminer l'équation cartésienne, sous sa forme centre-sommet, des cercles \\(\\Gamma_4\\) de rayon \\(@RAYON\\) qui sont tangents à \\(\\Gamma_3\\) en sachant que les deux centres ont la même @AXE.\\\\
|
|
120
|
+
Préciser la position relative entre \\(\\Gamma_3\\) et \\(\\Gamma_4\\)
|
|
121
|
+
\\[ \\trou{@R2a} \\]
|
|
122
|
+
\\[ \\trou{@R2b} \\]
|
|
123
|
+
`
|
|
124
|
+
|
|
125
|
+
for (let i = 0; i < 30; i++) {
|
|
126
|
+
let A = Random.Geometry.point({axis: false}),
|
|
127
|
+
triplet = Random.item(Numeric.pythagoricianTripletsWithTarget(
|
|
128
|
+
Random.item([5, 13, 17, 25, 29, 37, 41])
|
|
129
|
+
).filter(tr => {
|
|
130
|
+
// remove all items with zero values.
|
|
131
|
+
return tr.every(x => x !== 0)
|
|
132
|
+
})),
|
|
133
|
+
B = new Point(
|
|
134
|
+
A.x.value + triplet[0],
|
|
135
|
+
A.y.value + triplet[1]
|
|
136
|
+
),
|
|
137
|
+
delta = Random.number(2, triplet[2] - 1),
|
|
138
|
+
positionRelative = ['extérieure', 'intérieure', 'sécante', 'disjointe'][i % 4],
|
|
139
|
+
// positionRelative = Random.item(['extérieure', 'intérieure', 'sécante', 'disjointe']),
|
|
140
|
+
c1: Circle, c2: Circle
|
|
141
|
+
|
|
142
|
+
if (positionRelative === 'extérieure') {
|
|
143
|
+
c1 = new Circle(A, triplet[2] - delta)
|
|
144
|
+
c2 = new Circle(B, delta)
|
|
145
|
+
} else if (positionRelative === 'intérieure') {
|
|
146
|
+
c1 = new Circle(A, triplet[2] + delta)
|
|
147
|
+
c2 = new Circle(B, delta)
|
|
148
|
+
} else if (positionRelative === 'sécante') {
|
|
149
|
+
c1 = new Circle(A, triplet[2] + delta - Random.number(1, delta - 1))
|
|
150
|
+
c2 = new Circle(B, delta)
|
|
151
|
+
} else if (positionRelative === 'disjointe') {
|
|
152
|
+
c1 = new Circle(A, triplet[2] + delta + 1)
|
|
153
|
+
c2 = new Circle(B, delta)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const R1 = `\\delta(O_1;O_2)=${A.distanceTo(B).value}\\qquad r_1=${c1.radius.value} \\qquad ${c2.radius.value} \\qquad \\implies \\text{${positionRelative}} `
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
let C = Random.Geometry.point({axis: false}),
|
|
160
|
+
r1 = Random.number(2, 10),
|
|
161
|
+
c3 = new Circle(C, r1),
|
|
162
|
+
// Get a random number from 2 to 10 that is not equal to r1
|
|
163
|
+
r2 = Random.number(2, 10, [r1]),
|
|
164
|
+
axis = Random.item(['abscisse', 'ordonnée']),
|
|
165
|
+
centers: Point[] = []
|
|
166
|
+
|
|
167
|
+
const c3x = c3.center.x.value,
|
|
168
|
+
c3y = c3.center.y.value
|
|
169
|
+
if (axis === 'abscisse') {
|
|
170
|
+
|
|
171
|
+
centers = [
|
|
172
|
+
new Point(c3x, c3y - (r1 + r2)),
|
|
173
|
+
new Point(c3x, c3y - (r2 - r1)),
|
|
174
|
+
new Point(c3x, c3y - (r1 - r2)),
|
|
175
|
+
new Point(c3x, c3y + (r1 + r2))
|
|
176
|
+
]
|
|
177
|
+
} else {
|
|
178
|
+
centers = [
|
|
179
|
+
new Point(c3x - (r1 + r2), c3y),
|
|
180
|
+
new Point(c3x - (r2 - r1), c3y),
|
|
181
|
+
new Point(c3x - (r1 - r2), c3y),
|
|
182
|
+
new Point(c3x + (r1 + r2), c3y)
|
|
183
|
+
]
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
console.log(`(exercice ${i + 1}): ` + q
|
|
187
|
+
.replaceAll('@G1', c1.tex)
|
|
188
|
+
.replaceAll('@R1', R1)
|
|
189
|
+
.replaceAll('@G2', c2.tex)
|
|
190
|
+
.replaceAll('@G3', c3.developed)
|
|
191
|
+
.replaceAll('@RAYON', r2.toString())
|
|
192
|
+
.replaceAll('@AXE', axis)
|
|
193
|
+
.replaceAll('@R2a', centers.slice(0, 2).map(x => new Circle(x, r2).tex).join(' \\qquad '))
|
|
194
|
+
.replaceAll('@R2b', centers.slice(2, 4).map(x => new Circle(x, r2).tex).join(' \\qquad '))
|
|
195
|
+
+ '\\vfill' + (i % 2 === 1 ? '\\newpage' : '')
|
|
196
|
+
)
|
|
197
|
+
}
|
|
198
|
+
})
|
|
84
199
|
});
|
package/tests/numexp.test.ts
CHANGED
|
@@ -31,7 +31,7 @@ describe('Numerical expression', () => { // the tests container
|
|
|
31
31
|
expect(exprInvalid.isValid).to.be.false
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
-
it('souldd detect invalid expression withouth crahsing', function() {
|
|
34
|
+
it('souldd detect invalid expression withouth crahsing', function () {
|
|
35
35
|
const exprPourrie = new NumExp('3xsi'),
|
|
36
36
|
exprOk = new NumExp('3xsin(x)')
|
|
37
37
|
|
|
@@ -52,7 +52,7 @@ describe('Numerical expression', () => { // the tests container
|
|
|
52
52
|
expect(expr2.evaluate({x: 2})).to.be.equal(1)
|
|
53
53
|
});
|
|
54
54
|
|
|
55
|
-
it('should calculate sqrt from exp', function(){
|
|
55
|
+
it('should calculate sqrt from exp', function () {
|
|
56
56
|
let k = new NumExp('nthrt(x,3)')
|
|
57
57
|
expect(k.evaluate({x: -8})).to.be.equal(-2)
|
|
58
58
|
expect(k.evaluate({x: 27})).to.be.equal(3)
|
|
@@ -78,4 +78,12 @@ describe('Numerical expression', () => { // the tests container
|
|
|
78
78
|
let k = new NumExp('ln(3)')
|
|
79
79
|
expect(+k.evaluate().toFixed(6)).to.be.equal(1.098612)
|
|
80
80
|
});
|
|
81
|
+
|
|
82
|
+
it('should parse with sqrt and root', () => {
|
|
83
|
+
const expr1 = new NumExp('sqrt(9)');
|
|
84
|
+
expect(expr1.evaluate()).to.be.equal(3);
|
|
85
|
+
|
|
86
|
+
const expr2 = new NumExp('nthrt(8,3)');
|
|
87
|
+
expect(expr2.evaluate()).to.be.equal(2);
|
|
88
|
+
})
|
|
81
89
|
});
|