math-exercises 2.2.68 → 2.2.70

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.
Files changed (210) hide show
  1. package/lib/exercises/math/calcul/arithmetics/divisorsList.d.ts.map +1 -1
  2. package/lib/exercises/math/calcul/arithmetics/divisorsList.js +2 -1
  3. package/lib/exercises/math/calcul/arithmetics/primeNumbers.d.ts.map +1 -1
  4. package/lib/exercises/math/calcul/arithmetics/primeNumbers.js +2 -1
  5. package/lib/exercises/math/calcul/fractions/fractionsOperations.d.ts.map +1 -1
  6. package/lib/exercises/math/calcul/fractions/fractionsOperations.js +1 -0
  7. package/lib/exercises/math/calculLitteral/equation/equationType1Exercise.d.ts.map +1 -1
  8. package/lib/exercises/math/calculLitteral/equation/equationType1Exercise.js +3 -6
  9. package/lib/exercises/math/calculLitteral/equation/equationType2Exercise.d.ts.map +1 -1
  10. package/lib/exercises/math/calculLitteral/equation/equationType2Exercise.js +3 -8
  11. package/lib/exercises/math/calculLitteral/equation/equationType3Exercise.d.ts.map +1 -1
  12. package/lib/exercises/math/calculLitteral/equation/equationType3Exercise.js +7 -9
  13. package/lib/exercises/math/calculLitteral/equation/equationType4Exercise.d.ts.map +1 -1
  14. package/lib/exercises/math/calculLitteral/equation/equationType4Exercise.js +6 -19
  15. package/lib/exercises/math/calculLitteral/factorisation/factoByX.d.ts +8 -0
  16. package/lib/exercises/math/calculLitteral/factorisation/factoByX.d.ts.map +1 -0
  17. package/lib/exercises/math/calculLitteral/factorisation/factoByX.js +146 -0
  18. package/lib/exercises/math/calculLitteral/factorisation/index.d.ts +1 -0
  19. package/lib/exercises/math/calculLitteral/factorisation/index.d.ts.map +1 -1
  20. package/lib/exercises/math/calculLitteral/factorisation/index.js +1 -0
  21. package/lib/exercises/math/functions/absolute/absolueValueAffineEquation.d.ts +9 -0
  22. package/lib/exercises/math/functions/absolute/absolueValueAffineEquation.d.ts.map +1 -0
  23. package/lib/exercises/math/functions/absolute/absolueValueAffineEquation.js +175 -0
  24. package/lib/exercises/math/functions/absolute/index.d.ts +1 -0
  25. package/lib/exercises/math/functions/absolute/index.d.ts.map +1 -1
  26. package/lib/exercises/math/functions/absolute/index.js +1 -0
  27. package/lib/exercises/math/functions/trinoms/coefficientsIdentification.js +3 -3
  28. package/lib/exercises/math/functions/trinoms/findSecondRoot.d.ts +2 -2
  29. package/lib/exercises/math/functions/trinoms/findSecondRoot.d.ts.map +1 -1
  30. package/lib/exercises/math/functions/trinoms/findSecondRoot.js +5 -5
  31. package/lib/exercises/math/functions/trinoms/rootsProduct.d.ts +2 -2
  32. package/lib/exercises/math/functions/trinoms/rootsProduct.d.ts.map +1 -1
  33. package/lib/exercises/math/functions/trinoms/rootsProduct.js +7 -7
  34. package/lib/exercises/math/functions/trinoms/rootsSum.d.ts +2 -2
  35. package/lib/exercises/math/functions/trinoms/rootsSum.d.ts.map +1 -1
  36. package/lib/exercises/math/functions/trinoms/rootsSum.js +9 -10
  37. package/lib/exercises/math/functions/trinoms/trinomSignFromRoots.js +6 -6
  38. package/lib/exercises/math/geometry/areas/rightTriangleArea.d.ts +3 -1
  39. package/lib/exercises/math/geometry/areas/rightTriangleArea.d.ts.map +1 -1
  40. package/lib/exercises/math/geometry/areas/rightTriangleArea.js +10 -22
  41. package/lib/exercises/math/geometry/areas/triangleArea.d.ts +6 -1
  42. package/lib/exercises/math/geometry/areas/triangleArea.d.ts.map +1 -1
  43. package/lib/exercises/math/geometry/areas/triangleArea.js +34 -48
  44. package/lib/exercises/math/geometry/euclidianConstructions/pointImageFromTranslation.d.ts.map +1 -1
  45. package/lib/exercises/math/geometry/euclidianConstructions/pointImageFromTranslation.js +4 -1
  46. package/lib/exercises/math/geometry/index.d.ts +1 -0
  47. package/lib/exercises/math/geometry/index.d.ts.map +1 -1
  48. package/lib/exercises/math/geometry/index.js +1 -0
  49. package/lib/exercises/math/geometry/pythagore/isTriangleRight.d.ts.map +1 -1
  50. package/lib/exercises/math/geometry/pythagore/pythagore.d.ts +0 -3
  51. package/lib/exercises/math/geometry/pythagore/pythagore.d.ts.map +1 -1
  52. package/lib/exercises/math/geometry/pythagore/pythagore.js +19 -25
  53. package/lib/exercises/math/geometry/pythagore/pythagoreCalcul.d.ts +1 -2
  54. package/lib/exercises/math/geometry/pythagore/pythagoreCalcul.d.ts.map +1 -1
  55. package/lib/exercises/math/geometry/pythagore/pythagoreCalcul.js +30 -65
  56. package/lib/exercises/math/geometry/quadrilaterals/index.d.ts +2 -0
  57. package/lib/exercises/math/geometry/quadrilaterals/index.d.ts.map +1 -0
  58. package/lib/exercises/math/geometry/quadrilaterals/index.js +17 -0
  59. package/lib/exercises/math/geometry/quadrilaterals/quadrilateralRecognition.d.ts +14 -0
  60. package/lib/exercises/math/geometry/quadrilaterals/quadrilateralRecognition.d.ts.map +1 -0
  61. package/lib/exercises/math/geometry/quadrilaterals/quadrilateralRecognition.js +221 -0
  62. package/lib/exercises/math/geometry/thales/index.d.ts.map +1 -1
  63. package/lib/exercises/math/geometry/thales/index.js +0 -1
  64. package/lib/exercises/math/geometry/thales/thales.js +2 -2
  65. package/lib/exercises/math/geometry/thales/thalesCalcul.d.ts +3 -4
  66. package/lib/exercises/math/geometry/thales/thalesCalcul.d.ts.map +1 -1
  67. package/lib/exercises/math/geometry/thales/thalesCalcul.js +69 -78
  68. package/lib/exercises/math/geometry/volumes/parallelepipedVolume.d.ts.map +1 -1
  69. package/lib/exercises/math/geometry/volumes/parallelepipedVolume.js +4 -3
  70. package/lib/exercises/math/geometry/volumes/sphereVolume.js +1 -1
  71. package/lib/exercises/math/trigonometry/trigonometry.d.ts +2 -3
  72. package/lib/exercises/math/trigonometry/trigonometry.d.ts.map +1 -1
  73. package/lib/exercises/math/trigonometry/trigonometry.js +32 -31
  74. package/lib/exercises/math/trigonometry/trigonometryAngleCalcul.d.ts +3 -2
  75. package/lib/exercises/math/trigonometry/trigonometryAngleCalcul.d.ts.map +1 -1
  76. package/lib/exercises/math/trigonometry/trigonometryAngleCalcul.js +18 -28
  77. package/lib/exercises/math/trigonometry/trigonometrySideCalcul.d.ts +5 -4
  78. package/lib/exercises/math/trigonometry/trigonometrySideCalcul.d.ts.map +1 -1
  79. package/lib/exercises/math/trigonometry/trigonometrySideCalcul.js +60 -56
  80. package/lib/exercises/pc/index.d.ts +0 -4
  81. package/lib/exercises/pc/index.d.ts.map +1 -1
  82. package/lib/exercises/pc/index.js +6 -4
  83. package/lib/exercises/utils/geogebra/toGGBCommandsProps.d.ts +1 -0
  84. package/lib/exercises/utils/geogebra/toGGBCommandsProps.d.ts.map +1 -1
  85. package/lib/exercises/vea/equationVEA.d.ts +2 -0
  86. package/lib/exercises/vea/equationVEA.d.ts.map +1 -0
  87. package/lib/exercises/vea/equationVEA.js +24 -0
  88. package/lib/exercises/vea/rationalVEA.d.ts.map +1 -1
  89. package/lib/exercises/vea/sqrtVEA.d.ts +6 -0
  90. package/lib/exercises/vea/sqrtVEA.d.ts.map +1 -0
  91. package/lib/exercises/vea/sqrtVEA.js +30 -0
  92. package/lib/geogebra/geogebraConstructor.d.ts +2 -0
  93. package/lib/geogebra/geogebraConstructor.d.ts.map +1 -1
  94. package/lib/geogebra/geogebraConstructor.js +7 -0
  95. package/lib/index.d.ts +31 -46
  96. package/lib/index.d.ts.map +1 -1
  97. package/lib/math/complex/complex.d.ts +1 -1
  98. package/lib/math/geometry/angle.d.ts +26 -0
  99. package/lib/math/geometry/angle.d.ts.map +1 -0
  100. package/lib/math/geometry/angle.js +73 -0
  101. package/lib/math/geometry/line.d.ts +5 -1
  102. package/lib/math/geometry/line.d.ts.map +1 -1
  103. package/lib/math/geometry/line.js +17 -0
  104. package/lib/math/geometry/parallelogram.d.ts +23 -0
  105. package/lib/math/geometry/parallelogram.d.ts.map +1 -0
  106. package/lib/math/geometry/parallelogram.js +70 -0
  107. package/lib/math/geometry/point.d.ts +3 -0
  108. package/lib/math/geometry/point.d.ts.map +1 -1
  109. package/lib/math/geometry/point.js +16 -0
  110. package/lib/math/geometry/quadrilateral.d.ts +15 -0
  111. package/lib/math/geometry/quadrilateral.d.ts.map +1 -0
  112. package/lib/math/geometry/quadrilateral.js +38 -0
  113. package/lib/math/geometry/rectangle.d.ts +24 -0
  114. package/lib/math/geometry/rectangle.d.ts.map +1 -0
  115. package/lib/math/geometry/rectangle.js +64 -0
  116. package/lib/math/geometry/rhombus.d.ts +19 -0
  117. package/lib/math/geometry/rhombus.d.ts.map +1 -0
  118. package/lib/math/geometry/rhombus.js +46 -0
  119. package/lib/math/geometry/rightTriangle.d.ts +31 -0
  120. package/lib/math/geometry/rightTriangle.d.ts.map +1 -0
  121. package/lib/math/geometry/rightTriangle.js +113 -0
  122. package/lib/math/geometry/segment.d.ts +24 -6
  123. package/lib/math/geometry/segment.d.ts.map +1 -1
  124. package/lib/math/geometry/segment.js +70 -4
  125. package/lib/math/geometry/square.d.ts +22 -0
  126. package/lib/math/geometry/square.d.ts.map +1 -0
  127. package/lib/math/geometry/square.js +43 -0
  128. package/lib/math/geometry/triangle.d.ts +45 -45
  129. package/lib/math/geometry/triangle.d.ts.map +1 -1
  130. package/lib/math/geometry/triangle.js +159 -186
  131. package/lib/math/geometry/vector.d.ts +2 -2
  132. package/lib/math/geometry/vector.d.ts.map +1 -1
  133. package/lib/math/geometry/vector.js +18 -9
  134. package/lib/math/numbers/nombre.d.ts +5 -0
  135. package/lib/math/numbers/nombre.d.ts.map +1 -1
  136. package/lib/math/numbers/nombre.js +12 -0
  137. package/lib/math/numbers/rationals/rational.d.ts +1 -1
  138. package/lib/math/numbers/reals/extendedRingElement.d.ts +1 -1
  139. package/lib/math/numbers/reals/real.d.ts.map +1 -1
  140. package/lib/math/numbers/reals/real.js +3 -0
  141. package/lib/math/polynomials/generalAffine.d.ts +13 -0
  142. package/lib/math/polynomials/generalAffine.d.ts.map +1 -1
  143. package/lib/math/polynomials/generalAffine.js +25 -1
  144. package/lib/math/polynomials/polynomial.d.ts +1 -1
  145. package/lib/math/polynomials/trinom.d.ts +2 -2
  146. package/lib/math/utils/geometry/pythagoricianTriplets.d.ts +1 -0
  147. package/lib/math/utils/geometry/pythagoricianTriplets.d.ts.map +1 -1
  148. package/lib/math/utils/geometry/pythagoricianTriplets.js +14 -1
  149. package/lib/math/utils/random/randfloat.d.ts +1 -1
  150. package/lib/math/utils/random/randfloat.d.ts.map +1 -1
  151. package/lib/math/utils/random/randfloat.js +8 -1
  152. package/lib/math/utils/random/randint.d.ts +8 -1
  153. package/lib/math/utils/random/randint.d.ts.map +1 -1
  154. package/lib/math/utils/random/randint.js +6 -1
  155. package/lib/playground.d.ts.map +1 -1
  156. package/lib/tree/nodes/functions/absNode.d.ts +2 -1
  157. package/lib/tree/nodes/functions/absNode.d.ts.map +1 -1
  158. package/lib/tree/nodes/functions/absNode.js +6 -1
  159. package/lib/tree/nodes/functions/functionNode.d.ts +2 -2
  160. package/lib/tree/nodes/functions/functionNode.d.ts.map +1 -1
  161. package/lib/tree/nodes/functions/oppositeNode.d.ts +5 -5
  162. package/lib/tree/nodes/functions/oppositeNode.d.ts.map +1 -1
  163. package/lib/tree/nodes/node.d.ts +3 -1
  164. package/lib/tree/nodes/node.d.ts.map +1 -1
  165. package/lib/tree/nodes/node.js +1 -0
  166. package/lib/tree/nodes/nodeConstructor.d.ts +3 -0
  167. package/lib/tree/nodes/nodeConstructor.d.ts.map +1 -1
  168. package/lib/tree/nodes/nodeConstructor.js +9 -1
  169. package/lib/tree/nodes/numbers/numberNode.d.ts +2 -0
  170. package/lib/tree/nodes/numbers/numberNode.d.ts.map +1 -1
  171. package/lib/tree/nodes/numbers/numberNode.js +6 -1
  172. package/lib/tree/nodes/operators/addNode.d.ts.map +1 -1
  173. package/lib/tree/nodes/operators/addNode.js +2 -1
  174. package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
  175. package/lib/tree/nodes/operators/fractionNode.js +6 -1
  176. package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
  177. package/lib/tree/nodes/operators/multiplyNode.js +3 -3
  178. package/lib/tree/nodes/polynomials/trinomNode.d.ts +70 -0
  179. package/lib/tree/nodes/polynomials/trinomNode.d.ts.map +1 -0
  180. package/lib/tree/nodes/polynomials/trinomNode.js +156 -0
  181. package/lib/tree/nodes/variables/variableNode.d.ts.map +1 -1
  182. package/lib/tree/nodes/variables/variableNode.js +1 -1
  183. package/lib/tree/parsers/affineParser.d.ts.map +1 -1
  184. package/lib/tree/parsers/affineParser.js +1 -0
  185. package/lib/tree/parsers/discreteSetParser.d.ts +3 -0
  186. package/lib/tree/parsers/discreteSetParser.d.ts.map +1 -0
  187. package/lib/tree/parsers/discreteSetParser.js +23 -0
  188. package/lib/tree/parsers/equationSolutionParser.d.ts +1 -1
  189. package/lib/tree/parsers/equationSolutionParser.d.ts.map +1 -1
  190. package/lib/tree/parsers/equationSolutionParser.js +15 -4
  191. package/lib/tree/parsers/latexParser.d.ts +5 -1
  192. package/lib/tree/parsers/latexParser.d.ts.map +1 -1
  193. package/lib/tree/parsers/latexParser.js +17 -3
  194. package/lib/tree/parsers/monomParser.js +2 -2
  195. package/lib/tree/parsers/powerParser.d.ts +1 -1
  196. package/lib/tree/parsers/rationalParser.d.ts +1 -1
  197. package/lib/tree/parsers/rationalParser.d.ts.map +1 -1
  198. package/lib/tree/parsers/rationalParser.js +29 -24
  199. package/lib/tree/parsers/sqrtParser.d.ts +9 -0
  200. package/lib/tree/parsers/sqrtParser.d.ts.map +1 -0
  201. package/lib/tree/parsers/sqrtParser.js +52 -0
  202. package/lib/tree/parsers/trinomParser.d.ts +1 -1
  203. package/lib/tree/parsers/trinomParser.d.ts.map +1 -1
  204. package/lib/tree/parsers/trinomParser.js +14 -2
  205. package/lib/tree/utilities/functionComposition.d.ts +1 -1
  206. package/lib/tree/utilities/functionComposition.d.ts.map +1 -1
  207. package/lib/utils/arrays/rotation.d.ts +8 -0
  208. package/lib/utils/arrays/rotation.d.ts.map +1 -0
  209. package/lib/utils/arrays/rotation.js +17 -0
  210. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"pythagoreCalcul.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/pythagore/pythagoreCalcul.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAEL,mBAAmB,EACpB,MAAM,8BAA8B,CAAC;AAUtC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,mBAAmB,EAAE,mBAAmB,CAAC;CAC1C,CAAC;AAoGF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAcjD,CAAC"}
1
+ {"version":3,"file":"pythagoreCalcul.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/pythagore/pythagoreCalcul.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAQT,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAEL,mBAAmB,EACpB,MAAM,8BAA8B,CAAC;AAiBtC,KAAK,WAAW,GAAG;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,mBAAmB,EAAE,mBAAmB,CAAC;CAC1C,CAAC;AA+EF,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,WAAW,CAcjD,CAAC"}
@@ -4,95 +4,60 @@ exports.pythagoreCalcul = void 0;
4
4
  const exercise_1 = require("../../../../exercises/exercise");
5
5
  const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
6
6
  const geogebraConstructor_1 = require("../../../../geogebra/geogebraConstructor");
7
- const triangle_1 = require("../../../../math/geometry/triangle");
8
- const real_1 = require("../../../../math/numbers/reals/real");
9
- const randint_1 = require("../../../../math/utils/random/randint");
10
- const sqrtNode_1 = require("../../../../tree/nodes/functions/sqrtNode");
11
- const numberNode_1 = require("../../../../tree/nodes/numbers/numberNode");
12
- const coinFlip_1 = require("../../../../utils/alea/coinFlip");
13
- const isInt_1 = require("../../../../utils/isInt");
14
7
  const shuffle_1 = require("../../../../utils/alea/shuffle");
8
+ const random_1 = require("../../../../utils/alea/random");
9
+ const rightTriangle_1 = require("../../../../math/geometry/rightTriangle");
10
+ const sqrtVEA_1 = require("../../../../exercises/vea/sqrtVEA");
11
+ const powerNode_1 = require("../../../../tree/nodes/operators/powerNode");
12
+ const randfloat_1 = require("../../../../math/utils/random/randfloat");
13
+ const round_1 = require("../../../../math/utils/round");
15
14
  const getPythagoreCalcul = () => {
16
- const vertices = [];
17
- const code = 65 + (0, randint_1.randint)(0, 24); // Générer un code de caractère majuscule aléatoire (A-Z)
18
- for (let i = 0; i < 3; i++)
19
- vertices.push(String.fromCharCode(code + i));
20
- const triangle = triangle_1.TriangleConstructor.createRandomRightTriangle({
21
- minRapport: 0.7,
22
- maxRapport: 1.3,
23
- names: vertices,
15
+ const triangle = rightTriangle_1.RightTriangleConstructor.randomNiceSides({
16
+ randomName: true,
24
17
  });
25
- const sides = [
26
- triangle.getSideCName(),
27
- triangle.getSideBName(),
28
- triangle.getSideAName(),
29
- ];
30
- const sideLengths = [
31
- triangle.getSideCnumber(),
32
- triangle.getSideBnumber(),
33
- triangle.getSideAnumber(),
34
- ].map((el) => Math.round(el / 2));
35
- const zeroOrOne = (0, shuffle_1.shuffle)([0, 1]);
36
- const randoms = (0, coinFlip_1.coinFlip)() ? [...zeroOrOne, 2] : [2, ...zeroOrOne];
37
- // le but est d'avoir une chance sur 2 d'avoir un hépoténus et une 1 chance sur 2 d'avoir un a des 2 autres cote
38
- let answer;
39
- let square;
40
- if (randoms[2] === 2) {
41
- // cas de l'hypoténus
42
- square = sideLengths[0] ** 2 + sideLengths[1] ** 2;
43
- }
44
- else {
45
- // les deux autres cotés
46
- square = sideLengths[randoms[0]] ** 2 - sideLengths[randoms[1]] ** 2;
47
- }
48
- const sqrt = Math.sqrt(square);
49
- answer = (0, isInt_1.isInt)(sqrt) ? sqrt + "" : `\\sqrt{${square}}`;
50
- const commands = [
51
- ...triangle.generateCommands({
52
- showLabels: [...sides, sides[randoms[2]]],
53
- setCaptions: [...sideLengths.map((el) => el + ""), "?"],
54
- highlightedSide: sides[randoms[2]],
55
- }),
56
- ];
18
+ //une chance sur deux d'avoir hypoténuse
19
+ const sideIndexAsked = (0, random_1.random)([0, (0, random_1.random)([1, 2])]);
20
+ const answer = triangle.sides[sideIndexAsked].getLengthNode().toTex();
21
+ triangle.showSidesLength([sideIndexAsked]);
22
+ const commands = [...triangle.commands];
57
23
  const ggb = new geogebraConstructor_1.GeogebraConstructor({
58
24
  commands,
59
25
  hideAxes: true,
60
26
  hideGrid: true,
61
27
  });
62
28
  const triangleIdentifiers = triangle.toIdentifiers();
63
- answer = answer + "";
64
29
  const question = {
65
- instruction: `Dans le triangle $${triangle.getTriangleName()}$ rectangle en $${triangle.getRightAngle()}$, on sait que $${sides[randoms[0]]} = ${sideLengths[randoms[0]]}$ et que $${sides[randoms[1]]} = ${sideLengths[randoms[1]]}$. Calculer la longueur exacte $${sides[randoms[2]]}$.`,
30
+ instruction: `Dans le triangle $${triangle.name}$ rectangle en $${triangle.points[0].name}$, on sait que $${triangle.sides[(sideIndexAsked + 1) % 3].toLengthTex()}$ et que $${triangle.sides[(sideIndexAsked + 2) % 3].toLengthTex()}$.
31
+
32
+ Calculer la longueur exacte $${triangle.sides[sideIndexAsked].toInsideName()}$.`,
66
33
  answer,
67
- keys: [...vertices, "equal"],
34
+ keys: [],
68
35
  ggbOptions: ggb.getOptions({
69
36
  coords: triangle.generateCoords(),
70
37
  }),
71
38
  answerFormat: "tex",
72
- identifiers: { square, sideLengths, triangleIdentifiers },
39
+ identifiers: { sideAsked: sideIndexAsked, triangleIdentifiers },
73
40
  };
74
41
  return question;
75
42
  };
76
- const getPropositions = (n, { answer }) => {
43
+ const getPropositions = (n, { answer, triangleIdentifiers, sideAsked }) => {
77
44
  const propositions = [];
78
45
  (0, exercise_1.addValidProp)(propositions, answer);
46
+ const triangle = rightTriangle_1.RightTriangleConstructor.fromIdentifiers(triangleIdentifiers);
47
+ const lengths = triangle.sides.map((s) => s.getLength());
48
+ //erreur d'oubli de la racine
49
+ (0, exercise_1.tryToAddWrongProp)(propositions, (0, powerNode_1.square)(answer.unfrenchify()).simplify().toTex());
50
+ if (sideAsked !== 0) {
51
+ //erreur d'application a^2+b^2 = c^2 alors qu'on cherche pas l'hypo
52
+ (0, exercise_1.tryToAddWrongProp)(propositions, (0, round_1.round)(Math.sqrt(lengths[0] ** 2 + lengths[3 - sideAsked] ** 2), 1).frenchify());
53
+ }
79
54
  while (propositions.length < n) {
80
- const temp = (0, randint_1.randint)(2, 300);
81
- const squareRoot = new real_1.SquareRoot(temp);
82
- const wrongAnswer = Math.sqrt(temp) === Math.floor(Math.sqrt(temp))
83
- ? Math.sqrt(temp).toString()
84
- : squareRoot.toTree().toTex();
85
- (0, exercise_1.tryToAddWrongProp)(propositions, wrongAnswer);
55
+ (0, exercise_1.tryToAddWrongProp)(propositions, (0, randfloat_1.randfloat)(1, 100, 1).frenchify());
86
56
  }
87
57
  return (0, shuffle_1.shuffle)(propositions);
88
58
  };
89
- const isAnswerValid = (ans, { square }) => {
90
- const sqrt = Math.sqrt(square);
91
- const answer = (0, isInt_1.isInt)(sqrt)
92
- ? new numberNode_1.NumberNode(sqrt)
93
- : new sqrtNode_1.SqrtNode(new numberNode_1.NumberNode(square), { allowSimplifySqrt: true });
94
- const texs = answer.toAllValidTexs();
95
- return texs.includes(ans);
59
+ const isAnswerValid = (ans, { answer, sideAsked, triangleIdentifiers }) => {
60
+ return (0, sqrtVEA_1.sqrtVEA)(ans, answer);
96
61
  };
97
62
  exports.pythagoreCalcul = {
98
63
  id: "pythagoreCalcul",
@@ -0,0 +1,2 @@
1
+ export * from "./quadrilateralRecognition";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/quadrilaterals/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./quadrilateralRecognition"), exports);
@@ -0,0 +1,14 @@
1
+ import { Exercise } from "../../../../exercises/exercise";
2
+ import { ParallelogramIdentifiers } from "../../../../math/geometry/parallelogram";
3
+ import { RectangleIdentifiers } from "../../../../math/geometry/rectangle";
4
+ import { RhombusIdentifiers } from "../../../../math/geometry/rhombus";
5
+ import { SquareIdentifiers } from "../../../../math/geometry/square";
6
+ type Identifiers = {
7
+ shape: string;
8
+ showDiagonals: boolean;
9
+ drawAngles: boolean;
10
+ shapeIdentifiers: RectangleIdentifiers | SquareIdentifiers | RhombusIdentifiers | ParallelogramIdentifiers;
11
+ };
12
+ export declare const quadrilateralRecognition: Exercise<Identifiers>;
13
+ export {};
14
+ //# sourceMappingURL=quadrilateralRecognition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quadrilateralRecognition.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/quadrilaterals/quadrilateralRecognition.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAEL,wBAAwB,EACzB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAEL,oBAAoB,EACrB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAGL,kBAAkB,EACnB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,iBAAiB,EAClB,MAAM,4BAA4B,CAAC;AAIpC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,OAAO,CAAC;IACvB,UAAU,EAAE,OAAO,CAAC;IACpB,gBAAgB,EACZ,oBAAoB,GACpB,iBAAiB,GACjB,kBAAkB,GAClB,wBAAwB,CAAC;CAC9B,CAAC;AA0MF,eAAO,MAAM,wBAAwB,EAAE,QAAQ,CAAC,WAAW,CAoB1D,CAAC"}
@@ -0,0 +1,221 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.quadrilateralRecognition = void 0;
4
+ const exercise_1 = require("../../../../exercises/exercise");
5
+ const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
6
+ const geogebraConstructor_1 = require("../../../../geogebra/geogebraConstructor");
7
+ const parallelogram_1 = require("../../../../math/geometry/parallelogram");
8
+ const rectangle_1 = require("../../../../math/geometry/rectangle");
9
+ const rhombus_1 = require("../../../../math/geometry/rhombus");
10
+ const square_1 = require("../../../../math/geometry/square");
11
+ const coinFlip_1 = require("../../../../utils/alea/coinFlip");
12
+ const random_1 = require("../../../../utils/alea/random");
13
+ const getPropositions = (n, { answer }) => {
14
+ const propositions = [];
15
+ (0, exercise_1.addValidProp)(propositions, answer, "raw");
16
+ (0, exercise_1.tryToAddWrongProp)(propositions, "Un rectangle", "raw");
17
+ (0, exercise_1.tryToAddWrongProp)(propositions, "Un carré", "raw");
18
+ (0, exercise_1.tryToAddWrongProp)(propositions, "Un losange", "raw");
19
+ (0, exercise_1.tryToAddWrongProp)(propositions, "Un parallélogramme", "raw");
20
+ return (0, exercise_1.shuffleProps)(propositions, n);
21
+ };
22
+ const getAnswer = (identifiers) => {
23
+ switch (identifiers.shape) {
24
+ case "rectangle":
25
+ return "Un rectangle";
26
+ case "rhombus":
27
+ return "Un losange";
28
+ case "square":
29
+ return "Un carré";
30
+ case "parallelogram":
31
+ default:
32
+ return "Un parallélogramme";
33
+ }
34
+ };
35
+ const getInstruction = (identifiers) => {
36
+ return "Quelle est la nature du quadrilatère ci-dessous ? Donner la réponse la plus précise possible. ";
37
+ };
38
+ const getHint = (identifiers) => {
39
+ const { shape, showDiagonals, drawAngles } = identifiers;
40
+ switch (shape) {
41
+ case "rectangle":
42
+ if (showDiagonals) {
43
+ return "Les diagonales de $ABCD$ sont de même longueur et se coupent en leur milieu.";
44
+ }
45
+ else {
46
+ if (drawAngles) {
47
+ return "$ABCD$ est un quadrilatère avec $4$ angles droits.";
48
+ }
49
+ return "$ABCD$ possède un angle droit, et ses côtés sont égaux deux à deux.";
50
+ }
51
+ case "rhombus":
52
+ if (showDiagonals) {
53
+ return "Les diagonales de $ABCD$ sont perpendiculaires et se coupent en leur milieu.";
54
+ }
55
+ else {
56
+ return "$ABCD$ possède quatre côtés égaux.";
57
+ }
58
+ case "square":
59
+ if (showDiagonals) {
60
+ return "Les diagonales de $ABCD$ sont de même longueur, sont perpendiculaires et se coupent en leur milieu.";
61
+ }
62
+ else {
63
+ return "$ABCD$ est un quadrilatère avec $4$ angles droits et $4$ côtés égaux.";
64
+ }
65
+ case "parallelogram":
66
+ default:
67
+ if (showDiagonals) {
68
+ return "Les diagonales de $ABCD$ se coupent en leur milieu.";
69
+ }
70
+ else {
71
+ return "Les côtés de $ABCD$ sont égaux deux à deux.";
72
+ }
73
+ }
74
+ };
75
+ const getCorrection = (identifiers) => {
76
+ const { shape, showDiagonals, drawAngles } = identifiers;
77
+ switch (shape) {
78
+ case "rectangle":
79
+ if (showDiagonals) {
80
+ return "Les diagonales de $ABCD$ sont de même longueur et se coupent en leur milieu. Donc, $ABCD$ est un rectangle.";
81
+ }
82
+ else {
83
+ if (drawAngles) {
84
+ return "$ABCD$ est un quadrilatère avec $4$ angles droits : c'est donc un rectangle.";
85
+ }
86
+ return "$ABCD$ possède un angle droit, et ses côtés sont égaux deux à deux. Donc, $ABCD$ est un rectangle.";
87
+ }
88
+ case "rhombus":
89
+ if (showDiagonals) {
90
+ return "Les diagonales de $ABCD$ sont perpendiculaires et se coupent en leur milieu. Donc, $ABCD$ est un losange.";
91
+ }
92
+ else {
93
+ return "$ABCD$ possède quatre côtés égaux. Donc, $ABCD$ est un losange.";
94
+ }
95
+ case "square":
96
+ if (showDiagonals) {
97
+ return "Les diagonales de $ABCD$ sont de même longueur, sont perpendiculaires et se coupent en leur milieu. Donc, $ABCD$ est un carré.";
98
+ }
99
+ else {
100
+ return "$ABCD$ est un quadrilatère avec $4$ angles droits et $4$ côtés égaux : c'est donc un carré.";
101
+ }
102
+ case "parallelogram":
103
+ default:
104
+ if (showDiagonals) {
105
+ return "Les diagonales de $ABCD$ se coupent en leur milieu. Donc, $ABCD$ est un parallélogramme.";
106
+ }
107
+ else {
108
+ return "Les côtés de $ABCD$ sont égaux deux à deux. Donc, $ABCD$ est un parallélogramme.";
109
+ }
110
+ }
111
+ };
112
+ const getGGBOptions = (identifiers) => {
113
+ const { shape, showDiagonals, drawAngles } = identifiers;
114
+ let shapeObject;
115
+ switch (shape) {
116
+ case "rectangle":
117
+ shapeObject = rectangle_1.RectangleConstructor.fromIdentifiers(identifiers.shapeIdentifiers);
118
+ if (showDiagonals)
119
+ shapeObject.drawDiagonals({ drawCenter: true, drawDecorations: true });
120
+ else
121
+ shapeObject.drawSidesDecoration({
122
+ drawAngles: drawAngles,
123
+ drawSidesLengths: !drawAngles,
124
+ });
125
+ break;
126
+ case "square":
127
+ shapeObject = square_1.SquareConstructor.fromIdentifiers(identifiers.shapeIdentifiers);
128
+ if (showDiagonals)
129
+ shapeObject.drawDiagonals({ drawCenter: true, drawDecorations: true });
130
+ else
131
+ shapeObject.drawSidesDecoration({
132
+ drawAngles,
133
+ drawSidesLengths: !drawAngles,
134
+ });
135
+ break;
136
+ case "parallelogram":
137
+ shapeObject = parallelogram_1.ParallelogramConstructor.fromIdentifiers(identifiers.shapeIdentifiers);
138
+ if (showDiagonals)
139
+ shapeObject.drawDiagonals({
140
+ drawCenter: true,
141
+ drawDecorations: true,
142
+ });
143
+ else
144
+ shapeObject.drawSidesDecoration({});
145
+ break;
146
+ case "rhombus":
147
+ default:
148
+ shapeObject = rhombus_1.RhombusConstructor.fromIdentifiers(identifiers.shapeIdentifiers);
149
+ if (showDiagonals)
150
+ shapeObject.drawDiagonals({ drawCenter: true, drawDecorations: true });
151
+ else
152
+ shapeObject.drawSidesDecoration();
153
+ }
154
+ const cmds = shapeObject.toGGBCommands();
155
+ const ggb = new geogebraConstructor_1.GeogebraConstructor({ hideAxes: true, hideGrid: true });
156
+ ggb.commands = cmds;
157
+ return ggb.getOptions({ coords: [-10, 10, -10, 10] });
158
+ };
159
+ const getKeys = (identifiers) => {
160
+ return [];
161
+ };
162
+ const isAnswerValid = (ans, { answer }) => {
163
+ throw Error("VEA not implemented");
164
+ };
165
+ const getQuadrilateralRecognitionQuestion = (opts) => {
166
+ const shape = (0, random_1.random)(["rectangle", "rhombus", "parallelogram", "square"]);
167
+ let shapeObject;
168
+ switch (shape) {
169
+ case "rectangle":
170
+ shapeObject = rectangle_1.RectangleConstructor.random();
171
+ break;
172
+ case "square":
173
+ shapeObject = square_1.SquareConstructor.random();
174
+ break;
175
+ case "parallelogram":
176
+ shapeObject = parallelogram_1.ParallelogramConstructor.random();
177
+ break;
178
+ case "rhombus":
179
+ default:
180
+ shapeObject = rhombus_1.RhombusConstructor.random();
181
+ }
182
+ const showDiagonals = (0, coinFlip_1.coinFlip)();
183
+ const drawAngles = (0, coinFlip_1.coinFlip)();
184
+ const identifiers = {
185
+ showDiagonals,
186
+ drawAngles,
187
+ shape,
188
+ shapeIdentifiers: shapeObject.toIdentifiers(),
189
+ };
190
+ const question = {
191
+ answer: getAnswer(identifiers),
192
+ instruction: getInstruction(identifiers),
193
+ keys: getKeys(identifiers),
194
+ answerFormat: "raw",
195
+ identifiers,
196
+ hint: getHint(identifiers),
197
+ correction: getCorrection(identifiers),
198
+ ggbOptions: getGGBOptions(identifiers),
199
+ };
200
+ return question;
201
+ };
202
+ exports.quadrilateralRecognition = {
203
+ id: "quadrilateralRecognition",
204
+ connector: "=",
205
+ label: "Reconnaître un quadrilatère",
206
+ isSingleStep: true,
207
+ generator: (nb, opts) => (0, getDistinctQuestions_1.getDistinctQuestions)(() => getQuadrilateralRecognitionQuestion(opts), nb),
208
+ qcmTimer: 60,
209
+ freeTimer: 60,
210
+ getPropositions,
211
+ isAnswerValid,
212
+ subject: "Mathématiques",
213
+ getHint,
214
+ getCorrection,
215
+ getInstruction,
216
+ getAnswer,
217
+ getGGBOptions,
218
+ answerType: "QCU",
219
+ hasGeogebra: true,
220
+ hasHintAndCorrection: true,
221
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/thales/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AAEzB,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/thales/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC"}
@@ -15,5 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./thales"), exports);
18
- // export * from "./thalesCalculOld";
19
18
  __exportStar(require("./thalesCalcul"), exports);
@@ -92,8 +92,8 @@ const getPropositions = (n, { answer, vertices }) => {
92
92
  const indexRange = Array.from({ length: 8 }, (_, i) => i);
93
93
  while (propositions.length < n) {
94
94
  const rands = (0, shuffle_1.shuffle)(indexRange).slice(0, 6);
95
- (0, exercise_1.tryToAddWrongProp)(propositions, `\\frac{${wrongQuotients[rands[0]]}}{${wrongQuotients[rands[1]]}} =
96
- \\frac{${wrongQuotients[rands[2]]}}{${wrongQuotients[rands[3]]}} =
95
+ (0, exercise_1.tryToAddWrongProp)(propositions, `\\frac{${wrongQuotients[rands[0]]}}{${wrongQuotients[rands[1]]}} =
96
+ \\frac{${wrongQuotients[rands[2]]}}{${wrongQuotients[rands[3]]}} =
97
97
  \\frac{${wrongQuotients[rands[4]]}}{${wrongQuotients[rands[5]]}}`);
98
98
  }
99
99
  return (0, shuffle_1.shuffle)(propositions);
@@ -1,11 +1,10 @@
1
1
  import { Exercise } from "../../../../exercises/exercise";
2
- import { PointIdentifiers } from "../../../../math/geometry/point";
3
- import { SegmentIdentifiers } from "../../../../math/geometry/segment";
4
2
  import { TriangleIdentifiers } from "../../../../math/geometry/triangle";
5
3
  type Identifiers = {
4
+ ratio: number;
6
5
  triangleIdentifiers: TriangleIdentifiers;
7
- insidePointsIdentifiers: PointIdentifiers[];
8
- segmentAsked: SegmentIdentifiers;
6
+ insidePointsNames: string[];
7
+ segmentAskedName: string;
9
8
  isPapillon: boolean;
10
9
  };
11
10
  type Options = {
@@ -1 +1 @@
1
- {"version":3,"file":"thalesCalcul.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/thales/thalesCalcul.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAqBT,MAAM,0BAA0B,CAAC;AASlC,OAAO,EAAoB,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAGL,kBAAkB,EACnB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAGL,mBAAmB,EACpB,MAAM,8BAA8B,CAAC;AAUtC,KAAK,WAAW,GAAG;IACjB,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,uBAAuB,EAAE,gBAAgB,EAAE,CAAC;IAC5C,YAAY,EAAE,kBAAkB,CAAC;IACjC,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAsKF,KAAK,OAAO,GAAG;IACb,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAmEF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAwBvD,CAAC"}
1
+ {"version":3,"file":"thalesCalcul.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/thales/thalesCalcul.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAqBT,MAAM,0BAA0B,CAAC;AAMlC,OAAO,EAGL,mBAAmB,EACpB,MAAM,8BAA8B,CAAC;AAQtC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAqJF,KAAK,OAAO,GAAG;IACb,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AA8DF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAwBvD,CAAC"}
@@ -5,18 +5,25 @@ const exercise_1 = require("../../../../exercises/exercise");
5
5
  const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
6
6
  const numberVEA_1 = require("../../../../exercises/vea/numberVEA");
7
7
  const geogebraConstructor_1 = require("../../../../geogebra/geogebraConstructor");
8
- const line_1 = require("../../../../math/geometry/line");
9
- const point_1 = require("../../../../math/geometry/point");
10
8
  const segment_1 = require("../../../../math/geometry/segment");
11
9
  const triangle_1 = require("../../../../math/geometry/triangle");
10
+ const vector_1 = require("../../../../math/geometry/vector");
12
11
  const randfloat_1 = require("../../../../math/utils/random/randfloat");
13
- const randint_1 = require("../../../../math/utils/random/randint");
14
12
  const round_1 = require("../../../../math/utils/round");
15
- const fractionNode_1 = require("../../../../tree/nodes/operators/fractionNode");
16
- const multiplyNode_1 = require("../../../../tree/nodes/operators/multiplyNode");
17
13
  const coinFlip_1 = require("../../../../utils/alea/coinFlip");
18
14
  const random_1 = require("../../../../utils/alea/random");
19
15
  const randomLetter_1 = require("../../../../utils/strings/randomLetter");
16
+ const getSubTriangle = ({ triangle, insidePointsNames, ratio, isPapillon, }) => {
17
+ const [A, B, C] = triangle.points;
18
+ const [dName, eName] = insidePointsNames;
19
+ const vecAC = vector_1.VectorConstructor.fromPoints(A, C).times((1 - ratio).toTree());
20
+ const pointD = vecAC.getEndPoint(A, dName);
21
+ const vecBC = vector_1.VectorConstructor.fromPoints(B, C).times((1 - ratio).toTree());
22
+ const pointE = vecBC.getEndPoint(B, eName);
23
+ return new triangle_1.Triangle([pointD, pointE, triangle.points[2]], {
24
+ sidesLengths: triangle.sides.map((s) => (0, round_1.round)(s.getLength() * Math.abs(ratio), 2).toTree()),
25
+ });
26
+ };
20
27
  const getPropositions = (n, { answer }) => {
21
28
  const propositions = [];
22
29
  (0, exercise_1.addValidProp)(propositions, answer);
@@ -27,66 +34,41 @@ const getPropositions = (n, { answer }) => {
27
34
  };
28
35
  const getAnswer = (identifiers) => {
29
36
  const triangle = triangle_1.TriangleConstructor.fromIdentifiers(identifiers.triangleIdentifiers);
30
- const pointD = point_1.PointConstructor.fromIdentifiers(identifiers.insidePointsIdentifiers[0]);
31
- const pointE = point_1.PointConstructor.fromIdentifiers(identifiers.insidePointsIdentifiers[1]);
32
- //order is important
33
- const subTriangle = new triangle_1.Triangle(pointD, triangle.vertexB, pointE);
34
- const segmentAskedName = segment_1.SegmentConstructor.fromIdentifiers(identifiers.segmentAsked).toInsideName();
35
- const lengths = [
36
- ...triangle.getSegments().map((s) => {
37
- return {
38
- name: s.toInsideName(),
39
- length: (0, round_1.round)(s.getLength(), 1),
40
- };
41
- }),
42
- ...subTriangle.getSegments().map((s) => {
43
- return {
44
- name: s.toInsideName(),
45
- length: (0, round_1.round)(s.getLength(), 1),
46
- };
47
- }),
48
- ];
49
- const askedIndex = lengths.findIndex((l) => l.name === segmentAskedName);
50
- const otherIndex = (0, randint_1.randint)(0, 3, [askedIndex]);
51
- const ratio = (0, fractionNode_1.frac)(lengths[otherIndex].length, lengths[otherIndex + 3].length);
52
- if (askedIndex > 2) {
53
- return (0, round_1.round)((0, fractionNode_1.frac)(lengths[askedIndex - 3].length, ratio).evaluate(), 1).frenchify();
54
- }
55
- else {
56
- return (0, round_1.round)((0, multiplyNode_1.multiply)(ratio, lengths[askedIndex + 3].length).evaluate(), 1).frenchify();
37
+ let segment = triangle.sides.find((s) => s.name === identifiers.segmentAskedName);
38
+ if (segment) {
39
+ return segment.getLength().frenchify();
57
40
  }
41
+ const subTriangle = getSubTriangle({
42
+ triangle,
43
+ insidePointsNames: identifiers.insidePointsNames,
44
+ ratio: identifiers.ratio,
45
+ isPapillon: identifiers.isPapillon,
46
+ });
47
+ segment = subTriangle.sides.find((s) => s.name === identifiers.segmentAskedName);
48
+ if (!segment)
49
+ throw Error("Question poorly built");
50
+ return segment.getLength().frenchify();
58
51
  };
59
52
  const getInstruction = (identifiers) => {
60
53
  const triangle = triangle_1.TriangleConstructor.fromIdentifiers(identifiers.triangleIdentifiers);
61
- const pointD = point_1.PointConstructor.fromIdentifiers(identifiers.insidePointsIdentifiers[0]);
62
- const pointE = point_1.PointConstructor.fromIdentifiers(identifiers.insidePointsIdentifiers[1]);
63
- const subTriangle = new triangle_1.Triangle(pointD, triangle.vertexB, pointE);
64
- const oppositeSegment = triangle.getSideBName();
65
- const insideSegmentName = identifiers.insidePointsIdentifiers[0].name +
66
- identifiers.insidePointsIdentifiers[1].name;
67
- const segmentAskedName = segment_1.SegmentConstructor.fromIdentifiers(identifiers.segmentAsked).toInsideName();
68
- const lengths = [
69
- ...triangle.getSegments().map((s) => {
70
- return {
71
- name: s.toInsideName(),
72
- length: (0, round_1.round)(s.getLength(), 1).frenchify(),
73
- };
74
- }),
75
- ...subTriangle.getSegments().map((s) => {
76
- return {
77
- name: s.toInsideName(),
78
- length: (0, round_1.round)(s.getLength(), 1).frenchify(),
79
- };
80
- }),
81
- ];
82
- return `Dans le triangle $${triangle.getTriangleName()}$ ci-dessous, les droites $\\left(${insideSegmentName}\\right)$ et $\\left(${oppositeSegment}\\right)$ sont parallèles.
83
-
84
- On sait de plus que : ${lengths
54
+ const ratio = identifiers.ratio;
55
+ const subTriangle = getSubTriangle({
56
+ triangle,
57
+ insidePointsNames: identifiers.insidePointsNames,
58
+ ratio,
59
+ isPapillon: identifiers.isPapillon,
60
+ });
61
+ const oppositeSegment = triangle.sides[2].toInsideName();
62
+ const segmentAskedName = identifiers.segmentAskedName;
63
+ const allSides = [...triangle.sides, ...subTriangle.sides];
64
+ return `Dans le triangle $${triangle.name}$ ci-dessous, les droites $\\left(${subTriangle.sides[2].toInsideName()}\\right)$ et $\\left(${oppositeSegment}\\right)$ sont parallèles.
65
+
66
+ On sait de plus que : ${allSides
85
67
  .filter((e) => e.name !== segmentAskedName)
86
- .map((e) => `$${e.name}=${e.length}$`)
68
+ .map((e) => `$${e.toLengthTex()}$`)
87
69
  .join(" , ")}.
88
70
 
89
- Calculer $${segmentAskedName}$ (arrondir aux dixième).`;
71
+ Calculer $${segmentAskedName.slice(1, 3)}$ (arrondir aux dixième).`;
90
72
  };
91
73
  // const getHint : GetHint<Identifiers> = (identifiers)=>{
92
74
  // }
@@ -94,17 +76,22 @@ Calculer $${segmentAskedName}$ (arrondir aux dixième).`;
94
76
  // }
95
77
  const getGGBOptions = (identifiers) => {
96
78
  const triangle = triangle_1.TriangleConstructor.fromIdentifiers(identifiers.triangleIdentifiers);
97
- const points = identifiers.insidePointsIdentifiers.map((d) => point_1.PointConstructor.fromIdentifiers(d));
98
- const subTriangle = new triangle_1.Triangle(points[0], triangle.vertexB, points[1]);
79
+ const subTriangle = getSubTriangle({
80
+ triangle,
81
+ insidePointsNames: identifiers.insidePointsNames,
82
+ ratio: identifiers.ratio,
83
+ isPapillon: identifiers.isPapillon,
84
+ });
85
+ const points = [subTriangle.points[0], subTriangle.points[1]];
99
86
  const seg = new segment_1.Segment(points[0], points[1]);
100
87
  const commands = [
101
- ...triangle.generateCommands({}),
88
+ ...triangle.commands,
102
89
  ...points.flatMap((p) => p.toGGBCommand({ style: 0, color: "#444444", size: 4 })),
103
90
  ...seg.toGGBCommands(false),
104
91
  ];
105
92
  if (identifiers.isPapillon) {
106
- commands.push(...new segment_1.Segment(points[0], triangle.vertexB).toGGBCommands(false));
107
- commands.push(...new segment_1.Segment(points[1], triangle.vertexB).toGGBCommands(false));
93
+ commands.push(...new segment_1.Segment(points[0], triangle.points[2]).toGGBCommands(false));
94
+ commands.push(...new segment_1.Segment(points[1], triangle.points[2]).toGGBCommands(false));
108
95
  }
109
96
  const ggb = new geogebraConstructor_1.GeogebraConstructor({
110
97
  commands,
@@ -141,31 +128,35 @@ const options = [
141
128
  type: exercise_1.GeneratorOptionType.select,
142
129
  },
143
130
  ];
131
+ // (DE) // (AB)
144
132
  const getThalesFindSideQuestion = (opts) => {
145
- const summitNames = triangle_1.TriangleConstructor.randomName();
146
- const triangle = triangle_1.TriangleConstructor.createRandomTriangle({
147
- names: summitNames,
133
+ const triangle = triangle_1.TriangleConstructor.randomNiceSides({
134
+ randomName: true,
148
135
  });
136
+ const summitNames = triangle.points.map((p) => p.name);
149
137
  const isPapillon = !opts || opts?.configurationType === "Toutes"
150
138
  ? (0, coinFlip_1.coinFlip)()
151
139
  : opts.configurationType === "Uniquement papillon"
152
140
  ? true
153
141
  : false;
154
- const pointD = point_1.PointConstructor.onSegment(triangle.vertexA, triangle.vertexB, (0, randomLetter_1.randomLetter)(true, summitNames), isPapillon ? { coefficient: (0, randfloat_1.randfloat)(1.2, 1.8) } : { spacing: 0.2 });
155
- const line = new line_1.Line(triangle.vertexA, triangle.vertexC);
156
- const parallel = line.getParallele(pointD);
157
- const intersectLine = new line_1.Line(triangle.vertexB, triangle.vertexC);
158
- const pointE = parallel.intersect(intersectLine, (0, randomLetter_1.randomLetter)(true, [...summitNames, pointD.name]));
159
- const subTriangle = new triangle_1.Triangle(pointD, triangle.vertexB, pointE);
160
- const segmentAsked = (0, random_1.random)([
161
- ...triangle.getSegments(),
162
- ...subTriangle.getSegments(),
163
- ]);
142
+ //homothety rapport
143
+ // const ratio = !isPapillon ? randfloat(0.2, 0.8, 1) : randfloat(-0.2, -0.8, 1);
144
+ const ratio = 0.5;
145
+ const dName = (0, randomLetter_1.randomLetter)(true, summitNames);
146
+ const eName = (0, randomLetter_1.randomLetter)(true, [...summitNames, dName]);
147
+ const subTriangle = getSubTriangle({
148
+ triangle,
149
+ insidePointsNames: [dName, eName],
150
+ ratio,
151
+ isPapillon,
152
+ });
153
+ const segmentAsked = (0, random_1.random)([...triangle.sides, ...subTriangle.sides]);
164
154
  const identifiers = {
165
155
  triangleIdentifiers: triangle.toIdentifiers(),
166
- insidePointsIdentifiers: [pointD.toIdentifiers(), pointE.toIdentifiers()],
167
- segmentAsked: segmentAsked.toIdentifiers(),
156
+ insidePointsNames: [dName, eName],
157
+ segmentAskedName: segmentAsked.name,
168
158
  isPapillon,
159
+ ratio,
169
160
  };
170
161
  const question = {
171
162
  answer: getAnswer(identifiers),