math-exercises 2.2.18 → 2.2.20
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/geometry/euclidianConstructions/buildMediatriceWithCompass.d.ts +8 -0
- package/lib/exercises/math/geometry/euclidianConstructions/buildMediatriceWithCompass.d.ts.map +1 -0
- package/lib/exercises/math/geometry/euclidianConstructions/buildMediatriceWithCompass.js +117 -0
- package/lib/exercises/math/geometry/euclidianConstructions/index.d.ts +2 -0
- package/lib/exercises/math/geometry/euclidianConstructions/index.d.ts.map +1 -0
- package/lib/exercises/math/geometry/euclidianConstructions/index.js +17 -0
- package/lib/exercises/math/geometry/index.d.ts +2 -0
- package/lib/exercises/math/geometry/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/index.js +3 -0
- package/lib/exercises/math/geometry/shapes/basicShapesNaming.d.ts +8 -0
- package/lib/exercises/math/geometry/shapes/basicShapesNaming.d.ts.map +1 -0
- package/lib/exercises/math/geometry/shapes/basicShapesNaming.js +118 -0
- package/lib/exercises/math/geometry/shapes/basicShapesRecognition.d.ts +8 -0
- package/lib/exercises/math/geometry/shapes/basicShapesRecognition.d.ts.map +1 -0
- package/lib/exercises/math/geometry/shapes/basicShapesRecognition.js +83 -0
- package/lib/exercises/math/geometry/shapes/index.d.ts +3 -0
- package/lib/exercises/math/geometry/shapes/index.d.ts.map +1 -0
- package/lib/exercises/math/geometry/shapes/index.js +18 -0
- package/lib/exercises/math/geometry/triangles/index.d.ts +1 -0
- package/lib/exercises/math/geometry/triangles/index.d.ts.map +1 -0
- package/lib/exercises/math/geometry/triangles/index.js +2 -0
- package/lib/exercises/math/geometry/triangles/traceMedianInTriangle.d.ts +1 -0
- package/lib/exercises/math/geometry/triangles/traceMedianInTriangle.d.ts.map +1 -0
- package/lib/exercises/math/geometry/triangles/traceMedianInTriangle.js +55 -0
- package/lib/exercises/math/probaStat/conditionalProbability.d.ts +5 -3
- package/lib/exercises/math/probaStat/conditionalProbability.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/conditionalProbability.js +145 -19
- package/lib/exercises/math/sequences/arithmetic/recognizeArithmeticFromGraph.d.ts.map +1 -1
- package/lib/exercises/math/sequences/arithmetic/recognizeArithmeticFromGraph.js +3 -4
- package/lib/exercises/math/sequences/arithmetic/recognizeReasonFromGraph.d.ts.map +1 -1
- package/lib/exercises/math/sequences/arithmetic/recognizeReasonFromGraph.js +3 -4
- package/lib/exercises/utils/geogebra/toGGBCommandsProps.d.ts +6 -0
- package/lib/exercises/utils/geogebra/toGGBCommandsProps.d.ts.map +1 -0
- package/lib/exercises/utils/geogebra/toGGBCommandsProps.js +2 -0
- package/lib/exercises/utils/geogebra/toolBarConstructor.d.ts +1 -0
- package/lib/exercises/utils/geogebra/toolBarConstructor.d.ts.map +1 -1
- package/lib/exercises/utils/geogebra/toolBarConstructor.js +2 -0
- package/lib/exercises/utils/geometry/randomSegmentName.d.ts +2 -0
- package/lib/exercises/utils/geometry/randomSegmentName.d.ts.map +1 -0
- package/lib/exercises/utils/geometry/randomSegmentName.js +10 -0
- package/lib/index.d.ts +14 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/math/geometry/line.d.ts +10 -2
- package/lib/math/geometry/line.d.ts.map +1 -1
- package/lib/math/geometry/line.js +47 -5
- package/lib/math/geometry/point.d.ts +3 -1
- package/lib/math/geometry/point.d.ts.map +1 -1
- package/lib/math/geometry/point.js +16 -2
- package/lib/math/geometry/ray.d.ts +15 -0
- package/lib/math/geometry/ray.d.ts.map +1 -0
- package/lib/math/geometry/ray.js +44 -0
- package/lib/math/geometry/segment.d.ts +16 -0
- package/lib/math/geometry/segment.d.ts.map +1 -0
- package/lib/math/geometry/segment.js +47 -0
- package/lib/tree/parsers/isSegmentName.d.ts +2 -0
- package/lib/tree/parsers/isSegmentName.d.ts.map +1 -0
- package/lib/tree/parsers/isSegmentName.js +15 -0
- package/package.json +1 -1
|
@@ -6,62 +6,187 @@ const exercise_1 = require("../../exercise");
|
|
|
6
6
|
const getDistinctQuestions_1 = require("../../utils/getDistinctQuestions");
|
|
7
7
|
const round_1 = require("../../../math/utils/round");
|
|
8
8
|
const shuffle_1 = require("../../../utils/shuffle");
|
|
9
|
+
const alignTex_1 = require("../../../utils/alignTex");
|
|
9
10
|
const getConditionalProbability = () => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const pAB = (0, randint_1.randint)(1, Math.min(pA, pB));
|
|
13
|
-
const pA_B = (0, round_1.round)(pAB / pB, 2);
|
|
14
|
-
const pB_A = (0, round_1.round)(pAB / pA, 2);
|
|
11
|
+
let pA, pB, pAB, pA_B, pB_A;
|
|
12
|
+
let pAStr, pBStr, pABStr, pA_BStr, pB_AStr;
|
|
15
13
|
const flip = (0, randint_1.randint)(1, 7);
|
|
16
14
|
let instruction = `On considère deux événements $A$ et $B$ tels que `;
|
|
17
15
|
let startStatement = "";
|
|
18
16
|
let answer = "";
|
|
17
|
+
let correction = "";
|
|
19
18
|
switch (flip) {
|
|
20
19
|
case 1: {
|
|
21
|
-
|
|
20
|
+
pA = (0, randint_1.randint)(2, 100);
|
|
21
|
+
pAB = (0, randint_1.randint)(1, pA);
|
|
22
|
+
pAStr = (pA / 100).frenchify();
|
|
23
|
+
pABStr = (pAB / 100).frenchify();
|
|
24
|
+
pB_AStr = (0, round_1.round)(pAB / pA, 2).frenchify();
|
|
25
|
+
instruction += `$P(A) = ${pAStr}\\ $ et $\\ P(A \\cap B) = ${pABStr}$.$\\\\$Déterminer $P_A(B)$ (arrondir au centième).`;
|
|
22
26
|
startStatement = `P_A(B)`;
|
|
23
|
-
answer =
|
|
27
|
+
answer = pB_AStr;
|
|
28
|
+
correction = `
|
|
29
|
+
On sait que :
|
|
30
|
+
|
|
31
|
+
$$
|
|
32
|
+
P_A(B) = \\frac{P(A \\cap B)}{P(A)}
|
|
33
|
+
$$
|
|
34
|
+
|
|
35
|
+
On a donc :
|
|
36
|
+
|
|
37
|
+
$$
|
|
38
|
+
P_A(B) = \\frac{${pABStr}}{${pAStr}} \\approx ${answer}
|
|
39
|
+
$$
|
|
40
|
+
`;
|
|
24
41
|
break;
|
|
25
42
|
}
|
|
26
43
|
case 2: {
|
|
27
|
-
|
|
44
|
+
pB = (0, randint_1.randint)(2, 100);
|
|
45
|
+
pAB = (0, randint_1.randint)(1, pB);
|
|
46
|
+
pBStr = (pB / 100).frenchify();
|
|
47
|
+
pABStr = (pAB / 100).frenchify();
|
|
48
|
+
pA_BStr = (0, round_1.round)(pAB / pB, 2).frenchify();
|
|
49
|
+
instruction += `$P(B) = ${pBStr}\\ $ et $\\ P(B \\cap A) = ${pABStr}$.$\\\\$Déterminer $P_B(A)$ (arrondir au centième).`;
|
|
28
50
|
startStatement = `P_B(A)`;
|
|
29
|
-
answer =
|
|
51
|
+
answer = pA_BStr;
|
|
52
|
+
correction = `
|
|
53
|
+
On sait que :
|
|
54
|
+
|
|
55
|
+
$$
|
|
56
|
+
P_B(A) = \\frac{P(A \\cap B)}{P(B)}
|
|
57
|
+
$$
|
|
58
|
+
|
|
59
|
+
On a donc :
|
|
60
|
+
|
|
61
|
+
$$
|
|
62
|
+
P_B(A) = \\frac{${pABStr}}{${pBStr}} \\approx ${answer}
|
|
63
|
+
$$
|
|
64
|
+
`;
|
|
30
65
|
break;
|
|
31
66
|
}
|
|
32
67
|
case 3: {
|
|
33
|
-
|
|
68
|
+
pA = (0, randint_1.randint)(2, 100);
|
|
69
|
+
pAStr = (pA / 100).frenchify();
|
|
70
|
+
pB_A = (0, randint_1.randint)(1, pA);
|
|
71
|
+
pB_AStr = (pB_A / 100).frenchify();
|
|
72
|
+
pAB = (0, round_1.round)((pB_A * pA) / 10000, 2);
|
|
73
|
+
pABStr = pAB.frenchify();
|
|
74
|
+
instruction += `$P(A) = ${pAStr}\\ $ et $\\ P_A(B) = ${pB_AStr}$.$\\\\$Déterminer $P(A \\cap B)$ (arrondir au centième).`;
|
|
34
75
|
startStatement = `P(A \\cap B)`;
|
|
35
|
-
answer =
|
|
76
|
+
answer = pABStr;
|
|
77
|
+
correction = `
|
|
78
|
+
On sait que :
|
|
79
|
+
|
|
80
|
+
$$
|
|
81
|
+
P_A(B) = \\frac{P(A \\cap B)}{P(A)}
|
|
82
|
+
$$
|
|
83
|
+
|
|
84
|
+
On a donc :
|
|
85
|
+
|
|
86
|
+
${(0, alignTex_1.alignTex)([
|
|
87
|
+
["P(A \\cap B)", "=", "P_A(B)\\times P(A)"],
|
|
88
|
+
["", "=", `${pB_AStr}\\times ${pAStr}`],
|
|
89
|
+
["", "\\approx", answer],
|
|
90
|
+
])}
|
|
91
|
+
`;
|
|
36
92
|
break;
|
|
37
93
|
}
|
|
38
94
|
case 4: {
|
|
39
|
-
|
|
95
|
+
pB = (0, randint_1.randint)(2, 100);
|
|
96
|
+
pBStr = (pB / 100).frenchify();
|
|
97
|
+
pA_B = (0, randint_1.randint)(1, pB);
|
|
98
|
+
pA_BStr = pA_B.frenchify();
|
|
99
|
+
pAB = (0, round_1.round)((pA_B * pB) / 10000, 2);
|
|
100
|
+
pABStr = pAB.frenchify();
|
|
101
|
+
instruction += `$P(B) = ${pBStr}\\ $ et $\\ P_B(A) = ${pA_BStr}$.$\\\\$Déterminer $P(A \\cap B)$ (arrondir au centième).`;
|
|
40
102
|
startStatement = `P(A \\cap B)`;
|
|
41
|
-
answer =
|
|
103
|
+
answer = pABStr;
|
|
104
|
+
correction = `
|
|
105
|
+
On sait que :
|
|
106
|
+
|
|
107
|
+
$$
|
|
108
|
+
P_B(A) = \\frac{P(A \\cap B)}{P(B)}
|
|
109
|
+
$$
|
|
110
|
+
|
|
111
|
+
On a donc :
|
|
112
|
+
|
|
113
|
+
${(0, alignTex_1.alignTex)([
|
|
114
|
+
["P(A \\cap B)", "=", "P_B(A)\\times P(B)"],
|
|
115
|
+
["", "=", `${pA_BStr}\\times ${pBStr}`],
|
|
116
|
+
["", "\\approx", answer],
|
|
117
|
+
])}
|
|
118
|
+
`;
|
|
42
119
|
break;
|
|
43
120
|
}
|
|
44
121
|
case 5: {
|
|
45
|
-
|
|
122
|
+
pA_B = (0, randint_1.randint)(1, 100);
|
|
123
|
+
pAB = (0, randint_1.randint)(1, pA_B);
|
|
124
|
+
pABStr = (pAB / 100).frenchify();
|
|
125
|
+
pA_BStr = (pA_B / 100).frenchify();
|
|
126
|
+
pB = (0, round_1.round)(pAB / pA_B, 2);
|
|
127
|
+
pBStr = pB.frenchify();
|
|
128
|
+
instruction += `$P(A \\cap B) = ${pABStr}\\ $ et $\\ P_B(A) = ${pA_BStr}$.$\\\\$Déterminer $P(B)$ (arrondir au centième).`;
|
|
46
129
|
startStatement = `P(B)`;
|
|
47
|
-
answer =
|
|
130
|
+
answer = pBStr;
|
|
131
|
+
correction = `
|
|
132
|
+
On sait que :
|
|
133
|
+
|
|
134
|
+
$$
|
|
135
|
+
P_B(A) = \\frac{P(A \\cap B)}{P(B)}
|
|
136
|
+
$$
|
|
137
|
+
|
|
138
|
+
On a donc :
|
|
139
|
+
|
|
140
|
+
${(0, alignTex_1.alignTex)([
|
|
141
|
+
["P(B)", "=", "\\frac{P(A\\cap B)}{P_B(A)}"],
|
|
142
|
+
["", "=", `\\frac{${pABStr}}{${pA_BStr}}`],
|
|
143
|
+
["", "\\approx", answer],
|
|
144
|
+
])}
|
|
145
|
+
`;
|
|
48
146
|
break;
|
|
49
147
|
}
|
|
50
148
|
case 6: {
|
|
51
|
-
|
|
149
|
+
pB_A = (0, randint_1.randint)(1, 100);
|
|
150
|
+
pAB = (0, randint_1.randint)(1, pB_A);
|
|
151
|
+
pABStr = (pAB / 100).frenchify();
|
|
152
|
+
pB_AStr = (pB_A / 100).frenchify();
|
|
153
|
+
pA = (0, round_1.round)(pAB / pB_A, 2);
|
|
154
|
+
pAStr = pA.frenchify();
|
|
155
|
+
instruction += `$P(A \\cap B) = ${pABStr}\\ $ et $\\ P_A(B) = ${pB_AStr}$.$\\\\$Déterminer $P(A)$ (arrondir au centième).`;
|
|
52
156
|
startStatement = `P(A)`;
|
|
53
|
-
answer =
|
|
157
|
+
answer = pAStr;
|
|
158
|
+
correction = `
|
|
159
|
+
On sait que :
|
|
160
|
+
|
|
161
|
+
$$
|
|
162
|
+
P_A(B) = \\frac{P(A \\cap B)}{P(A)}
|
|
163
|
+
$$
|
|
164
|
+
|
|
165
|
+
On a donc :
|
|
166
|
+
|
|
167
|
+
${(0, alignTex_1.alignTex)([
|
|
168
|
+
["P(A)", "=", "\\frac{P(A\\cap B)}{P_A(B)}"],
|
|
169
|
+
["", "=", `\\frac{${pABStr}}{${pB_AStr}}`],
|
|
170
|
+
["", "\\approx", answer],
|
|
171
|
+
])}
|
|
172
|
+
`;
|
|
54
173
|
break;
|
|
55
174
|
}
|
|
56
175
|
}
|
|
57
|
-
answer = answer.replace(".", ",");
|
|
58
176
|
const question = {
|
|
59
177
|
instruction,
|
|
60
178
|
startStatement,
|
|
61
179
|
answer,
|
|
62
180
|
keys: ["p", "cap", "underscore"],
|
|
63
181
|
answerFormat: "tex",
|
|
64
|
-
identifiers: { flip, pA, pAB, pB },
|
|
182
|
+
identifiers: { flip, pA, pAB, pB, pA_B, pB_A },
|
|
183
|
+
hint: `Pour deux événements $M$ et $N$, on a:
|
|
184
|
+
|
|
185
|
+
$$
|
|
186
|
+
P_M(N) = \\frac{P(M \\cap N)}{P(M)}
|
|
187
|
+
$$
|
|
188
|
+
`,
|
|
189
|
+
correction,
|
|
65
190
|
};
|
|
66
191
|
return question;
|
|
67
192
|
};
|
|
@@ -89,4 +214,5 @@ exports.conditionalProbability = {
|
|
|
89
214
|
getPropositions,
|
|
90
215
|
isAnswerValid,
|
|
91
216
|
subject: "Mathématiques",
|
|
217
|
+
hasHintAndCorrection: true,
|
|
92
218
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recognizeArithmeticFromGraph.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/arithmetic/recognizeArithmeticFromGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AAQlC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;
|
|
1
|
+
{"version":3,"file":"recognizeArithmeticFromGraph.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/arithmetic/recognizeArithmeticFromGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AAQlC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AA8EF,eAAO,MAAM,4BAA4B,EAAE,QAAQ,CAAC,WAAW,CAe9D,CAAC"}
|
|
@@ -42,10 +42,9 @@ const getRecognizeArithmeticFromGraphQuestion = () => {
|
|
|
42
42
|
? new Array(10).fill(0).map((el, index) => firstAriTerm + reason * index)
|
|
43
43
|
: getRandomFirstNonAriTerms();
|
|
44
44
|
const answer = isAri ? "Oui" : "Non";
|
|
45
|
-
const commands = sequence.flatMap((nb, index) =>
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
]);
|
|
45
|
+
const commands = sequence.flatMap((nb, index) => new point_1.Point(`A_${index}`, index.toTree(), nb.toTree()).toGGBCommand({
|
|
46
|
+
showLabel: false,
|
|
47
|
+
}));
|
|
49
48
|
const ggb = new geogebraConstructor_1.GeogebraConstructor({
|
|
50
49
|
commands,
|
|
51
50
|
lockedAxesRatio: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recognizeReasonFromGraph.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/arithmetic/recognizeReasonFromGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AAMlC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;
|
|
1
|
+
{"version":3,"file":"recognizeReasonFromGraph.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/sequences/arithmetic/recognizeReasonFromGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AAMlC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAkDF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAe1D,CAAC"}
|
|
@@ -14,10 +14,9 @@ const getRecognizeReasonFromGraphQuestion = () => {
|
|
|
14
14
|
.map((el, index) => firstTerm + index * reason);
|
|
15
15
|
const yMin = Math.min(...sequence.slice(0, 5));
|
|
16
16
|
const yMax = Math.max(...sequence.slice(0, 5));
|
|
17
|
-
const commands = sequence.flatMap((nb, index) =>
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
]);
|
|
17
|
+
const commands = sequence.flatMap((nb, index) => new point_1.Point(`A_${index}`, index.toTree(), nb.toTree()).toGGBCommand({
|
|
18
|
+
showLabel: false,
|
|
19
|
+
}));
|
|
21
20
|
const ggb = new geogebraConstructor_1.GeogebraConstructor({
|
|
22
21
|
commands,
|
|
23
22
|
xAxis: { natural: true },
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toGGBCommandsProps.d.ts","sourceRoot":"","sources":["../../../../src/exercises/utils/geogebra/toGGBCommandsProps.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolBarConstructor.d.ts","sourceRoot":"","sources":["../../../../src/exercises/utils/geogebra/toolBarConstructor.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,YAAa;IAC1C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"toolBarConstructor.d.ts","sourceRoot":"","sources":["../../../../src/exercises/utils/geogebra/toolBarConstructor.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,YAAa;IAC1C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,WAUA,CAAC"}
|
|
@@ -15,6 +15,8 @@ const toolBarConstructor = (options) => {
|
|
|
15
15
|
customToolBar += "||5";
|
|
16
16
|
if (options.vector)
|
|
17
17
|
customToolBar += "||7";
|
|
18
|
+
if (options.circleTwoPoints)
|
|
19
|
+
customToolBar += "||10";
|
|
18
20
|
return customToolBar;
|
|
19
21
|
};
|
|
20
22
|
exports.toolBarConstructor = toolBarConstructor;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"randomSegmentName.d.ts","sourceRoot":"","sources":["../../../../src/exercises/utils/geometry/randomSegmentName.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,cAI7B,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.randomSegmentName = void 0;
|
|
4
|
+
const randomLetter_1 = require("../../../utils/strings/randomLetter");
|
|
5
|
+
const randomSegmentName = () => {
|
|
6
|
+
const A = (0, randomLetter_1.randomLetter)(true);
|
|
7
|
+
const B = (0, randomLetter_1.randomLetter)(true, [A]);
|
|
8
|
+
return `${A}${B}`;
|
|
9
|
+
};
|
|
10
|
+
exports.randomSegmentName = randomSegmentName;
|
package/lib/index.d.ts
CHANGED
|
@@ -964,6 +964,15 @@ declare const mathExercises: (import("./exercises/exercise").Exercise<{
|
|
|
964
964
|
width: number;
|
|
965
965
|
height: number;
|
|
966
966
|
angle: number;
|
|
967
|
+
}> | import("./exercises/exercise").Exercise<{
|
|
968
|
+
A: number[];
|
|
969
|
+
B: number[];
|
|
970
|
+
}> | import("./exercises/exercise").Exercise<{
|
|
971
|
+
type: number;
|
|
972
|
+
commands: string[];
|
|
973
|
+
}> | import("./exercises/exercise").Exercise<{
|
|
974
|
+
type: number;
|
|
975
|
+
commands: string[];
|
|
967
976
|
}> | import("./exercises/exercise").Exercise<{
|
|
968
977
|
coeffs: number[];
|
|
969
978
|
to: string;
|
|
@@ -1094,9 +1103,11 @@ declare const mathExercises: (import("./exercises/exercise").Exercise<{
|
|
|
1094
1103
|
questionType: string;
|
|
1095
1104
|
}> | import("./exercises/exercise").Exercise<{
|
|
1096
1105
|
flip: number;
|
|
1097
|
-
pA
|
|
1098
|
-
pB
|
|
1099
|
-
pAB
|
|
1106
|
+
pA?: number | undefined;
|
|
1107
|
+
pB?: number | undefined;
|
|
1108
|
+
pAB?: number | undefined;
|
|
1109
|
+
pA_B?: number | undefined;
|
|
1110
|
+
pB_A?: number | undefined;
|
|
1100
1111
|
}> | import("./exercises/exercise").Exercise<{
|
|
1101
1112
|
isParityQuestion: boolean;
|
|
1102
1113
|
isEvenQuestion: boolean;
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,yBAAyB,CAAC;AAEjC,QAAA,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,yBAAyB,CAAC;AAEjC,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAA+B,CAAC;AACnD,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -1,18 +1,26 @@
|
|
|
1
|
+
import { ToGGBCommandsProps } from "../../exercises/utils/geogebra/toGGBCommandsProps";
|
|
1
2
|
import { AlgebraicNode } from "../../tree/nodes/algebraicNode";
|
|
2
3
|
import { EqualNode } from "../../tree/nodes/equations/equalNode";
|
|
3
4
|
import { Point } from "./point";
|
|
4
5
|
import { Vector } from "./vector";
|
|
6
|
+
export declare abstract class LineConstructor {
|
|
7
|
+
static random(name?: string): Line;
|
|
8
|
+
}
|
|
5
9
|
export declare class Line {
|
|
6
10
|
pointA: Point;
|
|
7
11
|
pointB: Point;
|
|
8
12
|
isVertical: boolean;
|
|
9
13
|
a: AlgebraicNode | undefined;
|
|
10
14
|
b: AlgebraicNode | undefined;
|
|
11
|
-
|
|
15
|
+
name: string;
|
|
16
|
+
ggbName: string;
|
|
17
|
+
constructor(pointA: Point, pointB: Point, name?: string);
|
|
12
18
|
getParallele(point: Point): Line;
|
|
13
|
-
includes(point: Point): boolean;
|
|
19
|
+
includes(point: Point, allowApprox?: boolean): boolean;
|
|
14
20
|
getRandomPoint(name?: string): Point;
|
|
15
21
|
getEquation: (u: Vector, a: Point) => EqualNode;
|
|
16
22
|
getCartesianEquation(): EqualNode;
|
|
23
|
+
toTex(): string;
|
|
24
|
+
toGGBCommands(shouldBuildPoints: boolean, { isFixed, showLabel, showUnderlyingPointsLabel, }?: ToGGBCommandsProps): string[];
|
|
17
25
|
}
|
|
18
26
|
//# sourceMappingURL=line.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/line.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAQjE,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"line.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/line.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mDAAmD,CAAC;AAEvF,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAQjE,OAAO,EAAE,KAAK,EAAoB,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,8BAAsB,eAAe;IACnC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM;CAK5B;AACD,qBAAa,IAAI;IACf,MAAM,EAAE,KAAK,CAAC;IACd,MAAM,EAAE,KAAK,CAAC;IACd,UAAU,EAAE,OAAO,CAAC;IACpB,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IAC7B,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;gBACJ,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,MAAM;IAoBvD,YAAY,CAAC,KAAK,EAAE,KAAK;IASzB,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,WAAW,GAAE,OAAe;IAgBnD,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM;IAa5B,WAAW,MAAO,MAAM,KAAK,KAAK,KAAG,SAAS,CAmB5C;IAEF,oBAAoB,IAAI,SAAS;IAuBjC,KAAK;IAIL,aAAa,CACX,iBAAiB,EAAE,OAAO,EAC1B,EACE,OAAc,EACd,SAAiB,EACjB,yBAAgC,GACjC,GAAE,kBAAuB;CAoB7B"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Line = void 0;
|
|
3
|
+
exports.Line = exports.LineConstructor = void 0;
|
|
4
|
+
const randomSegmentName_1 = require("../../exercises/utils/geometry/randomSegmentName");
|
|
4
5
|
const equalNode_1 = require("../../tree/nodes/equations/equalNode");
|
|
5
6
|
const numberNode_1 = require("../../tree/nodes/numbers/numberNode");
|
|
6
7
|
const addNode_1 = require("../../tree/nodes/operators/addNode");
|
|
@@ -11,8 +12,16 @@ const variableNode_1 = require("../../tree/nodes/variables/variableNode");
|
|
|
11
12
|
const randint_1 = require("../utils/random/randint");
|
|
12
13
|
const point_1 = require("./point");
|
|
13
14
|
const vector_1 = require("./vector");
|
|
15
|
+
class LineConstructor {
|
|
16
|
+
static random(name) {
|
|
17
|
+
const names = (0, randomSegmentName_1.randomSegmentName)();
|
|
18
|
+
const points = point_1.PointConstructor.randomDifferent(names.split(""));
|
|
19
|
+
return new Line(points[0], points[1], name);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.LineConstructor = LineConstructor;
|
|
14
23
|
class Line {
|
|
15
|
-
constructor(pointA, pointB) {
|
|
24
|
+
constructor(pointA, pointB, name) {
|
|
16
25
|
this.getEquation = (u, a) => {
|
|
17
26
|
const x = new variableNode_1.VariableNode("x");
|
|
18
27
|
const y = new variableNode_1.VariableNode("y");
|
|
@@ -28,6 +37,8 @@ class Line {
|
|
|
28
37
|
};
|
|
29
38
|
this.pointA = pointA;
|
|
30
39
|
this.pointB = pointB;
|
|
40
|
+
this.name = name ?? `\\left(${pointA.name}${pointB.name}\\right)`;
|
|
41
|
+
this.ggbName = name ?? `line_{${pointA.name}${pointB.name}}`;
|
|
31
42
|
this.isVertical = pointA.x.equals(pointB.x);
|
|
32
43
|
if (this.isVertical) {
|
|
33
44
|
this.a = undefined;
|
|
@@ -47,11 +58,20 @@ class Line {
|
|
|
47
58
|
const secondPoint = new point_1.Point("D", x, y);
|
|
48
59
|
return new Line(point, secondPoint);
|
|
49
60
|
}
|
|
50
|
-
includes(point) {
|
|
61
|
+
includes(point, allowApprox = false) {
|
|
51
62
|
if (this.isVertical) {
|
|
52
|
-
|
|
63
|
+
if (allowApprox) {
|
|
64
|
+
}
|
|
65
|
+
else
|
|
66
|
+
return point.x.equals(this.pointA.x);
|
|
67
|
+
}
|
|
68
|
+
const evaluation = new substractNode_1.SubstractNode(point.y, new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(this.a, point.x), this.b)).evaluate({});
|
|
69
|
+
console.log("eval", evaluation);
|
|
70
|
+
if (allowApprox) {
|
|
71
|
+
return Math.abs(evaluation) < 0.0000001;
|
|
53
72
|
}
|
|
54
|
-
|
|
73
|
+
else
|
|
74
|
+
return evaluation === 0;
|
|
55
75
|
}
|
|
56
76
|
//! caution: simplify ne gère pas bien ici
|
|
57
77
|
getRandomPoint(name) {
|
|
@@ -71,5 +91,27 @@ class Line {
|
|
|
71
91
|
const y = new variableNode_1.VariableNode("y");
|
|
72
92
|
return new equalNode_1.EqualNode(new addNode_1.AddNode(new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(a), x).simplify(), new multiplyNode_1.MultiplyNode(new numberNode_1.NumberNode(b), y).simplify()), new numberNode_1.NumberNode(c)).simplify({ forbidFactorize: true }), new numberNode_1.NumberNode(0));
|
|
73
93
|
}
|
|
94
|
+
toTex() {
|
|
95
|
+
return this.name;
|
|
96
|
+
}
|
|
97
|
+
toGGBCommands(shouldBuildPoints, { isFixed = true, showLabel = false, showUnderlyingPointsLabel = true, } = {}) {
|
|
98
|
+
const commands = [
|
|
99
|
+
`${this.ggbName}=Line(${this.pointA.name},${this.pointB.name})`,
|
|
100
|
+
`SetFixed(${this.ggbName},${isFixed ? "true" : "false"})`,
|
|
101
|
+
`ShowLabel(${this.ggbName},${showLabel ? "true" : "false"})`,
|
|
102
|
+
];
|
|
103
|
+
if (shouldBuildPoints) {
|
|
104
|
+
const ACommands = this.pointA.toGGBCommand({
|
|
105
|
+
isFixed,
|
|
106
|
+
showLabel: showUnderlyingPointsLabel,
|
|
107
|
+
});
|
|
108
|
+
const BCommands = this.pointB.toGGBCommand({
|
|
109
|
+
isFixed,
|
|
110
|
+
showLabel: showUnderlyingPointsLabel,
|
|
111
|
+
});
|
|
112
|
+
commands.unshift(...ACommands, ...BCommands);
|
|
113
|
+
}
|
|
114
|
+
return commands;
|
|
115
|
+
}
|
|
74
116
|
}
|
|
75
117
|
exports.Line = Line;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { NodeIds } from "../../tree/nodes/node";
|
|
2
2
|
import { AlgebraicNode } from "../../tree/nodes/algebraicNode";
|
|
3
|
+
import { ToGGBCommandsProps } from "../../exercises/utils/geogebra/toGGBCommandsProps";
|
|
3
4
|
export declare abstract class PointConstructor {
|
|
4
5
|
static random(name: string): Point;
|
|
5
6
|
static randomDifferent(names: string[]): Point[];
|
|
7
|
+
static fromGGBCommand(str: string): Point;
|
|
6
8
|
}
|
|
7
9
|
export declare class Point {
|
|
8
10
|
name: string;
|
|
@@ -28,6 +30,6 @@ export declare class Point {
|
|
|
28
30
|
distanceTo(B: Point): number;
|
|
29
31
|
equals(B: Point): boolean;
|
|
30
32
|
isAligned(B: Point, C: Point): boolean;
|
|
31
|
-
toGGBCommand(): string;
|
|
33
|
+
toGGBCommand({ isFixed, showLabel }?: ToGGBCommandsProps): string[];
|
|
32
34
|
}
|
|
33
35
|
//# sourceMappingURL=point.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/point.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAY,MAAM,uBAAuB,CAAC;AAI1D,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/point.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAY,MAAM,uBAAuB,CAAC;AAI1D,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAG/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mDAAmD,CAAC;AAEvF,8BAAsB,gBAAgB;IACpC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK;IAMlC,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE;IAetC,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,MAAM;CAclC;AAED,qBAAa,KAAK;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,aAAa,CAAC;IACjB,CAAC,EAAE,aAAa,CAAC;gBACL,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa;IAM5D,KAAK,IAAI,MAAM;IAGf,aAAa;;;;;;;;;;IAQb,eAAe,IAAI,MAAM;IAGzB,QAAQ,IAAI,MAAM;IAIlB,UAAU,IAAI,MAAM;IAMpB,UAAU,IAAI,MAAM;IAMpB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,SAAM,GAAG,KAAK;IAiBrC,UAAU,CAAC,CAAC,EAAE,KAAK,GAAG,MAAM;IAM5B,MAAM,CAAC,CAAC,EAAE,KAAK,GAAG,OAAO;IAGzB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK;IAM5B,YAAY,CAAC,EAAE,OAAc,EAAE,SAAgB,EAAE,GAAE,kBAAuB;CAO3E"}
|
|
@@ -27,6 +27,16 @@ class PointConstructor {
|
|
|
27
27
|
}
|
|
28
28
|
return res;
|
|
29
29
|
}
|
|
30
|
+
static fromGGBCommand(str) {
|
|
31
|
+
const formatted = str.replace(" ", "");
|
|
32
|
+
const name = formatted.split("=")[0];
|
|
33
|
+
const [x, y] = formatted
|
|
34
|
+
.split("=")[1]
|
|
35
|
+
.replace("(", "")
|
|
36
|
+
.replace(")", "")
|
|
37
|
+
.split(",");
|
|
38
|
+
return new Point(name, new numberNode_1.NumberNode(Number(x)), new numberNode_1.NumberNode(Number(y)));
|
|
39
|
+
}
|
|
30
40
|
}
|
|
31
41
|
exports.PointConstructor = PointConstructor;
|
|
32
42
|
class Point {
|
|
@@ -86,8 +96,12 @@ class Point {
|
|
|
86
96
|
const AC = vector_1.VectorConstructor.fromPoints(this, C);
|
|
87
97
|
return AB.isColinear(AC);
|
|
88
98
|
}
|
|
89
|
-
toGGBCommand() {
|
|
90
|
-
return
|
|
99
|
+
toGGBCommand({ isFixed = true, showLabel = true } = {}) {
|
|
100
|
+
return [
|
|
101
|
+
`${this.name} = (${this.x.toMathString()}, ${this.y.toMathString()})`,
|
|
102
|
+
`SetFixed(${this.name},${isFixed ? "true" : "false"})`,
|
|
103
|
+
`ShowLabel(${this.name},${showLabel ? "true" : "false"})`,
|
|
104
|
+
];
|
|
91
105
|
}
|
|
92
106
|
}
|
|
93
107
|
exports.Point = Point;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ToGGBCommandsProps } from "../../exercises/utils/geogebra/toGGBCommandsProps";
|
|
2
|
+
import { Point } from "./point";
|
|
3
|
+
export declare abstract class RayConstructor {
|
|
4
|
+
static random(name?: string): Ray;
|
|
5
|
+
}
|
|
6
|
+
export declare class Ray {
|
|
7
|
+
startPoint: Point;
|
|
8
|
+
secondPoint: Point;
|
|
9
|
+
name: string;
|
|
10
|
+
ggbName: string;
|
|
11
|
+
constructor(startPoint: Point, secondPoint: Point, name?: string);
|
|
12
|
+
toTex(): string;
|
|
13
|
+
toGGBCommands(shouldBuildPoints: boolean, { isFixed, showLabel, showUnderlyingPointsLabel, }?: ToGGBCommandsProps): string[];
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=ray.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ray.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/ray.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mDAAmD,CAAC;AAEvF,OAAO,EAAE,KAAK,EAAoB,MAAM,SAAS,CAAC;AAElD,8BAAsB,cAAc;IAClC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM;CAK5B;AAED,qBAAa,GAAG;IACd,UAAU,EAAE,KAAK,CAAC;IAClB,WAAW,EAAE,KAAK,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;gBACJ,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,MAAM;IAOhE,KAAK;IAGL,aAAa,CACX,iBAAiB,EAAE,OAAO,EAC1B,EACE,OAAc,EACd,SAAiB,EACjB,yBAAgC,GACjC,GAAE,kBAAuB;CAoB7B"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Ray = exports.RayConstructor = void 0;
|
|
4
|
+
const randomSegmentName_1 = require("../../exercises/utils/geometry/randomSegmentName");
|
|
5
|
+
const point_1 = require("./point");
|
|
6
|
+
class RayConstructor {
|
|
7
|
+
static random(name) {
|
|
8
|
+
const names = (0, randomSegmentName_1.randomSegmentName)();
|
|
9
|
+
const points = point_1.PointConstructor.randomDifferent(names.split(""));
|
|
10
|
+
return new Ray(points[0], points[1], name);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.RayConstructor = RayConstructor;
|
|
14
|
+
class Ray {
|
|
15
|
+
constructor(startPoint, secondPoint, name) {
|
|
16
|
+
this.startPoint = startPoint;
|
|
17
|
+
this.secondPoint = secondPoint;
|
|
18
|
+
this.name = name ?? `[${startPoint.name}${secondPoint.name})`;
|
|
19
|
+
this.ggbName = name ?? `ray_{${startPoint.name}${secondPoint.name}}`;
|
|
20
|
+
}
|
|
21
|
+
toTex() {
|
|
22
|
+
return this.name;
|
|
23
|
+
}
|
|
24
|
+
toGGBCommands(shouldBuildPoints, { isFixed = true, showLabel = false, showUnderlyingPointsLabel = true, } = {}) {
|
|
25
|
+
const commands = [
|
|
26
|
+
`${this.ggbName}=Ray(${this.startPoint.name},${this.secondPoint.name})`,
|
|
27
|
+
`SetFixed(${this.ggbName},${isFixed ? "true" : "false"})`,
|
|
28
|
+
`ShowLabel(${this.ggbName},${showLabel ? "true" : "false"})`,
|
|
29
|
+
];
|
|
30
|
+
if (shouldBuildPoints) {
|
|
31
|
+
const ACommands = this.startPoint.toGGBCommand({
|
|
32
|
+
isFixed,
|
|
33
|
+
showLabel: showUnderlyingPointsLabel,
|
|
34
|
+
});
|
|
35
|
+
const BCommands = this.secondPoint.toGGBCommand({
|
|
36
|
+
isFixed,
|
|
37
|
+
showLabel: showUnderlyingPointsLabel,
|
|
38
|
+
});
|
|
39
|
+
commands.unshift(...ACommands, ...BCommands);
|
|
40
|
+
}
|
|
41
|
+
return commands;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.Ray = Ray;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ToGGBCommandsProps } from "../../exercises/utils/geogebra/toGGBCommandsProps";
|
|
2
|
+
import { Point } from "./point";
|
|
3
|
+
export declare abstract class SegmentConstructor {
|
|
4
|
+
static random(): Segment;
|
|
5
|
+
}
|
|
6
|
+
export declare class Segment {
|
|
7
|
+
pointA: Point;
|
|
8
|
+
pointB: Point;
|
|
9
|
+
name: string;
|
|
10
|
+
ggbName: string;
|
|
11
|
+
constructor(pointA: Point, pointB: Point);
|
|
12
|
+
getLength(): number;
|
|
13
|
+
toTex(): string;
|
|
14
|
+
toGGBCommands(shouldBuildPoints: boolean, { isFixed, showLabel, showUnderlyingPointsLabel, }?: ToGGBCommandsProps): string[];
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=segment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"segment.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/segment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mDAAmD,CAAC;AAEvF,OAAO,EAAE,KAAK,EAAoB,MAAM,SAAS,CAAC;AAElD,8BAAsB,kBAAkB;IACtC,MAAM,CAAC,MAAM;CAKd;AACD,qBAAa,OAAO;IAClB,MAAM,EAAE,KAAK,CAAC;IACd,MAAM,EAAE,KAAK,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;gBACJ,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK;IAMxC,SAAS;IAGT,KAAK;IAGL,aAAa,CACX,iBAAiB,EAAE,OAAO,EAC1B,EACE,OAAc,EACd,SAAiB,EACjB,yBAAgC,GACjC,GAAE,kBAAuB;CAoB7B"}
|