math-exercises 2.2.18 → 2.2.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/lib/exercises/math/geometry/euclidianConstructions/buildMediatriceWithCompass.d.ts +8 -0
  2. package/lib/exercises/math/geometry/euclidianConstructions/buildMediatriceWithCompass.d.ts.map +1 -0
  3. package/lib/exercises/math/geometry/euclidianConstructions/buildMediatriceWithCompass.js +125 -0
  4. package/lib/exercises/math/geometry/euclidianConstructions/index.d.ts +2 -0
  5. package/lib/exercises/math/geometry/euclidianConstructions/index.d.ts.map +1 -0
  6. package/lib/exercises/math/geometry/euclidianConstructions/index.js +17 -0
  7. package/lib/exercises/math/geometry/index.d.ts +1 -0
  8. package/lib/exercises/math/geometry/index.d.ts.map +1 -1
  9. package/lib/exercises/math/geometry/index.js +2 -0
  10. package/lib/exercises/math/geometry/triangles/index.d.ts +1 -0
  11. package/lib/exercises/math/geometry/triangles/index.d.ts.map +1 -0
  12. package/lib/exercises/math/geometry/triangles/index.js +2 -0
  13. package/lib/exercises/math/geometry/triangles/traceMedianInTriangle.d.ts +1 -0
  14. package/lib/exercises/math/geometry/triangles/traceMedianInTriangle.d.ts.map +1 -0
  15. package/lib/exercises/math/geometry/triangles/traceMedianInTriangle.js +55 -0
  16. package/lib/exercises/utils/geogebra/toolBarConstructor.d.ts +1 -0
  17. package/lib/exercises/utils/geogebra/toolBarConstructor.d.ts.map +1 -1
  18. package/lib/exercises/utils/geogebra/toolBarConstructor.js +2 -0
  19. package/lib/exercises/utils/geometry/randomSegmentName.d.ts +2 -0
  20. package/lib/exercises/utils/geometry/randomSegmentName.d.ts.map +1 -0
  21. package/lib/exercises/utils/geometry/randomSegmentName.js +10 -0
  22. package/lib/index.d.ts +3 -0
  23. package/lib/index.d.ts.map +1 -1
  24. package/lib/math/geometry/line.d.ts +1 -1
  25. package/lib/math/geometry/line.d.ts.map +1 -1
  26. package/lib/math/geometry/line.js +12 -3
  27. package/lib/math/geometry/point.d.ts +1 -0
  28. package/lib/math/geometry/point.d.ts.map +1 -1
  29. package/lib/math/geometry/point.js +10 -0
  30. package/lib/math/geometry/segment.d.ts +9 -0
  31. package/lib/math/geometry/segment.d.ts.map +1 -0
  32. package/lib/math/geometry/segment.js +16 -0
  33. package/package.json +1 -1
@@ -0,0 +1,8 @@
1
+ import { Exercise } from "../../../../exercises/exercise";
2
+ type Identifiers = {
3
+ A: number[];
4
+ B: number[];
5
+ };
6
+ export declare const buildMediatriceWithCompass: Exercise<Identifiers>;
7
+ export {};
8
+ //# sourceMappingURL=buildMediatriceWithCompass.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildMediatriceWithCompass.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/euclidianConstructions/buildMediatriceWithCompass.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAUT,MAAM,0BAA0B,CAAC;AAalC,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,EAAE,CAAC;IACZ,CAAC,EAAE,MAAM,EAAE,CAAC;CACb,CAAC;AA8GF,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,WAAW,CAe5D,CAAC"}
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildMediatriceWithCompass = void 0;
4
+ const exercise_1 = require("../../../../exercises/exercise");
5
+ const isGGBLine_1 = require("../../../../exercises/utils/geogebra/isGGBLine");
6
+ const toolBarConstructor_1 = require("../../../../exercises/utils/geogebra/toolBarConstructor");
7
+ const randomSegmentName_1 = require("../../../../exercises/utils/geometry/randomSegmentName");
8
+ const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
9
+ const colors_1 = require("../../../../geogebra/colors");
10
+ const geogebraConstructor_1 = require("../../../../geogebra/geogebraConstructor");
11
+ const point_1 = require("../../../../math/geometry/point");
12
+ const segment_1 = require("../../../../math/geometry/segment");
13
+ const getBuildMediatriceWithCompassQuestion = () => {
14
+ const segmentName = (0, randomSegmentName_1.randomSegmentName)();
15
+ const A = segmentName[0];
16
+ const B = segmentName[1];
17
+ const pointA = point_1.PointConstructor.random(A);
18
+ const pointB = point_1.PointConstructor.random(B);
19
+ const segment = new segment_1.Segment(pointA, pointB);
20
+ const length = segment.getLength();
21
+ const [xa, ya] = [pointA.x.evaluate({}), pointA.y.evaluate({})];
22
+ const [xb, yb] = [pointB.x.evaluate({}), pointB.y.evaluate({})];
23
+ const xMin = Math.min(xa, xb) - length;
24
+ const xMax = Math.max(xa, xb) + length;
25
+ const yMin = Math.min(ya, yb) - length;
26
+ const yMax = Math.max(ya, yb) + length;
27
+ const ggbAnswer = [
28
+ `${pointA.toGGBCommand()}`,
29
+ `${pointB.toGGBCommand()}`,
30
+ `SetFixed(${A}, true)`,
31
+ `SetFixed(${B}, true)`,
32
+ `ShowLabel(${A}, true)`,
33
+ `ShowLabel(${B}, true)`,
34
+ `Seg = Segment(${A},${B})`,
35
+ `C_1 = Circle(${A},${B})`,
36
+ `C_2 = Circle(${B},${A})`,
37
+ `I_1 = Intersect(C_1, C_2,1)`,
38
+ `I_2 = Intersect(C_1, C_2,2)`,
39
+ `Ans = Line(I_1,I_2)`,
40
+ `SetColor(Ans, "${colors_1.greenDark}")`,
41
+ ];
42
+ const studentGGB = new geogebraConstructor_1.GeogebraConstructor({
43
+ commands: [
44
+ `${pointA.toGGBCommand()}`,
45
+ `${pointB.toGGBCommand()}`,
46
+ `SetFixed(${A}, true)`,
47
+ `SetFixed(${B}, true)`,
48
+ `ShowLabel(${A}, true)`,
49
+ `ShowLabel(${B}, true)`,
50
+ `Seg = Segment(${A},${B})`,
51
+ ],
52
+ hideGrid: true,
53
+ hideAxes: true,
54
+ customToolBar: (0, toolBarConstructor_1.toolBarConstructor)({
55
+ join: true,
56
+ circleTwoPoints: true,
57
+ intersect: true,
58
+ }),
59
+ });
60
+ const question = {
61
+ ggbAnswer: ggbAnswer,
62
+ instruction: `Avec les outils disponibles, tracer la médiatrice du segment $[${segmentName}]$.`,
63
+ keys: [],
64
+ answerFormat: "tex",
65
+ identifiers: {
66
+ A: [xa, ya],
67
+ B: [xb, yb],
68
+ },
69
+ studentGgbOptions: studentGGB.getOptions({
70
+ coords: [xMin, xMax, yMin, yMax],
71
+ }),
72
+ };
73
+ return question;
74
+ };
75
+ const getPropositions = (n, { answer }) => {
76
+ const propositions = [];
77
+ (0, exercise_1.addValidProp)(propositions, answer);
78
+ while (propositions.length < n) {
79
+ throw Error("QCM not implemented");
80
+ }
81
+ return (0, exercise_1.shuffleProps)(propositions, n);
82
+ };
83
+ const isGGBAnswerValid = (ans, { ggbAnswer, A, B }) => {
84
+ const lines = ans.filter((s) => (0, isGGBLine_1.isGGBLine)(s));
85
+ const segmentPointA = new point_1.Point("Seg_A", A[0].toTree(), A[1].toTree());
86
+ const segmentPointB = new point_1.Point("Seg_B", B[0].toTree(), B[1].toTree());
87
+ if (!lines.length)
88
+ return false;
89
+ for (const line of lines) {
90
+ const formatted = line
91
+ .replace(" ", "")
92
+ .replace("Line", "")
93
+ .replace("[", "")
94
+ .replace("]", "")
95
+ .split("=")[1];
96
+ const [nameA, nameB] = formatted.split(",");
97
+ const pointACmd = ans.find((s) => s.startsWith(nameA));
98
+ const pointBCmd = ans.find((s) => s.startsWith(nameB));
99
+ if (!pointACmd || !pointBCmd)
100
+ return false;
101
+ const pointA = point_1.PointConstructor.fromGGBCommand(pointACmd);
102
+ const pointB = point_1.PointConstructor.fromGGBCommand(pointBCmd);
103
+ if (pointA.distanceTo(segmentPointA) - pointA.distanceTo(segmentPointB) <
104
+ 0.0000001 &&
105
+ pointB.distanceTo(segmentPointA) - pointB.distanceTo(segmentPointB) <
106
+ 0.0000001)
107
+ return true;
108
+ }
109
+ return false;
110
+ };
111
+ exports.buildMediatriceWithCompass = {
112
+ id: "buildMediatriceWithCompass",
113
+ connector: "=",
114
+ label: "Tracer une médiatrice avec un compas",
115
+ levels: [],
116
+ isSingleStep: true,
117
+ sections: [],
118
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getBuildMediatriceWithCompassQuestion, nb),
119
+ qcmTimer: 60,
120
+ freeTimer: 60,
121
+ getPropositions,
122
+ isGGBAnswerValid,
123
+ subject: "Mathématiques",
124
+ answerType: "GGB",
125
+ };
@@ -0,0 +1,2 @@
1
+ export * from "./buildMediatriceWithCompass";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/euclidianConstructions/index.ts"],"names":[],"mappings":"AAAA,cAAc,8BAA8B,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./buildMediatriceWithCompass"), exports);
@@ -6,4 +6,5 @@ export * from "./thales";
6
6
  export * from "./vectors";
7
7
  export * from "./convexity";
8
8
  export * from "./volumes";
9
+ export * from "./euclidianConstructions";
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/geometry/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/math/geometry/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAE1B,cAAc,0BAA0B,CAAC"}
@@ -22,3 +22,5 @@ __exportStar(require("./thales"), exports);
22
22
  __exportStar(require("./vectors"), exports);
23
23
  __exportStar(require("./convexity"), exports);
24
24
  __exportStar(require("./volumes"), exports);
25
+ // export * from "./triangles";
26
+ __exportStar(require("./euclidianConstructions"), exports);
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/triangles/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ // export * from './traceMedianInTriangle'
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=traceMedianInTriangle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"traceMedianInTriangle.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/triangles/traceMedianInTriangle.ts"],"names":[],"mappings":""}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ // import {
3
+ // Exercise,
4
+ // Proposition,
5
+ // QCMGenerator,
6
+ // Question,
7
+ // QuestionGenerator,
8
+ // VEA,
9
+ // GGBVEA,
10
+ // addValidProp,
11
+ // shuffleProps,
12
+ // tryToAddWrongProp,
13
+ // } from '../../../../exercises/exercise';
14
+ // import { getDistinctQuestions } from '../../../../exercises/utils/getDistinctQuestions';
15
+ // type Identifiers = {
16
+ // };
17
+ // const getTraceMedianInTriangleQuestion: QuestionGenerator<Identifiers> = ()=>{
18
+ // const question: Question<Identifiers> = {
19
+ // answer,
20
+ // instruction: ``,
21
+ // keys: [],
22
+ // answerFormat: 'tex',
23
+ // identifiers : {}
24
+ // };
25
+ // return question;
26
+ // }
27
+ // const getPropositions: QCMGenerator<Identifiers> = (n, { answer }) => {
28
+ // const propositions: Proposition[] = [];
29
+ // addValidProp(propositions, answer);
30
+ // while (propositions.length < n) {
31
+ // throw Error("QCM not implemented")
32
+ // }
33
+ // return shuffleProps(propositions, n);
34
+ // };
35
+ // const isAnswerValid: VEA<Identifiers> = (ans, {answer})=>{
36
+ // throw Error("VEA not implemented")
37
+ // }
38
+ // const isGGBAnswerValid: GGBVEA<Identifiers> = (ans, {ggbAnswer}) => {
39
+ // throw Error("GGBVea not implemented")
40
+ // }
41
+ // export const traceMedianInTriangle: Exercise<Identifiers> = {
42
+ // id: 'traceMedianInTriangle',
43
+ // connector: "",
44
+ // label: "",
45
+ // levels: [],
46
+ // isSingleStep: true,
47
+ // sections: [],
48
+ // generator: (nb: number) => getDistinctQuestions(getTraceMedianInTriangleQuestion, nb),
49
+ // qcmTimer: 60,
50
+ // freeTimer: 60,
51
+ // getPropositions,
52
+ // isAnswerValid,
53
+ // isGGBAnswerValid,
54
+ // subject: "Mathématiques"
55
+ // };
@@ -5,5 +5,6 @@ export declare const toolBarConstructor: (options: {
5
5
  orthogonal?: boolean;
6
6
  intersect?: boolean;
7
7
  vector?: boolean;
8
+ circleTwoPoints?: boolean;
8
9
  }) => string;
9
10
  //# sourceMappingURL=toolBarConstructor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"toolBarConstructor.d.ts","sourceRoot":"","sources":["../../../../src/exercises/utils/geogebra/toolBarConstructor.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,YAAa;IAC1C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,WASA,CAAC"}
1
+ {"version":3,"file":"toolBarConstructor.d.ts","sourceRoot":"","sources":["../../../../src/exercises/utils/geogebra/toolBarConstructor.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,YAAa;IAC1C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,WAUA,CAAC"}
@@ -15,6 +15,8 @@ const toolBarConstructor = (options) => {
15
15
  customToolBar += "||5";
16
16
  if (options.vector)
17
17
  customToolBar += "||7";
18
+ if (options.circleTwoPoints)
19
+ customToolBar += "||10";
18
20
  return customToolBar;
19
21
  };
20
22
  exports.toolBarConstructor = toolBarConstructor;
@@ -0,0 +1,2 @@
1
+ export declare const randomSegmentName: () => string;
2
+ //# sourceMappingURL=randomSegmentName.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"randomSegmentName.d.ts","sourceRoot":"","sources":["../../../../src/exercises/utils/geometry/randomSegmentName.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,cAI7B,CAAC"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.randomSegmentName = void 0;
4
+ const randomLetter_1 = require("../../../utils/strings/randomLetter");
5
+ const randomSegmentName = () => {
6
+ const A = (0, randomLetter_1.randomLetter)(true);
7
+ const B = (0, randomLetter_1.randomLetter)(true, [A]);
8
+ return `${A}${B}`;
9
+ };
10
+ exports.randomSegmentName = randomSegmentName;
package/lib/index.d.ts CHANGED
@@ -964,6 +964,9 @@ declare const mathExercises: (import("./exercises/exercise").Exercise<{
964
964
  width: number;
965
965
  height: number;
966
966
  angle: number;
967
+ }> | import("./exercises/exercise").Exercise<{
968
+ A: number[];
969
+ B: number[];
967
970
  }> | import("./exercises/exercise").Exercise<{
968
971
  coeffs: number[];
969
972
  to: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAaA,OAAO,yBAAyB,CAAC;AAEjC,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,CAAC"}
@@ -10,7 +10,7 @@ export declare class Line {
10
10
  b: AlgebraicNode | undefined;
11
11
  constructor(pointA: Point, pointB: Point);
12
12
  getParallele(point: Point): Line;
13
- includes(point: Point): boolean;
13
+ includes(point: Point, allowApprox?: boolean): boolean;
14
14
  getRandomPoint(name?: string): Point;
15
15
  getEquation: (u: Vector, a: Point) => EqualNode;
16
16
  getCartesianEquation(): EqualNode;
@@ -1 +1 @@
1
- {"version":3,"file":"line.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/line.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAQjE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,qBAAa,IAAI;IACf,MAAM,EAAE,KAAK,CAAC;IACd,MAAM,EAAE,KAAK,CAAC;IACd,UAAU,EAAE,OAAO,CAAC;IACpB,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IAC7B,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;gBACjB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK;IAkBxC,YAAY,CAAC,KAAK,EAAE,KAAK;IASzB,QAAQ,CAAC,KAAK,EAAE,KAAK;IAarB,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM;IAa5B,WAAW,MAAO,MAAM,KAAK,KAAK,KAAG,SAAS,CAmB5C;IAEF,oBAAoB,IAAI,SAAS;CAsBlC"}
1
+ {"version":3,"file":"line.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/line.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAQjE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,qBAAa,IAAI;IACf,MAAM,EAAE,KAAK,CAAC;IACd,MAAM,EAAE,KAAK,CAAC;IACd,UAAU,EAAE,OAAO,CAAC;IACpB,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IAC7B,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;gBACjB,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK;IAkBxC,YAAY,CAAC,KAAK,EAAE,KAAK;IASzB,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,WAAW,GAAE,OAAe;IAgBnD,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM;IAa5B,WAAW,MAAO,MAAM,KAAK,KAAK,KAAG,SAAS,CAmB5C;IAEF,oBAAoB,IAAI,SAAS;CAsBlC"}
@@ -47,11 +47,20 @@ class Line {
47
47
  const secondPoint = new point_1.Point("D", x, y);
48
48
  return new Line(point, secondPoint);
49
49
  }
50
- includes(point) {
50
+ includes(point, allowApprox = false) {
51
51
  if (this.isVertical) {
52
- return point.x.equals(this.pointA.x);
52
+ if (allowApprox) {
53
+ }
54
+ else
55
+ return point.x.equals(this.pointA.x);
53
56
  }
54
- return (new substractNode_1.SubstractNode(point.y, new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(this.a, point.x), this.b)).evaluate({}) === 0);
57
+ const evaluation = new substractNode_1.SubstractNode(point.y, new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(this.a, point.x), this.b)).evaluate({});
58
+ console.log("eval", evaluation);
59
+ if (allowApprox) {
60
+ return Math.abs(evaluation) < 0.0000001;
61
+ }
62
+ else
63
+ return evaluation === 0;
55
64
  }
56
65
  //! caution: simplify ne gère pas bien ici
57
66
  getRandomPoint(name) {
@@ -3,6 +3,7 @@ import { AlgebraicNode } from "../../tree/nodes/algebraicNode";
3
3
  export declare abstract class PointConstructor {
4
4
  static random(name: string): Point;
5
5
  static randomDifferent(names: string[]): Point[];
6
+ static fromGGBCommand(str: string): Point;
6
7
  }
7
8
  export declare class Point {
8
9
  name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/point.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAY,MAAM,uBAAuB,CAAC;AAI1D,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAI/D,8BAAsB,gBAAgB;IACpC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK;IAMlC,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE;CAevC;AAED,qBAAa,KAAK;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,aAAa,CAAC;IACjB,CAAC,EAAE,aAAa,CAAC;gBACL,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa;IAM5D,KAAK,IAAI,MAAM;IAGf,aAAa;;;;;;;;;;IAQb,eAAe,IAAI,MAAM;IAGzB,QAAQ,IAAI,MAAM;IAIlB,UAAU,IAAI,MAAM;IAMpB,UAAU,IAAI,MAAM;IAMpB,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;IAM5B,YAAY;CAKb"}
1
+ {"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/point.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAY,MAAM,uBAAuB,CAAC;AAI1D,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAI/D,8BAAsB,gBAAgB;IACpC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK;IAMlC,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE;IAetC,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,MAAM;CAclC;AAED,qBAAa,KAAK;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,aAAa,CAAC;IACjB,CAAC,EAAE,aAAa,CAAC;gBACL,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa;IAM5D,KAAK,IAAI,MAAM;IAGf,aAAa;;;;;;;;;;IAQb,eAAe,IAAI,MAAM;IAGzB,QAAQ,IAAI,MAAM;IAIlB,UAAU,IAAI,MAAM;IAMpB,UAAU,IAAI,MAAM;IAMpB,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;IAM5B,YAAY;CAKb"}
@@ -27,6 +27,16 @@ class PointConstructor {
27
27
  }
28
28
  return res;
29
29
  }
30
+ static fromGGBCommand(str) {
31
+ const formatted = str.replace(" ", "");
32
+ const name = formatted.split("=")[0];
33
+ const [x, y] = formatted
34
+ .split("=")[1]
35
+ .replace("(", "")
36
+ .replace(")", "")
37
+ .split(",");
38
+ return new Point(name, new numberNode_1.NumberNode(Number(x)), new numberNode_1.NumberNode(Number(y)));
39
+ }
30
40
  }
31
41
  exports.PointConstructor = PointConstructor;
32
42
  class Point {
@@ -0,0 +1,9 @@
1
+ import { Point } from "./point";
2
+ export declare class Segment {
3
+ pointA: Point;
4
+ pointB: Point;
5
+ constructor(pointA: Point, pointB: Point);
6
+ getLength(): number;
7
+ getName(): string;
8
+ }
9
+ //# sourceMappingURL=segment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"segment.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/segment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,qBAAa,OAAO;IAClB,MAAM,EAAE,KAAK,CAAC;IACd,MAAM,EAAE,KAAK,CAAC;gBACF,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK;IAIxC,SAAS;IAGT,OAAO;CAMR"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Segment = void 0;
4
+ class Segment {
5
+ constructor(pointA, pointB) {
6
+ this.pointA = pointA;
7
+ this.pointB = pointB;
8
+ }
9
+ getLength() {
10
+ return this.pointA.distanceTo(this.pointB);
11
+ }
12
+ getName() {
13
+ return `\\left[${this.pointA.name}, ${this.pointB.name}\\right]`;
14
+ }
15
+ }
16
+ exports.Segment = Segment;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "math-exercises",
3
- "version": "2.2.18",
3
+ "version": "2.2.19",
4
4
  "description": "Math exercises generator for middle school and high school",
5
5
  "main": "lib/index.js",
6
6
  "files": [