math-exercises 3.0.158 → 3.0.159

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 (218) hide show
  1. package/lib/exercises/math/calculLitteral/equation/exp/expOfFEqualsExpOfGEquation.js +7 -6
  2. package/lib/exercises/math/calculLitteral/equation/exp/expOfTrinomEquals1Equation.d.ts.map +1 -1
  3. package/lib/exercises/math/calculLitteral/equation/exp/expOfTrinomEquals1Equation.js +88 -9
  4. package/lib/exercises/math/calculLitteral/equation/factorizeEquation.d.ts.map +1 -1
  5. package/lib/exercises/math/calculLitteral/equation/factorizeEquation.js +8 -2
  6. package/lib/exercises/math/calculLitteral/equation/index.d.ts +1 -0
  7. package/lib/exercises/math/calculLitteral/equation/index.d.ts.map +1 -1
  8. package/lib/exercises/math/calculLitteral/equation/index.js +1 -0
  9. package/lib/exercises/math/calculLitteral/equation/multiplicationEquation.d.ts.map +1 -1
  10. package/lib/exercises/math/calculLitteral/equation/multiplicationEquation.js +27 -2
  11. package/lib/exercises/math/calculLitteral/equation/solveByFactorizingWithIdRmq3.d.ts.map +1 -1
  12. package/lib/exercises/math/calculLitteral/equation/solveByFactorizingWithIdRmq3.js +0 -1
  13. package/lib/exercises/math/calculLitteral/equation/square/equationSquareWithSteps.d.ts.map +1 -1
  14. package/lib/exercises/math/calculLitteral/equation/square/equationSquareWithSteps.js +0 -1
  15. package/lib/exercises/math/calculLitteral/inequations/exp/expOfFEqualsExpOfGInequation.d.ts.map +1 -1
  16. package/lib/exercises/math/calculLitteral/inequations/exp/expOfFEqualsExpOfGInequation.js +11 -4
  17. package/lib/exercises/math/calculLitteral/inequations/firstDegreeInequationsType3.d.ts.map +1 -1
  18. package/lib/exercises/math/calculLitteral/inequations/firstDegreeInequationsType3.js +11 -5
  19. package/lib/exercises/math/calculLitteral/inequations/index.d.ts +1 -0
  20. package/lib/exercises/math/calculLitteral/inequations/index.d.ts.map +1 -1
  21. package/lib/exercises/math/calculLitteral/inequations/index.js +1 -0
  22. package/lib/exercises/math/derivation/derivative/exp/expDerivativeFour.d.ts.map +1 -1
  23. package/lib/exercises/math/derivation/derivative/exp/expDerivativeFour.js +91 -21
  24. package/lib/exercises/math/derivation/derivative/exp/expDerivativeOne.d.ts.map +1 -1
  25. package/lib/exercises/math/derivation/derivative/exp/expDerivativeOne.js +63 -43
  26. package/lib/exercises/math/derivation/derivative/exp/expDerivativeThree.d.ts.map +1 -1
  27. package/lib/exercises/math/derivation/derivative/exp/expDerivativeThree.js +72 -49
  28. package/lib/exercises/math/derivation/derivative/exp/expDerivativeTwo.d.ts.map +1 -1
  29. package/lib/exercises/math/derivation/derivative/exp/expDerivativeTwo.js +19 -19
  30. package/lib/exercises/math/derivation/derivative/exp/expOverExpDerivative.d.ts.map +1 -1
  31. package/lib/exercises/math/derivation/derivative/exp/expOverExpDerivative.js +26 -14
  32. package/lib/exercises/math/derivation/derivative/exp/index.d.ts +1 -0
  33. package/lib/exercises/math/derivation/derivative/exp/index.d.ts.map +1 -1
  34. package/lib/exercises/math/derivation/derivative/exp/index.js +1 -0
  35. package/lib/exercises/math/derivation/variations/index.d.ts +1 -0
  36. package/lib/exercises/math/derivation/variations/index.d.ts.map +1 -1
  37. package/lib/exercises/math/derivation/variations/index.js +1 -0
  38. package/lib/exercises/math/derivation/variations/readExtremaAbscissFromDerivativeCurve.d.ts +7 -0
  39. package/lib/exercises/math/derivation/variations/readExtremaAbscissFromDerivativeCurve.d.ts.map +1 -0
  40. package/lib/exercises/math/derivation/variations/readExtremaAbscissFromDerivativeCurve.js +174 -0
  41. package/lib/exercises/math/functions/exponential/algebraic/approxExpAPlusB.d.ts.map +1 -1
  42. package/lib/exercises/math/functions/exponential/algebraic/approxExpAPlusB.js +30 -3
  43. package/lib/exercises/math/functions/exponential/algebraic/approxExpKa.d.ts.map +1 -1
  44. package/lib/exercises/math/functions/exponential/algebraic/approxExpKa.js +12 -7
  45. package/lib/exercises/math/functions/exponential/algebraic/approxExpN.js +1 -1
  46. package/lib/exercises/math/functions/exponential/algebraic/rewriteExpUsingExpA.js +2 -2
  47. package/lib/exercises/math/functions/exponential/definition/approxExpAPlusH.d.ts.map +1 -1
  48. package/lib/exercises/math/functions/exponential/definition/approxExpAPlusH.js +33 -44
  49. package/lib/exercises/math/functions/exponential/definition/expAntecedentFromGraph.d.ts.map +1 -1
  50. package/lib/exercises/math/functions/exponential/definition/expAntecedentFromGraph.js +80 -8
  51. package/lib/exercises/math/functions/exponential/definition/expImageFromGraph.d.ts.map +1 -1
  52. package/lib/exercises/math/functions/exponential/definition/expImageFromGraph.js +80 -25
  53. package/lib/exercises/math/functions/exponential/definition/isPlausibleExpFromGraph.d.ts.map +1 -1
  54. package/lib/exercises/math/functions/exponential/definition/isPlausibleExpFromGraph.js +6 -15
  55. package/lib/exercises/math/functions/exponential/expFactorization.d.ts.map +1 -1
  56. package/lib/exercises/math/functions/exponential/expFactorization.js +54 -42
  57. package/lib/exercises/math/functions/exponential/index.d.ts +2 -0
  58. package/lib/exercises/math/functions/exponential/index.d.ts.map +1 -1
  59. package/lib/exercises/math/functions/exponential/index.js +2 -0
  60. package/lib/exercises/math/functions/trinoms/equation/secondDegreeInequation.js +3 -0
  61. package/lib/exercises/math/functions/variations/exp/varOfAEXPlusB.d.ts.map +1 -1
  62. package/lib/exercises/math/functions/variations/exp/varOfAEXPlusB.js +18 -23
  63. package/lib/exercises/math/functions/variations/exp/varOfAEXPlusBOverCEXPlusD.d.ts.map +1 -1
  64. package/lib/exercises/math/functions/variations/exp/varOfAEXPlusBOverCEXPlusD.js +24 -26
  65. package/lib/exercises/math/functions/variations/index.d.ts +1 -0
  66. package/lib/exercises/math/functions/variations/index.d.ts.map +1 -1
  67. package/lib/exercises/math/functions/variations/index.js +1 -0
  68. package/lib/exercises/math/geometry/cartesian/cartesianEquationOfLineFromPerpendicularLine.d.ts +12 -0
  69. package/lib/exercises/math/geometry/cartesian/cartesianEquationOfLineFromPerpendicularLine.d.ts.map +1 -0
  70. package/lib/exercises/math/geometry/cartesian/cartesianEquationOfLineFromPerpendicularLine.js +230 -0
  71. package/lib/exercises/math/geometry/cartesian/cartesianEquationOfLineFromPointAndNormalVector.d.ts +10 -0
  72. package/lib/exercises/math/geometry/cartesian/cartesianEquationOfLineFromPointAndNormalVector.d.ts.map +1 -0
  73. package/lib/exercises/math/geometry/cartesian/cartesianEquationOfLineFromPointAndNormalVector.js +167 -0
  74. package/lib/exercises/math/geometry/cartesian/index.d.ts +3 -0
  75. package/lib/exercises/math/geometry/cartesian/index.d.ts.map +1 -1
  76. package/lib/exercises/math/geometry/cartesian/index.js +3 -0
  77. package/lib/exercises/math/geometry/cartesian/normalVectorFromCartesianLineEquation.d.ts +10 -0
  78. package/lib/exercises/math/geometry/cartesian/normalVectorFromCartesianLineEquation.d.ts.map +1 -0
  79. package/lib/exercises/math/geometry/cartesian/normalVectorFromCartesianLineEquation.js +131 -0
  80. package/lib/exercises/math/geometry/circles/index.d.ts +2 -0
  81. package/lib/exercises/math/geometry/circles/index.d.ts.map +1 -0
  82. package/lib/exercises/math/geometry/circles/index.js +1 -0
  83. package/lib/exercises/math/geometry/circles/isPointOnCircleFromCartesianEquation.d.ts +11 -0
  84. package/lib/exercises/math/geometry/circles/isPointOnCircleFromCartesianEquation.d.ts.map +1 -0
  85. package/lib/exercises/math/geometry/circles/isPointOnCircleFromCartesianEquation.js +131 -0
  86. package/lib/exercises/math/geometry/euclidian/pinSegmentFromRotation.d.ts.map +1 -1
  87. package/lib/exercises/math/geometry/euclidian/pinSegmentFromRotation.js +0 -2
  88. package/lib/exercises/math/geometry/index.d.ts +1 -0
  89. package/lib/exercises/math/geometry/index.d.ts.map +1 -1
  90. package/lib/exercises/math/geometry/index.js +1 -0
  91. package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/index.d.ts +4 -0
  92. package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/index.d.ts.map +1 -0
  93. package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/index.js +3 -0
  94. package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/scalarProductAlKashiAngle.d.ts +9 -0
  95. package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/scalarProductAlKashiAngle.d.ts.map +1 -0
  96. package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/scalarProductAlKashiAngle.js +247 -0
  97. package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/scalarProductAlKashiBH.d.ts +13 -0
  98. package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/scalarProductAlKashiBH.d.ts.map +1 -0
  99. package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/scalarProductAlKashiBH.js +452 -0
  100. package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/scalarProductAlKashiSideLength.d.ts +9 -0
  101. package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/scalarProductAlKashiSideLength.d.ts.map +1 -0
  102. package/lib/exercises/math/geometry/vectors/scalarProduct/alKashi/scalarProductAlKashiSideLength.js +253 -0
  103. package/lib/exercises/math/geometry/vectors/scalarProduct/alg/index.d.ts +4 -0
  104. package/lib/exercises/math/geometry/vectors/scalarProduct/alg/index.d.ts.map +1 -0
  105. package/lib/exercises/math/geometry/vectors/scalarProduct/alg/index.js +3 -0
  106. package/lib/exercises/math/geometry/vectors/scalarProduct/alg/scalarProductIdentities.d.ts +10 -0
  107. package/lib/exercises/math/geometry/vectors/scalarProduct/alg/scalarProductIdentities.d.ts.map +1 -0
  108. package/lib/exercises/math/geometry/vectors/scalarProduct/alg/scalarProductIdentities.js +174 -0
  109. package/lib/exercises/math/geometry/vectors/scalarProduct/alg/scalarProductInOrthonormalBasisIJ.d.ts +9 -0
  110. package/lib/exercises/math/geometry/vectors/scalarProduct/alg/scalarProductInOrthonormalBasisIJ.d.ts.map +1 -0
  111. package/lib/exercises/math/geometry/vectors/scalarProduct/alg/scalarProductInOrthonormalBasisIJ.js +231 -0
  112. package/lib/exercises/math/geometry/vectors/scalarProduct/alg/scalarProductLamdbaULambdaV.d.ts +14 -0
  113. package/lib/exercises/math/geometry/vectors/scalarProduct/alg/scalarProductLamdbaULambdaV.d.ts.map +1 -0
  114. package/lib/exercises/math/geometry/vectors/scalarProduct/alg/scalarProductLamdbaULambdaV.js +292 -0
  115. package/lib/exercises/math/geometry/vectors/scalarProduct/orth/index.d.ts +6 -0
  116. package/lib/exercises/math/geometry/vectors/scalarProduct/orth/index.d.ts.map +1 -0
  117. package/lib/exercises/math/geometry/vectors/scalarProduct/orth/index.js +5 -0
  118. package/lib/exercises/math/geometry/vectors/scalarProduct/orth/scalarProductIsOrthogonalVecsBasisIJ.d.ts +9 -0
  119. package/lib/exercises/math/geometry/vectors/scalarProduct/orth/scalarProductIsOrthogonalVecsBasisIJ.d.ts.map +1 -0
  120. package/lib/exercises/math/geometry/vectors/scalarProduct/orth/scalarProductIsOrthogonalVecsBasisIJ.js +202 -0
  121. package/lib/exercises/math/geometry/vectors/scalarProduct/orth/scalarProductIsOrthogonalVecsUsingCoords.d.ts +9 -0
  122. package/lib/exercises/math/geometry/vectors/scalarProduct/orth/scalarProductIsOrthogonalVecsUsingCoords.d.ts.map +1 -0
  123. package/lib/exercises/math/geometry/vectors/scalarProduct/orth/scalarProductIsOrthogonalVecsUsingCoords.js +127 -0
  124. package/lib/exercises/math/geometry/vectors/scalarProduct/orth/scalarProductIsPointOnCircle.d.ts +12 -0
  125. package/lib/exercises/math/geometry/vectors/scalarProduct/orth/scalarProductIsPointOnCircle.d.ts.map +1 -0
  126. package/lib/exercises/math/geometry/vectors/scalarProduct/orth/scalarProductIsPointOnCircle.js +167 -0
  127. package/lib/exercises/math/geometry/vectors/scalarProduct/orth/scalarProductIsPointOnPerpendicularBisector.d.ts +12 -0
  128. package/lib/exercises/math/geometry/vectors/scalarProduct/orth/scalarProductIsPointOnPerpendicularBisector.d.ts.map +1 -0
  129. package/lib/exercises/math/geometry/vectors/scalarProduct/orth/scalarProductIsPointOnPerpendicularBisector.js +180 -0
  130. package/lib/exercises/math/geometry/vectors/scalarProduct/orth/scalarProductIsRightTriangleUsingPointCoords.d.ts +12 -0
  131. package/lib/exercises/math/geometry/vectors/scalarProduct/orth/scalarProductIsRightTriangleUsingPointCoords.d.ts.map +1 -0
  132. package/lib/exercises/math/geometry/vectors/scalarProduct/orth/scalarProductIsRightTriangleUsingPointCoords.js +235 -0
  133. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductComputeBH.d.ts +12 -0
  134. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductComputeBH.d.ts.map +1 -0
  135. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductComputeBH.js +423 -0
  136. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductOfVectsOnGrid1.d.ts +17 -0
  137. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductOfVectsOnGrid1.d.ts.map +1 -0
  138. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductOfVectsOnGrid1.js +347 -0
  139. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductParallelogramDiagonalPlus.d.ts +8 -0
  140. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductParallelogramDiagonalPlus.d.ts.map +1 -0
  141. package/lib/exercises/math/geometry/vectors/scalarProduct/scalarProductParallelogramDiagonalPlus.js +301 -0
  142. package/lib/exercises/math/probaStat/randomVariable/findValueForFairRandomVariable.d.ts +9 -0
  143. package/lib/exercises/math/probaStat/randomVariable/findValueForFairRandomVariable.d.ts.map +1 -0
  144. package/lib/exercises/math/probaStat/randomVariable/findValueForFairRandomVariable.js +141 -0
  145. package/lib/exercises/math/probaStat/randomVariable/findValueToMatchRandomVariableAverage.d.ts +10 -0
  146. package/lib/exercises/math/probaStat/randomVariable/findValueToMatchRandomVariableAverage.d.ts.map +1 -0
  147. package/lib/exercises/math/probaStat/randomVariable/findValueToMatchRandomVariableAverage.js +174 -0
  148. package/lib/exercises/math/probaStat/randomVariable/index.d.ts +1 -0
  149. package/lib/exercises/math/probaStat/randomVariable/index.d.ts.map +1 -1
  150. package/lib/exercises/math/probaStat/randomVariable/index.js +2 -0
  151. package/lib/exercises/math/sequences/generation/index.d.ts +2 -0
  152. package/lib/exercises/math/sequences/generation/index.d.ts.map +1 -0
  153. package/lib/exercises/math/sequences/generation/index.js +1 -0
  154. package/lib/exercises/math/sequences/generation/recognizeRecurrenceOrExplicit.d.ts +8 -0
  155. package/lib/exercises/math/sequences/generation/recognizeRecurrenceOrExplicit.d.ts.map +1 -0
  156. package/lib/exercises/math/sequences/generation/recognizeRecurrenceOrExplicit.js +63 -0
  157. package/lib/exercises/math/sequences/graph/index.d.ts +2 -0
  158. package/lib/exercises/math/sequences/graph/index.d.ts.map +1 -0
  159. package/lib/exercises/math/sequences/graph/index.js +1 -0
  160. package/lib/exercises/math/sequences/graph/placeFirstSequencePoints.d.ts +11 -0
  161. package/lib/exercises/math/sequences/graph/placeFirstSequencePoints.d.ts.map +1 -0
  162. package/lib/exercises/math/sequences/graph/placeFirstSequencePoints.js +113 -0
  163. package/lib/exercises/math/sequences/index.d.ts +2 -0
  164. package/lib/exercises/math/sequences/index.d.ts.map +1 -1
  165. package/lib/exercises/math/sequences/index.js +2 -0
  166. package/lib/exercises/math/sequences/notation/identifyRankInSequenceTermsList.d.ts +12 -0
  167. package/lib/exercises/math/sequences/notation/identifyRankInSequenceTermsList.d.ts.map +1 -0
  168. package/lib/exercises/math/sequences/notation/identifyRankInSequenceTermsList.js +114 -0
  169. package/lib/exercises/math/sequences/notation/identifySequenceTermInList.d.ts +12 -0
  170. package/lib/exercises/math/sequences/notation/identifySequenceTermInList.d.ts.map +1 -0
  171. package/lib/exercises/math/sequences/notation/identifySequenceTermInList.js +111 -0
  172. package/lib/exercises/math/sequences/notation/index.d.ts +3 -0
  173. package/lib/exercises/math/sequences/notation/index.d.ts.map +1 -0
  174. package/lib/exercises/math/sequences/notation/index.js +2 -0
  175. package/lib/exercises/math/spaceGeometry/basis/findSpacePointOnRectangularPrism.d.ts.map +1 -1
  176. package/lib/exercises/math/spaceGeometry/basis/findSpacePointOnRectangularPrism.js +0 -1
  177. package/lib/exercises/math/spaceGeometry/sphere/sphereLatLonReading.2d.d.ts.map +1 -1
  178. package/lib/exercises/math/spaceGeometry/sphere/sphereLatLonReading.2d.js +0 -2
  179. package/lib/exercises/vea/cartesianLineVEA.d.ts +2 -0
  180. package/lib/exercises/vea/cartesianLineVEA.d.ts.map +1 -0
  181. package/lib/exercises/vea/cartesianLineVEA.js +1 -0
  182. package/lib/index.d.ts +123 -0
  183. package/lib/index.d.ts.map +1 -1
  184. package/lib/math/geometry/line.d.ts +2 -0
  185. package/lib/math/geometry/line.d.ts.map +1 -1
  186. package/lib/math/geometry/line.js +7 -0
  187. package/lib/math/geometry/point.d.ts +1 -0
  188. package/lib/math/geometry/point.d.ts.map +1 -1
  189. package/lib/math/geometry/point.js +5 -0
  190. package/lib/math/geometry/polygons/relationPP.d.ts +8 -0
  191. package/lib/math/geometry/polygons/relationPP.d.ts.map +1 -0
  192. package/lib/math/geometry/polygons/relationPP.js +41 -0
  193. package/lib/math/polynomials/trinom.d.ts +1 -1
  194. package/lib/math/polynomials/trinom.d.ts.map +1 -1
  195. package/lib/math/polynomials/trinom.js +15 -6
  196. package/lib/math/utils/arithmetic/primeFactors.js +1 -1
  197. package/lib/math/utils/geometry/randomVecs2.d.ts +6 -0
  198. package/lib/math/utils/geometry/randomVecs2.d.ts.map +1 -0
  199. package/lib/math/utils/geometry/randomVecs2.js +34 -0
  200. package/lib/tests/questionTest.d.ts.map +1 -1
  201. package/lib/tests/questionTest.js +2 -2
  202. package/lib/tree/nodes/equations/equationSolutionNode.d.ts +1 -0
  203. package/lib/tree/nodes/equations/equationSolutionNode.d.ts.map +1 -1
  204. package/lib/tree/nodes/equations/equationSolutionNode.js +3 -0
  205. package/lib/tree/nodes/functions/expNode.d.ts +1 -1
  206. package/lib/tree/nodes/functions/expNode.d.ts.map +1 -1
  207. package/lib/tree/nodes/inequations/inequationSolutionNode.d.ts +1 -0
  208. package/lib/tree/nodes/inequations/inequationSolutionNode.d.ts.map +1 -1
  209. package/lib/tree/nodes/inequations/inequationSolutionNode.js +3 -0
  210. package/lib/tree/nodes/operators/fractionNode.d.ts +1 -1
  211. package/lib/tree/nodes/operators/fractionNode.d.ts.map +1 -1
  212. package/lib/tree/nodes/operators/fractionNode.js +6 -4
  213. package/lib/tree/nodes/sets/intervalNode.d.ts +6 -0
  214. package/lib/tree/nodes/sets/intervalNode.d.ts.map +1 -1
  215. package/lib/tree/nodes/sets/namedIntervalNode.d.ts +31 -0
  216. package/lib/tree/nodes/sets/namedIntervalNode.d.ts.map +1 -0
  217. package/lib/tree/nodes/sets/namedIntervalNode.js +77 -0
  218. package/package.json +1 -1
@@ -0,0 +1,423 @@
1
+ import { addValidProp, shuffleProps, GeneratorOptionType, GeneratorOptionTarget, tryToAddWrongProp, propWhile, } from "../../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { orange } from "../../../../../geogebra/colors.js";
4
+ import { GeogebraConstructor } from "../../../../../geogebra/geogebraConstructor.js";
5
+ import { Angle } from "../../../../../math/geometry/angle.js";
6
+ import { Point, PointConstructor, } from "../../../../../math/geometry/point.js";
7
+ import { relationPP } from "../../../../../math/geometry/polygons/relationPP.js";
8
+ import { Segment } from "../../../../../math/geometry/segment.js";
9
+ import { Triangle } from "../../../../../math/geometry/triangles/triangle.js";
10
+ import { VectorConstructor } from "../../../../../math/geometry/vector.js";
11
+ import { randint } from "../../../../../math/utils/random/randint.js";
12
+ import { abs } from "../../../../../tree/nodes/functions/absNode.js";
13
+ import { add } from "../../../../../tree/nodes/operators/addNode.js";
14
+ import { frac, isFractionNode, } from "../../../../../tree/nodes/operators/fractionNode.js";
15
+ import { multiply } from "../../../../../tree/nodes/operators/multiplyNode.js";
16
+ import { substract } from "../../../../../tree/nodes/operators/substractNode.js";
17
+ import { parseAlgebraic } from "../../../../../tree/parsers/latexParser.js";
18
+ import { coinFlip } from "../../../../../utils/alea/coinFlip.js";
19
+ import { random } from "../../../../../utils/alea/random.js";
20
+ import { handleVEAError } from "../../../../../utils/errors/handleVEAError.js";
21
+ const getHydratedPoints = (identifiers) => {
22
+ const { pointIds } = identifiers;
23
+ return pointIds.map((pointIds) => PointConstructor.fromIdentifiers(pointIds));
24
+ };
25
+ const getInstruction = (identifiers) => {
26
+ const [B, A, C, _] = getHydratedPoints(identifiers);
27
+ return `Soient les points :
28
+
29
+ ${[A, B, C].map((point) => `- $${point.toTexWithCoords()}$`).join(`
30
+ `)}
31
+
32
+ Dans $BAC$, $H$ est le pied de la hauteur issue de $A$.
33
+
34
+ Calculer la longueur $BH$.
35
+
36
+ *Donner la valeur exacte.*`;
37
+ };
38
+ const getAnswerNode = (identifiers) => {
39
+ const [pointB, pointA, pointC, _] = getHydratedPoints(identifiers);
40
+ const vecBC = VectorConstructor.fromPoints(pointB, pointC);
41
+ const nodeLengthBC = vecBC.getNorm();
42
+ const vecBA = VectorConstructor.fromPoints(pointB, pointA);
43
+ return frac(abs(vecBA.scalarProduct(vecBC)), nodeLengthBC);
44
+ };
45
+ const getAnswer = (identifiers) => {
46
+ return getAnswerNode(identifiers).simplify().toTex();
47
+ };
48
+ const getHint = () => {
49
+ return `Combien vaut le produit scalaire $\\overrightarrow{BA} \\cdot \\overrightarrow{BC}$ ?
50
+
51
+ Est-ce qu'il est égal à $\\overrightarrow{BH} \\cdot \\overrightarrow{BC}$ ? Et pourquoi ?`;
52
+ };
53
+ const getCorrection = (identifiers) => {
54
+ const [pointB, pointA, pointC, _] = getHydratedPoints(identifiers);
55
+ const vecBC = VectorConstructor.fromPoints(pointB, pointC);
56
+ const nodeLengthBC = vecBC.getNorm();
57
+ const vecBA = VectorConstructor.fromPoints(pointB, pointA);
58
+ const nodeScalarProduct = vecBA.scalarProduct(vecBC);
59
+ return `Dans $BAC$, $H$ est le pied de la hauteur issue de $A$.
60
+
61
+ Autrement dit, $H$ est le projeté orthogonal de $A$ sur $(BC)$.
62
+
63
+ Par conséquent :
64
+
65
+ $$
66
+ \\overrightarrow{BA} \\cdot \\overrightarrow{BC} = \\overrightarrow{BH} \\cdot \\overrightarrow{BC}
67
+ $$
68
+
69
+ Or, puisque $B$,$C$ et $H$ sont alignés :
70
+
71
+ $$
72
+ \\lvert \\overrightarrow{BH} \\cdot \\overrightarrow{BC} \\rvert = BH \\times BC
73
+ $$
74
+
75
+ On a donc :
76
+
77
+ $$
78
+ BH = \\frac{\\lvert \\overrightarrow{BA} \\cdot \\overrightarrow{BC} \\rvert}{BC}
79
+ $$
80
+
81
+ Application numérique :
82
+
83
+ $$
84
+ \\overrightarrow{BA} = ${vecBA.toCoords()}
85
+ $$
86
+
87
+ $$
88
+ \\overrightarrow{BC} = ${vecBC.toCoords()}
89
+ $$
90
+
91
+ $$
92
+ \\overrightarrow{BA} \\cdot \\overrightarrow{BC} = ${nodeScalarProduct.toTex()}
93
+ $$
94
+
95
+ $$
96
+ BC = ${nodeLengthBC.toTex()}
97
+ $$
98
+
99
+ $$
100
+ BH = ${getAnswer(identifiers)}
101
+ $$
102
+
103
+ `;
104
+ };
105
+ const getGGBOptions = (identifiers) => {
106
+ const [B, A, C, H] = getHydratedPoints(identifiers);
107
+ const triangle = new Triangle([B, A, C]);
108
+ const ggb = new GeogebraConstructor({
109
+ commands: [
110
+ //triangle
111
+ ...triangle.commands,
112
+ //AH
113
+ ...H.toGGBCommand({ isFixed: true, showLabel: true }),
114
+ ...new Segment(A, H).toGGBCommands(false, {
115
+ isFixed: true,
116
+ style: 2,
117
+ color: `${orange}`,
118
+ }),
119
+ //BH
120
+ ...new Segment(B, H).toGGBCommands(false, {
121
+ isFixed: true,
122
+ style: 2,
123
+ }),
124
+ //angle
125
+ ...new Angle([A, H, C]).toCommands(),
126
+ ],
127
+ hideAxes: true,
128
+ });
129
+ return ggb.getOptions({
130
+ coords: ggb.getCoordsForPoints([B, A, C, H]),
131
+ });
132
+ };
133
+ const getPropositions = (n, { answer, ...identifiers }) => {
134
+ const propositions = [];
135
+ addValidProp(propositions, answer);
136
+ const nodeAnswer = getAnswerNode(identifiers);
137
+ //student does scalarProduct(CA,BC) instead of scalarProduct(BA,BC)
138
+ function createNodeMistakeWrongScalarProduct(identifiers) {
139
+ const [pointB, pointA, pointC, _] = getHydratedPoints(identifiers);
140
+ const vecBC = VectorConstructor.fromPoints(pointB, pointC);
141
+ const nodeLengthBC = vecBC.getNorm();
142
+ const vecCA = VectorConstructor.fromPoints(pointC, pointA);
143
+ const nodeScalarProduct = vecCA.scalarProduct(vecBC);
144
+ return frac(abs(nodeScalarProduct), nodeLengthBC).simplify();
145
+ }
146
+ const nodeWrongSP = createNodeMistakeWrongScalarProduct(identifiers);
147
+ tryToAddWrongProp(propositions, nodeWrongSP.toTex());
148
+ //student does scalarProduct(CA,BC) instead of scalarProduct(BA,BC) + divides by CA
149
+ function createNodeMistakeWrongScalarProductAndWrongDen(identifiers) {
150
+ const [pointB, pointA, pointC, _] = getHydratedPoints(identifiers);
151
+ const vecBC = VectorConstructor.fromPoints(pointB, pointC);
152
+ const vecCA = VectorConstructor.fromPoints(pointC, pointA);
153
+ const nodeLengthCA = vecCA.getNorm();
154
+ const nodeScalarProduct = vecCA.scalarProduct(vecBC);
155
+ return frac(abs(nodeScalarProduct), nodeLengthCA).simplify();
156
+ }
157
+ const nodeWrongSPAndDen = createNodeMistakeWrongScalarProductAndWrongDen(identifiers);
158
+ tryToAddWrongProp(propositions, nodeWrongSPAndDen.toTex());
159
+ //terror: wrong sign
160
+ function createNodeTerrorSign(nodeSrc) {
161
+ if (isFractionNode(nodeSrc)) {
162
+ const nodeNum = nodeSrc.leftChild;
163
+ const nodeDen = nodeSrc.rightChild;
164
+ const nodeWrong = frac(multiply(-1, nodeNum).simplify(), nodeDen);
165
+ return nodeWrong;
166
+ }
167
+ }
168
+ const nodeTerrorSign = createNodeTerrorSign(coinFlip() ? nodeAnswer : random([nodeWrongSP, nodeWrongSPAndDen]));
169
+ if (nodeTerrorSign) {
170
+ tryToAddWrongProp(propositions, nodeTerrorSign.simplify().toTex());
171
+ }
172
+ //terror: frac num (related to: student has made a mistake when computing scalarProduct)
173
+ function createNodeTerrorFracNum(nodeSrc) {
174
+ if (isFractionNode(nodeSrc)) {
175
+ const nodeNum = nodeSrc.leftChild;
176
+ const nodeDen = nodeSrc.rightChild;
177
+ const nodeWrong = frac(add(nodeNum, randint(-3, 3, [0])).simplify(), nodeDen);
178
+ return nodeWrong;
179
+ }
180
+ }
181
+ const nodeTerrorFracNum = createNodeTerrorFracNum(coinFlip()
182
+ ? nodeAnswer
183
+ : random([
184
+ nodeWrongSP,
185
+ nodeWrongSPAndDen,
186
+ ...(nodeTerrorSign ? [nodeTerrorSign] : []),
187
+ ]));
188
+ if (nodeTerrorFracNum) {
189
+ tryToAddWrongProp(propositions, nodeTerrorFracNum.simplify().toTex());
190
+ }
191
+ //filler
192
+ propWhile(propositions, n, () => {
193
+ const [B, A, C, H] = getHydratedPoints(identifiers);
194
+ const BWrong = new Point("B", add(B.x, randint(-3, 3, [0])).simplify(), B.y);
195
+ const identifiersWrong = Object.assign({}, identifiers, {
196
+ pointIds: [BWrong, A, C, H].map((point) => point.toIdentifiers()),
197
+ });
198
+ const nodeWrong = getAnswerNode(identifiersWrong);
199
+ tryToAddWrongProp(propositions, nodeWrong.simplify().toTex());
200
+ });
201
+ return shuffleProps(propositions, n);
202
+ };
203
+ const getKeys = () => {
204
+ return [];
205
+ };
206
+ const isAnswerValid = (ans, { answer, ...identifiers }) => {
207
+ try {
208
+ const nodeAns = parseAlgebraic(ans);
209
+ const nodeAnswer = getAnswerNode(identifiers);
210
+ return substract(nodeAns, nodeAnswer).simplify().evaluate() === 0;
211
+ }
212
+ catch (err) {
213
+ return handleVEAError(err);
214
+ }
215
+ };
216
+ const getScalarProductComputeBHQuestion = (optsIn) => {
217
+ const arrayedOptions = optsIn ?? optsDefault;
218
+ const opts = {
219
+ sectorOfPointH: random(arrayedOptions.sectorOfPointH),
220
+ isPositiveCoordsOnly: arrayedOptions.isPositiveCoordsOnly,
221
+ };
222
+ const { sectorOfPointH, isPositiveCoordsOnly } = opts;
223
+ function createRandomIdentifiers() {
224
+ const offsetBtoC = 10;
225
+ const pointB = (() => {
226
+ if (isPositiveCoordsOnly) {
227
+ return new Point("B", randint(0, 10), randint(0, 10));
228
+ }
229
+ else {
230
+ return new Point("B", randint(-10, 0), randint(-10, 0));
231
+ }
232
+ })();
233
+ const pointC = new Point("C", pointB.x.evaluate() + offsetBtoC + randint(-2, 8), randint(0, 10, [pointB.y.evaluate()]));
234
+ const vecBC = VectorConstructor.fromPoints(pointB, pointC);
235
+ const nodeLengthBC = vecBC.getNorm();
236
+ const vecBCUnited = vecBC.times(frac(1, nodeLengthBC));
237
+ const vecOrthUnited = vecBCUnited.getOrthogonal().times((-1).toTree());
238
+ //rect PQRS will contain A, D is Proj(P,(BC)), E is Proj(S,(BC))
239
+ const nodeOffsetDtoE = (10).toTree();
240
+ const nodeOffsetBtoD = (() => {
241
+ switch (sectorOfPointH) {
242
+ case "Entre $B$ et $C$":
243
+ return (0).toTree();
244
+ case "Après $C$":
245
+ return nodeLengthBC;
246
+ case "Avant $B$":
247
+ return multiply((-1).toTree(), nodeOffsetDtoE);
248
+ default:
249
+ throw new Error("Unsupported opts.sectorOfPointH: " + opts.sectorOfPointH);
250
+ }
251
+ })();
252
+ const pointD = vecBCUnited.times(nodeOffsetBtoD).getEndPoint(pointB);
253
+ const pointE = vecBCUnited.times(nodeOffsetDtoE).getEndPoint(pointD);
254
+ const minOffsetBCtoA = 3;
255
+ const maxOffsetBCtoA = minOffsetBCtoA + 10;
256
+ const pointP = vecOrthUnited
257
+ .times(minOffsetBCtoA.toTree())
258
+ .getEndPoint(pointD);
259
+ const pointQ = vecOrthUnited
260
+ .times((maxOffsetBCtoA - minOffsetBCtoA).toTree())
261
+ .getEndPoint(pointP);
262
+ const pointS = vecOrthUnited
263
+ .times(minOffsetBCtoA.toTree())
264
+ .getEndPoint(pointE);
265
+ const pointR = vecOrthUnited
266
+ .times((maxOffsetBCtoA - minOffsetBCtoA).toTree())
267
+ .getEndPoint(pointS);
268
+ function getCoordsForPoints(points) {
269
+ const xMin = Math.min(...points.map((p) => p.x.evaluate()));
270
+ const xMax = Math.max(...points.map((p) => p.x.evaluate()));
271
+ const yMin = Math.min(...points.map((p) => p.y.evaluate()));
272
+ const yMax = Math.max(...points.map((p) => p.y.evaluate()));
273
+ return [xMin, xMax, yMin, yMax];
274
+ }
275
+ function getRandomIntegerPointInside(points) {
276
+ const [xMin, xMax, yMin, yMax] = getCoordsForPoints(points);
277
+ let point;
278
+ let counter = -1;
279
+ let isValid = false;
280
+ while (!isValid && counter < 1000) {
281
+ counter++;
282
+ const x = randint(Math.ceil(xMin), Math.floor(xMax));
283
+ const y = randint(Math.ceil(yMin), Math.floor(yMax));
284
+ const pointCandidate = new Point("RIP", x, y);
285
+ isValid = relationPP(pointCandidate, points) !== -1;
286
+ if (isValid) {
287
+ point = pointCandidate;
288
+ }
289
+ }
290
+ if (!isValid) {
291
+ throw new Error("getRandomIntegerPointInside: too many iterations");
292
+ }
293
+ return point;
294
+ }
295
+ const pointRand = getRandomIntegerPointInside([
296
+ pointP,
297
+ pointQ,
298
+ pointR,
299
+ pointS,
300
+ ]);
301
+ const pointA = new Point("A", pointRand.x, pointRand.y);
302
+ const vecBA = VectorConstructor.fromPoints(pointB, pointA);
303
+ const vecBH = vecBCUnited.times(frac(vecBA.scalarProduct(vecBC), nodeLengthBC));
304
+ const pointH = vecBH.getEndPoint(pointB, "H");
305
+ return {
306
+ pointIds: [pointB, pointA, pointC, pointH].map((point) => point.toIdentifiers()),
307
+ };
308
+ }
309
+ function isIntegerPoint(point) {
310
+ const isIntegerX = () => point.x.evaluate() % 1 === 0;
311
+ const isIntegerY = () => point.y.evaluate() % 1 === 0;
312
+ return isIntegerX() && isIntegerY();
313
+ }
314
+ function isPositiveCoords(point) {
315
+ const isPositiveX = () => point.x.evaluate() >= 0;
316
+ const isPositiveY = () => point.y.evaluate() >= 0;
317
+ return isPositiveX() && isPositiveY();
318
+ }
319
+ function isValidIdentifiers(identifiersCandidate) {
320
+ const [B, A, C, H] = getHydratedPoints(identifiersCandidate);
321
+ const minDistance = 2;
322
+ const isHFarEnough = () => B.distanceTo(H) > minDistance && C.distanceTo(H) > minDistance;
323
+ const isValidPositivelyWise = () => isPositiveCoordsOnly
324
+ ? isPositiveCoords(B) && isPositiveCoords(A) && isPositiveCoords(C)
325
+ : true;
326
+ return !isIntegerPoint(H) && isHFarEnough() && isValidPositivelyWise();
327
+ }
328
+ let identifiers;
329
+ let counter = -1;
330
+ let isValid = false;
331
+ while (!isValid && counter < 100) {
332
+ counter++;
333
+ try {
334
+ const identifiersCandidate = createRandomIdentifiers();
335
+ isValid = isValidIdentifiers(identifiersCandidate);
336
+ if (isValid) {
337
+ identifiers = identifiersCandidate;
338
+ }
339
+ }
340
+ catch (_) {
341
+ (() => { })();
342
+ }
343
+ }
344
+ if (!isValid) {
345
+ const pointB = new Point("B", 0, 0);
346
+ const pointC = new Point("C", 10, 1);
347
+ const pointA = new Point("A", 4, 7);
348
+ const vecBC = VectorConstructor.fromPoints(pointB, pointC);
349
+ const nodeLengthBC = vecBC.getNorm();
350
+ const vecBCUnited = vecBC.times(frac(1, nodeLengthBC));
351
+ const vecBA = VectorConstructor.fromPoints(pointB, pointA);
352
+ const vecBH = vecBCUnited.times(frac(vecBA.scalarProduct(vecBC), nodeLengthBC));
353
+ const pointH = vecBH.getEndPoint(pointB);
354
+ const identifiersDefault = {
355
+ pointIds: [pointB, pointA, pointC, pointH].map((point) => point.toIdentifiers()),
356
+ };
357
+ identifiers = identifiersDefault;
358
+ }
359
+ return getQuestionFromIdentifiers(identifiers, opts);
360
+ };
361
+ const getQuestionFromIdentifiers = (identifiers, opts) => {
362
+ const question = {
363
+ answer: getAnswer(identifiers, opts),
364
+ instruction: getInstruction(identifiers, opts),
365
+ keys: getKeys(identifiers, opts),
366
+ answerFormat: "tex",
367
+ identifiers,
368
+ hint: getHint(identifiers, opts),
369
+ correction: getCorrection(identifiers, opts),
370
+ ggbOptions: getGGBOptions(identifiers, opts),
371
+ options: opts,
372
+ };
373
+ return question;
374
+ };
375
+ const optsDefault = {
376
+ sectorOfPointH: ["Entre $B$ et $C$"],
377
+ isPositiveCoordsOnly: true,
378
+ };
379
+ const options = [
380
+ {
381
+ id: "sectorOfPointH",
382
+ label: "Position du point $H$",
383
+ target: GeneratorOptionTarget.generation,
384
+ type: GeneratorOptionType.multiselect,
385
+ values: ["Entre $B$ et $C$", "Après $C$", "Avant $B$"],
386
+ defaultValue: optsDefault.sectorOfPointH,
387
+ },
388
+ {
389
+ id: "isPositiveCoordsOnly",
390
+ label: "Coordonnées positives uniquement",
391
+ target: GeneratorOptionTarget.generation,
392
+ type: GeneratorOptionType.checkbox,
393
+ defaultValue: optsDefault.isPositiveCoordsOnly,
394
+ },
395
+ ];
396
+ export const scalarProductComputeBH = {
397
+ id: "scalarProductComputeBH",
398
+ connector: "=",
399
+ label: "À partir de $A$, $B$ et $C$ ($H$ étant le projeté de $A$ sur $(BC)$), calculer $BH$",
400
+ isSingleStep: true,
401
+ generator: (nb, opts) => getDistinctQuestions(() => getScalarProductComputeBHQuestion(opts), nb),
402
+ options,
403
+ validateOptions: (opts) => {
404
+ return {
405
+ valid: !!(opts?.sectorOfPointH.length > 0),
406
+ message: "Veuillez choisir au moins un secteur pour le point $H$.",
407
+ };
408
+ },
409
+ qcmTimer: 60,
410
+ freeTimer: 60,
411
+ ggbTimer: 60,
412
+ getPropositions,
413
+ isAnswerValid,
414
+ subject: "Mathématiques",
415
+ getAnswer,
416
+ getGGBOptions,
417
+ getInstruction,
418
+ hasGeogebra: true,
419
+ getQuestionFromIdentifiers,
420
+ getHint,
421
+ getCorrection,
422
+ hasHintAndCorrection: true,
423
+ };
@@ -0,0 +1,17 @@
1
+ import { Exercise } from "../../../../../exercises/exercise.js";
2
+ import { PointIdentifiers } from "../../../../../math/geometry/point.js";
3
+ import { VectorIdentifiers } from "../../../../../math/geometry/vector.js";
4
+ type Identifiers = {
5
+ vecIds1: VectorIdentifiers;
6
+ vecIds2: VectorIdentifiers;
7
+ pointIds1A: PointIdentifiers;
8
+ pointIds2A: PointIdentifiers;
9
+ isVec1OnAxis: boolean;
10
+ isOnAxisX: boolean;
11
+ };
12
+ type Options = {
13
+ isSameStartPoint: boolean;
14
+ };
15
+ export declare const scalarProductOfVectsOnGrid1: Exercise<Identifiers, Options>;
16
+ export {};
17
+ //# sourceMappingURL=scalarProductOfVectsOnGrid1.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scalarProductOfVectsOnGrid1.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/geometry/vectors/scalarProduct/scalarProductOfVectsOnGrid1.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAmBT,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EAGL,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAGL,iBAAiB,EAClB,MAAM,+BAA+B,CAAC;AAWvC,KAAK,WAAW,GAAG;IACjB,OAAO,EAAE,iBAAiB,CAAC;IAC3B,OAAO,EAAE,iBAAiB,CAAC;IAC3B,UAAU,EAAE,gBAAgB,CAAC;IAC7B,UAAU,EAAE,gBAAgB,CAAC;IAC7B,YAAY,EAAE,OAAO,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AAiYF,KAAK,OAAO,GAAG;IACb,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CAAC;AAgBF,eAAO,MAAM,2BAA2B,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAyBtE,CAAC"}