math-exercises 3.0.21 → 3.0.22

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 (26) hide show
  1. package/lib/exercises/math/functions/affines/algebricExpressionOfAffine.d.ts.map +1 -1
  2. package/lib/exercises/math/functions/affines/algebricExpressionOfAffine.js +14 -3
  3. package/lib/exercises/math/geometry/cartesian/pointCoordinates.d.ts.map +1 -1
  4. package/lib/exercises/math/geometry/cartesian/pointCoordinates.js +30 -29
  5. package/lib/exercises/math/geometry/euclidian/index.d.ts +1 -1
  6. package/lib/exercises/math/geometry/euclidian/index.d.ts.map +1 -1
  7. package/lib/exercises/math/geometry/euclidian/index.js +1 -2
  8. package/lib/exercises/math/geometry/euclidian/pythagoreOrThales.d.ts +9 -0
  9. package/lib/exercises/math/geometry/euclidian/pythagoreOrThales.d.ts.map +1 -1
  10. package/lib/exercises/math/geometry/euclidian/pythagoreOrThales.js +205 -187
  11. package/lib/exercises/math/geometry/index.d.ts +1 -0
  12. package/lib/exercises/math/geometry/index.d.ts.map +1 -1
  13. package/lib/exercises/math/geometry/index.js +1 -1
  14. package/lib/exercises/math/geometry/thales/thalesCalcul.d.ts.map +1 -1
  15. package/lib/exercises/math/geometry/thales/thalesCalcul.js +1 -1
  16. package/lib/exercises/utils/geogebra/toGGBCommandsProps.d.ts +1 -0
  17. package/lib/exercises/utils/geogebra/toGGBCommandsProps.d.ts.map +1 -1
  18. package/lib/index.d.ts +5 -0
  19. package/lib/index.d.ts.map +1 -1
  20. package/lib/math/geometry/segment.d.ts +6 -2
  21. package/lib/math/geometry/segment.d.ts.map +1 -1
  22. package/lib/math/geometry/segment.js +11 -6
  23. package/lib/math/geometry/triangle.d.ts +2 -1
  24. package/lib/math/geometry/triangle.d.ts.map +1 -1
  25. package/lib/math/geometry/triangle.js +31 -13
  26. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"algebricExpressionOfAffine.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/algebricExpressionOfAffine.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAKrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAoDF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAa5D,CAAC"}
1
+ {"version":3,"file":"algebricExpressionOfAffine.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/functions/affines/algebricExpressionOfAffine.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAQrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AA6DF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAa5D,CAAC"}
@@ -2,6 +2,8 @@ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exer
2
2
  import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
3
  import { Affine, AffineConstructor } from "../../../../math/polynomials/affine.js";
4
4
  import { randint } from "../../../../math/utils/random/randint.js";
5
+ import { polynomialParser } from "../../../../tree/parsers/polynomialParser.js";
6
+ import { handleVEAError } from "../../../../utils/errors/handleVEAError.js";
5
7
  const getAlgebricExpressionOfAffineQuestion = () => {
6
8
  const f = AffineConstructor.random();
7
9
  const a = f.a;
@@ -26,9 +28,18 @@ const getPropositions = (n, { answer, a, b }) => {
26
28
  }
27
29
  return shuffleProps(propositions, n);
28
30
  };
29
- const isAnswerValid = (ans, { a, b }) => {
30
- const f = new Affine(a, b, "x");
31
- return f.toTree().toAllValidTexs().includes(ans);
31
+ const isAnswerValid = (ans, { answer, a, b }) => {
32
+ try {
33
+ const parsed = polynomialParser(ans);
34
+ if (parsed === false)
35
+ return false;
36
+ return (parsed
37
+ .simplify({ forbidFactorize: true, towardsDistribute: true })
38
+ .toTex() === answer);
39
+ }
40
+ catch (err) {
41
+ return handleVEAError(err);
42
+ }
32
43
  };
33
44
  const generatePropositions = (a, b) => {
34
45
  const firstProposition = new Affine(b !== 0 ? b : randint(-10, 11, [0]), a, "x");
@@ -1 +1 @@
1
- {"version":3,"file":"pointCoordinates.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/cartesian/pointCoordinates.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAkFF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAclD,CAAC"}
1
+ {"version":3,"file":"pointCoordinates.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/cartesian/pointCoordinates.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAYT,MAAM,6BAA6B,CAAC;AAOrC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAiFF,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,WAAW,CAclD,CAAC"}
@@ -3,44 +3,45 @@ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQue
3
3
  import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
4
4
  import { Point } from "../../../../math/geometry/point.js";
5
5
  import { randint } from "../../../../math/utils/random/randint.js";
6
- const getPointCoordinatesQuestion = () => {
7
- const x = randint(-10, 10);
8
- const y = randint(-10, 10);
6
+ const getInstruction = (identifiers) => {
7
+ return `Lire les coordonnées du point $A$ représenté dans le repère ci-dessous : `;
8
+ };
9
+ const getAnswer = (identifiers) => {
10
+ const { x, y } = identifiers;
11
+ const A = new Point("A", x, y);
12
+ return A.toCoords();
13
+ };
14
+ const getGGBOptions = (identifiers) => {
15
+ const { x, y } = identifiers;
9
16
  const xMin = Math.min(x) - 5;
10
17
  const xMax = Math.max(x) + 5;
11
18
  const yMin = Math.min(y) - 5;
12
19
  const yMax = Math.max(y) + 5;
13
- const instruction = `Lire les coordonnées du point $A$ représenté dans le repère ci-dessous : `;
14
- const commands = [
15
- `A = (${x}, ${y})`,
16
- `ShowLabel(A, true)`,
17
- "SetPointStyle(A, 1)",
18
- `SetVisibleInView(A, 1, true)`,
19
- `SetCoords(A, ${x}, ${y})`,
20
- `SetPointStyle(A, 0)`,
21
- `SetPointSize(A, 5)`,
22
- `SetFixed(A, true)`,
23
- `ZoomIn(${xMin}, ${yMin}, ${xMax}, ${yMax})`,
24
- ];
20
+ const A = new Point("A", x, y);
25
21
  const ggb = new GeogebraConstructor({
26
- commands,
22
+ commands: A.toGGBCommand(),
27
23
  });
28
- const A = new Point("A", x.toTree(), y.toTree());
29
- const question = {
30
- answer: A.toCoords(),
31
- instruction,
32
- ggbOptions: ggb.getOptions({
33
- coords: ggb.getAdaptedCoords({
34
- xMin,
35
- xMax,
36
- yMin,
37
- yMax,
38
- forceShowAxes: true,
39
- }),
24
+ return ggb.getOptions({
25
+ coords: ggb.getAdaptedCoords({
26
+ xMin,
27
+ xMax,
28
+ yMin,
29
+ yMax,
30
+ forceShowAxes: true,
40
31
  }),
32
+ });
33
+ };
34
+ const getPointCoordinatesQuestion = () => {
35
+ const x = randint(-10, 10);
36
+ const y = randint(-10, 10);
37
+ const identifiers = { x, y };
38
+ const question = {
39
+ answer: getAnswer(identifiers),
40
+ instruction: getInstruction(identifiers),
41
+ ggbOptions: getGGBOptions(identifiers),
41
42
  keys: ["x", "y", "semicolon"],
42
43
  answerFormat: "tex",
43
- identifiers: { x, y },
44
+ identifiers,
44
45
  };
45
46
  return question;
46
47
  };
@@ -1,2 +1,2 @@
1
- export {};
1
+ export * from "./pythagoreOrThales.js";
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/euclidian/index.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/euclidian/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC"}
@@ -1,2 +1 @@
1
- export {};
2
- // export * from "./pythagoreOrThales.js";
1
+ export * from "./pythagoreOrThales.js";
@@ -1,2 +1,11 @@
1
+ import { Exercise } from "../../../../exercises/exercise.js";
2
+ import { PointIdentifiers } from "../../../../math/geometry/point.js";
3
+ type Identifiers = {
4
+ isAskingLength: boolean;
5
+ isSegmentHeight: boolean;
6
+ pointsIdentifiers: PointIdentifiers[];
7
+ lengths: number[];
8
+ };
9
+ export declare const pythagoreOrThales: Exercise<Identifiers>;
1
10
  export {};
2
11
  //# sourceMappingURL=pythagoreOrThales.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pythagoreOrThales.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/euclidian/pythagoreOrThales.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"pythagoreOrThales.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/euclidian/pythagoreOrThales.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAkBT,MAAM,6BAA6B,CAAC;AAKrC,OAAO,EAGL,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AAkBtC,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,OAAO,CAAC;IACxB,eAAe,EAAE,OAAO,CAAC;IAEzB,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;IACtC,OAAO,EAAE,MAAM,EAAE,CAAC;CAQnB,CAAC;AA+MF,eAAO,MAAM,iBAAiB,EAAE,QAAQ,CAAC,WAAW,CAkBnD,CAAC"}
@@ -1,187 +1,205 @@
1
- // import {
2
- // Exercise,
3
- // Proposition,
4
- // QCMGenerator,
5
- // Question,
6
- // QuestionGenerator,
7
- // VEA,
8
- // GGBVEA,
9
- // addValidProp,
10
- // shuffleProps,
11
- // tryToAddWrongProp,
12
- // GetAnswer,
13
- // GetHint,
14
- // GetCorrection,
15
- // GetInstruction,
16
- // GetKeys,
17
- // GetGGBOptions,
18
- // GetStudentGGBOptions,
19
- // GetGGBAnswer,
20
- // } from "../../../../exercises/exercise.js";
21
- // import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
22
- // import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
23
- // import { Line, LineConstructor } from "../../../../math/geometry/line.js";
24
- // import {
25
- // Point,
26
- // PointConstructor,
27
- // PointIdentifiers,
28
- // } from "../../../../math/geometry/point.js";
29
- // import {
30
- // Segment,
31
- // SegmentConstructor,
32
- // SegmentIdentifiers,
33
- // } from "../../../../math/geometry/segment.js";
34
- // import {
35
- // Triangle,
36
- // TriangleConstructor,
37
- // TriangleIdentifiers,
38
- // } from "../../../../math/geometry/triangle.js";
39
- // import { coinFlip } from "../../../../utils/alea/coinFlip.js";
40
- export {};
41
- // type Identifiers = {
42
- // isAskingLength: boolean;
43
- // triangleIdentifiers: TriangleIdentifiers;
44
- // extraPoints: PointIdentifiers[];
45
- // isSegmentHeight: boolean; // si hauteur alors configuration pythagore
46
- // };
47
- // const getPropositions: QCMGenerator<Identifiers> = (n, { answer }) => {
48
- // const propositions: Proposition[] = [];
49
- // addValidProp(propositions, answer, "raw");
50
- // tryToAddWrongProp(propositions, "Le théorème de Thalès", "raw");
51
- // tryToAddWrongProp(propositions, "La réciproque du théorème de Thalès", "raw");
52
- // tryToAddWrongProp(propositions, "Le théorème de Pythagore", "raw");
53
- // tryToAddWrongProp(
54
- // propositions,
55
- // "La réciproque du théorème de Pythagore",
56
- // "raw",
57
- // );
58
- // return shuffleProps(propositions, n);
59
- // };
60
- // const getAnswer: GetAnswer<Identifiers> = (identifiers) => {
61
- // const { isAskingLength, triangleIdentifiers, isSegmentHeight } = identifiers;
62
- // return isSegmentHeight
63
- // ? isAskingLength
64
- // ? "Le théorème de Pythagore"
65
- // : "La réciproque du théorème de Pythagore"
66
- // : isAskingLength
67
- // ? "Le théorème de Thalès"
68
- // : "La réciproque du théorème de Thalès";
69
- // };
70
- // const getInstruction: GetInstruction<Identifiers> = (identifiers) => {
71
- // const { isAskingLength, triangleIdentifiers, isSegmentHeight, extraPoints } = identifiers;
72
- // const triangle = TriangleConstructor.fromIdentifiers(triangleIdentifiers);
73
- // const points = extraPoints.map((e) => PointConstructor.fromIdentifiers(e));
74
- // let instruction = ``;
75
- // if(isSegmentHeight){
76
- // if(isAskingLength){
77
- // instruction = `calculer la longueur $${triangle.sides[2].toInsideName()}$`
78
- // } else {
79
- // instruction = `prouver que le triangle $${triangle.points[1].name}${triangle.points[2].name}${points[0].name}$ est rectangle en $${points[0].name}$`
80
- // }
81
- // } else {
82
- // if(isAskingLength){
83
- // instruction = `calculer la longueur $${points[0].name}${points[1].name}$`
84
- // } else {
85
- // instruction = `prouver que les droites $${}$ et $${}$ sont parallèles`
86
- // }
87
- // }
88
- // return `On donne la figure ci-dessous.
89
- // Pour ${instruction}, il faut utiliser... `;
90
- // };
91
- // // const getHint: GetHint<Identifiers> = (identifiers) => {};
92
- // // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
93
- // const getGGBOptions: GetGGBOptions<Identifiers> = (identifiers) => {
94
- // const { isAskingLength, triangleIdentifiers, extraPoints, isSegmentHeight } =
95
- // identifiers;
96
- // const triangle = TriangleConstructor.fromIdentifiers(triangleIdentifiers);
97
- // const points = extraPoints.map((e) => PointConstructor.fromIdentifiers(e));
98
- // const commands = [
99
- // ...triangle.commands,
100
- // ...points.flatMap((p) => p.toGGBCommand()),
101
- // ];
102
- // if (isSegmentHeight) {
103
- // commands.push(
104
- // ...new Segment(triangle.points[1], points[0]).toGGBCommands(false),
105
- // );
106
- // } else {
107
- // commands.push(...new Segment(points[0], points[1]).toGGBCommands(false));
108
- // }
109
- // const ggb = new GeogebraConstructor({
110
- // commands,
111
- // hideAxes: true,
112
- // hideGrid: true,
113
- // });
114
- // return ggb.getOptions({
115
- // coords: triangle.generateCoords(),
116
- // });
117
- // };
118
- // const getKeys: GetKeys<Identifiers> = (identifiers) => {
119
- // return [];
120
- // };
121
- // const isAnswerValid: VEA<Identifiers> = (ans, { answer }) => {
122
- // throw Error("VEA not implemented");
123
- // };
124
- // const getPythagoreOrThalesQuestion: QuestionGenerator<Identifiers> = (opts) => {
125
- // // const triangle = TriangleConstructor.randomNiceSides({});
126
- // const A = new Point("A", 0, 0);
127
- // const B = new Point("B", 4, 4);
128
- // const C = new Point("C", 8, 0);
129
- // const triangle = new Triangle([A, B, C]);
130
- // const isSegmentHeight = coinFlip();
131
- // const isAskingLength = coinFlip();
132
- // let extraPoints: PointIdentifiers[] = [];
133
- // if (isSegmentHeight) {
134
- // const baseLine = LineConstructor.fromSegment(triangle.sides[1]);
135
- // const height = baseLine.getPerpendicular(triangle.points[1]);
136
- // extraPoints.push(height.intersect(baseLine, "H").toIdentifiers());
137
- // } else {
138
- // const baseLine = LineConstructor.fromSegment(triangle.sides[1]);
139
- // const D = PointConstructor.onSegment(triangle.sides[2], "D", {
140
- // spacing: 0.3,
141
- // });
142
- // const para = baseLine.getParallele(D);
143
- // const E = para.intersect(
144
- // LineConstructor.fromSegment(triangle.sides[0]),
145
- // "E",
146
- // );
147
- // extraPoints.push(D.toIdentifiers());
148
- // extraPoints.push(E.toIdentifiers());
149
- // }
150
- // const identifiers: Identifiers = {
151
- // triangleIdentifiers: triangle.toIdentifiers(),
152
- // // segmentIdentifiers: triangle.sides[0].toIdentifiers(),
153
- // extraPoints,
154
- // isAskingLength,
155
- // isSegmentHeight,
156
- // };
157
- // const question: Question<Identifiers> = {
158
- // answer: getAnswer(identifiers),
159
- // instruction: getInstruction(identifiers),
160
- // keys: getKeys(identifiers),
161
- // answerFormat: "raw",
162
- // identifiers,
163
- // // hint: getHint(identifiers),
164
- // // correction: getCorrection(identifiers),
165
- // ggbOptions: getGGBOptions(identifiers),
166
- // };
167
- // return question;
168
- // };
169
- // export const pythagoreOrThales: Exercise<Identifiers> = {
170
- // id: "pythagoreOrThales",
171
- // label: "",
172
- // isSingleStep: true,
173
- // generator: (nb, opts) =>
174
- // getDistinctQuestions(() => getPythagoreOrThalesQuestion(opts), nb),
175
- // qcmTimer: 60,
176
- // freeTimer: 60,
177
- // getPropositions,
178
- // isAnswerValid,
179
- // subject: "Mathématiques",
180
- // // getHint,
181
- // // getCorrection,
182
- // getInstruction,
183
- // getAnswer,
184
- // getGGBOptions,
185
- // hasGeogebra: true,
186
- // answerType: "QCU",
187
- // };
1
+ import { addValidProp, shuffleProps, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
2
+ import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
3
+ import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
4
+ import { Angle } from "../../../../math/geometry/angle.js";
5
+ import { PointConstructor, } from "../../../../math/geometry/point.js";
6
+ import { RightTriangleConstructor } from "../../../../math/geometry/rightTriangle.js";
7
+ import { Segment, } from "../../../../math/geometry/segment.js";
8
+ import { Triangle, TriangleConstructor, } from "../../../../math/geometry/triangle.js";
9
+ import { VectorConstructor } from "../../../../math/geometry/vector.js";
10
+ import { round } from "../../../../math/utils/round.js";
11
+ import { NumberNode } from "../../../../tree/nodes/numbers/numberNode.js";
12
+ import { coinFlip } from "../../../../utils/alea/coinFlip.js";
13
+ const getPropositions = (n, { answer }) => {
14
+ const propositions = [];
15
+ addValidProp(propositions, answer, "raw");
16
+ tryToAddWrongProp(propositions, "Le théorème de Thalès", "raw");
17
+ tryToAddWrongProp(propositions, "La réciproque du théorème de Thalès", "raw");
18
+ tryToAddWrongProp(propositions, "Le théorème de Pythagore", "raw");
19
+ tryToAddWrongProp(propositions, "La réciproque du théorème de Pythagore", "raw");
20
+ return shuffleProps(propositions, n);
21
+ };
22
+ const getAnswer = (identifiers) => {
23
+ const { isAskingLength, isSegmentHeight } = identifiers;
24
+ return isSegmentHeight
25
+ ? isAskingLength
26
+ ? "Le théorème de Pythagore"
27
+ : "La réciproque du théorème de Pythagore"
28
+ : isAskingLength
29
+ ? "Le théorème de Thalès"
30
+ : "La réciproque du théorème de Thalès";
31
+ };
32
+ const getInstruction = (identifiers) => {
33
+ const { isAskingLength, pointsIdentifiers, isSegmentHeight } = identifiers;
34
+ const points = pointsIdentifiers.map((p) => PointConstructor.fromIdentifiers(p));
35
+ let instruction = ``;
36
+ if (isSegmentHeight) {
37
+ if (isAskingLength) {
38
+ instruction = `calculer la longueur $${points[0].name}${points[1].name}$`;
39
+ }
40
+ else {
41
+ instruction = `prouver que le triangle $${points[1].name}${points[2].name}${points[3].name}$ est rectangle en $${points[3].name}$`;
42
+ }
43
+ }
44
+ else {
45
+ if (isAskingLength) {
46
+ instruction = `calculer la longueur $${points[1].name}${points[3].name}$`;
47
+ }
48
+ else {
49
+ instruction = `prouver que les droites $\\left(${points[1].name}${points[3].name}\\right)$ et $\\left(${points[0].name}${points[4].name}\\right)$ sont parallèles`;
50
+ }
51
+ }
52
+ return `On donne la figure ci-dessous${!isSegmentHeight && isAskingLength
53
+ ? `, où les droites $\\left(${points[1].name}${points[3].name}\\right)$ et $\\left(${points[0].name}${points[4].name}\\right)$ sont parallèles.`
54
+ : "."}
55
+
56
+ Pour ${instruction}, il faut utiliser... `;
57
+ };
58
+ // const getHint: GetHint<Identifiers> = (identifiers) => {};
59
+ // const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
60
+ const getGGBOptions = (identifiers) => {
61
+ const { isAskingLength, lengths, pointsIdentifiers, isSegmentHeight } = identifiers;
62
+ const points = pointsIdentifiers.map((p) => PointConstructor.fromIdentifiers(p));
63
+ let segments;
64
+ if (isSegmentHeight) {
65
+ const withoutA = points.slice(1);
66
+ segments = withoutA.map((p, i) => new Segment(p, withoutA[(i + 1) % 3], {
67
+ lengthNode: new NumberNode(lengths[i]),
68
+ }));
69
+ segments.push(new Segment(points[3], points[0], {
70
+ lengthNode: new NumberNode(lengths[3]),
71
+ }));
72
+ segments.push(new Segment(points[0], points[1]));
73
+ }
74
+ else {
75
+ segments = points.map((p, i) => new Segment(p, points[(i + 1) % points.length], {
76
+ lengthNode: new NumberNode(lengths[i]),
77
+ }));
78
+ segments.push(new Segment(points[1], points[3]));
79
+ }
80
+ const commands = [
81
+ ...points.flatMap((p) => p.toGGBCommand()),
82
+ ...segments.flatMap((s, i) => s.toGGBCommands(false, { color: "grey", thickness: 3 })),
83
+ ...segments
84
+ .slice(0, segments.length - 1)
85
+ .flatMap((s, i) => s.getFitCaptionCommands({ size: "scriptsize", color: "red" })),
86
+ ...(isAskingLength && isSegmentHeight
87
+ ? new Angle([points[1], points[3], points[0]]).toCommands()
88
+ : []),
89
+ ];
90
+ const ggb = new GeogebraConstructor({
91
+ commands,
92
+ hideAxes: true,
93
+ hideGrid: true,
94
+ });
95
+ return ggb.getOptions({
96
+ coords: ggb.getCoordsForPoints(points),
97
+ });
98
+ };
99
+ const getKeys = (identifiers) => {
100
+ return [];
101
+ };
102
+ const isAnswerValid = (ans, { answer }) => {
103
+ throw Error("VEA not implemented");
104
+ };
105
+ const getPythagoreOrThalesQuestion = (opts) => {
106
+ const isSegmentHeight = coinFlip();
107
+ const isAskingLength = coinFlip();
108
+ let points;
109
+ let lengths;
110
+ const triangle = isSegmentHeight
111
+ ? RightTriangleConstructor.randomNiceSides({ names: ["D", "B", "C"] })
112
+ : TriangleConstructor.randomNiceSides({ minAngle: 40 });
113
+ const summitNames = triangle.points.map((p) => p.name);
114
+ if (isSegmentHeight) {
115
+ const triangle = RightTriangleConstructor.randomNiceSides({
116
+ names: ["D", "B", "C"],
117
+ });
118
+ const ratio = round(0.4 + Math.random() * 0.2, 1);
119
+ const triangleLengths = triangle.sides.map((s) => s.getLength());
120
+ const A = VectorConstructor.fromPoints(triangle.points[2], triangle.points[0])
121
+ .times(ratio.toTree())
122
+ .getEndPoint(triangle.points[0], "A");
123
+ points = [A, triangle.points[1], triangle.points[2], triangle.points[0]];
124
+ lengths = [
125
+ round(triangleLengths[0], 2),
126
+ round(triangleLengths[1], 2),
127
+ round(triangleLengths[2], 2),
128
+ round(A.distanceTo(triangle.points[0]), 2),
129
+ ];
130
+ }
131
+ else {
132
+ const triangle = TriangleConstructor.randomNiceSides({ minAngle: 40 });
133
+ const ratio = round(0.4 + Math.random() * 0.2, 1);
134
+ const dName = "D";
135
+ const eName = "E";
136
+ const subTriangle = getSubTriangle({
137
+ triangle,
138
+ insidePointsNames: [dName, eName],
139
+ ratio,
140
+ isPapillon: false,
141
+ });
142
+ const triangleLengths = triangle.sides.map((s) => s.getLength());
143
+ const subTriangleLengths = subTriangle.sides.map((s) => s.getLength());
144
+ points = [
145
+ triangle.points[0],
146
+ subTriangle.points[0],
147
+ triangle.points[1],
148
+ subTriangle.points[2],
149
+ triangle.points[2],
150
+ ];
151
+ lengths = [
152
+ round(triangleLengths[2] - subTriangleLengths[2], 2),
153
+ round(subTriangleLengths[2], 2),
154
+ round(subTriangleLengths[0], 2),
155
+ round(triangleLengths[0] - subTriangleLengths[0], 2),
156
+ round(triangleLengths[1], 2),
157
+ ];
158
+ }
159
+ const identifiers = {
160
+ lengths,
161
+ pointsIdentifiers: points.map((p) => p.toIdentifiers()),
162
+ isAskingLength,
163
+ isSegmentHeight,
164
+ };
165
+ const question = {
166
+ answer: getAnswer(identifiers),
167
+ instruction: getInstruction(identifiers),
168
+ keys: getKeys(identifiers),
169
+ answerFormat: "raw",
170
+ identifiers,
171
+ // hint: getHint(identifiers),
172
+ // correction: getCorrection(identifiers),
173
+ ggbOptions: getGGBOptions(identifiers),
174
+ };
175
+ return question;
176
+ };
177
+ export const pythagoreOrThales = {
178
+ id: "pythagoreOrThales",
179
+ label: "Choisir entre Thalès, Pythagore et leurs réciproques",
180
+ isSingleStep: true,
181
+ generator: (nb, opts) => getDistinctQuestions(() => getPythagoreOrThalesQuestion(opts), nb),
182
+ qcmTimer: 60,
183
+ freeTimer: 60,
184
+ getPropositions,
185
+ isAnswerValid,
186
+ subject: "Mathématiques",
187
+ // getHint,
188
+ // getCorrection,
189
+ getInstruction,
190
+ getAnswer,
191
+ getGGBOptions,
192
+ hasGeogebra: true,
193
+ answerType: "QCU",
194
+ };
195
+ const getSubTriangle = ({ triangle, insidePointsNames, ratio, isPapillon, }) => {
196
+ const [A, B, C] = triangle.points;
197
+ const [dName, eName] = insidePointsNames;
198
+ const vecAB = VectorConstructor.fromPoints(A, B).times((1 - ratio).toTree());
199
+ const pointD = vecAB.getEndPoint(A, dName);
200
+ const vecCB = VectorConstructor.fromPoints(C, B).times((1 - ratio).toTree());
201
+ const pointE = vecCB.getEndPoint(C, eName);
202
+ return new Triangle([pointD, triangle.points[1], pointE], {
203
+ sidesLengths: triangle.sides.map((s) => round(s.getLength() * Math.abs(ratio), 2).toTree()),
204
+ });
205
+ };
@@ -8,6 +8,7 @@ export * from "./convexity/index.js";
8
8
  export * from "./volumes/index.js";
9
9
  export * from "./euclidianConstructions/index.js";
10
10
  export * from "./shapes/index.js";
11
+ export * from "./euclidian/index.js";
11
12
  export * from "./parametric/index.js";
12
13
  export * from "./quadrilaterals/index.js";
13
14
  export * from "./angles/index.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/geometry/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AAEnC,cAAc,mCAAmC,CAAC;AAClD,cAAc,mBAAmB,CAAC;AAElC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/geometry/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AAEnC,cAAc,mCAAmC,CAAC;AAClD,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC"}
@@ -9,7 +9,7 @@ export * from "./volumes/index.js";
9
9
  // export * from "./triangles.js";
10
10
  export * from "./euclidianConstructions/index.js";
11
11
  export * from "./shapes/index.js";
12
- // export * from "./euclidian/index.js";
12
+ export * from "./euclidian/index.js";
13
13
  export * from "./parametric/index.js";
14
14
  export * from "./quadrilaterals/index.js";
15
15
  export * from "./angles/index.js";
@@ -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,6BAA6B,CAAC;AAMrC,OAAO,EAGL,mBAAmB,EACpB,MAAM,iCAAiC,CAAC;AAQzC,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"}
1
+ {"version":3,"file":"thalesCalcul.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/thales/thalesCalcul.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAqBT,MAAM,6BAA6B,CAAC;AAMrC,OAAO,EAGL,mBAAmB,EACpB,MAAM,iCAAiC,CAAC;AAQzC,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;AAmJF,KAAK,OAAO,GAAG;IACb,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AA8DF,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAwBvD,CAAC"}
@@ -83,7 +83,7 @@ const getGGBOptions = (identifiers) => {
83
83
  const seg = new Segment(points[0], points[1]);
84
84
  const commands = [
85
85
  ...triangle.commands,
86
- ...points.flatMap((p) => p.toGGBCommand({ style: 0, color: "#444444", size: 4 })),
86
+ ...points.flatMap((p) => p.toGGBCommand({ color: "#444444", size: 4 })),
87
87
  ...seg.toGGBCommands(false),
88
88
  ];
89
89
  if (identifiers.isPapillon) {
@@ -8,5 +8,6 @@ export type ToGGBCommandsProps = {
8
8
  color?: string;
9
9
  showLength?: boolean;
10
10
  label?: string;
11
+ thickness?: number;
11
12
  };
12
13
  //# sourceMappingURL=toGGBCommandsProps.d.ts.map
@@ -1 +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;IACpC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC"}
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;IACpC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC"}
package/lib/index.d.ts CHANGED
@@ -1260,6 +1260,11 @@ declare const mathExercises: (Exercise<{
1260
1260
  }, {}> | Exercise<{
1261
1261
  type: number;
1262
1262
  commands: string[];
1263
+ }, {}> | Exercise<{
1264
+ isAskingLength: boolean;
1265
+ isSegmentHeight: boolean;
1266
+ pointsIdentifiers: import("./math/geometry/point.js").PointIdentifiers[];
1267
+ lengths: number[];
1263
1268
  }, {}> | Exercise<{
1264
1269
  startPoint: number[];
1265
1270
  vector: number[];
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAG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,EAAE,cAAc,EAAE,CAAC"}
@@ -35,8 +35,12 @@ export declare class Segment {
35
35
  toTex(): string;
36
36
  toInsideName(): string;
37
37
  toLengthTex(): string;
38
- getFitCaptionCommands(text?: string, color?: string): string[];
39
- toGGBCommands(shouldBuildPoints: boolean, { isFixed, showLabel, showUnderlyingPointsLabel, showLength, style, }?: ToGGBCommandsProps): string[];
38
+ getFitCaptionCommands({ text, color, size, }?: {
39
+ text?: string;
40
+ color?: string;
41
+ size?: "scriptsize" | "tiny" | "small" | "large";
42
+ }): string[];
43
+ toGGBCommands(shouldBuildPoints: boolean, { isFixed, showLabel, showUnderlyingPointsLabel, showLength, style, thickness, }?: ToGGBCommandsProps): string[];
40
44
  includes(point: Point): boolean;
41
45
  toVector(): Vector;
42
46
  }
@@ -1 +1 @@
1
- {"version":3,"file":"segment.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/segment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sDAAsD,CAAC;AAE1F,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAElE,OAAO,EAEL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAK7C,OAAO,EAAE,KAAK,EAAoB,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EAAE,MAAM,EAAqB,MAAM,aAAa,CAAC;AAExD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,gBAAgB,CAAC;IACzB,MAAM,EAAE,gBAAgB,CAAC;IACzB,KAAK,CAAC,EAAE,uBAAuB,CAAC;CACjC,CAAC;AACF,8BAAsB,kBAAkB;IACtC,MAAM,CAAC,MAAM;IAOb,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,kBAAkB;CAYvD;AAED,KAAK,uBAAuB,GAAG;IAC7B,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AACF,KAAK,YAAY,GAAG;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FitCaptionCommands(text, color) {
77
+ getFitCaptionCommands({ text, color, size, } = {}) {
78
78
  const txt = text ?? this.getLength().frenchify();
79
79
  const midPoint = this.getMidpoint().toMathString();
80
80
  const cmds = [
81
- `angle_{${this.name}} = Angle(Vector(${this.pointA.name}, ${this.pointB.name}))`,
82
- `SetVisibleInView(angle_{${this.name}}, 1, false)`,
83
- `text_{${this.name}} = Text(RotateText("${txt}", If(angle_{${this.name}} > 90° ∧ angle_{${this.name}} < 270°, angle_{${this.name}} + 180°, angle_{${this.name}})), ${midPoint}, true, true, 0, 0)`,
81
+ // `angle_{${this.name}} = Angle(Vector(${this.pointA.name}, ${this.pointB.name}))`,
82
+ // `SetVisibleInView(angle_{${this.name}}, 1, false)`,
83
+ // `text_{${this.name}} = Text(RotateText("${txt}", If(angle_{${this.name}} > 90° ∧ angle_{${this.name}} < 270°, angle_{${this.name}} + 180°, angle_{${this.name}})), ${midPoint}, true, true, 0, 0)`,
84
+ `text_{${this.name}} = Text("${size ? `\\${size}` : ""} ${txt}", ${midPoint}, true, true, 0, 0)`,
85
+ // `SetBackgroundColor(text_{${this.name}}, "white")`,
84
86
  ];
85
87
  if (color) {
86
88
  cmds.push(`SetColor(text_{${this.name}}, "${color}")`);
87
89
  }
88
90
  return cmds;
89
91
  }
90
- toGGBCommands(shouldBuildPoints, { isFixed = true, showLabel = false, showUnderlyingPointsLabel = true, showLength = false, style, } = {}) {
92
+ toGGBCommands(shouldBuildPoints, { isFixed = true, showLabel = false, showUnderlyingPointsLabel = true, showLength = false, style, thickness, } = {}) {
91
93
  const commands = [
92
94
  `${this.ggbName}=Segment(${this.pointA.name},${this.pointB.name})`,
93
95
  `SetFixed(${this.ggbName},${isFixed ? "true" : "false"})`,
@@ -98,9 +100,12 @@ export class Segment {
98
100
  }
99
101
  if (showLength) {
100
102
  const length = this.getLengthNode().toTex();
101
- commands.push(`SetCaption(${this.ggbName}, ${length})`);
103
+ commands.push(`SetCaption(${this.ggbName}, "${length}")`);
102
104
  commands.push(`ShowLabel(${this.ggbName}, true)`);
103
105
  }
106
+ if (thickness !== undefined) {
107
+ commands.push(`SetLineThickness(${this.ggbName}, ${thickness})`);
108
+ }
104
109
  if (shouldBuildPoints) {
105
110
  const ACommands = this.pointA.toGGBCommand({
106
111
  isFixed,
@@ -9,10 +9,11 @@ export type TriangleIdentifiers = {
9
9
  };
10
10
  export declare abstract class TriangleConstructor {
11
11
  static fromIdentifiers(identifiers: TriangleIdentifiers): Triangle;
12
- static randomNiceSides({ names, randomName, intSides, }: {
12
+ static randomNiceSides({ names, randomName, intSides, minAngle, }: {
13
13
  names?: string[] | undefined;
14
14
  randomName?: boolean | undefined;
15
15
  intSides?: boolean | undefined;
16
+ minAngle?: number | undefined;
16
17
  }): Triangle;
17
18
  static randomName(): string[];
18
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"triangle.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/triangle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAoB,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEvE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAKnC,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAEL,eAAe,EAEhB,MAAM,qCAAqC,CAAC;AAG7C,MAAM,MAAM,mBAAmB,GAAG;IAChC,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,KAAK,CAAC,EAAE,wBAAwB,CAAC;CAClC,CAAC;AAEF,8BAAsB,mBAAmB;IACvC,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,mBAAmB,GAAG,QAAQ;IAgBlE,MAAM,CAAC,eAAe,CAAC,EACrB,KAAuB,EACvB,UAAkB,EAClB,QAAgB,GACjB;;;;KAAA,GAAG,QAAQ;IA8BZ,MAAM,CAAC,UAAU;CAQlB;AAED,MAAM,MAAM,wBAAwB,GAAG;IAC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esLengths: identifiers.props?.sidesLengths?.map((n) => n ? reifyAlgebraic(n) : undefined),
17
17
  });
18
18
  }
19
- static randomNiceSides({ names = ["A", "B", "C"], randomName = false, intSides = false, }) {
19
+ static randomNiceSides({ names = ["A", "B", "C"], randomName = false, intSides = false, minAngle = 0, }) {
20
20
  let vertices = [];
21
21
  if (randomName)
22
22
  vertices = TriangleConstructor.randomName();
23
23
  else
24
24
  vertices = names;
25
- const angle = randfloat(0, 2 * Math.PI);
26
- const addAngle = randfloat(Math.PI / 4, (3 * Math.PI) / 4);
27
- //on construit [AC] sur (Ox) de milieu O et de taille 2*xRand
28
- //puis [AB] sur (Ox) qu'on rotate
29
- const xRand = intSides ? randint(5, 9) : randfloat(5, 8, 1);
30
- const xRand2 = intSides ? randint(-5, 5) : randfloat(-5, 5, 1);
31
- const origin = new Point("O", (0).toTree(), (0).toTree());
32
- const startA = new Point(vertices[0], (-xRand).toTree(), (0).toTree());
33
- const A = startA.rotate(angle, origin);
34
- const C = new Point(vertices[2], xRand.toTree(), (0).toTree()).rotate(angle, origin);
35
- const B = new Point(vertices[1], (-xRand + xRand2).toTree(), (0).toTree()).rotate(angle + addAngle, startA);
25
+ let A;
26
+ let B;
27
+ let C;
28
+ const anglesAreNice = () => {
29
+ const values = [
30
+ new Angle([C, B, A]).evaluate(),
31
+ new Angle([A, C, B]).evaluate(),
32
+ new Angle([B, A, C]).evaluate(),
33
+ ];
34
+ if (minAngle)
35
+ return values.every((v) => v > minAngle && v < 180 - minAngle);
36
+ return values.every((v) => v > 20 && v < 110);
37
+ };
38
+ do {
39
+ const angle = randfloat(0, 2 * Math.PI);
40
+ const addAngle = randfloat(Math.PI / 4, (3 * Math.PI) / 4);
41
+ //on construit [AC] sur (Ox) de milieu O et de taille 2*xRand
42
+ //puis [AB] sur (Ox) qu'on rotate
43
+ const xRand = intSides ? randint(5, 9) : randfloat(5, 8, 1);
44
+ const xRand2 = intSides ? randint(-5, 5) : randfloat(-5, 5, 1);
45
+ const origin = new Point("O", (0).toTree(), (0).toTree());
46
+ const startA = new Point(vertices[0], (-xRand).toTree(), (0).toTree());
47
+ A = startA.rotate(angle, origin);
48
+ C = new Point(vertices[2], xRand.toTree(), (0).toTree()).rotate(angle, origin);
49
+ B = new Point(vertices[1], (-xRand + xRand2).toTree(), (0).toTree()).rotate(angle + addAngle, startA);
50
+ } while (!anglesAreNice());
36
51
  return new Triangle([A, B, C], {
37
52
  sidesLengths: [
38
53
  round(B.distanceTo(C), intSides ? 0 : 1).toTree(),
@@ -138,7 +153,10 @@ export class Triangle {
138
153
  if (opts.color)
139
154
  this.commands.push(`SetColor(${side.ggbName}, "${opts.color}")`);
140
155
  if (opts.caption) {
141
- this.commands.push(...side.getFitCaptionCommands(opts.caption, opts.color));
156
+ this.commands.push(...side.getFitCaptionCommands({
157
+ text: opts.caption,
158
+ color: opts.color,
159
+ }));
142
160
  }
143
161
  }
144
162
  highlightAngle(index, opts) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "math-exercises",
3
3
  "type": "module",
4
- "version": "3.0.21",
4
+ "version": "3.0.22",
5
5
  "description": "Math exercises generator for middle school and high school",
6
6
  "main": "lib/index.js",
7
7
  "files": [