math-exercises 2.2.51 → 2.2.53
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/lib/exercises/math/calcul/fractions/simplifyFraction.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/simplifyFraction.js +12 -2
- package/lib/exercises/math/calcul/proportionality/findCoeffInProportionalTableNonIntegers.d.ts +10 -0
- package/lib/exercises/math/calcul/proportionality/findCoeffInProportionalTableNonIntegers.d.ts.map +1 -0
- package/lib/exercises/math/calcul/proportionality/findCoeffInProportionalTableNonIntegers.js +122 -0
- package/lib/exercises/math/calcul/proportionality/index.d.ts +2 -0
- package/lib/exercises/math/calcul/proportionality/index.d.ts.map +1 -1
- package/lib/exercises/math/calcul/proportionality/index.js +2 -0
- package/lib/exercises/math/calcul/proportionality/isTableProportionalNonInteger.d.ts +11 -0
- package/lib/exercises/math/calcul/proportionality/isTableProportionalNonInteger.d.ts.map +1 -0
- package/lib/exercises/math/calcul/proportionality/isTableProportionalNonInteger.js +113 -0
- package/lib/exercises/math/calculLitteral/equation/equationWithDistributivity.d.ts +16 -0
- package/lib/exercises/math/calculLitteral/equation/equationWithDistributivity.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/equation/equationWithDistributivity.js +128 -0
- package/lib/exercises/math/calculLitteral/equation/index.d.ts +1 -0
- package/lib/exercises/math/calculLitteral/equation/index.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/index.js +1 -0
- package/lib/exercises/math/calculLitteral/factorisation/factoType1Exercise.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/factorisation/factoType1Exercise.js +5 -1
- package/lib/exercises/math/functions/basics/imageFunctionGeogebra.d.ts +5 -4
- package/lib/exercises/math/functions/basics/imageFunctionGeogebra.d.ts.map +1 -1
- package/lib/exercises/math/functions/basics/imageFunctionGeogebra.js +44 -42
- package/lib/exercises/math/functions/parity/parityFromGraph.js +1 -1
- package/lib/exercises/math/functions/trinoms/secondDegreeInequation.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts +4 -1
- package/lib/exercises/math/probaStat/probaFromTableWithContext.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/probaFromTableWithContext.js +18 -6
- package/lib/exercises/math/probaStat/probabilityTree.d.ts +4 -1
- package/lib/exercises/math/probaStat/probabilityTree.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/probabilityTree.js +52 -21
- package/lib/exercises/math/probaStat/stats1var/averageWithTable.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/averageWithTable.js +2 -1
- package/lib/exercises/math/squareRoots/index.d.ts +1 -0
- package/lib/exercises/math/squareRoots/index.d.ts.map +1 -1
- package/lib/exercises/math/squareRoots/index.js +1 -0
- package/lib/exercises/math/squareRoots/squareRootsProducts.d.ts +10 -0
- package/lib/exercises/math/squareRoots/squareRootsProducts.d.ts.map +1 -0
- package/lib/exercises/math/squareRoots/squareRootsProducts.js +83 -0
- package/lib/exercises/options/allowNonIrreductibleFractions.d.ts +3 -0
- package/lib/exercises/options/allowNonIrreductibleFractions.d.ts.map +1 -0
- package/lib/exercises/options/allowNonIrreductibleFractions.js +10 -0
- package/lib/geogebra/geogebraConstructor.js +11 -10
- package/lib/geogebra/lagrange.d.ts +8 -0
- package/lib/geogebra/lagrange.d.ts.map +1 -0
- package/lib/geogebra/lagrange.js +73 -0
- package/lib/geogebra/spline.d.ts +11 -0
- package/lib/geogebra/spline.d.ts.map +1 -0
- package/lib/geogebra/spline.js +74 -0
- package/lib/index.d.ts +36 -6
- package/lib/index.d.ts.map +1 -1
- package/lib/playground.d.ts.map +1 -1
- package/lib/playground.js +2 -5
- package/lib/tree/nodes/algebraicNode.d.ts +1 -0
- package/lib/tree/nodes/algebraicNode.d.ts.map +1 -1
- package/lib/tree/nodes/equations/equalNode.d.ts +2 -0
- package/lib/tree/nodes/equations/equalNode.d.ts.map +1 -1
- package/lib/tree/nodes/equations/equalNode.js +7 -1
- package/lib/tree/nodes/inequations/inequationNode.d.ts +3 -2
- package/lib/tree/nodes/inequations/inequationNode.d.ts.map +1 -1
- package/lib/tree/nodes/nodeConstructor.d.ts.map +1 -1
- package/lib/tree/nodes/operators/multiplyNode.d.ts +1 -1
- package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/multiplyNode.js +46 -26
- package/lib/tree/nodes/sets/intervalNode.d.ts +5 -4
- package/lib/tree/nodes/sets/intervalNode.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -3,62 +3,64 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.imageFunctionGeogebra = void 0;
|
|
4
4
|
const exercise_1 = require("../../../../exercises/exercise");
|
|
5
5
|
const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
|
|
6
|
-
const
|
|
6
|
+
const numberVEA_1 = require("../../../../exercises/vea/numberVEA");
|
|
7
7
|
const geogebraConstructor_1 = require("../../../../geogebra/geogebraConstructor");
|
|
8
|
-
const
|
|
8
|
+
const lagrange_1 = require("../../../../geogebra/lagrange");
|
|
9
|
+
const spline_1 = require("../../../../geogebra/spline");
|
|
10
|
+
const point_1 = require("../../../../math/geometry/point");
|
|
9
11
|
const randint_1 = require("../../../../math/utils/random/randint");
|
|
12
|
+
const round_1 = require("../../../../math/utils/round");
|
|
13
|
+
const closure_1 = require("../../../../tree/nodes/sets/closure");
|
|
14
|
+
const intervalNode_1 = require("../../../../tree/nodes/sets/intervalNode");
|
|
10
15
|
const coinFlip_1 = require("../../../../utils/alea/coinFlip");
|
|
11
16
|
const shuffle_1 = require("../../../../utils/alea/shuffle");
|
|
12
17
|
const getImageFunctionGeogebra = () => {
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
} while (polynome2.calculate(xValue) > 10 ||
|
|
28
|
-
polynome2.calculate(xValue) < -10);
|
|
29
|
-
const statement = `Quelle est l'image de $${xValue}$ par la fonction $f$ représentée ci dessous ?`;
|
|
30
|
-
const answer = rand
|
|
31
|
-
? polynome1.calculate(xValue)
|
|
32
|
-
: polynome2.calculate(xValue);
|
|
33
|
-
const xMin = xValue;
|
|
34
|
-
const xMax = xValue;
|
|
35
|
-
const yMin = answer;
|
|
36
|
-
const yMax = answer;
|
|
37
|
-
const commands = [
|
|
38
|
-
`f(x) = ${rand ? polynome1.toString() : polynome2.toString()}`,
|
|
39
|
-
`SetColor(f, "${(0, colors_1.randomColor)()}")`,
|
|
40
|
-
];
|
|
41
|
-
const ggb = new geogebraConstructor_1.GeogebraConstructor({ commands });
|
|
42
|
-
const answerTex = answer + "";
|
|
18
|
+
const x = (0, randint_1.randint)(-8, 9);
|
|
19
|
+
const y = (0, randint_1.randint)(-8, 9);
|
|
20
|
+
const isSpline = (0, coinFlip_1.coinFlip)();
|
|
21
|
+
const spline = new (isSpline ? spline_1.Spline : lagrange_1.Lagrange)(new intervalNode_1.IntervalNode((-10).toTree(), (10).toTree(), closure_1.ClosureType.FF), [
|
|
22
|
+
new point_1.Point("A", x.toTree(), y.toTree()),
|
|
23
|
+
//distractor point with ordonnée = x
|
|
24
|
+
new point_1.Point("B", (y + (0, randint_1.randint)(-3, 4, [0, x - y, 10 - y, -10 - y])).toTree(), x.toTree()),
|
|
25
|
+
]);
|
|
26
|
+
const ggb = new geogebraConstructor_1.GeogebraConstructor({ commands: spline.getCommands() });
|
|
27
|
+
const xMin = spline.points[0][0];
|
|
28
|
+
const xMax = spline.points[spline.points.length - 1][0];
|
|
29
|
+
const yMin = Math.min(...spline.points.map((p) => p[1])) - 1;
|
|
30
|
+
const yMax = Math.max(...spline.points.map((p) => p[1])) + 1;
|
|
31
|
+
const instruction = `Quelle est l'image de $${x}$ par la fonction $f$ représentée ci dessous ?`;
|
|
43
32
|
const question = {
|
|
44
|
-
instruction
|
|
45
|
-
startStatement: `f(${
|
|
46
|
-
answer:
|
|
33
|
+
instruction,
|
|
34
|
+
startStatement: `f(${x})`,
|
|
35
|
+
answer: y.frenchify(),
|
|
47
36
|
keys: [],
|
|
48
|
-
ggbOptions: ggb.getOptions({
|
|
37
|
+
ggbOptions: ggb.getOptions({
|
|
38
|
+
coords: ggb.getAdaptedCoords({
|
|
39
|
+
forceShowAxes: true,
|
|
40
|
+
xMax,
|
|
41
|
+
xMin,
|
|
42
|
+
yMax,
|
|
43
|
+
yMin,
|
|
44
|
+
}),
|
|
45
|
+
}),
|
|
49
46
|
answerFormat: "tex",
|
|
50
47
|
identifiers: {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
splinePoints: spline.points,
|
|
49
|
+
x,
|
|
50
|
+
y,
|
|
51
|
+
isSpline,
|
|
55
52
|
},
|
|
56
53
|
};
|
|
57
54
|
return question;
|
|
58
55
|
};
|
|
59
|
-
const getPropositions = (n, { answer }) => {
|
|
56
|
+
const getPropositions = (n, { answer, splinePoints, x, y }) => {
|
|
60
57
|
const propositions = [];
|
|
61
58
|
(0, exercise_1.addValidProp)(propositions, answer);
|
|
59
|
+
//old questions have spline POint undefined
|
|
60
|
+
(splinePoints ?? [])
|
|
61
|
+
.filter((p) => p[1] === x)
|
|
62
|
+
.map((e) => (0, round_1.round)(e[0], 0))
|
|
63
|
+
.forEach((y) => (0, exercise_1.tryToAddWrongProp)(propositions, y.frenchify()));
|
|
62
64
|
while (propositions.length < n) {
|
|
63
65
|
const wrongAnswer = Number(answer) + (0, randint_1.randint)(-10, 11, [0]);
|
|
64
66
|
(0, exercise_1.tryToAddWrongProp)(propositions, wrongAnswer + "");
|
|
@@ -66,7 +68,7 @@ const getPropositions = (n, { answer }) => {
|
|
|
66
68
|
return (0, shuffle_1.shuffle)(propositions);
|
|
67
69
|
};
|
|
68
70
|
const isAnswerValid = (ans, { answer }) => {
|
|
69
|
-
return ans
|
|
71
|
+
return (0, numberVEA_1.numberVEA)(ans, answer);
|
|
70
72
|
};
|
|
71
73
|
exports.imageFunctionGeogebra = {
|
|
72
74
|
id: "imageFunctionGeogebra",
|
|
@@ -105,7 +105,7 @@ const getPropositions = (n, { answer }) => {
|
|
|
105
105
|
(0, exercise_1.addValidProp)(propositions, answer, "raw");
|
|
106
106
|
(0, exercise_1.tryToAddWrongProp)(propositions, "Paire", "raw");
|
|
107
107
|
(0, exercise_1.tryToAddWrongProp)(propositions, "Impaire", "raw");
|
|
108
|
-
(0, exercise_1.tryToAddWrongProp)(propositions, "Ni paire ni impaire", "raw");
|
|
108
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, "Ni paire, ni impaire", "raw");
|
|
109
109
|
(0, exercise_1.tryToAddWrongProp)(propositions, "On ne peut pas savoir", "raw");
|
|
110
110
|
return (0, exercise_1.shuffleProps)(propositions, n);
|
|
111
111
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secondDegreeInequation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/trinoms/secondDegreeInequation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,gBAAgB,EAGjB,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"secondDegreeInequation.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/trinoms/secondDegreeInequation.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,gBAAgB,EAGjB,MAAM,mCAAmC,CAAC;AAe3C,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,gBAAgB,CAAC;CAC5B,CAAC;AAsHF,eAAO,MAAM,sBAAsB,EAAE,QAAQ,CAAC,WAAW,CAexD,CAAC"}
|
|
@@ -8,6 +8,9 @@ type Identifiers = {
|
|
|
8
8
|
type: string;
|
|
9
9
|
probaFrac: number[];
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
type Options = {
|
|
12
|
+
allowNonIrreductible?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare const probaFromTableWithContext: Exercise<Identifiers, Options>;
|
|
12
15
|
export {};
|
|
13
16
|
//# sourceMappingURL=probaFromTableWithContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"probaFromTableWithContext.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/probaFromTableWithContext.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"probaFromTableWithContext.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/probaFromTableWithContext.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAWT,MAAM,0BAA0B,CAAC;AAWlC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AA2HF,KAAK,OAAO,GAAG;IACb,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAsBF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAoBpE,CAAC"}
|
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.probaFromTableWithContext = void 0;
|
|
4
4
|
const exercise_1 = require("../../../exercises/exercise");
|
|
5
|
+
const allowNonIrreductibleFractions_1 = require("../../../exercises/options/allowNonIrreductibleFractions");
|
|
5
6
|
const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
|
|
6
7
|
const rational_1 = require("../../../math/numbers/rationals/rational");
|
|
7
8
|
const randint_1 = require("../../../math/utils/random/randint");
|
|
8
9
|
const fractionNode_1 = require("../../../tree/nodes/operators/fractionNode");
|
|
10
|
+
const rationalParser_1 = require("../../../tree/parsers/rationalParser");
|
|
9
11
|
const random_1 = require("../../../utils/alea/random");
|
|
10
12
|
const dollarize_1 = require("../../../utils/latex/dollarize");
|
|
11
13
|
const mdTable_1 = require("../../../utils/markdown/mdTable");
|
|
@@ -107,11 +109,20 @@ const getPropositions = (n, { answer, aBarreCapB, aBarreCapBBarre, aCapB, aCapBB
|
|
|
107
109
|
}
|
|
108
110
|
return (0, exercise_1.shuffleProps)(propositions, n);
|
|
109
111
|
};
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
.
|
|
114
|
-
|
|
112
|
+
const options = [allowNonIrreductibleFractions_1.allowNonIrreductibleOption];
|
|
113
|
+
const isAnswerValid = (ans, { answer, probaFrac }, options) => {
|
|
114
|
+
if (options?.allowNonIrreductible) {
|
|
115
|
+
const parsed = (0, rationalParser_1.rationalParser)(ans);
|
|
116
|
+
if (!parsed)
|
|
117
|
+
return false;
|
|
118
|
+
return parsed.simplify().toTex() === answer;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
const fracTexs = new fractionNode_1.FractionNode(probaFrac[0].toTree(), probaFrac[1].toTree())
|
|
122
|
+
.simplify()
|
|
123
|
+
.toAllValidTexs();
|
|
124
|
+
return fracTexs.includes(ans);
|
|
125
|
+
}
|
|
115
126
|
};
|
|
116
127
|
exports.probaFromTableWithContext = {
|
|
117
128
|
id: "probaFromTableWithContext",
|
|
@@ -120,11 +131,12 @@ exports.probaFromTableWithContext = {
|
|
|
120
131
|
levels: ["1rePro", "1reSpé", "1reTech", "1reESM", "2ndPro"],
|
|
121
132
|
isSingleStep: true,
|
|
122
133
|
sections: ["Probabilités"],
|
|
123
|
-
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getProbaFromTableWithContextQuestion, nb),
|
|
134
|
+
generator: (nb, options) => (0, getDistinctQuestions_1.getDistinctQuestions)(() => getProbaFromTableWithContextQuestion(options), nb),
|
|
124
135
|
qcmTimer: 60,
|
|
125
136
|
freeTimer: 60,
|
|
126
137
|
getPropositions,
|
|
127
138
|
isAnswerValid,
|
|
128
139
|
subject: "Mathématiques",
|
|
129
140
|
getInstruction,
|
|
141
|
+
options,
|
|
130
142
|
};
|
|
@@ -8,6 +8,9 @@ type Identifiers = {
|
|
|
8
8
|
BC: number;
|
|
9
9
|
BD: number;
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
type Options = {
|
|
12
|
+
allowApproximate: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const probabilityTree: Exercise<Identifiers, Options>;
|
|
12
15
|
export {};
|
|
13
16
|
//# sourceMappingURL=probabilityTree.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"probabilityTree.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/probabilityTree.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"probabilityTree.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/probaStat/probabilityTree.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,QAAQ,EAWT,MAAM,gBAAgB,CAAC;AAGxB,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAwIF,KAAK,OAAO,GAAG;IACb,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC;AA0CF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAwB1D,CAAC"}
|
|
@@ -2,33 +2,35 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.probabilityTree = void 0;
|
|
4
4
|
const geogebraConstructor_1 = require("../../../geogebra/geogebraConstructor");
|
|
5
|
-
const integer_1 = require("../../../math/numbers/integer/integer");
|
|
6
|
-
const rational_1 = require("../../../math/numbers/rationals/rational");
|
|
7
5
|
const gcd_1 = require("../../../math/utils/arithmetic/gcd");
|
|
8
6
|
const randint_1 = require("../../../math/utils/random/randint");
|
|
7
|
+
const round_1 = require("../../../math/utils/round");
|
|
8
|
+
const fractionNode_1 = require("../../../tree/nodes/operators/fractionNode");
|
|
9
|
+
const multiplyNode_1 = require("../../../tree/nodes/operators/multiplyNode");
|
|
10
|
+
const latexParser_1 = require("../../../tree/parsers/latexParser");
|
|
9
11
|
const shuffle_1 = require("../../../utils/alea/shuffle");
|
|
10
12
|
const exercise_1 = require("../../exercise");
|
|
11
13
|
const getDistinctQuestions_1 = require("../../utils/getDistinctQuestions");
|
|
12
14
|
const getAnswerNode = ({ type, A, B, AC, AD, BC, BD }) => {
|
|
13
|
-
const pA =
|
|
14
|
-
const pB =
|
|
15
|
-
const pA_C =
|
|
16
|
-
const pA_D =
|
|
17
|
-
const pB_C =
|
|
18
|
-
const pB_D =
|
|
15
|
+
const pA = (0, fractionNode_1.frac)(A, A + B);
|
|
16
|
+
const pB = (0, fractionNode_1.frac)(B, A + B);
|
|
17
|
+
const pA_C = (0, fractionNode_1.frac)(AC, AC + AD);
|
|
18
|
+
const pA_D = (0, fractionNode_1.frac)(AD, AC + AD);
|
|
19
|
+
const pB_C = (0, fractionNode_1.frac)(BC, BC + BD);
|
|
20
|
+
const pB_D = (0, fractionNode_1.frac)(BD, BC + BD);
|
|
19
21
|
switch (type) {
|
|
20
22
|
case 1:
|
|
21
|
-
return
|
|
23
|
+
return (0, multiplyNode_1.multiply)(pA, pA_C).simplify();
|
|
22
24
|
case 2:
|
|
23
|
-
return
|
|
25
|
+
return (0, multiplyNode_1.multiply)(pA, pA_D).simplify();
|
|
24
26
|
case 3:
|
|
25
|
-
return
|
|
27
|
+
return (0, multiplyNode_1.multiply)(pB, pB_C).simplify();
|
|
26
28
|
case 4:
|
|
27
29
|
default:
|
|
28
|
-
return
|
|
30
|
+
return (0, multiplyNode_1.multiply)(pB, pB_D).simplify();
|
|
29
31
|
}
|
|
30
32
|
};
|
|
31
|
-
const getProbabilityTree = () => {
|
|
33
|
+
const getProbabilityTree = (opts) => {
|
|
32
34
|
const A = (0, randint_1.randint)(2, 9);
|
|
33
35
|
const B = (0, randint_1.randint)(2, 10 - A);
|
|
34
36
|
const AC = (0, randint_1.randint)(2, 9);
|
|
@@ -39,7 +41,7 @@ const getProbabilityTree = () => {
|
|
|
39
41
|
let startStatement = "";
|
|
40
42
|
const type = (0, randint_1.randint)(1, 5);
|
|
41
43
|
const answer = getAnswerNode({ type, A, AC, AD, B, BC, BD });
|
|
42
|
-
const answerTex = answer.
|
|
44
|
+
const answerTex = answer.toTex();
|
|
43
45
|
switch (type) {
|
|
44
46
|
case 1: {
|
|
45
47
|
instruction += `calculer $P(A \\cap C)$.`;
|
|
@@ -62,6 +64,9 @@ const getProbabilityTree = () => {
|
|
|
62
64
|
break;
|
|
63
65
|
}
|
|
64
66
|
}
|
|
67
|
+
if (opts?.allowApproximate) {
|
|
68
|
+
instruction += ` Donner la valeur exacte ou une valeur arrondie au ${opts.allowApproximate}.`;
|
|
69
|
+
}
|
|
65
70
|
let commands = [
|
|
66
71
|
"A = Point({2,2})",
|
|
67
72
|
"B = Point({2,-2})",
|
|
@@ -111,16 +116,41 @@ const getPropositions = (n, { answer, A, AC, AD, B, BC, BD, type }) => {
|
|
|
111
116
|
(0, exercise_1.addValidProp)(propositions, answer);
|
|
112
117
|
const answerNode = getAnswerNode({ A, AC, AD, B, BC, BD, type });
|
|
113
118
|
while (propositions.length < n) {
|
|
114
|
-
const wrongAnswer =
|
|
115
|
-
(0, exercise_1.tryToAddWrongProp)(propositions, wrongAnswer.
|
|
119
|
+
const wrongAnswer = (0, multiplyNode_1.multiply)(answerNode, (0, randint_1.randint)(2, 11)).simplify();
|
|
120
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, wrongAnswer.toTex());
|
|
116
121
|
}
|
|
117
122
|
return (0, shuffle_1.shuffle)(propositions);
|
|
118
123
|
};
|
|
119
|
-
const isAnswerValid = (ans, { A, AC, AD, B, BC, BD, type }) => {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
124
|
+
const isAnswerValid = (ans, { answer, A, AC, AD, B, BC, BD, type }, opts) => {
|
|
125
|
+
try {
|
|
126
|
+
const parsed = (0, latexParser_1.parseAlgebraic)(ans);
|
|
127
|
+
if (!parsed)
|
|
128
|
+
return false;
|
|
129
|
+
const simplified = parsed.simplify();
|
|
130
|
+
if (opts?.allowApproximate) {
|
|
131
|
+
const rank = ["dixième", "centième", "millième"].indexOf(opts.allowApproximate);
|
|
132
|
+
return (answer === simplified.toTex() ||
|
|
133
|
+
simplified.evaluate() ===
|
|
134
|
+
(0, round_1.round)(getAnswerNode({ type, A, AC, AD, B, BC, BD }).evaluate(), rank + 1));
|
|
135
|
+
}
|
|
136
|
+
return answer === simplified.toTex();
|
|
137
|
+
// const answer = getAnswerNode({ type, A, AC, AD, B, BC, BD });
|
|
138
|
+
// const texs = answer.toTree({ allowFractionToDecimal: true }).toAllValidTexs();
|
|
139
|
+
}
|
|
140
|
+
catch (err) {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
123
143
|
};
|
|
144
|
+
const options = [
|
|
145
|
+
{
|
|
146
|
+
id: "allowApproximate",
|
|
147
|
+
label: "Autoriser les valeurs approchées au : ",
|
|
148
|
+
target: exercise_1.GeneratorOptionTarget.vea,
|
|
149
|
+
type: exercise_1.GeneratorOptionType.select,
|
|
150
|
+
defaultValue: "centieme",
|
|
151
|
+
values: ["dixième", "centième", "millième"],
|
|
152
|
+
},
|
|
153
|
+
];
|
|
124
154
|
exports.probabilityTree = {
|
|
125
155
|
id: "probabilityTree",
|
|
126
156
|
connector: "=",
|
|
@@ -136,11 +166,12 @@ exports.probabilityTree = {
|
|
|
136
166
|
],
|
|
137
167
|
isSingleStep: false,
|
|
138
168
|
sections: ["Probabilités"],
|
|
139
|
-
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getProbabilityTree, nb),
|
|
169
|
+
generator: (nb, opts) => (0, getDistinctQuestions_1.getDistinctQuestions)(() => getProbabilityTree(opts), nb),
|
|
140
170
|
qcmTimer: 60,
|
|
141
171
|
freeTimer: 60,
|
|
142
172
|
getPropositions,
|
|
143
173
|
isAnswerValid,
|
|
144
174
|
hasGeogebra: true,
|
|
145
175
|
subject: "Mathématiques",
|
|
176
|
+
options,
|
|
146
177
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"averageWithTable.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/averageWithTable.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,QAAQ,EAST,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"averageWithTable.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/averageWithTable.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,QAAQ,EAST,MAAM,mBAAmB,CAAC;AAI3B,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B,CAAC;AAgFF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAelD,CAAC"}
|
|
@@ -8,6 +8,7 @@ const mdTable_1 = require("../../../../utils/markdown/mdTable");
|
|
|
8
8
|
const dollarize_1 = require("../../../../utils/latex/dollarize");
|
|
9
9
|
const exercise_1 = require("../../../exercise");
|
|
10
10
|
const getDistinctQuestions_1 = require("../../../utils/getDistinctQuestions");
|
|
11
|
+
const numberVEA_1 = require("../../../../exercises/vea/numberVEA");
|
|
11
12
|
const getInstruction = ({ randomEffectives, randomValues, }) => {
|
|
12
13
|
return `On considère le tableau d'effectifs suivant :
|
|
13
14
|
|
|
@@ -58,7 +59,7 @@ const getPropositions = (n, { answer }) => {
|
|
|
58
59
|
return (0, shuffle_1.shuffle)(propositions);
|
|
59
60
|
};
|
|
60
61
|
const isAnswerValid = (ans, { answer }) => {
|
|
61
|
-
return ans
|
|
62
|
+
return (0, numberVEA_1.numberVEA)(ans, answer);
|
|
62
63
|
};
|
|
63
64
|
exports.averageWithTable = {
|
|
64
65
|
id: "averageWithTable",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/squareRoots/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/squareRoots/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC"}
|
|
@@ -19,3 +19,4 @@ __exportStar(require("./squareRootEquation"), exports);
|
|
|
19
19
|
__exportStar(require("./squareRootIdentities"), exports);
|
|
20
20
|
__exportStar(require("./squareRootsDistributivity"), exports);
|
|
21
21
|
__exportStar(require("./squareRootsSum"), exports);
|
|
22
|
+
__exportStar(require("./squareRootsProducts"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Exercise } from "../../../exercises/exercise";
|
|
2
|
+
type Identifiers = {
|
|
3
|
+
a: number;
|
|
4
|
+
b: number;
|
|
5
|
+
c: number;
|
|
6
|
+
d: number;
|
|
7
|
+
};
|
|
8
|
+
export declare const squareRootsProducts: Exercise<Identifiers>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=squareRootsProducts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"squareRootsProducts.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/squareRoots/squareRootsProducts.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,0BAA0B,CAAC;AAQlC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAmEF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAerD,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.squareRootsProducts = void 0;
|
|
4
|
+
const exercise_1 = require("../../../exercises/exercise");
|
|
5
|
+
const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
|
|
6
|
+
const real_1 = require("../../../math/numbers/reals/real");
|
|
7
|
+
const randint_1 = require("../../../math/utils/random/randint");
|
|
8
|
+
const sqrtNode_1 = require("../../../tree/nodes/functions/sqrtNode");
|
|
9
|
+
const multiplyNode_1 = require("../../../tree/nodes/operators/multiplyNode");
|
|
10
|
+
const coinFlip_1 = require("../../../utils/alea/coinFlip");
|
|
11
|
+
const getPropositions = (n, { answer }) => {
|
|
12
|
+
const propositions = [];
|
|
13
|
+
(0, exercise_1.addValidProp)(propositions, answer);
|
|
14
|
+
while (propositions.length < n) {
|
|
15
|
+
const int = (0, randint_1.randint)(-30, 30, [0]);
|
|
16
|
+
const sqrt = real_1.SquareRootConstructor.randomIrreductible().toTree();
|
|
17
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, (0, multiplyNode_1.multiply)(int, sqrt).toTex());
|
|
18
|
+
}
|
|
19
|
+
return (0, exercise_1.shuffleProps)(propositions, n);
|
|
20
|
+
};
|
|
21
|
+
const getAnswer = (identifiers) => {
|
|
22
|
+
const { a, b, c, d } = identifiers;
|
|
23
|
+
return (0, multiplyNode_1.multiply)((0, multiplyNode_1.multiply)(a, (0, sqrtNode_1.sqrt)(b)), (0, multiplyNode_1.multiply)(c, (0, sqrtNode_1.sqrt)(d)))
|
|
24
|
+
.simplify()
|
|
25
|
+
.toTex();
|
|
26
|
+
};
|
|
27
|
+
const getInstruction = (identifiers) => {
|
|
28
|
+
const { a, b, c, d } = identifiers;
|
|
29
|
+
return `Ecrire sous la forme $a\\sqrt{b}$, avec $b$ le plus petit possible :
|
|
30
|
+
|
|
31
|
+
$$
|
|
32
|
+
${(0, multiplyNode_1.multiply)((0, multiplyNode_1.multiply)(a, (0, sqrtNode_1.sqrt)(b)), (0, multiplyNode_1.multiply)(c, (0, sqrtNode_1.sqrt)(d)), {
|
|
33
|
+
forceTimesSign: true,
|
|
34
|
+
}).toTex()}
|
|
35
|
+
$$
|
|
36
|
+
`;
|
|
37
|
+
};
|
|
38
|
+
// const getHint: GetHint<Identifiers> = (identifiers) => {};
|
|
39
|
+
// const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
|
|
40
|
+
const getKeys = (identifiers) => {
|
|
41
|
+
return [];
|
|
42
|
+
};
|
|
43
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
44
|
+
return ans === answer;
|
|
45
|
+
};
|
|
46
|
+
// a
|
|
47
|
+
const getSquareRootsProductsQuestion = () => {
|
|
48
|
+
const a = (0, randint_1.randint)(-10, 10, [0]);
|
|
49
|
+
const b = (0, randint_1.randint)(2, 10);
|
|
50
|
+
const c = (0, randint_1.randint)(-10, 10, [0]);
|
|
51
|
+
const d = (0, coinFlip_1.coinFlip)()
|
|
52
|
+
? (0, randint_1.randint)(2, 10)
|
|
53
|
+
: real_1.SquareRootConstructor.randomSimplifiable({
|
|
54
|
+
allowPerfectSquare: false,
|
|
55
|
+
maxSquare: 5,
|
|
56
|
+
}).operand;
|
|
57
|
+
const identifiers = { a, b, c, d };
|
|
58
|
+
const question = {
|
|
59
|
+
answer: getAnswer(identifiers),
|
|
60
|
+
instruction: getInstruction(identifiers),
|
|
61
|
+
keys: getKeys(identifiers),
|
|
62
|
+
answerFormat: "tex",
|
|
63
|
+
identifiers,
|
|
64
|
+
// hint: getHint(identifiers),
|
|
65
|
+
// correction: getCorrection(identifiers),
|
|
66
|
+
};
|
|
67
|
+
return question;
|
|
68
|
+
};
|
|
69
|
+
exports.squareRootsProducts = {
|
|
70
|
+
id: "squareRootsProducts",
|
|
71
|
+
connector: "=",
|
|
72
|
+
label: "Produits de racines carrées",
|
|
73
|
+
isSingleStep: true,
|
|
74
|
+
generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getSquareRootsProductsQuestion, nb),
|
|
75
|
+
qcmTimer: 60,
|
|
76
|
+
freeTimer: 60,
|
|
77
|
+
getPropositions,
|
|
78
|
+
isAnswerValid,
|
|
79
|
+
subject: "Mathématiques",
|
|
80
|
+
// getHint,
|
|
81
|
+
// getCorrection,
|
|
82
|
+
getAnswer,
|
|
83
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"allowNonIrreductibleFractions.d.ts","sourceRoot":"","sources":["../../../src/exercises/options/allowNonIrreductibleFractions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAGhB,MAAM,aAAa,CAAC;AAErB,eAAO,MAAM,0BAA0B,EAAE,eAKxC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.allowNonIrreductibleOption = void 0;
|
|
4
|
+
const exercise_1 = require("../exercise");
|
|
5
|
+
exports.allowNonIrreductibleOption = {
|
|
6
|
+
id: "allowNonIrreductible",
|
|
7
|
+
label: "Autoriser les fractions non réduites",
|
|
8
|
+
target: exercise_1.GeneratorOptionTarget.vea,
|
|
9
|
+
type: exercise_1.GeneratorOptionType.checkbox,
|
|
10
|
+
};
|
|
@@ -21,15 +21,16 @@ class GeogebraConstructor {
|
|
|
21
21
|
const showAxes = forceShowAxes ?? (this.hideAxes ? false : true);
|
|
22
22
|
const xDelta = xMax - xMin;
|
|
23
23
|
const yDelta = yMax - yMin;
|
|
24
|
+
const coeff = 0.1;
|
|
24
25
|
if (this.is3D && zMin !== undefined && zMax !== undefined) {
|
|
25
26
|
const zDelta = zMax - zMin;
|
|
26
27
|
const coords = [
|
|
27
|
-
xMin === xMax ? xMin - 1 : xMin - Math.max(1,
|
|
28
|
-
xMin === xMax ? xMax + 1 : xMax + Math.max(1,
|
|
29
|
-
yMin === yMax ? yMin - 1 : yMin - Math.max(1,
|
|
30
|
-
yMin === yMax ? yMax + 1 : yMax + Math.max(1,
|
|
31
|
-
zMin === zMax ? zMin - 1 : zMin - Math.max(1,
|
|
32
|
-
zMin === zMax ? zMax + 1 : zMax + Math.max(1,
|
|
28
|
+
xMin === xMax ? xMin - 1 : xMin - Math.max(1, coeff * Math.abs(xDelta)),
|
|
29
|
+
xMin === xMax ? xMax + 1 : xMax + Math.max(1, coeff * Math.abs(xDelta)),
|
|
30
|
+
yMin === yMax ? yMin - 1 : yMin - Math.max(1, coeff * Math.abs(yDelta)),
|
|
31
|
+
yMin === yMax ? yMax + 1 : yMax + Math.max(1, coeff * Math.abs(yDelta)),
|
|
32
|
+
zMin === zMax ? zMin - 1 : zMin - Math.max(1, coeff * Math.abs(zDelta)),
|
|
33
|
+
zMin === zMax ? zMax + 1 : zMax + Math.max(1, coeff * Math.abs(zDelta)),
|
|
33
34
|
];
|
|
34
35
|
if (showAxes) {
|
|
35
36
|
coords[0] = Math.min(-1, coords[0]);
|
|
@@ -43,10 +44,10 @@ class GeogebraConstructor {
|
|
|
43
44
|
}
|
|
44
45
|
else {
|
|
45
46
|
const coords = [
|
|
46
|
-
xMin === xMax ? xMin - 1 : xMin - Math.max(1,
|
|
47
|
-
xMin === xMax ? xMax + 1 : xMax + Math.max(1,
|
|
48
|
-
yMin === yMax ? yMin - 1 : yMin - Math.max(1,
|
|
49
|
-
yMin === yMax ? yMax + 1 : yMax + Math.max(1,
|
|
47
|
+
xMin === xMax ? xMin - 1 : xMin - Math.max(1, coeff * Math.abs(xDelta)),
|
|
48
|
+
xMin === xMax ? xMax + 1 : xMax + Math.max(1, coeff * Math.abs(xDelta)),
|
|
49
|
+
yMin === yMax ? yMin - 1 : yMin - Math.max(1, coeff * Math.abs(yDelta)),
|
|
50
|
+
yMin === yMax ? yMax + 1 : yMax + Math.max(1, coeff * Math.abs(yDelta)),
|
|
50
51
|
];
|
|
51
52
|
if (showAxes) {
|
|
52
53
|
coords[0] = Math.min(-1, coords[0]);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Point } from "../math/geometry/point";
|
|
2
|
+
import { IntervalNode } from "../tree/nodes/sets/intervalNode";
|
|
3
|
+
export declare class Lagrange {
|
|
4
|
+
points: number[][];
|
|
5
|
+
constructor(interval: IntervalNode, points?: Point[]);
|
|
6
|
+
getCommands(): string[];
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=lagrange.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lagrange.d.ts","sourceRoot":"","sources":["../../src/geogebra/lagrange.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAKlD,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAelE,qBAAa,QAAQ;IACnB,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;gBAEP,QAAQ,EAAE,YAAY,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE;IAuDpD,WAAW;CAUZ"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Lagrange = void 0;
|
|
4
|
+
const randfloat_1 = require("../math/utils/random/randfloat");
|
|
5
|
+
const randint_1 = require("../math/utils/random/randint");
|
|
6
|
+
const colors_1 = require("./colors");
|
|
7
|
+
// export abstract class LagrangeConstructor {
|
|
8
|
+
// random() {
|
|
9
|
+
// const a = randint(-10, 0);
|
|
10
|
+
// const b = doWhile(
|
|
11
|
+
// () => randint(0, 10),
|
|
12
|
+
// (x) => Math.abs(x - a) < 5,
|
|
13
|
+
// );
|
|
14
|
+
// return new Spline(new IntervalNode(a.toTree(), b.toTree(), ClosureType.FF));
|
|
15
|
+
// }
|
|
16
|
+
// }
|
|
17
|
+
class Lagrange {
|
|
18
|
+
constructor(interval, points) {
|
|
19
|
+
const a = interval.a.evaluate({});
|
|
20
|
+
const b = interval.b.evaluate();
|
|
21
|
+
this.points = [];
|
|
22
|
+
const sortedPoints = points
|
|
23
|
+
?.map((a) => [a.x.evaluate({}), a.y.evaluate({})])
|
|
24
|
+
.sort((a, b) => a[0] - b[0]);
|
|
25
|
+
if (!Number.isFinite(a) || !Number.isFinite(b))
|
|
26
|
+
throw Error("unimplement infinity lagrange");
|
|
27
|
+
const length = Math.abs(b - a);
|
|
28
|
+
const nbOfSlices = sortedPoints?.length
|
|
29
|
+
? sortedPoints.length + 5
|
|
30
|
+
: (0, randint_1.randint)(4, 8);
|
|
31
|
+
const step = length / nbOfSlices;
|
|
32
|
+
const yCoeff = 1 / nbOfSlices;
|
|
33
|
+
for (let i = 0; i < nbOfSlices; i++) {
|
|
34
|
+
const xMin = a + i * step;
|
|
35
|
+
const xMax = xMin + step;
|
|
36
|
+
if (i === 0) {
|
|
37
|
+
const pointInSlice = sortedPoints?.length && sortedPoints[0][0] < xMax;
|
|
38
|
+
this.points.push([
|
|
39
|
+
a,
|
|
40
|
+
pointInSlice
|
|
41
|
+
? sortedPoints[0][1] + yCoeff * (0, randfloat_1.randfloat)(-2, 3)
|
|
42
|
+
: (0, randfloat_1.randfloat)(-10, 10),
|
|
43
|
+
]);
|
|
44
|
+
}
|
|
45
|
+
const fittedPoints = sortedPoints?.filter((point) => point[0] >= xMin && point[0] < xMax);
|
|
46
|
+
this.points.push(...(fittedPoints ?? []));
|
|
47
|
+
if (!fittedPoints?.length && i > 0 && i < nbOfSlices - 1) {
|
|
48
|
+
const nextYInSlice = sortedPoints?.find((p) => p[0] >= xMax && p[0] < xMax + step)?.[1];
|
|
49
|
+
const x = (0, randfloat_1.randfloat)(xMin + step / 4, xMax - step / 4, 6);
|
|
50
|
+
const prevy = this.points[this.points.length - 1][1];
|
|
51
|
+
const y = nextYInSlice !== undefined
|
|
52
|
+
? prevy + (nextYInSlice - prevy) / 2
|
|
53
|
+
: prevy + yCoeff * (0, randfloat_1.randfloat)(-3, 4, 5);
|
|
54
|
+
this.points.push([x, y]);
|
|
55
|
+
}
|
|
56
|
+
if (i === nbOfSlices - 1) {
|
|
57
|
+
const prevY = this.points[this.points.length - 1][1];
|
|
58
|
+
this.points.push([b, prevY + yCoeff * (0, randfloat_1.randfloat)(-2, 3)]);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
getCommands() {
|
|
63
|
+
const commands = [
|
|
64
|
+
`P = Polynomial(${this.points
|
|
65
|
+
.map((point) => `(${point[0]},${point[1]})`)
|
|
66
|
+
.join(",")})`,
|
|
67
|
+
"SetFixed(P, true)",
|
|
68
|
+
`SetColor(P, "${(0, colors_1.randomColor)()}")`,
|
|
69
|
+
];
|
|
70
|
+
return commands;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.Lagrange = Lagrange;
|