math-exercises 3.0.99 → 3.0.101
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/exercises/math/geometry/areas/calculateAreaFromCodedShape.d.ts +9 -0
- package/lib/exercises/math/geometry/areas/calculateAreaFromCodedShape.d.ts.map +1 -0
- package/lib/exercises/math/geometry/areas/calculateAreaFromCodedShape.js +156 -0
- package/lib/exercises/math/geometry/areas/index.d.ts +1 -0
- package/lib/exercises/math/geometry/areas/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/areas/index.js +1 -0
- package/lib/exercises/math/geometry/euclidian/index.d.ts +1 -0
- package/lib/exercises/math/geometry/euclidian/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/euclidian/index.js +1 -0
- package/lib/exercises/math/geometry/euclidian/orthogonalProjectFromPicture.d.ts +8 -0
- package/lib/exercises/math/geometry/euclidian/orthogonalProjectFromPicture.d.ts.map +1 -0
- package/lib/exercises/math/geometry/euclidian/orthogonalProjectFromPicture.js +197 -0
- package/lib/exercises/math/geometry/euclidianConstructions/pointImageFromTranslation.d.ts.map +1 -1
- package/lib/exercises/math/geometry/euclidianConstructions/pointImageFromTranslation.js +45 -17
- package/lib/exercises/math/geometry/pythagore/calculateDiagonalFromSides.d.ts +9 -0
- package/lib/exercises/math/geometry/pythagore/calculateDiagonalFromSides.d.ts.map +1 -0
- package/lib/exercises/math/geometry/pythagore/calculateDiagonalFromSides.js +155 -0
- package/lib/exercises/math/geometry/pythagore/index.d.ts +1 -0
- package/lib/exercises/math/geometry/pythagore/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/pythagore/index.js +2 -0
- package/lib/exercises/math/geometry/pythagore/pythagoreCalcul.js +1 -1
- package/lib/exercises/math/geometry/pythagore/triangleHeight.d.ts +9 -0
- package/lib/exercises/math/geometry/pythagore/triangleHeight.d.ts.map +1 -0
- package/lib/exercises/math/geometry/pythagore/triangleHeight.js +105 -0
- package/lib/exercises/math/geometry/quadrilaterals/index.d.ts +2 -0
- package/lib/exercises/math/geometry/quadrilaterals/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/quadrilaterals/index.js +2 -0
- package/lib/exercises/math/geometry/quadrilaterals/parallelogramRectangle.d.ts +11 -0
- package/lib/exercises/math/geometry/quadrilaterals/parallelogramRectangle.d.ts.map +1 -0
- package/lib/exercises/math/geometry/quadrilaterals/parallelogramRectangle.js +140 -0
- package/lib/exercises/math/geometry/quadrilaterals/parallelogramRhombus.d.ts +11 -0
- package/lib/exercises/math/geometry/quadrilaterals/parallelogramRhombus.d.ts.map +1 -0
- package/lib/exercises/math/geometry/quadrilaterals/parallelogramRhombus.js +144 -0
- package/lib/exercises/math/geometry/vectors/colinearity/colinearityFromPicture.d.ts +9 -0
- package/lib/exercises/math/geometry/vectors/colinearity/colinearityFromPicture.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/colinearity/colinearityFromPicture.js +201 -0
- package/lib/exercises/math/geometry/vectors/colinearity/determinant.d.ts +8 -0
- package/lib/exercises/math/geometry/vectors/colinearity/determinant.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/colinearity/determinant.js +101 -0
- package/lib/exercises/math/geometry/vectors/colinearity/index.d.ts +2 -0
- package/lib/exercises/math/geometry/vectors/colinearity/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/colinearity/index.js +2 -0
- package/lib/exercises/math/geometry/vectors/constructions/drawAVectorInGGB.d.ts +8 -0
- package/lib/exercises/math/geometry/vectors/constructions/drawAVectorInGGB.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/constructions/drawAVectorInGGB.js +78 -0
- package/lib/exercises/math/geometry/vectors/constructions/index.d.ts +8 -0
- package/lib/exercises/math/geometry/vectors/constructions/index.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/constructions/index.js +7 -0
- package/lib/exercises/math/geometry/vectors/constructions/linearVectorCombinationFromGraph.d.ts +9 -0
- package/lib/exercises/math/geometry/vectors/constructions/linearVectorCombinationFromGraph.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/constructions/linearVectorCombinationFromGraph.js +179 -0
- package/lib/exercises/math/geometry/vectors/constructions/placePointFromPointAndVector.d.ts +12 -0
- package/lib/exercises/math/geometry/vectors/constructions/placePointFromPointAndVector.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/constructions/placePointFromPointAndVector.js +171 -0
- package/lib/exercises/math/geometry/vectors/constructions/traceOppositeVector.d.ts +10 -0
- package/lib/exercises/math/geometry/vectors/constructions/traceOppositeVector.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/constructions/traceOppositeVector.js +135 -0
- package/lib/exercises/math/geometry/vectors/constructions/traceVectorDifference.d.ts +11 -0
- package/lib/exercises/math/geometry/vectors/constructions/traceVectorDifference.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/constructions/traceVectorDifference.js +163 -0
- package/lib/exercises/math/geometry/vectors/constructions/traceVectorMultiple.d.ts +11 -0
- package/lib/exercises/math/geometry/vectors/constructions/traceVectorMultiple.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/constructions/traceVectorMultiple.js +148 -0
- package/lib/exercises/math/geometry/vectors/constructions/traceVectorSum.d.ts +11 -0
- package/lib/exercises/math/geometry/vectors/constructions/traceVectorSum.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/constructions/traceVectorSum.js +160 -0
- package/lib/exercises/math/geometry/vectors/coordinatesReading.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/coordinatesReading.js +63 -14
- package/lib/exercises/math/geometry/vectors/equalCaracteristicFromGraph.d.ts +3 -0
- package/lib/exercises/math/geometry/vectors/equalCaracteristicFromGraph.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/equalCaracteristicFromGraph.js +63 -2
- package/lib/exercises/math/geometry/vectors/index.d.ts +4 -8
- package/lib/exercises/math/geometry/vectors/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/index.js +4 -8
- package/lib/exercises/math/geometry/vectors/parallelogram/fourthParallelogramPoint.d.ts +14 -0
- package/lib/exercises/math/geometry/vectors/parallelogram/fourthParallelogramPoint.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/parallelogram/fourthParallelogramPoint.js +78 -0
- package/lib/exercises/math/geometry/vectors/parallelogram/index.d.ts +4 -0
- package/lib/exercises/math/geometry/vectors/parallelogram/index.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/parallelogram/index.js +3 -0
- package/lib/exercises/math/geometry/vectors/parallelogram/parallelogramCriterion.d.ts +8 -0
- package/lib/exercises/math/geometry/vectors/parallelogram/parallelogramCriterion.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/parallelogram/parallelogramCriterion.js +193 -0
- package/lib/exercises/math/geometry/vectors/parallelogram/parallelogramViaEqualVectors.d.ts +14 -0
- package/lib/exercises/math/geometry/vectors/parallelogram/parallelogramViaEqualVectors.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/parallelogram/parallelogramViaEqualVectors.js +116 -0
- package/lib/exercises/math/geometry/vectors/translationFromPicture.d.ts +8 -0
- package/lib/exercises/math/geometry/vectors/translationFromPicture.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/translationFromPicture.js +104 -0
- package/lib/exercises/math/geometry/vectors/vectorRepresentative.d.ts +8 -0
- package/lib/exercises/math/geometry/vectors/vectorRepresentative.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/vectorRepresentative.js +161 -0
- package/lib/exercises/math/geometry/volumes/index.d.ts +1 -0
- package/lib/exercises/math/geometry/volumes/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/volumes/index.js +1 -0
- package/lib/exercises/math/geometry/volumes/variableVolume.d.ts +9 -0
- package/lib/exercises/math/geometry/volumes/variableVolume.d.ts.map +1 -0
- package/lib/exercises/math/geometry/volumes/variableVolume.js +203 -0
- package/lib/index.d.ts +89 -40
- package/lib/index.d.ts.map +1 -1
- package/lib/math/geometry/point.d.ts +1 -0
- package/lib/math/geometry/point.d.ts.map +1 -1
- package/lib/math/geometry/point.js +3 -0
- package/lib/math/geometry/vector.d.ts +1 -0
- package/lib/math/geometry/vector.d.ts.map +1 -1
- package/lib/math/geometry/vector.js +3 -0
- package/lib/playground.d.ts.map +1 -1
- package/lib/tests/pdfs/quizPdfPreambule.js +1 -1
- package/lib/tests/questionTest.d.ts.map +1 -1
- package/lib/tests/questionTest.js +4 -4
- package/lib/tree/nodes/functions/sqrtNode.d.ts +1 -1
- package/lib/tree/nodes/functions/sqrtNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/sqrtNode.js +8 -2
- package/package.json +1 -1
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { toolBarConstructor } from "../../../../../exercises/utils/geogebra/toolBarConstructor.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { GeogebraConstructor } from "../../../../../geogebra/geogebraConstructor.js";
|
|
4
|
+
import { ggbPointToCoords } from "../../../../../geogebra/parsers/ggbPointToCoords.js";
|
|
5
|
+
import { parseGGBPoints } from "../../../../../geogebra/parsers/parseGGBPoints.js";
|
|
6
|
+
import { Point, PointConstructor, } from "../../../../../math/geometry/point.js";
|
|
7
|
+
import { Vector, VectorConstructor, } from "../../../../../math/geometry/vector.js";
|
|
8
|
+
import { randTupleInt } from "../../../../../math/utils/random/randTupleInt.js";
|
|
9
|
+
import { add } from "../../../../../tree/nodes/operators/addNode.js";
|
|
10
|
+
import { substract } from "../../../../../tree/nodes/operators/substractNode.js";
|
|
11
|
+
import { coinFlip } from "../../../../../utils/alea/coinFlip.js";
|
|
12
|
+
import { random } from "../../../../../utils/alea/random.js";
|
|
13
|
+
import { randomLetter } from "../../../../../utils/strings/randomLetter.js";
|
|
14
|
+
const getInstruction = (identifiers) => {
|
|
15
|
+
const { pointAskedName, isStartingPointAsked, pointIds, vectorIds } = identifiers;
|
|
16
|
+
const point = PointConstructor.fromIdentifiers(pointIds);
|
|
17
|
+
const vector = VectorConstructor.fromIdentifiers(vectorIds);
|
|
18
|
+
const name = isStartingPointAsked
|
|
19
|
+
? `\\overrightarrow{${pointAskedName}${point.toTex()}}`
|
|
20
|
+
: `\\overrightarrow{${point.toTex()}${pointAskedName}}`;
|
|
21
|
+
return `Construire le point $${pointAskedName}$ tel que $${name} = ${vector.toTex()}$.`;
|
|
22
|
+
};
|
|
23
|
+
const getHint = (identifiers) => {
|
|
24
|
+
const { isStartingPointAsked, pointAskedName, pointIds, vectorIds } = identifiers;
|
|
25
|
+
const point = PointConstructor.fromIdentifiers(pointIds);
|
|
26
|
+
const vector = VectorConstructor.fromIdentifiers(vectorIds);
|
|
27
|
+
if (isStartingPointAsked) {
|
|
28
|
+
return `Trace le vecteur $${vector.toTex()}$ de telle sorte que l'extrémité du vecteur soit le point $${point.toTex()}$.`;
|
|
29
|
+
}
|
|
30
|
+
return `Trace le vecteur $${vector.toTex()}$ à partir du point $${point.toTex()}$.`;
|
|
31
|
+
};
|
|
32
|
+
const getCorrection = (identifiers) => {
|
|
33
|
+
const { isStartingPointAsked, pointAskedName, pointIds, vectorIds } = identifiers;
|
|
34
|
+
const point = PointConstructor.fromIdentifiers(pointIds);
|
|
35
|
+
const vector = VectorConstructor.fromIdentifiers(vectorIds);
|
|
36
|
+
if (isStartingPointAsked) {
|
|
37
|
+
return `On trace le vecteur $${vector.toTex()}$ de telle sorte que l'extrémité du vecteur soit le point $${point.toTex()}$. L'origine du vecteur est alors le point recherché.`;
|
|
38
|
+
}
|
|
39
|
+
return `On trace le vecteur $${vector.toTex()}$ à partir du point $${point.toTex()}$. On obtient alors le point recherché.`;
|
|
40
|
+
};
|
|
41
|
+
const getSolutionPoint = (identifiers) => {
|
|
42
|
+
const { pointAskedName, isStartingPointAsked, pointIds, vectorIds } = identifiers;
|
|
43
|
+
const point = PointConstructor.fromIdentifiers(pointIds);
|
|
44
|
+
const vector = VectorConstructor.fromIdentifiers(vectorIds);
|
|
45
|
+
if (isStartingPointAsked) {
|
|
46
|
+
//x = xA-xu
|
|
47
|
+
//y = yA-yu
|
|
48
|
+
return new Point(pointAskedName, substract(point.x, vector.x).simplify(), substract(point.y, vector.y).simplify());
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
//x = xA+xu
|
|
52
|
+
//y = yA+yu
|
|
53
|
+
return new Point(pointAskedName, add(point.x, vector.x).simplify(), add(point.y, vector.y).simplify());
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const getGGBAnswer = (identifiers) => {
|
|
57
|
+
const { pointAskedName, isStartingPointAsked, pointIds, vectorIds } = identifiers;
|
|
58
|
+
const point = PointConstructor.fromIdentifiers(pointIds);
|
|
59
|
+
const solutionPoint = getSolutionPoint(identifiers);
|
|
60
|
+
return [
|
|
61
|
+
...solutionPoint.toGGBCommand(),
|
|
62
|
+
isStartingPointAsked
|
|
63
|
+
? `a = Vector(${solutionPoint.toMathString()},${point.toMathString()})`
|
|
64
|
+
: `a = Vector(${point.toMathString()}, ${solutionPoint.toMathString()})`,
|
|
65
|
+
`SetFixed(a, true)`,
|
|
66
|
+
];
|
|
67
|
+
};
|
|
68
|
+
const getStudentGGBOptions = (identifiers) => {
|
|
69
|
+
const { pointAskedName, isStartingPointAsked, pointIds, vectorIds } = identifiers;
|
|
70
|
+
const point = PointConstructor.fromIdentifiers(pointIds);
|
|
71
|
+
const vector = VectorConstructor.fromIdentifiers(vectorIds);
|
|
72
|
+
const pointSolution = getSolutionPoint(identifiers);
|
|
73
|
+
let deltaX, deltaY;
|
|
74
|
+
do {
|
|
75
|
+
[deltaX, deltaY] = randTupleInt(2, {
|
|
76
|
+
excludes: [[0, 0]],
|
|
77
|
+
from: 2,
|
|
78
|
+
to: 5,
|
|
79
|
+
});
|
|
80
|
+
coinFlip() && (deltaX *= -1);
|
|
81
|
+
coinFlip() && (deltaY *= -1);
|
|
82
|
+
//empecher une translation colinéaire pour s'assurer de ne pas gener l'élève dans son input GGB
|
|
83
|
+
} while (deltaX * vector.y.evaluate() - deltaY * vector.x.evaluate() === 0);
|
|
84
|
+
const vectorStartPoint = (isStartingPointAsked ? pointSolution : point).translate(deltaX, deltaY);
|
|
85
|
+
const vectorEndPoint = (isStartingPointAsked ? point : pointSolution).translate(deltaX, deltaY);
|
|
86
|
+
const ggb = new GeogebraConstructor({
|
|
87
|
+
commands: [
|
|
88
|
+
...point.toGGBCommand(),
|
|
89
|
+
`${vector.name}=Vector(${vectorStartPoint.toMathString()},${vectorEndPoint.toMathString()})`,
|
|
90
|
+
`SetCaption(${vector.name},"$${vector.toTex()}$")`,
|
|
91
|
+
`ShowLabel(${vector.name},true)`,
|
|
92
|
+
`SetFixed(${vector.name},true)`,
|
|
93
|
+
],
|
|
94
|
+
customToolBar: toolBarConstructor({
|
|
95
|
+
point: true,
|
|
96
|
+
}),
|
|
97
|
+
hideAxes: true,
|
|
98
|
+
});
|
|
99
|
+
const oppositeSolution = getSolutionPoint({
|
|
100
|
+
...identifiers,
|
|
101
|
+
isStartingPointAsked: !isStartingPointAsked,
|
|
102
|
+
});
|
|
103
|
+
const points = [
|
|
104
|
+
oppositeSolution,
|
|
105
|
+
vectorStartPoint,
|
|
106
|
+
vectorEndPoint,
|
|
107
|
+
point,
|
|
108
|
+
pointSolution,
|
|
109
|
+
];
|
|
110
|
+
return ggb.getOptions({
|
|
111
|
+
coords: ggb.getCoordsForPoints(points),
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
const isGGBAnswerValid = (ans, { ggbAnswer, ...identifiers }) => {
|
|
115
|
+
const { isStartingPointAsked, pointAskedName, pointIds, vectorIds } = identifiers;
|
|
116
|
+
const point = PointConstructor.fromIdentifiers(pointIds);
|
|
117
|
+
const vector = VectorConstructor.fromIdentifiers(vectorIds);
|
|
118
|
+
const studentAns = ans.filter((c) => ![point.name, vector.name, "D"].includes(c[0]));
|
|
119
|
+
if (studentAns.length !== 1)
|
|
120
|
+
return false;
|
|
121
|
+
const solutionPoint = getSolutionPoint(identifiers);
|
|
122
|
+
const pointCoords = parseGGBPoints(studentAns).map((p) => ggbPointToCoords(p));
|
|
123
|
+
if (pointCoords.length !== 1)
|
|
124
|
+
return false;
|
|
125
|
+
return (new Point("K", pointCoords[0].x, pointCoords[0].y).distanceTo(solutionPoint) < 1);
|
|
126
|
+
};
|
|
127
|
+
const getPlacePointFromPointAndVectorQuestion = () => {
|
|
128
|
+
const isStartingPointAsked = coinFlip();
|
|
129
|
+
const point = PointConstructor.random(randomLetter(true));
|
|
130
|
+
const pointAskedName = randomLetter(true, [point.name]);
|
|
131
|
+
const vectorName = random(["u", "v", "w"]);
|
|
132
|
+
const [vectorX, vectorY] = randTupleInt(2, {
|
|
133
|
+
from: -3,
|
|
134
|
+
to: 4,
|
|
135
|
+
excludes: [[0, 0]],
|
|
136
|
+
});
|
|
137
|
+
const identifiers = {
|
|
138
|
+
isStartingPointAsked,
|
|
139
|
+
pointAskedName,
|
|
140
|
+
pointIds: point.toIdentifiers(),
|
|
141
|
+
vectorIds: new Vector(vectorName, vectorX.toTree(), vectorY.toTree()).toIdentifiers(),
|
|
142
|
+
};
|
|
143
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
144
|
+
};
|
|
145
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
146
|
+
return {
|
|
147
|
+
ggbAnswer: getGGBAnswer(identifiers),
|
|
148
|
+
instruction: getInstruction(identifiers),
|
|
149
|
+
studentGgbOptions: getStudentGGBOptions(identifiers),
|
|
150
|
+
identifiers,
|
|
151
|
+
hint: getHint(identifiers),
|
|
152
|
+
correction: getCorrection(identifiers),
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
export const placePointFromPointAndVector = {
|
|
156
|
+
id: "placePointFromPointAndVector",
|
|
157
|
+
label: "Construire un point à partir d'un point et d'un vecteur donné",
|
|
158
|
+
isSingleStep: true,
|
|
159
|
+
generator: (nb, opts) => getDistinctQuestions(() => getPlacePointFromPointAndVectorQuestion(opts), nb),
|
|
160
|
+
ggbTimer: 60,
|
|
161
|
+
isGGBAnswerValid,
|
|
162
|
+
subject: "Mathématiques",
|
|
163
|
+
getHint,
|
|
164
|
+
getInstruction,
|
|
165
|
+
getCorrection,
|
|
166
|
+
getGGBAnswer,
|
|
167
|
+
getStudentGGBOptions,
|
|
168
|
+
answerType: "GGB",
|
|
169
|
+
getQuestionFromIdentifiers,
|
|
170
|
+
hasHintAndCorrection: true,
|
|
171
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Exercise } from "../../../../../exercises/exercise.js";
|
|
2
|
+
import { PointIdentifiers } from "../../../../../math/geometry/point.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
points: PointIdentifiers[];
|
|
5
|
+
startPointIndex: number;
|
|
6
|
+
vectorPointsIndexes: number[];
|
|
7
|
+
};
|
|
8
|
+
export declare const traceOppositeVector: Exercise<Identifiers>;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=traceOppositeVector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traceOppositeVector.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/geometry/vectors/constructions/traceOppositeVector.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAOrC,OAAO,EAGL,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AAOtC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,mBAAmB,EAAE,MAAM,EAAE,CAAC;CAC/B,CAAC;AAuJF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAkBrD,CAAC"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { toolBarConstructor } from "../../../../../exercises/utils/geogebra/toolBarConstructor.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { red } from "../../../../../geogebra/colors.js";
|
|
4
|
+
import { GeogebraConstructor } from "../../../../../geogebra/geogebraConstructor.js";
|
|
5
|
+
import { ggbPointToCoords } from "../../../../../geogebra/parsers/ggbPointToCoords.js";
|
|
6
|
+
import { parseGGBPoints } from "../../../../../geogebra/parsers/parseGGBPoints.js";
|
|
7
|
+
import { Point, PointConstructor, } from "../../../../../math/geometry/point.js";
|
|
8
|
+
import { VectorConstructor } from "../../../../../math/geometry/vector.js";
|
|
9
|
+
import { randint } from "../../../../../math/utils/random/randint.js";
|
|
10
|
+
import { randomMany } from "../../../../../utils/alea/random.js";
|
|
11
|
+
const getSolutionPoint = (identifiers) => {
|
|
12
|
+
const points = identifiers.points.map(PointConstructor.fromIdentifiers);
|
|
13
|
+
const origin = points[identifiers.startPointIndex];
|
|
14
|
+
const vec = VectorConstructor.fromPoints(points[identifiers.vectorPointsIndexes[0]], points[identifiers.vectorPointsIndexes[1]]);
|
|
15
|
+
return vec.opposite().getEndPoint(origin, "K");
|
|
16
|
+
};
|
|
17
|
+
const getInstruction = (identifiers) => {
|
|
18
|
+
const { startPointIndex, vectorPointsIndexes } = identifiers;
|
|
19
|
+
const origin = identifiers.points[startPointIndex].name;
|
|
20
|
+
const vec = `${identifiers.points[vectorPointsIndexes[0]].name}${identifiers.points[vectorPointsIndexes[1]].name}`;
|
|
21
|
+
return `Placer le point $K$ tel que :
|
|
22
|
+
|
|
23
|
+
$$
|
|
24
|
+
\\overrightarrow{${origin}K} = -\\overrightarrow{${vec}}
|
|
25
|
+
$$`;
|
|
26
|
+
};
|
|
27
|
+
const getHint = (identifiers) => {
|
|
28
|
+
const { startPointIndex, points, vectorPointsIndexes } = identifiers;
|
|
29
|
+
const origin = identifiers.points[startPointIndex].name;
|
|
30
|
+
const vec = `${identifiers.points[vectorPointsIndexes[0]].name}${identifiers.points[vectorPointsIndexes[1]].name}`;
|
|
31
|
+
return `Rappelle toi que $-\\overrightarrow{v}$ est le vecteur de même norme et de même direction que $\\overrightarrow{v}$, mais de sens opposé.`;
|
|
32
|
+
};
|
|
33
|
+
const getCorrection = (identifiers) => {
|
|
34
|
+
const { startPointIndex, points, vectorPointsIndexes } = identifiers;
|
|
35
|
+
const origin = identifiers.points[startPointIndex].name;
|
|
36
|
+
const vec = `${identifiers.points[vectorPointsIndexes[0]].name}${identifiers.points[vectorPointsIndexes[1]].name}`;
|
|
37
|
+
const trueVec = vec.split("").reverse().join("");
|
|
38
|
+
return `On se place au point $${origin}$. On trace à partir de ce point le vecteur $-\\overrightarrow{${vec}} = \\overrightarrow{${trueVec}}$. Le point d'arrivée est le point $K$ recherché.`;
|
|
39
|
+
};
|
|
40
|
+
const getGGBAnswer = (identifiers) => {
|
|
41
|
+
const { startPointIndex, points, vectorPointsIndexes } = identifiers;
|
|
42
|
+
const origin = identifiers.points[startPointIndex].name;
|
|
43
|
+
const vec = [
|
|
44
|
+
identifiers.points[vectorPointsIndexes[1]].name,
|
|
45
|
+
identifiers.points[vectorPointsIndexes[0]].name,
|
|
46
|
+
];
|
|
47
|
+
const endPoint = getSolutionPoint(identifiers);
|
|
48
|
+
return [
|
|
49
|
+
...endPoint.toGGBCommand(),
|
|
50
|
+
`a = Vector(${origin}, K)`,
|
|
51
|
+
`SetColor(a, "${red}")`,
|
|
52
|
+
];
|
|
53
|
+
};
|
|
54
|
+
const getStudentGGBOptions = (identifiers) => {
|
|
55
|
+
const commands = identifiers.points.flatMap((p) => PointConstructor.fromIdentifiers(p).toGGBCommand({ size: 4 }));
|
|
56
|
+
const ggb = new GeogebraConstructor({
|
|
57
|
+
commands,
|
|
58
|
+
customToolBar: toolBarConstructor({
|
|
59
|
+
point: true,
|
|
60
|
+
}),
|
|
61
|
+
hideAxes: true,
|
|
62
|
+
fontSize: 16,
|
|
63
|
+
});
|
|
64
|
+
const points = identifiers.points.map((p) => PointConstructor.fromIdentifiers(p));
|
|
65
|
+
const solutionPoint = getSolutionPoint(identifiers);
|
|
66
|
+
return ggb.getOptions({
|
|
67
|
+
coords: ggb.getCoordsForPoints([...points, solutionPoint]),
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
const isGGBAnswerValid = (ans, { ggbAnswer, ...identifiers }) => {
|
|
71
|
+
const studentAns = ans.filter((c) => !["A", "B", "C"].includes(c[0]));
|
|
72
|
+
if (studentAns.length !== 1)
|
|
73
|
+
return false;
|
|
74
|
+
const solutionPoint = getSolutionPoint(identifiers);
|
|
75
|
+
const pointCoords = parseGGBPoints(studentAns).map((p) => ggbPointToCoords(p));
|
|
76
|
+
if (pointCoords.length !== 1)
|
|
77
|
+
return false;
|
|
78
|
+
return (new Point("K", pointCoords[0].x, pointCoords[0].y).distanceTo(solutionPoint) < 1);
|
|
79
|
+
};
|
|
80
|
+
const getTraceOppositeVectorQuestion = () => {
|
|
81
|
+
const names = ["A", "B", "C"];
|
|
82
|
+
let points = [];
|
|
83
|
+
let startPointIndex;
|
|
84
|
+
let vectorPointsIndexes;
|
|
85
|
+
while (true) {
|
|
86
|
+
points = [];
|
|
87
|
+
points.push(...PointConstructor.randomDifferent(3, {
|
|
88
|
+
minDistance: 2,
|
|
89
|
+
names,
|
|
90
|
+
minDistanceToOrigin: 3,
|
|
91
|
+
}));
|
|
92
|
+
startPointIndex = randint(0, names.length);
|
|
93
|
+
vectorPointsIndexes = randomMany([0, 1, 2], 2);
|
|
94
|
+
const vec = VectorConstructor.fromPoints(points[vectorPointsIndexes[0]], points[vectorPointsIndexes[1]]);
|
|
95
|
+
const endPoint = vec.opposite().getEndPoint(points[startPointIndex], "K");
|
|
96
|
+
if (endPoint.distanceTo(new Point("O", 0, 0)) > 10 ||
|
|
97
|
+
points.some((p) => p.equals(endPoint)))
|
|
98
|
+
continue;
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
const identifiers = {
|
|
102
|
+
vectorPointsIndexes,
|
|
103
|
+
points: points.map((p) => p.toIdentifiers()),
|
|
104
|
+
startPointIndex,
|
|
105
|
+
};
|
|
106
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
107
|
+
};
|
|
108
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
109
|
+
const question = {
|
|
110
|
+
ggbAnswer: getGGBAnswer(identifiers),
|
|
111
|
+
instruction: getInstruction(identifiers),
|
|
112
|
+
studentGgbOptions: getStudentGGBOptions(identifiers),
|
|
113
|
+
identifiers,
|
|
114
|
+
hint: getHint(identifiers),
|
|
115
|
+
correction: getCorrection(identifiers),
|
|
116
|
+
};
|
|
117
|
+
return question;
|
|
118
|
+
};
|
|
119
|
+
export const traceOppositeVector = {
|
|
120
|
+
id: "traceOppositeVector",
|
|
121
|
+
label: "Placer un point $K$ tel que $\\overrightarrow{AK} = -\\overrightarrow{BC}$",
|
|
122
|
+
isSingleStep: true,
|
|
123
|
+
generator: (nb, opts) => getDistinctQuestions(() => getTraceOppositeVectorQuestion(opts), nb),
|
|
124
|
+
ggbTimer: 60,
|
|
125
|
+
isGGBAnswerValid,
|
|
126
|
+
subject: "Mathématiques",
|
|
127
|
+
// getHint,
|
|
128
|
+
getInstruction,
|
|
129
|
+
// getCorrection,
|
|
130
|
+
getGGBAnswer,
|
|
131
|
+
getStudentGGBOptions,
|
|
132
|
+
answerType: "GGB",
|
|
133
|
+
getQuestionFromIdentifiers,
|
|
134
|
+
hasHintAndCorrection: true,
|
|
135
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Exercise } from "../../../../../exercises/exercise.js";
|
|
2
|
+
import { PointIdentifiers } from "../../../../../math/geometry/point.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
points: PointIdentifiers[];
|
|
5
|
+
startPointIndex: number;
|
|
6
|
+
firstVectorPointsIndexes: number[];
|
|
7
|
+
secondVectorPointsIndexes: number[];
|
|
8
|
+
};
|
|
9
|
+
export declare const traceVectorDifference: Exercise<Identifiers>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=traceVectorDifference.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traceVectorDifference.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/geometry/vectors/constructions/traceVectorDifference.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAOrC,OAAO,EAGL,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AAMtC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,wBAAwB,EAAE,MAAM,EAAE,CAAC;IACnC,yBAAyB,EAAE,MAAM,EAAE,CAAC;CACrC,CAAC;AA4NF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAiBvD,CAAC"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { toolBarConstructor } from "../../../../../exercises/utils/geogebra/toolBarConstructor.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { purpleDark, red } from "../../../../../geogebra/colors.js";
|
|
4
|
+
import { GeogebraConstructor } from "../../../../../geogebra/geogebraConstructor.js";
|
|
5
|
+
import { ggbPointToCoords } from "../../../../../geogebra/parsers/ggbPointToCoords.js";
|
|
6
|
+
import { parseGGBPoints } from "../../../../../geogebra/parsers/parseGGBPoints.js";
|
|
7
|
+
import { Point, PointConstructor, } from "../../../../../math/geometry/point.js";
|
|
8
|
+
import { VectorConstructor } from "../../../../../math/geometry/vector.js";
|
|
9
|
+
import { randint } from "../../../../../math/utils/random/randint.js";
|
|
10
|
+
import { randomMany } from "../../../../../utils/alea/random.js";
|
|
11
|
+
import { doWhile } from "../../../../../utils/doWhile.js";
|
|
12
|
+
const getSolutionPoint = (identifiers) => {
|
|
13
|
+
const points = identifiers.points.map(PointConstructor.fromIdentifiers);
|
|
14
|
+
const origin = points[identifiers.startPointIndex];
|
|
15
|
+
const vecs = [
|
|
16
|
+
VectorConstructor.fromPoints(points[identifiers.firstVectorPointsIndexes[0]], points[identifiers.firstVectorPointsIndexes[1]]),
|
|
17
|
+
VectorConstructor.fromPoints(points[identifiers.secondVectorPointsIndexes[0]], points[identifiers.secondVectorPointsIndexes[1]]),
|
|
18
|
+
];
|
|
19
|
+
return vecs[0].substract(vecs[1]).getEndPoint(origin, "K");
|
|
20
|
+
};
|
|
21
|
+
const getInstruction = (identifiers) => {
|
|
22
|
+
const { startPointIndex, firstVectorPointsIndexes, secondVectorPointsIndexes, } = identifiers;
|
|
23
|
+
const origin = identifiers.points[startPointIndex].name;
|
|
24
|
+
const firstVec = `${identifiers.points[firstVectorPointsIndexes[0]].name}${identifiers.points[firstVectorPointsIndexes[1]].name}`;
|
|
25
|
+
const secondVec = `${identifiers.points[secondVectorPointsIndexes[0]].name}${identifiers.points[secondVectorPointsIndexes[1]].name}`;
|
|
26
|
+
return `Placer le point $K$ tel que :
|
|
27
|
+
|
|
28
|
+
$$
|
|
29
|
+
\\overrightarrow{${origin}K} = \\overrightarrow{${firstVec}} - \\overrightarrow{${secondVec}}
|
|
30
|
+
$$`;
|
|
31
|
+
};
|
|
32
|
+
const getHint = (identifiers) => {
|
|
33
|
+
const { startPointIndex, firstVectorPointsIndexes, secondVectorPointsIndexes, points, } = identifiers;
|
|
34
|
+
const origin = identifiers.points[startPointIndex].name;
|
|
35
|
+
const firstVec = `${identifiers.points[firstVectorPointsIndexes[0]].name}${identifiers.points[firstVectorPointsIndexes[1]].name}`;
|
|
36
|
+
const secondVec = `${identifiers.points[secondVectorPointsIndexes[0]].name}${identifiers.points[secondVectorPointsIndexes[1]].name}`;
|
|
37
|
+
return `À partir du point $${origin}$, trace à la suite les vecteurs $\\overrightarrow{${firstVec}}$ et $-\\overrightarrow{${secondVec}}$. Rappelle toi que $-\\overrightarrow{v}$ est le vecteur de même norme et de même direction que $\\overrightarrow{v}$, mais de sens opposé.`;
|
|
38
|
+
};
|
|
39
|
+
const getCorrection = (identifiers) => {
|
|
40
|
+
const { startPointIndex, firstVectorPointsIndexes, secondVectorPointsIndexes, points, } = identifiers;
|
|
41
|
+
const origin = identifiers.points[startPointIndex].name;
|
|
42
|
+
const firstVec = `${identifiers.points[firstVectorPointsIndexes[0]].name}${identifiers.points[firstVectorPointsIndexes[1]].name}`;
|
|
43
|
+
const secondVec = `${identifiers.points[secondVectorPointsIndexes[0]].name}${identifiers.points[secondVectorPointsIndexes[1]].name}`;
|
|
44
|
+
return `On se place au point $${origin}$. On trace à partir de ce point le vecteur $\\overrightarrow{${firstVec}}$. Puis, à la suite, on trace le vecteur $-\\overrightarrow{${secondVec}} = \\overrightarrow{${secondVec
|
|
45
|
+
.split("")
|
|
46
|
+
.reverse()
|
|
47
|
+
.join("")}}$. Le point d'arrivée est le point $K$ recherché.`;
|
|
48
|
+
};
|
|
49
|
+
const getGGBAnswer = (identifiers) => {
|
|
50
|
+
const { startPointIndex, firstVectorPointsIndexes, secondVectorPointsIndexes, points, } = identifiers;
|
|
51
|
+
const origin = identifiers.points[startPointIndex].name;
|
|
52
|
+
const firstVec = [
|
|
53
|
+
identifiers.points[firstVectorPointsIndexes[0]].name,
|
|
54
|
+
identifiers.points[firstVectorPointsIndexes[1]].name,
|
|
55
|
+
];
|
|
56
|
+
const secondVec = [
|
|
57
|
+
identifiers.points[secondVectorPointsIndexes[0]].name,
|
|
58
|
+
identifiers.points[secondVectorPointsIndexes[1]].name,
|
|
59
|
+
];
|
|
60
|
+
const midPoint = `${origin}+Vector(${firstVec[0]}, ${firstVec[1]})`;
|
|
61
|
+
const endPoint = getSolutionPoint(identifiers);
|
|
62
|
+
return [
|
|
63
|
+
...endPoint.toGGBCommand(),
|
|
64
|
+
`a = Vector(${origin}, ${midPoint})`,
|
|
65
|
+
`SetColor(a, "${red}")`,
|
|
66
|
+
`b = Vector(${midPoint}, K)`,
|
|
67
|
+
`SetColor(b, "${purpleDark}")`,
|
|
68
|
+
];
|
|
69
|
+
};
|
|
70
|
+
const getStudentGGBOptions = (identifiers) => {
|
|
71
|
+
const { firstVectorPointsIndexes, secondVectorPointsIndexes, startPointIndex, } = identifiers;
|
|
72
|
+
const commands = identifiers.points.flatMap((p) => PointConstructor.fromIdentifiers(p).toGGBCommand({ size: 4 }));
|
|
73
|
+
const ggb = new GeogebraConstructor({
|
|
74
|
+
commands,
|
|
75
|
+
customToolBar: toolBarConstructor({
|
|
76
|
+
point: true,
|
|
77
|
+
}),
|
|
78
|
+
hideAxes: true,
|
|
79
|
+
fontSize: 16,
|
|
80
|
+
});
|
|
81
|
+
const points = identifiers.points.map((p) => PointConstructor.fromIdentifiers(p));
|
|
82
|
+
const firstVec = VectorConstructor.fromPoints(points[firstVectorPointsIndexes[0]], points[firstVectorPointsIndexes[1]]);
|
|
83
|
+
const origin = points[startPointIndex];
|
|
84
|
+
const midPoint = firstVec.getEndPoint(origin);
|
|
85
|
+
const solutionPoint = getSolutionPoint(identifiers);
|
|
86
|
+
return ggb.getOptions({
|
|
87
|
+
coords: ggb.getCoordsForPoints([...points, solutionPoint, midPoint]),
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
const isGGBAnswerValid = (ans, { ggbAnswer, ...identifiers }) => {
|
|
91
|
+
const studentAns = ans.filter((c) => !["A", "B", "C", "D"].includes(c[0]));
|
|
92
|
+
if (studentAns.length !== 1)
|
|
93
|
+
return false;
|
|
94
|
+
const solutionPoint = getSolutionPoint(identifiers);
|
|
95
|
+
const pointCoords = parseGGBPoints(studentAns).map((p) => ggbPointToCoords(p));
|
|
96
|
+
if (pointCoords.length !== 1)
|
|
97
|
+
return false;
|
|
98
|
+
return (new Point("K", pointCoords[0].x, pointCoords[0].y).distanceTo(solutionPoint) < 1);
|
|
99
|
+
};
|
|
100
|
+
const getTraceVectorDifferenceQuestion = () => {
|
|
101
|
+
const names = ["A", "B", "C", "D"];
|
|
102
|
+
let points = [];
|
|
103
|
+
let startPointIndex;
|
|
104
|
+
let firstVectorPointsIndexes;
|
|
105
|
+
let secondVectorPointsIndexes;
|
|
106
|
+
while (true) {
|
|
107
|
+
points = [];
|
|
108
|
+
points.push(...PointConstructor.randomDifferent(4, {
|
|
109
|
+
minDistance: 2,
|
|
110
|
+
names,
|
|
111
|
+
minDistanceToOrigin: 3,
|
|
112
|
+
}));
|
|
113
|
+
startPointIndex = randint(0, names.length);
|
|
114
|
+
firstVectorPointsIndexes = randomMany([0, 1, 2, 3], 2);
|
|
115
|
+
secondVectorPointsIndexes = doWhile(() => randomMany([0, 1, 2, 3], 2), (arr) => arr[0] === firstVectorPointsIndexes[0] &&
|
|
116
|
+
arr[1] === firstVectorPointsIndexes[1]);
|
|
117
|
+
//AC = AB+BC
|
|
118
|
+
const firstVec = VectorConstructor.fromPoints(points[firstVectorPointsIndexes[0]], points[firstVectorPointsIndexes[1]]);
|
|
119
|
+
const second = VectorConstructor.fromPoints(points[secondVectorPointsIndexes[0]], points[secondVectorPointsIndexes[1]]);
|
|
120
|
+
const endPoint = firstVec
|
|
121
|
+
.substract(second)
|
|
122
|
+
.getEndPoint(points[startPointIndex], "K");
|
|
123
|
+
if (endPoint.distanceTo(new Point("O", 0, 0)) > 10 ||
|
|
124
|
+
points.some((p) => p.equals(endPoint)))
|
|
125
|
+
continue;
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
const identifiers = {
|
|
129
|
+
firstVectorPointsIndexes,
|
|
130
|
+
points: points.map((p) => p.toIdentifiers()),
|
|
131
|
+
secondVectorPointsIndexes,
|
|
132
|
+
startPointIndex,
|
|
133
|
+
};
|
|
134
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
135
|
+
};
|
|
136
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
137
|
+
const question = {
|
|
138
|
+
ggbAnswer: getGGBAnswer(identifiers),
|
|
139
|
+
instruction: getInstruction(identifiers),
|
|
140
|
+
studentGgbOptions: getStudentGGBOptions(identifiers),
|
|
141
|
+
identifiers,
|
|
142
|
+
hint: getHint(identifiers),
|
|
143
|
+
correction: getCorrection(identifiers),
|
|
144
|
+
};
|
|
145
|
+
return question;
|
|
146
|
+
};
|
|
147
|
+
export const traceVectorDifference = {
|
|
148
|
+
id: "traceVectorDifference",
|
|
149
|
+
label: "Placer un point défini par une différence de vecteurs",
|
|
150
|
+
isSingleStep: true,
|
|
151
|
+
generator: (nb, opts) => getDistinctQuestions(() => getTraceVectorDifferenceQuestion(opts), nb),
|
|
152
|
+
ggbTimer: 60,
|
|
153
|
+
isGGBAnswerValid,
|
|
154
|
+
subject: "Mathématiques",
|
|
155
|
+
// getHint,
|
|
156
|
+
getInstruction,
|
|
157
|
+
// getCorrection,
|
|
158
|
+
getGGBAnswer,
|
|
159
|
+
getStudentGGBOptions,
|
|
160
|
+
answerType: "GGB",
|
|
161
|
+
getQuestionFromIdentifiers,
|
|
162
|
+
hasHintAndCorrection: true,
|
|
163
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Exercise } from "../../../../../exercises/exercise.js";
|
|
2
|
+
import { PointIdentifiers } from "../../../../../math/geometry/point.js";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
points: PointIdentifiers[];
|
|
5
|
+
startPointIndex: number;
|
|
6
|
+
vectorPointsIndexes: number[];
|
|
7
|
+
coeff: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const traceVectorMultiple: Exercise<Identifiers>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=traceVectorMultiple.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traceVectorMultiple.d.ts","sourceRoot":"","sources":["../../../../../../src/exercises/math/geometry/vectors/constructions/traceVectorMultiple.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,6BAA6B,CAAC;AAOrC,OAAO,EAGL,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AAOtC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AA0KF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAkBrD,CAAC"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { toolBarConstructor } from "../../../../../exercises/utils/geogebra/toolBarConstructor.js";
|
|
2
|
+
import { getDistinctQuestions } from "../../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
|
+
import { purpleDark, red } from "../../../../../geogebra/colors.js";
|
|
4
|
+
import { GeogebraConstructor } from "../../../../../geogebra/geogebraConstructor.js";
|
|
5
|
+
import { ggbPointToCoords } from "../../../../../geogebra/parsers/ggbPointToCoords.js";
|
|
6
|
+
import { parseGGBPoints } from "../../../../../geogebra/parsers/parseGGBPoints.js";
|
|
7
|
+
import { Point, PointConstructor, } from "../../../../../math/geometry/point.js";
|
|
8
|
+
import { VectorConstructor } from "../../../../../math/geometry/vector.js";
|
|
9
|
+
import { randint } from "../../../../../math/utils/random/randint.js";
|
|
10
|
+
import { random, randomMany } from "../../../../../utils/alea/random.js";
|
|
11
|
+
const getSolutionPoint = (identifiers) => {
|
|
12
|
+
const points = identifiers.points.map(PointConstructor.fromIdentifiers);
|
|
13
|
+
const origin = points[identifiers.startPointIndex];
|
|
14
|
+
const vec = VectorConstructor.fromPoints(points[identifiers.vectorPointsIndexes[0]], points[identifiers.vectorPointsIndexes[1]]);
|
|
15
|
+
return vec.times(identifiers.coeff.toTree()).getEndPoint(origin, "K");
|
|
16
|
+
};
|
|
17
|
+
const getInstruction = (identifiers) => {
|
|
18
|
+
const { startPointIndex, vectorPointsIndexes } = identifiers;
|
|
19
|
+
const origin = identifiers.points[startPointIndex].name;
|
|
20
|
+
const vec = `${identifiers.points[vectorPointsIndexes[0]].name}${identifiers.points[vectorPointsIndexes[1]].name}`;
|
|
21
|
+
return `Placer le point $K$ tel que :
|
|
22
|
+
|
|
23
|
+
$$
|
|
24
|
+
\\overrightarrow{${origin}K} = ${identifiers.coeff}\\overrightarrow{${vec}}
|
|
25
|
+
$$`;
|
|
26
|
+
};
|
|
27
|
+
const getHint = (identifiers) => {
|
|
28
|
+
const { startPointIndex, points, coeff, vectorPointsIndexes } = identifiers;
|
|
29
|
+
const origin = identifiers.points[startPointIndex].name;
|
|
30
|
+
const vec = `${identifiers.points[vectorPointsIndexes[0]].name}${identifiers.points[vectorPointsIndexes[1]].name}`;
|
|
31
|
+
return `Rappelle toi que $-\\overrightarrow{v}$ est le vecteur de même norme et de même direction que $\\overrightarrow{v}$, mais de sens opposé.`;
|
|
32
|
+
};
|
|
33
|
+
const getCorrection = (identifiers) => {
|
|
34
|
+
const { startPointIndex, points, coeff, vectorPointsIndexes } = identifiers;
|
|
35
|
+
const origin = identifiers.points[startPointIndex].name;
|
|
36
|
+
const vec = `${identifiers.points[vectorPointsIndexes[0]].name}${identifiers.points[vectorPointsIndexes[1]].name}`;
|
|
37
|
+
const trueVec = coeff < 0 ? vec.split("").reverse().join("") : vec;
|
|
38
|
+
return `On se place au point $${origin}$. On trace à partir de ce point le vecteur ${coeff < 0
|
|
39
|
+
? `$-\\overrightarrow{${vec}} = \\overrightarrow{${trueVec}}$`
|
|
40
|
+
: `$\\overrightarrow{${vec}}$`}, $${Math.abs(coeff)}$ fois à la suite. Le point d'arrivée est le point $K$ recherché.`;
|
|
41
|
+
};
|
|
42
|
+
const getGGBAnswer = (identifiers) => {
|
|
43
|
+
const { startPointIndex, points, coeff, vectorPointsIndexes } = identifiers;
|
|
44
|
+
const origin = identifiers.points[startPointIndex].name;
|
|
45
|
+
const vec = [
|
|
46
|
+
identifiers.points[vectorPointsIndexes[coeff < 0 ? 1 : 0]].name,
|
|
47
|
+
identifiers.points[vectorPointsIndexes[coeff < 0 ? 0 : 1]].name,
|
|
48
|
+
];
|
|
49
|
+
const endPoint = getSolutionPoint(identifiers);
|
|
50
|
+
const commands = [...endPoint.toGGBCommand()];
|
|
51
|
+
let midPoint = `${origin}`;
|
|
52
|
+
for (let i = 0; i < Math.abs(coeff); i++) {
|
|
53
|
+
const next = midPoint + `+Vector(${vec[0]}, ${vec[1]})`;
|
|
54
|
+
commands.push(...[
|
|
55
|
+
`a_${i} = Vector(${midPoint}, ${next})`,
|
|
56
|
+
`SetColor(a_${i}, "${i % 2 === 0 ? red : purpleDark}")`,
|
|
57
|
+
]);
|
|
58
|
+
midPoint = next;
|
|
59
|
+
}
|
|
60
|
+
return [...endPoint.toGGBCommand(), ...commands];
|
|
61
|
+
};
|
|
62
|
+
const getStudentGGBOptions = (identifiers) => {
|
|
63
|
+
const commands = identifiers.points.flatMap((p) => PointConstructor.fromIdentifiers(p).toGGBCommand({ size: 4 }));
|
|
64
|
+
const ggb = new GeogebraConstructor({
|
|
65
|
+
commands,
|
|
66
|
+
customToolBar: toolBarConstructor({
|
|
67
|
+
point: true,
|
|
68
|
+
}),
|
|
69
|
+
hideAxes: true,
|
|
70
|
+
fontSize: 16,
|
|
71
|
+
});
|
|
72
|
+
const points = identifiers.points.map((p) => PointConstructor.fromIdentifiers(p));
|
|
73
|
+
const solutionPoint = getSolutionPoint(identifiers);
|
|
74
|
+
return ggb.getOptions({
|
|
75
|
+
coords: ggb.getCoordsForPoints([...points, solutionPoint]),
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
const isGGBAnswerValid = (ans, { ggbAnswer, ...identifiers }) => {
|
|
79
|
+
const studentAns = ans.filter((c) => !["A", "B", "C"].includes(c[0]));
|
|
80
|
+
if (studentAns.length !== 1)
|
|
81
|
+
return false;
|
|
82
|
+
const solutionPoint = getSolutionPoint(identifiers);
|
|
83
|
+
const pointCoords = parseGGBPoints(studentAns).map((p) => ggbPointToCoords(p));
|
|
84
|
+
if (pointCoords.length !== 1)
|
|
85
|
+
return false;
|
|
86
|
+
return (new Point("K", pointCoords[0].x, pointCoords[0].y).distanceTo(solutionPoint) < 1);
|
|
87
|
+
};
|
|
88
|
+
const getTraceVectorMultipleQuestion = () => {
|
|
89
|
+
const names = ["A", "B", "C"];
|
|
90
|
+
let points = [];
|
|
91
|
+
let startPointIndex;
|
|
92
|
+
let vectorPointsIndexes;
|
|
93
|
+
let coeff = 0;
|
|
94
|
+
while (true) {
|
|
95
|
+
points = [];
|
|
96
|
+
coeff = random([-3, -2, 2, 3]);
|
|
97
|
+
points.push(...PointConstructor.randomDifferent(3, {
|
|
98
|
+
minDistance: 2,
|
|
99
|
+
names,
|
|
100
|
+
minDistanceToOrigin: 3,
|
|
101
|
+
}));
|
|
102
|
+
startPointIndex = randint(0, names.length);
|
|
103
|
+
vectorPointsIndexes = randomMany([0, 1, 2], 2);
|
|
104
|
+
const vec = VectorConstructor.fromPoints(points[vectorPointsIndexes[0]], points[vectorPointsIndexes[1]]);
|
|
105
|
+
const endPoint = vec
|
|
106
|
+
.times(coeff.toTree())
|
|
107
|
+
.getEndPoint(points[startPointIndex], "K");
|
|
108
|
+
if (endPoint.distanceTo(new Point("O", 0, 0)) > 10 ||
|
|
109
|
+
points.some((p) => p.equals(endPoint)))
|
|
110
|
+
continue;
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
const identifiers = {
|
|
114
|
+
vectorPointsIndexes,
|
|
115
|
+
points: points.map((p) => p.toIdentifiers()),
|
|
116
|
+
startPointIndex,
|
|
117
|
+
coeff,
|
|
118
|
+
};
|
|
119
|
+
return getQuestionFromIdentifiers(identifiers);
|
|
120
|
+
};
|
|
121
|
+
const getQuestionFromIdentifiers = (identifiers) => {
|
|
122
|
+
const question = {
|
|
123
|
+
ggbAnswer: getGGBAnswer(identifiers),
|
|
124
|
+
instruction: getInstruction(identifiers),
|
|
125
|
+
studentGgbOptions: getStudentGGBOptions(identifiers),
|
|
126
|
+
identifiers,
|
|
127
|
+
hint: getHint(identifiers),
|
|
128
|
+
correction: getCorrection(identifiers),
|
|
129
|
+
};
|
|
130
|
+
return question;
|
|
131
|
+
};
|
|
132
|
+
export const traceVectorMultiple = {
|
|
133
|
+
id: "traceVectorMultiple",
|
|
134
|
+
label: "Placer un point $M$ tel que $\\overrightarrow{AM} = k\\overrightarrow{BC}$",
|
|
135
|
+
isSingleStep: true,
|
|
136
|
+
generator: (nb, opts) => getDistinctQuestions(() => getTraceVectorMultipleQuestion(opts), nb),
|
|
137
|
+
ggbTimer: 60,
|
|
138
|
+
isGGBAnswerValid,
|
|
139
|
+
subject: "Mathématiques",
|
|
140
|
+
// getHint,
|
|
141
|
+
getInstruction,
|
|
142
|
+
// getCorrection,
|
|
143
|
+
getGGBAnswer,
|
|
144
|
+
getStudentGGBOptions,
|
|
145
|
+
answerType: "GGB",
|
|
146
|
+
getQuestionFromIdentifiers,
|
|
147
|
+
hasHintAndCorrection: true,
|
|
148
|
+
};
|