math-exercises 2.2.75 → 2.2.77
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/functions/absolute/absolueValueInequationsSup.js +1 -1
- package/lib/exercises/math/functions/basics/graphicInequation.js +6 -6
- package/lib/exercises/math/functions/basics/graphicInequationAffine.js +1 -1
- package/lib/exercises/math/functions/basics/twoFunctionsInequation.js +6 -6
- package/lib/exercises/math/geometry/euclidianConstructions/pointImageFromTranslation.js +1 -1
- package/lib/exercises/math/geometry/vectors/alignementViaColinearity.js +1 -1
- package/lib/exercises/math/geometry/vectors/fourthParallelogramPoint.js +1 -1
- package/lib/exercises/math/geometry/vectors/index.d.ts +4 -0
- package/lib/exercises/math/geometry/vectors/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/index.js +4 -0
- package/lib/exercises/math/geometry/vectors/paralellismViaColinearity.js +1 -1
- package/lib/exercises/math/geometry/vectors/parallelogramViaEqualVectors.js +1 -1
- package/lib/exercises/math/geometry/vectors/traceOppositeVector.d.ts +10 -0
- package/lib/exercises/math/geometry/vectors/traceOppositeVector.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/traceOppositeVector.js +109 -0
- package/lib/exercises/math/geometry/vectors/traceVectorDifference.d.ts +11 -0
- package/lib/exercises/math/geometry/vectors/traceVectorDifference.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/traceVectorDifference.js +122 -0
- package/lib/exercises/math/geometry/vectors/traceVectorMultiple.d.ts +11 -0
- package/lib/exercises/math/geometry/vectors/traceVectorMultiple.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/traceVectorMultiple.js +114 -0
- package/lib/exercises/math/geometry/vectors/traceVectorSum.d.ts +11 -0
- package/lib/exercises/math/geometry/vectors/traceVectorSum.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/traceVectorSum.js +122 -0
- package/lib/index.d.ts +19 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/math/geometry/CloudPoints.d.ts.map +1 -1
- package/lib/math/geometry/CloudPoints.js +1 -1
- package/lib/math/geometry/line.d.ts.map +1 -1
- package/lib/math/geometry/line.js +3 -1
- package/lib/math/geometry/point.d.ts +8 -2
- package/lib/math/geometry/point.d.ts.map +1 -1
- package/lib/math/geometry/point.js +19 -8
- package/lib/math/geometry/ray.d.ts.map +1 -1
- package/lib/math/geometry/ray.js +3 -1
- package/lib/math/geometry/segment.d.ts.map +1 -1
- package/lib/math/geometry/segment.js +3 -1
- 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/tree/nodes/inequations/inequationSolutionNode.js +1 -1
- package/lib/tree/nodes/sets/unionIntervalNode.js +1 -1
- package/lib/utils/alea/random.d.ts +1 -0
- package/lib/utils/alea/random.d.ts.map +1 -1
- package/lib/utils/alea/random.js +13 -1
- package/package.json +1 -1
|
@@ -84,7 +84,7 @@ const getAbsolueValueInequationsSupQuestion = (ops) => {
|
|
|
84
84
|
exports.absolueValueInequationsSup = {
|
|
85
85
|
id: "absolueValueInequationsSup",
|
|
86
86
|
connector: "\\iff",
|
|
87
|
-
label: "Résoudre une inéquation avec valeur absolue du type $|ax+b| > c",
|
|
87
|
+
label: "Résoudre une inéquation avec valeur absolue du type $|ax+b| > c$",
|
|
88
88
|
isSingleStep: true,
|
|
89
89
|
generator: (nb, opts) => (0, getDistinctQuestions_1.getDistinctQuestions)(() => getAbsolueValueInequationsSupQuestion(opts), nb),
|
|
90
90
|
qcmTimer: 60,
|
|
@@ -76,8 +76,8 @@ const getGraphicInequationQuestion = () => {
|
|
|
76
76
|
const yMax = Math.max(...splinePoints.map((point) => point[1]));
|
|
77
77
|
const intervalsNodes = intervals.map((i) => new intervalNode_1.IntervalNode(new numberNode_1.NumberNode(i.a), new numberNode_1.NumberNode(i.b), i.closure));
|
|
78
78
|
const answer = intervalsNodes.length === 1
|
|
79
|
-
? `S
|
|
80
|
-
: `S
|
|
79
|
+
? `S=\\ ${intervalsNodes[0].toTex()}`
|
|
80
|
+
: `S=\\ ${new unionIntervalNode_1.UnionIntervalNode(intervalsNodes).toTex()}`;
|
|
81
81
|
const commands = [
|
|
82
82
|
`S =Spline(${splinePoints
|
|
83
83
|
.map((point) => `(${point[0]},${point[1]})`)
|
|
@@ -121,20 +121,20 @@ const getPropositions = (n, { answer, intervals, splinePoints, yValue }) => {
|
|
|
121
121
|
(0, exercise_1.tryToAddWrongProp)(propositions, `S=\\varnothing`);
|
|
122
122
|
if (intervals.length === 1) {
|
|
123
123
|
const interval = new intervalNode_1.IntervalNode(intervals[0].a.toTree(), intervals[0].b.toTree(), intervals[0].closure);
|
|
124
|
-
(0, exercise_1.tryToAddWrongProp)(propositions, `S
|
|
124
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, `S=\\ ${interval.toRandomDifferentClosure().toTex()}`);
|
|
125
125
|
}
|
|
126
126
|
else if (intervals.length === 2) {
|
|
127
127
|
const rightIntervals = intervals.map((i) => new intervalNode_1.IntervalNode(i.a.toTree(), i.b.toTree(), i.closure));
|
|
128
128
|
const fakeIntervals = intervals.map((i) => new intervalNode_1.IntervalNode(i.a.toTree(), i.b.toTree(), i.closure));
|
|
129
|
-
(0, exercise_1.tryToAddWrongProp)(propositions, `S
|
|
130
|
-
(0, exercise_1.tryToAddWrongProp)(propositions, `S
|
|
129
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, `S=\\ ${rightIntervals[(0, coinFlip_1.coinFlip)() ? 0 : 1].toTex()}`);
|
|
130
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, `S=\\ ${new unionIntervalNode_1.UnionIntervalNode(fakeIntervals.map((i) => i.toRandomDifferentClosure())).toTex()}`);
|
|
131
131
|
}
|
|
132
132
|
while (propositions.length < n) {
|
|
133
133
|
let a = (0, randint_1.randint)(splinePoints[0][0], splinePoints[splinePoints.length - 1][0] + 1);
|
|
134
134
|
let b = (0, randint_1.randint)(splinePoints[0][0], splinePoints[splinePoints.length - 1][0] + 1, [a]);
|
|
135
135
|
if (a > b)
|
|
136
136
|
[a, b] = [b, a];
|
|
137
|
-
(0, exercise_1.tryToAddWrongProp)(propositions, `S
|
|
137
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, `S=\\ ${new intervalNode_1.IntervalNode(new numberNode_1.NumberNode(a), new numberNode_1.NumberNode(b), closure_1.ClosureType.FF).toTex()}`);
|
|
138
138
|
}
|
|
139
139
|
return (0, exercise_1.shuffleProps)(propositions, n);
|
|
140
140
|
};
|
|
@@ -76,7 +76,7 @@ const getKeys = (identifiers) => {
|
|
|
76
76
|
};
|
|
77
77
|
const isAnswerValid = (ans, { answer }) => {
|
|
78
78
|
const inter = answer;
|
|
79
|
-
return ans === inter || ans === "S
|
|
79
|
+
return ans === inter || ans === "S=\\ " + inter;
|
|
80
80
|
throw Error("VEA not implemented");
|
|
81
81
|
};
|
|
82
82
|
const getGraphicInequationAffineQuestion = (opts) => {
|
|
@@ -108,8 +108,8 @@ const getTwoFunctionsInequationQuestion = () => {
|
|
|
108
108
|
const ggb = new geogebraConstructor_1.GeogebraConstructor({ commands });
|
|
109
109
|
const intervalsNodes = intervals.map((i) => new intervalNode_1.IntervalNode(new numberNode_1.NumberNode(i.a), new numberNode_1.NumberNode(i.b), i.closure));
|
|
110
110
|
const answer = intervalsNodes.length === 1
|
|
111
|
-
? `S
|
|
112
|
-
: `S
|
|
111
|
+
? `S=\\ ${intervalsNodes[0].toTex()}`
|
|
112
|
+
: `S=\\ ${new unionIntervalNode_1.UnionIntervalNode(intervalsNodes).toTex()}`;
|
|
113
113
|
const question = {
|
|
114
114
|
answer,
|
|
115
115
|
instruction: `Déterminer graphiquement les solutions de l'inéquation $f(x) ${ineq.symbol} g(x)$ où $f$ et $g$ sont les fonctions représentées ci-dessous.`,
|
|
@@ -145,13 +145,13 @@ const getPropositions = (n, { answer, intervals, fSplinePoints, ineqSymbol }) =>
|
|
|
145
145
|
(0, exercise_1.tryToAddWrongProp)(propositions, `S=\\varnothing`);
|
|
146
146
|
if (intervals.length === 1) {
|
|
147
147
|
const interval = new intervalNode_1.IntervalNode(intervals[0].a.toTree(), intervals[0].b.toTree(), intervals[0].closure);
|
|
148
|
-
(0, exercise_1.tryToAddWrongProp)(propositions, `S
|
|
148
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, `S=\\ ${interval.toRandomDifferentClosure().toTex()}`);
|
|
149
149
|
}
|
|
150
150
|
else {
|
|
151
151
|
const rightIntervals = intervals.map((i) => new intervalNode_1.IntervalNode(i.a.toTree(), i.b.toTree(), i.closure));
|
|
152
152
|
const fakeIntervals = intervals.map((i) => new intervalNode_1.IntervalNode(i.a.toTree(), i.b.toTree(), i.closure));
|
|
153
|
-
(0, exercise_1.tryToAddWrongProp)(propositions, `S
|
|
154
|
-
(0, exercise_1.tryToAddWrongProp)(propositions, `S
|
|
153
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, `S=\\ ${rightIntervals[(0, coinFlip_1.coinFlip)() ? 0 : 1].toTex()}`);
|
|
154
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, `S=\\ ${new unionIntervalNode_1.UnionIntervalNode(fakeIntervals.map((i) => i.toRandomDifferentClosure())).toTex()}`);
|
|
155
155
|
}
|
|
156
156
|
while (propositions.length < n) {
|
|
157
157
|
const isStrict = ineqSymbol === "<" || ineqSymbol === ">";
|
|
@@ -159,7 +159,7 @@ const getPropositions = (n, { answer, intervals, fSplinePoints, ineqSymbol }) =>
|
|
|
159
159
|
const x2 = (0, randint_1.randint)(x1 + 1, x1 + 5);
|
|
160
160
|
const x3 = (0, randint_1.randint)(x2 + 3, x2 + 6);
|
|
161
161
|
const x4 = (0, randint_1.randint)(x3 + 1, x3 + 3);
|
|
162
|
-
(0, exercise_1.tryToAddWrongProp)(propositions, `S
|
|
162
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, `S=\\ ${new unionIntervalNode_1.UnionIntervalNode([
|
|
163
163
|
new intervalNode_1.IntervalNode(x1.toTree(), x2.toTree(), isStrict ? closure_1.ClosureType.FO : closure_1.ClosureType.FF),
|
|
164
164
|
new intervalNode_1.IntervalNode(x3.toTree(), x4.toTree(), isStrict ? closure_1.ClosureType.OF : closure_1.ClosureType.FF),
|
|
165
165
|
]).toTex()}`);
|
|
@@ -69,7 +69,7 @@ const getPointImageFromTranslationQuestion = (opts) => {
|
|
|
69
69
|
const points = [];
|
|
70
70
|
for (let i = 0; i < 4; i++) {
|
|
71
71
|
const name = String.fromCharCode(65 + i);
|
|
72
|
-
const newPoint = (0, doWhile_1.doWhile)(() => point_1.PointConstructor.random(name, -4, 5), (p) => points.some((p2) => p.
|
|
72
|
+
const newPoint = (0, doWhile_1.doWhile)(() => point_1.PointConstructor.random(name, -4, 5), (p) => points.some((p2) => p.distanceTo(p2) < 2));
|
|
73
73
|
points.push(newPoint);
|
|
74
74
|
}
|
|
75
75
|
const startPoint = (0, random_1.random)(points).name;
|
|
@@ -10,7 +10,7 @@ const numberNode_1 = require("../../../../tree/nodes/numbers/numberNode");
|
|
|
10
10
|
const coinFlip_1 = require("../../../../utils/alea/coinFlip");
|
|
11
11
|
const shuffle_1 = require("../../../../utils/alea/shuffle");
|
|
12
12
|
const getAlignementViaColinearityQuestion = () => {
|
|
13
|
-
const points = point_1.PointConstructor.randomDifferent(["A", "B"]);
|
|
13
|
+
const points = point_1.PointConstructor.randomDifferent(2, { names: ["A", "B"] });
|
|
14
14
|
const AB = vector_1.VectorConstructor.fromPoints(points[0], points[1]);
|
|
15
15
|
let C;
|
|
16
16
|
const isAligned = (0, coinFlip_1.coinFlip)();
|
|
@@ -10,7 +10,7 @@ const randint_1 = require("../../../../math/utils/random/randint");
|
|
|
10
10
|
const numberNode_1 = require("../../../../tree/nodes/numbers/numberNode");
|
|
11
11
|
const shuffle_1 = require("../../../../utils/alea/shuffle");
|
|
12
12
|
const getFourthParallelogramPointQuestion = () => {
|
|
13
|
-
const points = point_1.PointConstructor.randomDifferent(["A", "B"]);
|
|
13
|
+
const points = point_1.PointConstructor.randomDifferent(2, { names: ["A", "B"] });
|
|
14
14
|
const AB = vector_1.VectorConstructor.fromPoints(points[0], points[1]);
|
|
15
15
|
let D;
|
|
16
16
|
do {
|
|
@@ -13,4 +13,8 @@ export * from "./vectorNormCalculation";
|
|
|
13
13
|
export * from "./lineFromDirectorVector";
|
|
14
14
|
export * from "./drawAVectorInGGB";
|
|
15
15
|
export * from "./scalarProduct";
|
|
16
|
+
export * from "./traceVectorSum";
|
|
17
|
+
export * from "./traceVectorDifference";
|
|
18
|
+
export * from "./traceOppositeVector";
|
|
19
|
+
export * from "./traceVectorMultiple";
|
|
16
20
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/vectors/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,kCAAkC,CAAC;AACjD,cAAc,eAAe,CAAC;AAC9B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/vectors/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,kCAAkC,CAAC;AACjD,cAAc,eAAe,CAAC;AAC9B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC"}
|
|
@@ -29,3 +29,7 @@ __exportStar(require("./vectorNormCalculation"), exports);
|
|
|
29
29
|
__exportStar(require("./lineFromDirectorVector"), exports);
|
|
30
30
|
__exportStar(require("./drawAVectorInGGB"), exports);
|
|
31
31
|
__exportStar(require("./scalarProduct"), exports);
|
|
32
|
+
__exportStar(require("./traceVectorSum"), exports);
|
|
33
|
+
__exportStar(require("./traceVectorDifference"), exports);
|
|
34
|
+
__exportStar(require("./traceOppositeVector"), exports);
|
|
35
|
+
__exportStar(require("./traceVectorMultiple"), exports);
|
|
@@ -13,7 +13,7 @@ const shuffle_1 = require("../../../../utils/alea/shuffle");
|
|
|
13
13
|
const getParalellismViaColinearityQuestion = () => {
|
|
14
14
|
let points = [];
|
|
15
15
|
do {
|
|
16
|
-
points = point_1.PointConstructor.randomDifferent(["A", "B"]);
|
|
16
|
+
points = point_1.PointConstructor.randomDifferent(2, { names: ["A", "B"] });
|
|
17
17
|
} while (points[0].x.equals(points[1].x));
|
|
18
18
|
const line = new line_1.Line(points[0], points[1]);
|
|
19
19
|
let C;
|
|
@@ -8,7 +8,7 @@ const vector_1 = require("../../../../math/geometry/vector");
|
|
|
8
8
|
const coinFlip_1 = require("../../../../utils/alea/coinFlip");
|
|
9
9
|
const shuffle_1 = require("../../../../utils/alea/shuffle");
|
|
10
10
|
const getParallelogramViaEqualVectorsQuestion = () => {
|
|
11
|
-
const points = point_1.PointConstructor.randomDifferent(["A", "B"]);
|
|
11
|
+
const points = point_1.PointConstructor.randomDifferent(2, { names: ["A", "B"] });
|
|
12
12
|
const AB = vector_1.VectorConstructor.fromPoints(points[0], points[1]);
|
|
13
13
|
let D;
|
|
14
14
|
do {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise";
|
|
2
|
+
import { PointIdentifiers } from "../../../../math/geometry/point";
|
|
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/traceOppositeVector.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AAMlC,OAAO,EAGL,gBAAgB,EACjB,MAAM,2BAA2B,CAAC;AAOnC,KAAK,WAAW,GAAG;IACjB,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,mBAAmB,EAAE,MAAM,EAAE,CAAC;CAC/B,CAAC;AAqHF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAgBrD,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.traceOppositeVector = void 0;
|
|
4
|
+
const toolBarConstructor_1 = require("../../../../exercises/utils/geogebra/toolBarConstructor");
|
|
5
|
+
const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
|
|
6
|
+
const geogebraConstructor_1 = require("../../../../geogebra/geogebraConstructor");
|
|
7
|
+
const ggbPointToCoords_1 = require("../../../../geogebra/parsers/ggbPointToCoords");
|
|
8
|
+
const parseGGBPoints_1 = require("../../../../geogebra/parsers/parseGGBPoints");
|
|
9
|
+
const point_1 = require("../../../../math/geometry/point");
|
|
10
|
+
const vector_1 = require("../../../../math/geometry/vector");
|
|
11
|
+
const randint_1 = require("../../../../math/utils/random/randint");
|
|
12
|
+
const random_1 = require("../../../../utils/alea/random");
|
|
13
|
+
const getSolutionPoint = (identifiers) => {
|
|
14
|
+
const points = identifiers.points.map(point_1.PointConstructor.fromIdentifiers);
|
|
15
|
+
const origin = points[identifiers.startPointIndex];
|
|
16
|
+
const vec = vector_1.VectorConstructor.fromPoints(points[identifiers.vectorPointsIndexes[0]], points[identifiers.vectorPointsIndexes[1]]);
|
|
17
|
+
return vec.opposite().getEndPoint(origin, "K");
|
|
18
|
+
};
|
|
19
|
+
const getInstruction = (identifiers) => {
|
|
20
|
+
const { startPointIndex, vectorPointsIndexes } = identifiers;
|
|
21
|
+
const origin = identifiers.points[startPointIndex].name;
|
|
22
|
+
const vec = `${identifiers.points[vectorPointsIndexes[0]].name}${identifiers.points[vectorPointsIndexes[1]].name}`;
|
|
23
|
+
return `Placer le point $K$ tel que :
|
|
24
|
+
|
|
25
|
+
$$
|
|
26
|
+
\\overrightarrow{${origin}K} = -\\overrightarrow{${vec}}
|
|
27
|
+
$$`;
|
|
28
|
+
};
|
|
29
|
+
// const getHint: GetHint<Identifiers> = (identifiers) => {};
|
|
30
|
+
// const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
|
|
31
|
+
const getGGBAnswer = (identifiers) => {
|
|
32
|
+
return getSolutionPoint(identifiers).toGGBCommand();
|
|
33
|
+
};
|
|
34
|
+
const getStudentGGBOptions = (identifiers) => {
|
|
35
|
+
const commands = identifiers.points.flatMap((p) => point_1.PointConstructor.fromIdentifiers(p).toGGBCommand());
|
|
36
|
+
const ggb = new geogebraConstructor_1.GeogebraConstructor({
|
|
37
|
+
commands,
|
|
38
|
+
customToolBar: (0, toolBarConstructor_1.toolBarConstructor)({
|
|
39
|
+
point: true,
|
|
40
|
+
}),
|
|
41
|
+
hideAxes: true,
|
|
42
|
+
});
|
|
43
|
+
const points = identifiers.points.map((p) => point_1.PointConstructor.fromIdentifiers(p));
|
|
44
|
+
const solutionPoint = getSolutionPoint(identifiers);
|
|
45
|
+
return ggb.getOptions({
|
|
46
|
+
coords: ggb.getCoordsForPoints([...points, solutionPoint]),
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
const isGGBAnswerValid = (ans, { ggbAnswer, ...identifiers }) => {
|
|
50
|
+
const studentAns = ans.filter((c) => !["A", "B", "C"].includes(c[0]));
|
|
51
|
+
if (studentAns.length !== 1)
|
|
52
|
+
return false;
|
|
53
|
+
const solutionPoint = getSolutionPoint(identifiers);
|
|
54
|
+
const pointCoords = (0, parseGGBPoints_1.parseGGBPoints)(studentAns).map((p) => (0, ggbPointToCoords_1.ggbPointToCoords)(p));
|
|
55
|
+
if (pointCoords.length !== 1)
|
|
56
|
+
return false;
|
|
57
|
+
return (new point_1.Point("K", pointCoords[0].x, pointCoords[0].y).distanceTo(solutionPoint) < 1);
|
|
58
|
+
};
|
|
59
|
+
const getTraceOppositeVectorQuestion = () => {
|
|
60
|
+
const names = ["A", "B", "C"];
|
|
61
|
+
let points = [];
|
|
62
|
+
let startPointIndex;
|
|
63
|
+
let vectorPointsIndexes;
|
|
64
|
+
while (true) {
|
|
65
|
+
points = [];
|
|
66
|
+
points.push(...point_1.PointConstructor.randomDifferent(3, {
|
|
67
|
+
minDistance: 2,
|
|
68
|
+
names,
|
|
69
|
+
minDistanceToOrigin: 3,
|
|
70
|
+
}));
|
|
71
|
+
startPointIndex = (0, randint_1.randint)(0, names.length);
|
|
72
|
+
vectorPointsIndexes = (0, random_1.randomMany)([0, 1, 2], 2);
|
|
73
|
+
const vec = vector_1.VectorConstructor.fromPoints(points[vectorPointsIndexes[0]], points[vectorPointsIndexes[1]]);
|
|
74
|
+
const endPoint = vec.opposite().getEndPoint(points[startPointIndex], "K");
|
|
75
|
+
if (endPoint.distanceTo(new point_1.Point("O", 0, 0)) > 10 ||
|
|
76
|
+
points.some((p) => p.equals(endPoint)))
|
|
77
|
+
continue;
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
const identifiers = {
|
|
81
|
+
vectorPointsIndexes,
|
|
82
|
+
points: points.map((p) => p.toIdentifiers()),
|
|
83
|
+
startPointIndex,
|
|
84
|
+
};
|
|
85
|
+
const question = {
|
|
86
|
+
ggbAnswer: getGGBAnswer(identifiers),
|
|
87
|
+
instruction: getInstruction(identifiers),
|
|
88
|
+
studentGgbOptions: getStudentGGBOptions(identifiers),
|
|
89
|
+
identifiers,
|
|
90
|
+
// hint: getHint(identifiers),
|
|
91
|
+
// correction: getCorrection(identifiers),
|
|
92
|
+
};
|
|
93
|
+
return question;
|
|
94
|
+
};
|
|
95
|
+
exports.traceOppositeVector = {
|
|
96
|
+
id: "traceOppositeVector",
|
|
97
|
+
label: "Placer un point $K$ tel que $\\overrightarrow{AK} = -\\overrightarrow{BC}$",
|
|
98
|
+
isSingleStep: true,
|
|
99
|
+
generator: (nb, opts) => (0, getDistinctQuestions_1.getDistinctQuestions)(() => getTraceOppositeVectorQuestion(opts), nb),
|
|
100
|
+
ggbTimer: 60,
|
|
101
|
+
isGGBAnswerValid,
|
|
102
|
+
subject: "Mathématiques",
|
|
103
|
+
// getHint,
|
|
104
|
+
getInstruction,
|
|
105
|
+
// getCorrection,
|
|
106
|
+
getGGBAnswer,
|
|
107
|
+
getStudentGGBOptions,
|
|
108
|
+
answerType: "GGB",
|
|
109
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise";
|
|
2
|
+
import { PointIdentifiers } from "../../../../math/geometry/point";
|
|
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/traceVectorDifference.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AAMlC,OAAO,EAGL,gBAAgB,EACjB,MAAM,2BAA2B,CAAC;AAMnC,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;AAgJF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,WAAW,CAevD,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.traceVectorDifference = void 0;
|
|
4
|
+
const toolBarConstructor_1 = require("../../../../exercises/utils/geogebra/toolBarConstructor");
|
|
5
|
+
const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
|
|
6
|
+
const geogebraConstructor_1 = require("../../../../geogebra/geogebraConstructor");
|
|
7
|
+
const ggbPointToCoords_1 = require("../../../../geogebra/parsers/ggbPointToCoords");
|
|
8
|
+
const parseGGBPoints_1 = require("../../../../geogebra/parsers/parseGGBPoints");
|
|
9
|
+
const point_1 = require("../../../../math/geometry/point");
|
|
10
|
+
const vector_1 = require("../../../../math/geometry/vector");
|
|
11
|
+
const randint_1 = require("../../../../math/utils/random/randint");
|
|
12
|
+
const random_1 = require("../../../../utils/alea/random");
|
|
13
|
+
const doWhile_1 = require("../../../../utils/doWhile");
|
|
14
|
+
const getSolutionPoint = (identifiers) => {
|
|
15
|
+
const points = identifiers.points.map(point_1.PointConstructor.fromIdentifiers);
|
|
16
|
+
const origin = points[identifiers.startPointIndex];
|
|
17
|
+
const vecs = [
|
|
18
|
+
vector_1.VectorConstructor.fromPoints(points[identifiers.firstVectorPointsIndexes[0]], points[identifiers.firstVectorPointsIndexes[1]]),
|
|
19
|
+
vector_1.VectorConstructor.fromPoints(points[identifiers.secondVectorPointsIndexes[0]], points[identifiers.secondVectorPointsIndexes[1]]),
|
|
20
|
+
];
|
|
21
|
+
return vecs[0].substract(vecs[1]).getEndPoint(origin, "K");
|
|
22
|
+
};
|
|
23
|
+
const getInstruction = (identifiers) => {
|
|
24
|
+
const { startPointIndex, firstVectorPointsIndexes, secondVectorPointsIndexes, } = identifiers;
|
|
25
|
+
const origin = identifiers.points[startPointIndex].name;
|
|
26
|
+
const firstVec = `${identifiers.points[firstVectorPointsIndexes[0]].name}${identifiers.points[firstVectorPointsIndexes[1]].name}`;
|
|
27
|
+
const secondVec = `${identifiers.points[secondVectorPointsIndexes[0]].name}${identifiers.points[secondVectorPointsIndexes[1]].name}`;
|
|
28
|
+
return `Placer le point $K$ tel que :
|
|
29
|
+
|
|
30
|
+
$$
|
|
31
|
+
\\overrightarrow{${origin}K} = \\overrightarrow{${firstVec}} - \\overrightarrow{${secondVec}}
|
|
32
|
+
$$`;
|
|
33
|
+
};
|
|
34
|
+
// const getHint: GetHint<Identifiers> = (identifiers) => {};
|
|
35
|
+
// const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
|
|
36
|
+
const getGGBAnswer = (identifiers) => {
|
|
37
|
+
return getSolutionPoint(identifiers).toGGBCommand();
|
|
38
|
+
};
|
|
39
|
+
const getStudentGGBOptions = (identifiers) => {
|
|
40
|
+
const commands = identifiers.points.flatMap((p) => point_1.PointConstructor.fromIdentifiers(p).toGGBCommand());
|
|
41
|
+
const ggb = new geogebraConstructor_1.GeogebraConstructor({
|
|
42
|
+
commands,
|
|
43
|
+
customToolBar: (0, toolBarConstructor_1.toolBarConstructor)({
|
|
44
|
+
point: true,
|
|
45
|
+
}),
|
|
46
|
+
hideAxes: true,
|
|
47
|
+
});
|
|
48
|
+
const points = identifiers.points.map((p) => point_1.PointConstructor.fromIdentifiers(p));
|
|
49
|
+
const solutionPoint = getSolutionPoint(identifiers);
|
|
50
|
+
return ggb.getOptions({
|
|
51
|
+
coords: ggb.getCoordsForPoints([...points, solutionPoint]),
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
const isGGBAnswerValid = (ans, { ggbAnswer, ...identifiers }) => {
|
|
55
|
+
const studentAns = ans.filter((c) => !["A", "B", "C", "D"].includes(c[0]));
|
|
56
|
+
if (studentAns.length !== 1)
|
|
57
|
+
return false;
|
|
58
|
+
const solutionPoint = getSolutionPoint(identifiers);
|
|
59
|
+
const pointCoords = (0, parseGGBPoints_1.parseGGBPoints)(studentAns).map((p) => (0, ggbPointToCoords_1.ggbPointToCoords)(p));
|
|
60
|
+
if (pointCoords.length !== 1)
|
|
61
|
+
return false;
|
|
62
|
+
return (new point_1.Point("K", pointCoords[0].x, pointCoords[0].y).distanceTo(solutionPoint) < 1);
|
|
63
|
+
};
|
|
64
|
+
const getTraceVectorDifferenceQuestion = () => {
|
|
65
|
+
const names = ["A", "B", "C", "D"];
|
|
66
|
+
let points = [];
|
|
67
|
+
let startPointIndex;
|
|
68
|
+
let firstVectorPointsIndexes;
|
|
69
|
+
let secondVectorPointsIndexes;
|
|
70
|
+
while (true) {
|
|
71
|
+
points = [];
|
|
72
|
+
points.push(...point_1.PointConstructor.randomDifferent(4, {
|
|
73
|
+
minDistance: 2,
|
|
74
|
+
names,
|
|
75
|
+
minDistanceToOrigin: 3,
|
|
76
|
+
}));
|
|
77
|
+
startPointIndex = (0, randint_1.randint)(0, names.length);
|
|
78
|
+
firstVectorPointsIndexes = (0, random_1.randomMany)([0, 1, 2, 3], 2);
|
|
79
|
+
secondVectorPointsIndexes = (0, doWhile_1.doWhile)(() => (0, random_1.randomMany)([0, 1, 2, 3], 2), (arr) => arr[0] === firstVectorPointsIndexes[0] &&
|
|
80
|
+
arr[1] === firstVectorPointsIndexes[1]);
|
|
81
|
+
//AC = AB+BC
|
|
82
|
+
const firstVec = vector_1.VectorConstructor.fromPoints(points[firstVectorPointsIndexes[0]], points[firstVectorPointsIndexes[1]]);
|
|
83
|
+
const second = vector_1.VectorConstructor.fromPoints(points[secondVectorPointsIndexes[0]], points[secondVectorPointsIndexes[1]]);
|
|
84
|
+
const endPoint = firstVec
|
|
85
|
+
.substract(second)
|
|
86
|
+
.getEndPoint(points[startPointIndex], "K");
|
|
87
|
+
if (endPoint.distanceTo(new point_1.Point("O", 0, 0)) > 10 ||
|
|
88
|
+
points.some((p) => p.equals(endPoint)))
|
|
89
|
+
continue;
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
const identifiers = {
|
|
93
|
+
firstVectorPointsIndexes,
|
|
94
|
+
points: points.map((p) => p.toIdentifiers()),
|
|
95
|
+
secondVectorPointsIndexes,
|
|
96
|
+
startPointIndex,
|
|
97
|
+
};
|
|
98
|
+
const question = {
|
|
99
|
+
ggbAnswer: getGGBAnswer(identifiers),
|
|
100
|
+
instruction: getInstruction(identifiers),
|
|
101
|
+
studentGgbOptions: getStudentGGBOptions(identifiers),
|
|
102
|
+
identifiers,
|
|
103
|
+
// hint: getHint(identifiers),
|
|
104
|
+
// correction: getCorrection(identifiers),
|
|
105
|
+
};
|
|
106
|
+
return question;
|
|
107
|
+
};
|
|
108
|
+
exports.traceVectorDifference = {
|
|
109
|
+
id: "traceVectorDifference",
|
|
110
|
+
label: "Placer un point défini par une différence de vecteurs",
|
|
111
|
+
isSingleStep: true,
|
|
112
|
+
generator: (nb, opts) => (0, getDistinctQuestions_1.getDistinctQuestions)(() => getTraceVectorDifferenceQuestion(opts), nb),
|
|
113
|
+
ggbTimer: 60,
|
|
114
|
+
isGGBAnswerValid,
|
|
115
|
+
subject: "Mathématiques",
|
|
116
|
+
// getHint,
|
|
117
|
+
getInstruction,
|
|
118
|
+
// getCorrection,
|
|
119
|
+
getGGBAnswer,
|
|
120
|
+
getStudentGGBOptions,
|
|
121
|
+
answerType: "GGB",
|
|
122
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise";
|
|
2
|
+
import { PointIdentifiers } from "../../../../math/geometry/point";
|
|
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/traceVectorMultiple.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AAMlC,OAAO,EAGL,gBAAgB,EACjB,MAAM,2BAA2B,CAAC;AAOnC,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;AA0HF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAgBrD,CAAC"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.traceVectorMultiple = void 0;
|
|
4
|
+
const toolBarConstructor_1 = require("../../../../exercises/utils/geogebra/toolBarConstructor");
|
|
5
|
+
const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
|
|
6
|
+
const geogebraConstructor_1 = require("../../../../geogebra/geogebraConstructor");
|
|
7
|
+
const ggbPointToCoords_1 = require("../../../../geogebra/parsers/ggbPointToCoords");
|
|
8
|
+
const parseGGBPoints_1 = require("../../../../geogebra/parsers/parseGGBPoints");
|
|
9
|
+
const point_1 = require("../../../../math/geometry/point");
|
|
10
|
+
const vector_1 = require("../../../../math/geometry/vector");
|
|
11
|
+
const randint_1 = require("../../../../math/utils/random/randint");
|
|
12
|
+
const random_1 = require("../../../../utils/alea/random");
|
|
13
|
+
const getSolutionPoint = (identifiers) => {
|
|
14
|
+
const points = identifiers.points.map(point_1.PointConstructor.fromIdentifiers);
|
|
15
|
+
const origin = points[identifiers.startPointIndex];
|
|
16
|
+
const vec = vector_1.VectorConstructor.fromPoints(points[identifiers.vectorPointsIndexes[0]], points[identifiers.vectorPointsIndexes[1]]);
|
|
17
|
+
return vec.times(identifiers.coeff.toTree()).getEndPoint(origin, "K");
|
|
18
|
+
};
|
|
19
|
+
const getInstruction = (identifiers) => {
|
|
20
|
+
const { startPointIndex, vectorPointsIndexes } = identifiers;
|
|
21
|
+
const origin = identifiers.points[startPointIndex].name;
|
|
22
|
+
const vec = `${identifiers.points[vectorPointsIndexes[0]].name}${identifiers.points[vectorPointsIndexes[1]].name}`;
|
|
23
|
+
return `Placer le point $K$ tel que :
|
|
24
|
+
|
|
25
|
+
$$
|
|
26
|
+
\\overrightarrow{${origin}K} = ${identifiers.coeff}\\overrightarrow{${vec}}
|
|
27
|
+
$$`;
|
|
28
|
+
};
|
|
29
|
+
// const getHint: GetHint<Identifiers> = (identifiers) => {};
|
|
30
|
+
// const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
|
|
31
|
+
const getGGBAnswer = (identifiers) => {
|
|
32
|
+
return getSolutionPoint(identifiers).toGGBCommand();
|
|
33
|
+
};
|
|
34
|
+
const getStudentGGBOptions = (identifiers) => {
|
|
35
|
+
const commands = identifiers.points.flatMap((p) => point_1.PointConstructor.fromIdentifiers(p).toGGBCommand());
|
|
36
|
+
const ggb = new geogebraConstructor_1.GeogebraConstructor({
|
|
37
|
+
commands,
|
|
38
|
+
customToolBar: (0, toolBarConstructor_1.toolBarConstructor)({
|
|
39
|
+
point: true,
|
|
40
|
+
}),
|
|
41
|
+
hideAxes: true,
|
|
42
|
+
});
|
|
43
|
+
const points = identifiers.points.map((p) => point_1.PointConstructor.fromIdentifiers(p));
|
|
44
|
+
const solutionPoint = getSolutionPoint(identifiers);
|
|
45
|
+
return ggb.getOptions({
|
|
46
|
+
coords: ggb.getCoordsForPoints([...points, solutionPoint]),
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
const isGGBAnswerValid = (ans, { ggbAnswer, ...identifiers }) => {
|
|
50
|
+
const studentAns = ans.filter((c) => !["A", "B", "C"].includes(c[0]));
|
|
51
|
+
if (studentAns.length !== 1)
|
|
52
|
+
return false;
|
|
53
|
+
const solutionPoint = getSolutionPoint(identifiers);
|
|
54
|
+
const pointCoords = (0, parseGGBPoints_1.parseGGBPoints)(studentAns).map((p) => (0, ggbPointToCoords_1.ggbPointToCoords)(p));
|
|
55
|
+
if (pointCoords.length !== 1)
|
|
56
|
+
return false;
|
|
57
|
+
return (new point_1.Point("K", pointCoords[0].x, pointCoords[0].y).distanceTo(solutionPoint) < 1);
|
|
58
|
+
};
|
|
59
|
+
const getTraceVectorMultipleQuestion = () => {
|
|
60
|
+
const names = ["A", "B", "C"];
|
|
61
|
+
let points = [];
|
|
62
|
+
let startPointIndex;
|
|
63
|
+
let vectorPointsIndexes;
|
|
64
|
+
let coeff = 0;
|
|
65
|
+
while (true) {
|
|
66
|
+
points = [];
|
|
67
|
+
coeff = (0, random_1.random)([-3, -2, 2, 3]);
|
|
68
|
+
points.push(...point_1.PointConstructor.randomDifferent(3, {
|
|
69
|
+
minDistance: 2,
|
|
70
|
+
names,
|
|
71
|
+
minDistanceToOrigin: 3,
|
|
72
|
+
}));
|
|
73
|
+
startPointIndex = (0, randint_1.randint)(0, names.length);
|
|
74
|
+
vectorPointsIndexes = (0, random_1.randomMany)([0, 1, 2], 2);
|
|
75
|
+
const vec = vector_1.VectorConstructor.fromPoints(points[vectorPointsIndexes[0]], points[vectorPointsIndexes[1]]);
|
|
76
|
+
const endPoint = vec
|
|
77
|
+
.times(coeff.toTree())
|
|
78
|
+
.getEndPoint(points[startPointIndex], "K");
|
|
79
|
+
if (endPoint.distanceTo(new point_1.Point("O", 0, 0)) > 10 ||
|
|
80
|
+
points.some((p) => p.equals(endPoint)))
|
|
81
|
+
continue;
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
const identifiers = {
|
|
85
|
+
vectorPointsIndexes,
|
|
86
|
+
points: points.map((p) => p.toIdentifiers()),
|
|
87
|
+
startPointIndex,
|
|
88
|
+
coeff,
|
|
89
|
+
};
|
|
90
|
+
const question = {
|
|
91
|
+
ggbAnswer: getGGBAnswer(identifiers),
|
|
92
|
+
instruction: getInstruction(identifiers),
|
|
93
|
+
studentGgbOptions: getStudentGGBOptions(identifiers),
|
|
94
|
+
identifiers,
|
|
95
|
+
// hint: getHint(identifiers),
|
|
96
|
+
// correction: getCorrection(identifiers),
|
|
97
|
+
};
|
|
98
|
+
return question;
|
|
99
|
+
};
|
|
100
|
+
exports.traceVectorMultiple = {
|
|
101
|
+
id: "traceVectorMultiple",
|
|
102
|
+
label: "Placer un point $M$ tel que $\\overrightarrow{AM} = k\\overrightarrow{BC}$",
|
|
103
|
+
isSingleStep: true,
|
|
104
|
+
generator: (nb, opts) => (0, getDistinctQuestions_1.getDistinctQuestions)(() => getTraceVectorMultipleQuestion(opts), nb),
|
|
105
|
+
ggbTimer: 60,
|
|
106
|
+
isGGBAnswerValid,
|
|
107
|
+
subject: "Mathématiques",
|
|
108
|
+
// getHint,
|
|
109
|
+
getInstruction,
|
|
110
|
+
// getCorrection,
|
|
111
|
+
getGGBAnswer,
|
|
112
|
+
getStudentGGBOptions,
|
|
113
|
+
answerType: "GGB",
|
|
114
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Exercise } from "../../../../exercises/exercise";
|
|
2
|
+
import { PointIdentifiers } from "../../../../math/geometry/point";
|
|
3
|
+
type Identifiers = {
|
|
4
|
+
points: PointIdentifiers[];
|
|
5
|
+
startPointIndex: number;
|
|
6
|
+
firstVectorPointsIndexes: number[];
|
|
7
|
+
secondVectorPointsIndexes: number[];
|
|
8
|
+
};
|
|
9
|
+
export declare const traceVectorSum: Exercise<Identifiers>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=traceVectorSum.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traceVectorSum.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/vectors/traceVectorSum.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAST,MAAM,0BAA0B,CAAC;AAMlC,OAAO,EAGL,gBAAgB,EACjB,MAAM,2BAA2B,CAAC;AAMnC,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;AAgJF,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,WAAW,CAehD,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.traceVectorSum = void 0;
|
|
4
|
+
const toolBarConstructor_1 = require("../../../../exercises/utils/geogebra/toolBarConstructor");
|
|
5
|
+
const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
|
|
6
|
+
const geogebraConstructor_1 = require("../../../../geogebra/geogebraConstructor");
|
|
7
|
+
const ggbPointToCoords_1 = require("../../../../geogebra/parsers/ggbPointToCoords");
|
|
8
|
+
const parseGGBPoints_1 = require("../../../../geogebra/parsers/parseGGBPoints");
|
|
9
|
+
const point_1 = require("../../../../math/geometry/point");
|
|
10
|
+
const vector_1 = require("../../../../math/geometry/vector");
|
|
11
|
+
const randint_1 = require("../../../../math/utils/random/randint");
|
|
12
|
+
const random_1 = require("../../../../utils/alea/random");
|
|
13
|
+
const doWhile_1 = require("../../../../utils/doWhile");
|
|
14
|
+
const getSolutionPoint = (identifiers) => {
|
|
15
|
+
const points = identifiers.points.map(point_1.PointConstructor.fromIdentifiers);
|
|
16
|
+
const origin = points[identifiers.startPointIndex];
|
|
17
|
+
const vecs = [
|
|
18
|
+
vector_1.VectorConstructor.fromPoints(points[identifiers.firstVectorPointsIndexes[0]], points[identifiers.firstVectorPointsIndexes[1]]),
|
|
19
|
+
vector_1.VectorConstructor.fromPoints(points[identifiers.secondVectorPointsIndexes[0]], points[identifiers.secondVectorPointsIndexes[1]]),
|
|
20
|
+
];
|
|
21
|
+
return vecs[0].add(vecs[1]).getEndPoint(origin, "K");
|
|
22
|
+
};
|
|
23
|
+
const getInstruction = (identifiers) => {
|
|
24
|
+
const { startPointIndex, firstVectorPointsIndexes, secondVectorPointsIndexes, } = identifiers;
|
|
25
|
+
const origin = identifiers.points[startPointIndex].name;
|
|
26
|
+
const firstVec = `${identifiers.points[firstVectorPointsIndexes[0]].name}${identifiers.points[firstVectorPointsIndexes[1]].name}`;
|
|
27
|
+
const secondVec = `${identifiers.points[secondVectorPointsIndexes[0]].name}${identifiers.points[secondVectorPointsIndexes[1]].name}`;
|
|
28
|
+
return `Placer le point $K$ tel que :
|
|
29
|
+
|
|
30
|
+
$$
|
|
31
|
+
\\overrightarrow{${origin}K} = \\overrightarrow{${firstVec}} + \\overrightarrow{${secondVec}}
|
|
32
|
+
$$`;
|
|
33
|
+
};
|
|
34
|
+
// const getHint: GetHint<Identifiers> = (identifiers) => {};
|
|
35
|
+
// const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
|
|
36
|
+
const getGGBAnswer = (identifiers) => {
|
|
37
|
+
return getSolutionPoint(identifiers).toGGBCommand();
|
|
38
|
+
};
|
|
39
|
+
const getStudentGGBOptions = (identifiers) => {
|
|
40
|
+
const commands = identifiers.points.flatMap((p) => point_1.PointConstructor.fromIdentifiers(p).toGGBCommand());
|
|
41
|
+
const ggb = new geogebraConstructor_1.GeogebraConstructor({
|
|
42
|
+
commands,
|
|
43
|
+
customToolBar: (0, toolBarConstructor_1.toolBarConstructor)({
|
|
44
|
+
point: true,
|
|
45
|
+
}),
|
|
46
|
+
hideAxes: true,
|
|
47
|
+
});
|
|
48
|
+
const points = identifiers.points.map((p) => point_1.PointConstructor.fromIdentifiers(p));
|
|
49
|
+
const solutionPoint = getSolutionPoint(identifiers);
|
|
50
|
+
return ggb.getOptions({
|
|
51
|
+
coords: ggb.getCoordsForPoints([...points, solutionPoint]),
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
const isGGBAnswerValid = (ans, { ggbAnswer, ...identifiers }) => {
|
|
55
|
+
const studentAns = ans.filter((c) => !["A", "B", "C", "D"].includes(c[0]));
|
|
56
|
+
if (studentAns.length !== 1)
|
|
57
|
+
return false;
|
|
58
|
+
const solutionPoint = getSolutionPoint(identifiers);
|
|
59
|
+
const pointCoords = (0, parseGGBPoints_1.parseGGBPoints)(studentAns).map((p) => (0, ggbPointToCoords_1.ggbPointToCoords)(p));
|
|
60
|
+
if (pointCoords.length !== 1)
|
|
61
|
+
return false;
|
|
62
|
+
return (new point_1.Point("K", pointCoords[0].x, pointCoords[0].y).distanceTo(solutionPoint) < 1);
|
|
63
|
+
};
|
|
64
|
+
const getTraceVectorSumQuestion = () => {
|
|
65
|
+
const names = ["A", "B", "C", "D"];
|
|
66
|
+
let points = [];
|
|
67
|
+
let startPointIndex;
|
|
68
|
+
let firstVectorPointsIndexes;
|
|
69
|
+
let secondVectorPointsIndexes;
|
|
70
|
+
while (true) {
|
|
71
|
+
points = [];
|
|
72
|
+
points.push(...point_1.PointConstructor.randomDifferent(4, {
|
|
73
|
+
minDistance: 2,
|
|
74
|
+
names,
|
|
75
|
+
minDistanceToOrigin: 3,
|
|
76
|
+
}));
|
|
77
|
+
startPointIndex = (0, randint_1.randint)(0, names.length);
|
|
78
|
+
firstVectorPointsIndexes = (0, random_1.randomMany)([0, 1, 2, 3], 2);
|
|
79
|
+
secondVectorPointsIndexes = (0, doWhile_1.doWhile)(() => (0, random_1.randomMany)([0, 1, 2, 3], 2), (arr) => arr[0] === firstVectorPointsIndexes[0] &&
|
|
80
|
+
arr[1] === firstVectorPointsIndexes[1]);
|
|
81
|
+
//AC = AB+BC
|
|
82
|
+
const firstVec = vector_1.VectorConstructor.fromPoints(points[firstVectorPointsIndexes[0]], points[firstVectorPointsIndexes[1]]);
|
|
83
|
+
const second = vector_1.VectorConstructor.fromPoints(points[secondVectorPointsIndexes[0]], points[secondVectorPointsIndexes[1]]);
|
|
84
|
+
const endPoint = firstVec
|
|
85
|
+
.add(second)
|
|
86
|
+
.getEndPoint(points[startPointIndex], "K");
|
|
87
|
+
if (endPoint.distanceTo(new point_1.Point("O", 0, 0)) > 10 ||
|
|
88
|
+
points.some((p) => p.equals(endPoint)))
|
|
89
|
+
continue;
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
const identifiers = {
|
|
93
|
+
firstVectorPointsIndexes,
|
|
94
|
+
points: points.map((p) => p.toIdentifiers()),
|
|
95
|
+
secondVectorPointsIndexes,
|
|
96
|
+
startPointIndex,
|
|
97
|
+
};
|
|
98
|
+
const question = {
|
|
99
|
+
ggbAnswer: getGGBAnswer(identifiers),
|
|
100
|
+
instruction: getInstruction(identifiers),
|
|
101
|
+
studentGgbOptions: getStudentGGBOptions(identifiers),
|
|
102
|
+
identifiers,
|
|
103
|
+
// hint: getHint(identifiers),
|
|
104
|
+
// correction: getCorrection(identifiers),
|
|
105
|
+
};
|
|
106
|
+
return question;
|
|
107
|
+
};
|
|
108
|
+
exports.traceVectorSum = {
|
|
109
|
+
id: "traceVectorSum",
|
|
110
|
+
label: "Placer un point défini par une somme de vecteurs",
|
|
111
|
+
isSingleStep: true,
|
|
112
|
+
generator: (nb, opts) => (0, getDistinctQuestions_1.getDistinctQuestions)(() => getTraceVectorSumQuestion(opts), nb),
|
|
113
|
+
ggbTimer: 60,
|
|
114
|
+
isGGBAnswerValid,
|
|
115
|
+
subject: "Mathématiques",
|
|
116
|
+
// getHint,
|
|
117
|
+
getInstruction,
|
|
118
|
+
// getCorrection,
|
|
119
|
+
getGGBAnswer,
|
|
120
|
+
getStudentGGBOptions,
|
|
121
|
+
answerType: "GGB",
|
|
122
|
+
};
|
package/lib/index.d.ts
CHANGED
|
@@ -1117,6 +1117,25 @@ declare const mathExercises: (Exercise<{
|
|
|
1117
1117
|
AB: number;
|
|
1118
1118
|
AC: number;
|
|
1119
1119
|
trigoPoint: string;
|
|
1120
|
+
}, {}> | Exercise<{
|
|
1121
|
+
points: import("./math/geometry/point").PointIdentifiers[];
|
|
1122
|
+
startPointIndex: number;
|
|
1123
|
+
firstVectorPointsIndexes: number[];
|
|
1124
|
+
secondVectorPointsIndexes: number[];
|
|
1125
|
+
}, {}> | Exercise<{
|
|
1126
|
+
points: import("./math/geometry/point").PointIdentifiers[];
|
|
1127
|
+
startPointIndex: number;
|
|
1128
|
+
firstVectorPointsIndexes: number[];
|
|
1129
|
+
secondVectorPointsIndexes: number[];
|
|
1130
|
+
}, {}> | Exercise<{
|
|
1131
|
+
points: import("./math/geometry/point").PointIdentifiers[];
|
|
1132
|
+
startPointIndex: number;
|
|
1133
|
+
vectorPointsIndexes: number[];
|
|
1134
|
+
}, {}> | Exercise<{
|
|
1135
|
+
points: import("./math/geometry/point").PointIdentifiers[];
|
|
1136
|
+
startPointIndex: number;
|
|
1137
|
+
vectorPointsIndexes: number[];
|
|
1138
|
+
coeff: number;
|
|
1120
1139
|
}, {}> | Exercise<{
|
|
1121
1140
|
trinom: number[];
|
|
1122
1141
|
}, {}> | Exercise<{
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAA+B,CAAC;AACnD,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudPoints.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/CloudPoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAoB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAGjE,OAAO,EAAE,UAAU,EAAgB,MAAM,qCAAqC,CAAC;AAM/E,MAAM,MAAM,sBAAsB,GAAG;IACnC,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;CACvC,CAAC;AACF,8BAAsB,sBAAsB;IAC1C,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"CloudPoints.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/CloudPoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAoB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAGjE,OAAO,EAAE,UAAU,EAAgB,MAAM,qCAAqC,CAAC;AAM/E,MAAM,MAAM,sBAAsB,GAAG;IACnC,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;CACvC,CAAC;AACF,8BAAsB,sBAAsB;IAC1C,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM;IAU9B,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM;CAyBrC;AAED,qBAAa,WAAW;IACtB,MAAM,EAAE,KAAK,EAAE,CAAC;gBAEJ,MAAM,EAAE,KAAK,EAAE;IAI3B,aAAa,IAAI,sBAAsB;IAMvC,kBAAkB,IAAI,SAAS;IA8C/B,mBAAmB;CAsBpB"}
|
|
@@ -16,7 +16,7 @@ class CloudPointsConstructor {
|
|
|
16
16
|
for (let i = 0; i < nbPoints; i++) {
|
|
17
17
|
names.push(`a${i}`);
|
|
18
18
|
}
|
|
19
|
-
return new CloudPoints(point_1.PointConstructor.randomDifferent(names));
|
|
19
|
+
return new CloudPoints(point_1.PointConstructor.randomDifferent(nbPoints, { names }));
|
|
20
20
|
}
|
|
21
21
|
static randomLinear(nbPoints) {
|
|
22
22
|
const points = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"line.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/line.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mDAAmD,CAAC;AAEvF,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAGjE,OAAO,EAAE,OAAO,EAAO,MAAM,oCAAoC,CAAC;AAMlE,OAAO,EACL,aAAa,EAEd,MAAM,0CAA0C,CAAC;AAKlD,OAAO,EAAE,KAAK,EAAoB,gBAAgB,EAAE,MA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C;IACd,UAAU,EAAE,OAAO,CAAC;IACpB,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IAC7B,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;gBACJ,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,MAAM;IAsBvD,aAAa;;;;;IAOb,WAAW,CAAC,IAAI,EAAE,IAAI;IAYtB,iBAAiB;IAIjB,YAAY,CAAC,KAAK,EAAE,KAAK;IAYzB,gBAAgB,CAAC,KAAK,EAAE,KAAK;IAW7B,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,WAAW,GAAE,OAAe;IAgBnD,aAAa,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,MAAM;IAK7C,aAAa,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,MAAM;IAW7C,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM;IAa5B,WAAW,MAAO,MAAM,KAAK,KAAK,KAAG,SAAS,CAmB5C;IAEF,oBAAoB,IAAI,SAAS;IAuBjC,WAAW;IAMX,iBAAiB;;;;;IAcjB,KAAK;IAGL,gBAAgB;IAIhB,aAAa,CACX,iBAAiB,EAAE,OAAO,EAC1B,EACE,OAAc,EACd,SAAiB,EACjB,yBAAgC,GACjC,GAAE,kBAAuB;IAqB5B,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,CAAC,EAAE,MAAM;CAW7C"}
|
|
@@ -17,7 +17,9 @@ const vector_1 = require("./vector");
|
|
|
17
17
|
class LineConstructor {
|
|
18
18
|
static random(name) {
|
|
19
19
|
const names = (0, randomSegmentName_1.randomSegmentName)();
|
|
20
|
-
const points = point_1.PointConstructor.randomDifferent(
|
|
20
|
+
const points = point_1.PointConstructor.randomDifferent(2, {
|
|
21
|
+
names: names.split(""),
|
|
22
|
+
});
|
|
21
23
|
return new Line(points[0], points[1], name);
|
|
22
24
|
}
|
|
23
25
|
static fromIdentifiers(identifiers) {
|
|
@@ -8,6 +8,8 @@ export type PointIdentifiers = {
|
|
|
8
8
|
y: NodeIdentifiers;
|
|
9
9
|
};
|
|
10
10
|
export declare abstract class PointConstructor {
|
|
11
|
+
static randomName(excludes?: string[]): string;
|
|
12
|
+
static randomNames(count: number): string[];
|
|
11
13
|
static origin(name?: string): Point;
|
|
12
14
|
static random(name: string, min?: number, max?: number): Point;
|
|
13
15
|
static fromIdentifiers(identifiers: PointIdentifiers): Point;
|
|
@@ -15,14 +17,18 @@ export declare abstract class PointConstructor {
|
|
|
15
17
|
spacing?: number;
|
|
16
18
|
coefficient?: number;
|
|
17
19
|
}): Point;
|
|
18
|
-
static randomDifferent(
|
|
20
|
+
static randomDifferent(count: number, { names, minDistance, minDistanceToOrigin, }: {
|
|
21
|
+
names?: string[];
|
|
22
|
+
minDistance?: number;
|
|
23
|
+
minDistanceToOrigin?: number;
|
|
24
|
+
}): Point[];
|
|
19
25
|
static fromGGBCommand(str: string): Point;
|
|
20
26
|
}
|
|
21
27
|
export declare class Point {
|
|
22
28
|
name: string;
|
|
23
29
|
x: AlgebraicNode;
|
|
24
30
|
y: AlgebraicNode;
|
|
25
|
-
constructor(name: string, x: AlgebraicNode, y: AlgebraicNode);
|
|
31
|
+
constructor(name: string, x: AlgebraicNode | number, y: AlgebraicNode | number);
|
|
26
32
|
toTex(): string;
|
|
27
33
|
toIdentifiers(): PointIdentifiers;
|
|
28
34
|
toTexWithCoords(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/point.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAG/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mDAAmD,CAAC;AACvF,OAAO,EAEL,eAAe,EAChB,MA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;CAclC;AAED,qBAAa,KAAK;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,aAAa,CAAC;IACjB,CAAC,EAAE,aAAa,CAAC;gBAEf,IAAI,EAAE,MAAM,EACZ,CAAC,EAAE,aAAa,GAAG,MAAM,EACzB,CAAC,EAAE,aAAa,GAAG,MAAM;IAO3B,KAAK,IAAI,MAAM;IAGf,aAAa,IAAI,gBAAgB;IAQjC,eAAe,IAAI,MAAM;IAGzB,QAAQ,IAAI,MAAM;IAIlB,UAAU,IAAI,MAAM;IAIpB,UAAU,IAAI,MAAM;IAIpB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,SAAM,GAAG,KAAK;IAiBrC,UAAU,CAAC,CAAC,EAAE,KAAK,GAAG,MAAM;IAM5B,MAAM,CAAC,CAAC,EAAE,KAAK,GAAG,OAAO;IAGzB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK;IAK5B,YAAY;IAGZ,YAAY,CAAC,EACX,OAAc,EACd,SAAgB,EAChB,KAAK,EACL,IAAI,EACJ,KAAK,GACN,GAAE,kBAAuB;IAiB1B,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK;IAiBnC,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,SAAkB;CAItD"}
|
|
@@ -11,7 +11,17 @@ const randfloat_1 = require("../utils/random/randfloat");
|
|
|
11
11
|
const substractNode_1 = require("../../tree/nodes/operators/substractNode");
|
|
12
12
|
const multiplyNode_1 = require("../../tree/nodes/operators/multiplyNode");
|
|
13
13
|
const addNode_1 = require("../../tree/nodes/operators/addNode");
|
|
14
|
+
const randomLetter_1 = require("../../utils/strings/randomLetter");
|
|
14
15
|
class PointConstructor {
|
|
16
|
+
static randomName(excludes) {
|
|
17
|
+
return (0, randomLetter_1.randomLetter)(true, ["O", ...(excludes ?? [])]);
|
|
18
|
+
}
|
|
19
|
+
static randomNames(count) {
|
|
20
|
+
const res = [];
|
|
21
|
+
for (let i = 0; i < count; i++)
|
|
22
|
+
res.push(PointConstructor.randomName(res));
|
|
23
|
+
return res;
|
|
24
|
+
}
|
|
15
25
|
static origin(name = "O") {
|
|
16
26
|
return new Point(name, new numberNode_1.NumberNode(0), new numberNode_1.NumberNode(0));
|
|
17
27
|
}
|
|
@@ -29,18 +39,19 @@ class PointConstructor {
|
|
|
29
39
|
const point = vector.getEndPoint(A, name);
|
|
30
40
|
return point;
|
|
31
41
|
}
|
|
32
|
-
static randomDifferent(names) {
|
|
42
|
+
static randomDifferent(count, { names, minDistance, minDistanceToOrigin, }) {
|
|
33
43
|
const res = [];
|
|
34
44
|
const points = [];
|
|
35
|
-
|
|
45
|
+
const pointNames = names ?? PointConstructor.randomNames(count);
|
|
46
|
+
for (let i = 0; i < count; i++) {
|
|
36
47
|
let x;
|
|
37
48
|
let y;
|
|
38
49
|
do {
|
|
39
|
-
x = (0, randint_1.randint)(-10,
|
|
40
|
-
y = (0, randint_1.randint)(-10,
|
|
41
|
-
} while (points.some((point) => point[0]
|
|
50
|
+
x = (0, randint_1.randint)(-(minDistanceToOrigin ?? 10), (minDistanceToOrigin ?? 10) + 1);
|
|
51
|
+
y = (0, randint_1.randint)(-(minDistanceToOrigin ?? 10), (minDistanceToOrigin ?? 10) + 1);
|
|
52
|
+
} while (points.some((point) => Math.hypot(point[0] - x, point[1] - y) < (minDistance ?? 1)));
|
|
42
53
|
points.push([x, y]);
|
|
43
|
-
res.push(new Point(
|
|
54
|
+
res.push(new Point(pointNames[i], new numberNode_1.NumberNode(x), new numberNode_1.NumberNode(y)));
|
|
44
55
|
}
|
|
45
56
|
return res;
|
|
46
57
|
}
|
|
@@ -59,8 +70,8 @@ exports.PointConstructor = PointConstructor;
|
|
|
59
70
|
class Point {
|
|
60
71
|
constructor(name, x, y) {
|
|
61
72
|
this.name = name;
|
|
62
|
-
this.x = x;
|
|
63
|
-
this.y = y;
|
|
73
|
+
this.x = typeof x === "number" ? x.toTree() : x;
|
|
74
|
+
this.y = typeof y === "number" ? y.toTree() : y;
|
|
64
75
|
}
|
|
65
76
|
toTex() {
|
|
66
77
|
return `${this.name}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ray.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/ray.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mDAAmD,CAAC;AAEvF,OAAO,EAAE,KAAK,EAAoB,MAAM,SAAS,CAAC;AAElD,8BAAsB,cAAc;IAClC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"ray.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/ray.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mDAAmD,CAAC;AAEvF,OAAO,EAAE,KAAK,EAAoB,MAAM,SAAS,CAAC;AAElD,8BAAsB,cAAc;IAClC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM;CAO5B;AAED,qBAAa,GAAG;IACd,UAAU,EAAE,KAAK,CAAC;IAClB,WAAW,EAAE,KAAK,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;gBACJ,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,MAAM;IAOhE,KAAK;IAGL,aAAa,CACX,iBAAiB,EAAE,OAAO,EAC1B,EACE,OAAc,EACd,SAAiB,EACjB,yBAAgC,GACjC,GAAE,kBAAuB;CAoB7B"}
|
package/lib/math/geometry/ray.js
CHANGED
|
@@ -6,7 +6,9 @@ const point_1 = require("./point");
|
|
|
6
6
|
class RayConstructor {
|
|
7
7
|
static random(name) {
|
|
8
8
|
const names = (0, randomSegmentName_1.randomSegmentName)();
|
|
9
|
-
const points = point_1.PointConstructor.randomDifferent(
|
|
9
|
+
const points = point_1.PointConstructor.randomDifferent(2, {
|
|
10
|
+
names: names.split(""),
|
|
11
|
+
});
|
|
10
12
|
return new Ray(points[0], points[1], name);
|
|
11
13
|
}
|
|
12
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"segment.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/segment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mDAAmD,CAAC;AAEvF,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE/D,OAAO,EAEL,eAAe,EAEhB,MAAM,kCAAkC,CAAC;AAK1C,OAAO,EAAE,KAAK,EAAoB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,EAAE,MAAM,EAAqB,MAAM,UAAU,CAAC;AAErD,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;
|
|
1
|
+
{"version":3,"file":"segment.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/segment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mDAAmD,CAAC;AAEvF,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE/D,OAAO,EAEL,eAAe,EAEhB,MAAM,kCAAkC,CAAC;AAK1C,OAAO,EAAE,KAAK,EAAoB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,EAAE,MAAM,EAAqB,MAAM,UAAU,CAAC;AAErD,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;IAAE,UAAU,CAAC,EAAE,aAAa,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAC3E,qBAAa,OAAO;IAClB,MAAM,EAAE,KAAK,CAAC;IACd,MAAM,EAAE,KAAK,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,aAAa,CAAC;IAC3B,KAAK,CAAC,EAAE,YAAY,CAAC;gBACT,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,YAAY;IAS9D,aAAa,IAAI,kBAAkB;IAUnC,WAAW;IAGX,SAAS;IAST,aAAa;IAYb,KAAK;IAGL,YAAY;IAGZ,WAAW;IAGX,qBAAqB,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;IAanD,aAAa,CACX,iBAAiB,EAAE,OAAO,EAC1B,EACE,OAAc,EACd,SAAiB,EACjB,yBAAgC,EAChC,UAAkB,EAClB,KAAK,GACN,GAAE,kBAAuB;IA8B5B,QAAQ,CAAC,KAAK,EAAE,KAAK;IAOrB,QAAQ;CAGT"}
|
|
@@ -13,7 +13,9 @@ const vector_1 = require("./vector");
|
|
|
13
13
|
class SegmentConstructor {
|
|
14
14
|
static random() {
|
|
15
15
|
const name = (0, randomSegmentName_1.randomSegmentName)();
|
|
16
|
-
const points = point_1.PointConstructor.randomDifferent(
|
|
16
|
+
const points = point_1.PointConstructor.randomDifferent(2, {
|
|
17
|
+
names: name.split(""),
|
|
18
|
+
});
|
|
17
19
|
return new Segment(points[0], points[1]);
|
|
18
20
|
}
|
|
19
21
|
static fromIdentifiers(identifiers) {
|
|
@@ -21,6 +21,7 @@ export declare class Vector {
|
|
|
21
21
|
opposite(): Vector;
|
|
22
22
|
scalarProduct(v: Vector): AlgebraicNode;
|
|
23
23
|
add(v: Vector): Vector;
|
|
24
|
+
substract(v: Vector): Vector;
|
|
24
25
|
getNorm(): AlgebraicNode;
|
|
25
26
|
getEndPoint(startPoint: Point, name?: string): Point;
|
|
26
27
|
equals(v: Vector): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/vector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAgB/D,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,8BAAsB,iBAAiB;IACrC,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,GAAG,MAAM;IAOpD,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,UAAO,GAAG,MAAM;CAOtD;AAED,qBAAa,MAAM;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,EAAE,aAAa,CAAC;IACjB,CAAC,EAAE,aAAa,CAAC;gBACL,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa;IAO5D,KAAK,IAAI,MAAM;IAIf,eAAe,IAAI,MAAM;IAMzB,iBAAiB,IAAI,MAAM;IAM3B,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO;IAK9B,sBAAsB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO;IAI1C,kBAAkB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO;IAItC,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,aAAa;IAIrC,KAAK,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,MAAM;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UAAU,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,MAAM;IAO5C,MAAM,CAAC,CAAC,EAAE,MAAM;IAIhB,YAAY;IAMZ,YAAY;IAOZ,aAAa;CAGd"}
|
|
@@ -80,6 +80,9 @@ class Vector {
|
|
|
80
80
|
const resultY = new addNode_1.AddNode(this.y, y);
|
|
81
81
|
return new Vector(`${this.name}+${v.name}`, resultX.simplify(), resultY.simplify());
|
|
82
82
|
}
|
|
83
|
+
substract(v) {
|
|
84
|
+
return this.add(v.opposite());
|
|
85
|
+
}
|
|
83
86
|
getNorm() {
|
|
84
87
|
const xValue = this.x.simplify().value;
|
|
85
88
|
const yValue = this.y.simplify().value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"random.d.ts","sourceRoot":"","sources":["../../../src/utils/alea/random.ts"],"names":[],"mappings":"AAEA,wBAAgB,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,KAMnD"}
|
|
1
|
+
{"version":3,"file":"random.d.ts","sourceRoot":"","sources":["../../../src/utils/alea/random.ts"],"names":[],"mappings":"AAEA,wBAAgB,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,KAMnD;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,OAUtE"}
|
package/lib/utils/alea/random.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.random = void 0;
|
|
3
|
+
exports.randomMany = exports.random = void 0;
|
|
4
4
|
function random(array, excludes) {
|
|
5
5
|
if (excludes?.length) {
|
|
6
6
|
const filtered = array.filter((t) => !excludes.includes(t));
|
|
@@ -9,3 +9,15 @@ function random(array, excludes) {
|
|
|
9
9
|
return array[Math.floor(Math.random() * array.length)];
|
|
10
10
|
}
|
|
11
11
|
exports.random = random;
|
|
12
|
+
function randomMany(array, count, excludes) {
|
|
13
|
+
const res = [];
|
|
14
|
+
let i = 0;
|
|
15
|
+
while (res.length < count) {
|
|
16
|
+
if (i > 10000)
|
|
17
|
+
throw new Error("randomMany malformed");
|
|
18
|
+
i++;
|
|
19
|
+
res.push(random(array, [...res, ...(excludes ?? [])]));
|
|
20
|
+
}
|
|
21
|
+
return res;
|
|
22
|
+
}
|
|
23
|
+
exports.randomMany = randomMany;
|