math-exercises 2.0.19 → 2.0.21

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 (48) hide show
  1. package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType0.d.ts.map +1 -1
  2. package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType0.js +1 -1
  3. package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType1.d.ts.map +1 -1
  4. package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType1.js +1 -1
  5. package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType2.d.ts.map +1 -1
  6. package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType2.js +1 -1
  7. package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType3.d.ts.map +1 -1
  8. package/lib/exercises/calculLitteral/inequations/firstDegreeInequationsType3.js +1 -1
  9. package/lib/exercises/geometry/vectors/alignementViaColinearity.d.ts +12 -0
  10. package/lib/exercises/geometry/vectors/alignementViaColinearity.d.ts.map +1 -0
  11. package/lib/exercises/geometry/vectors/alignementViaColinearity.js +61 -0
  12. package/lib/exercises/geometry/vectors/colinearity.d.ts +10 -0
  13. package/lib/exercises/geometry/vectors/colinearity.d.ts.map +1 -0
  14. package/lib/exercises/geometry/vectors/colinearity.js +59 -0
  15. package/lib/exercises/geometry/vectors/index.d.ts +1 -0
  16. package/lib/exercises/geometry/vectors/index.d.ts.map +1 -1
  17. package/lib/exercises/geometry/vectors/index.js +2 -0
  18. package/lib/exercises/probaStat/independancy.d.ts +9 -0
  19. package/lib/exercises/probaStat/independancy.d.ts.map +1 -0
  20. package/lib/exercises/probaStat/independancy.js +59 -0
  21. package/lib/exercises/probaStat/index.d.ts +1 -0
  22. package/lib/exercises/probaStat/index.d.ts.map +1 -1
  23. package/lib/exercises/probaStat/index.js +1 -0
  24. package/lib/exercises/trigonometry/remarkableValues.js +1 -1
  25. package/lib/index.d.ts +9 -0
  26. package/lib/index.d.ts.map +1 -1
  27. package/lib/math/geometry/line.d.ts +10 -0
  28. package/lib/math/geometry/line.d.ts.map +1 -1
  29. package/lib/math/geometry/line.js +34 -0
  30. package/lib/math/geometry/point.d.ts +4 -15
  31. package/lib/math/geometry/point.d.ts.map +1 -1
  32. package/lib/math/geometry/point.js +28 -20
  33. package/lib/math/geometry/vector.d.ts +8 -5
  34. package/lib/math/geometry/vector.d.ts.map +1 -1
  35. package/lib/math/geometry/vector.js +13 -3
  36. package/lib/math/numbers/decimals/decimal.d.ts +1 -2
  37. package/lib/math/numbers/decimals/decimal.d.ts.map +1 -1
  38. package/lib/math/numbers/decimals/decimal.js +31 -87
  39. package/lib/server.js +29 -7
  40. package/lib/tree/nodes/functions/oppositeNode.d.ts +1 -1
  41. package/lib/tree/nodes/functions/oppositeNode.js +2 -1
  42. package/lib/tree/nodes/operators/powerNode.d.ts.map +1 -1
  43. package/lib/tree/nodes/operators/powerNode.js +6 -3
  44. package/lib/tree/nodes/operators/substractNode.js +1 -1
  45. package/lib/tree/parsers/latexParser.d.ts +1 -0
  46. package/lib/tree/parsers/latexParser.d.ts.map +1 -1
  47. package/lib/tree/parsers/latexParser.js +240 -133
  48. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"firstDegreeInequationsType0.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calculLitteral/inequations/firstDegreeInequationsType0.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAQb,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,gBAAgB,EAGjB,MAAM,mCAAmC,CAAC;AAW3C,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,gBAAgB,CAAC;CAC5B,CAAC;AA2DF,eAAO,MAAM,2BAA2B,EAAE,YAAY,CAAC,WAAW,CAajE,CAAC"}
1
+ {"version":3,"file":"firstDegreeInequationsType0.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calculLitteral/inequations/firstDegreeInequationsType0.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAQb,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,gBAAgB,EAGjB,MAAM,mCAAmC,CAAC;AAW3C,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,gBAAgB,CAAC;CAC5B,CAAC;AA6DF,eAAO,MAAM,2BAA2B,EAAE,YAAY,CAAC,WAAW,CAajE,CAAC"}
@@ -21,7 +21,7 @@ const getFirstDegreeInequationsQuestion = () => {
21
21
  const answer = `x${ineqType.symbol}${result}`;
22
22
  const question = {
23
23
  answer: answer,
24
- instruction: `Résoudre l'inéquation : $${affine.toTex()} ${ineqType} ${c}$ `,
24
+ instruction: `Résoudre l'inéquation : $${affine.toTex()} ${ineqType.symbol} ${c}$ `,
25
25
  keys: inequationKeys_1.inequationKeys,
26
26
  answerFormat: "tex",
27
27
  identifiers: { ineqType: ineqType.symbol, b: affine.b, c },
@@ -1 +1 @@
1
- {"version":3,"file":"firstDegreeInequationsType1.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calculLitteral/inequations/firstDegreeInequationsType1.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAQb,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,gBAAgB,EAGjB,MAAM,mCAAmC,CAAC;AAa3C,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,gBAAgB,CAAC;CAC5B,CAAC;AAmEF,eAAO,MAAM,2BAA2B,EAAE,YAAY,CAAC,WAAW,CAcjE,CAAC"}
1
+ {"version":3,"file":"firstDegreeInequationsType1.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calculLitteral/inequations/firstDegreeInequationsType1.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAQb,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,gBAAgB,EAGjB,MAAM,mCAAmC,CAAC;AAS3C,KAAK,WAAW,GAAG;IACjB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,QAAQ,EAAE,gBAAgB,CAAC;CAC5B,CAAC;AAqEF,eAAO,MAAM,2BAA2B,EAAE,YAAY,CAAC,WAAW,CAcjE,CAAC"}
@@ -22,7 +22,7 @@ const getFirstDegreeInequationsQuestion = () => {
22
22
  const answer = `x${affine.a > 0 ? ineqType.symbol : invIneqType}${result}`;
23
23
  const question = {
24
24
  answer: answer,
25
- instruction: `Résoudre l'inéquation : $${affine.toTex()} ${ineqType} ${b}$ `,
25
+ instruction: `Résoudre l'inéquation : $${affine.toTex()} ${ineqType.symbol} ${b}$ `,
26
26
  keys: inequationKeys_1.inequationKeys,
27
27
  answerFormat: "tex",
28
28
  identifiers: { a: affine.a, b, ineqType: ineqType.symbol },
@@ -1 +1 @@
1
- {"version":3,"file":"firstDegreeInequationsType2.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calculLitteral/inequations/firstDegreeInequationsType2.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAQb,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,gBAAgB,EAGjB,MAAM,mCAAmC,CAAC;AAc3C,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAsEF,eAAO,MAAM,2BAA2B,EAAE,YAAY,CAAC,WAAW,CAajE,CAAC"}
1
+ {"version":3,"file":"firstDegreeInequationsType2.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calculLitteral/inequations/firstDegreeInequationsType2.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAQb,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,gBAAgB,EAGjB,MAAM,mCAAmC,CAAC;AAc3C,KAAK,WAAW,GAAG;IACjB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAwEF,eAAO,MAAM,2BAA2B,EAAE,YAAY,CAAC,WAAW,CAajE,CAAC"}
@@ -25,7 +25,7 @@ const getFirstDegreeInequationsQuestion = () => {
25
25
  const answer = `x${affine.a > 0 ? ineqType.symbol : invIneqType}${result}`;
26
26
  const question = {
27
27
  answer: answer,
28
- instruction: `Résoudre l'inéquation : $${affine.toTex()} ${ineqType} ${c}$ `,
28
+ instruction: `Résoudre l'inéquation : $${affine.toTex()} ${ineqType.symbol} ${c}$ `,
29
29
  keys: inequationKeys_1.inequationKeys,
30
30
  answerFormat: "tex",
31
31
  identifiers: { a: affine.a, b: affine.b, c, ineqType: ineqType.symbol },
@@ -1 +1 @@
1
- {"version":3,"file":"firstDegreeInequationsType3.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calculLitteral/inequations/firstDegreeInequationsType3.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAQb,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,gBAAgB,EAGjB,MAAM,mCAAmC,CAAC;AAW3C,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAkFF,eAAO,MAAM,2BAA2B,EAAE,YAAY,CAAC,WAAW,CAajE,CAAC"}
1
+ {"version":3,"file":"firstDegreeInequationsType3.d.ts","sourceRoot":"","sources":["../../../../src/exercises/calculLitteral/inequations/firstDegreeInequationsType3.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAQb,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,gBAAgB,EAGjB,MAAM,mCAAmC,CAAC;AAW3C,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAoFF,eAAO,MAAM,2BAA2B,EAAE,YAAY,CAAC,WAAW,CAajE,CAAC"}
@@ -26,7 +26,7 @@ const getFirstDegreeInequationsQuestion = () => {
26
26
  const answer = `x${coeff > 0 ? ineqType.symbol : invIneqType}${result}`;
27
27
  const question = {
28
28
  answer: answer,
29
- instruction: `Résoudre l'inéquation : $${affine1.toTex()} ${ineqType} ${affine2.toTex()}$ `,
29
+ instruction: `Résoudre l'inéquation : $${affine1.toTex()} ${ineqType.symbol} ${affine2.toTex()}$ `,
30
30
  keys: inequationKeys_1.inequationKeys,
31
31
  answerFormat: "tex",
32
32
  identifiers: {
@@ -0,0 +1,12 @@
1
+ import { MathExercise } from "../../../exercises/exercise";
2
+ type Identifiers = {
3
+ xA: number;
4
+ xB: number;
5
+ xC: number;
6
+ yA: number;
7
+ yB: number;
8
+ yC: number;
9
+ };
10
+ export declare const alignementViaColinearity: MathExercise<Identifiers>;
11
+ export {};
12
+ //# sourceMappingURL=alignementViaColinearity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alignementViaColinearity.d.ts","sourceRoot":"","sources":["../../../../src/exercises/geometry/vectors/alignementViaColinearity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EASb,MAAM,0BAA0B,CAAC;AASlC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AA8CF,eAAO,MAAM,wBAAwB,EAAE,YAAY,CAAC,WAAW,CAY9D,CAAC"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.alignementViaColinearity = void 0;
4
+ const exercise_1 = require("../../../exercises/exercise");
5
+ const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
6
+ const line_1 = require("../../../math/geometry/line");
7
+ const point_1 = require("../../../math/geometry/point");
8
+ const coinFlip_1 = require("../../../utils/coinFlip");
9
+ const shuffle_1 = require("../../../utils/shuffle");
10
+ const getAlignementViaColinearityQuestion = () => {
11
+ const points = point_1.PointConstructor.randomDifferent(["A", "B"]);
12
+ const line = new line_1.Line(points[0], points[1]);
13
+ let C;
14
+ const isAligned = (0, coinFlip_1.coinFlip)();
15
+ if (isAligned) {
16
+ do {
17
+ C = line.getRandomPoint("C");
18
+ } while (C.equals(points[0]) || C.equals(points[1]));
19
+ }
20
+ else {
21
+ do {
22
+ C = point_1.PointConstructor.random("C");
23
+ } while (C.equals(points[0]) || C.equals(points[1]) || line.includes(C));
24
+ }
25
+ const answer = isAligned ? "Oui" : "Non";
26
+ const question = {
27
+ answer,
28
+ instruction: `Soient trois points $${points[0].toTexWithCoords()}$, $${points[1].toTexWithCoords()}$ et $${C.toTexWithCoords()}$. Les points $A$, $B$ et $C$ sont-ils alignés ?`,
29
+ keys: [],
30
+ answerFormat: "raw",
31
+ identifiers: {
32
+ xA: points[0].x.evaluate({}),
33
+ xB: points[1].x.evaluate({}),
34
+ xC: C.x.evaluate({}),
35
+ yA: points[0].y.evaluate({}),
36
+ yB: points[1].y.evaluate({}),
37
+ yC: C.y.evaluate({}),
38
+ },
39
+ };
40
+ return question;
41
+ };
42
+ const getPropositions = (n, { answer }) => {
43
+ const propositions = [];
44
+ (0, exercise_1.addValidProp)(propositions, answer, "raw");
45
+ (0, exercise_1.tryToAddWrongProp)(propositions, "Oui", "raw");
46
+ (0, exercise_1.tryToAddWrongProp)(propositions, "Non", "raw");
47
+ (0, exercise_1.tryToAddWrongProp)(propositions, "On ne peut pas savoir", "raw");
48
+ return (0, shuffle_1.shuffle)(propositions);
49
+ };
50
+ exports.alignementViaColinearity = {
51
+ id: "alignementViaColinearity",
52
+ label: "",
53
+ levels: ["2nde", "1reSpé"],
54
+ isSingleStep: true,
55
+ sections: ["Vecteurs", "Droites"],
56
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getAlignementViaColinearityQuestion, nb),
57
+ qcmTimer: 60,
58
+ freeTimer: 60,
59
+ getPropositions,
60
+ answerType: "QCM",
61
+ };
@@ -0,0 +1,10 @@
1
+ import { MathExercise } from "../../../exercises/exercise";
2
+ type Identifiers = {
3
+ xu: number;
4
+ yu: number;
5
+ xv: number;
6
+ yv: number;
7
+ };
8
+ export declare const colinearity: MathExercise<Identifiers>;
9
+ export {};
10
+ //# sourceMappingURL=colinearity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colinearity.d.ts","sourceRoot":"","sources":["../../../../src/exercises/geometry/vectors/colinearity.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EASb,MAAM,0BAA0B,CAAC;AAQlC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAyCF,eAAO,MAAM,WAAW,EAAE,YAAY,CAAC,WAAW,CAWjD,CAAC"}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.colinearity = void 0;
4
+ const exercise_1 = require("../../../exercises/exercise");
5
+ const getDistinctQuestions_1 = require("../../../exercises/utils/getDistinctQuestions");
6
+ const vector_1 = require("../../../math/geometry/vector");
7
+ const randint_1 = require("../../../math/utils/random/randint");
8
+ const numberNode_1 = require("../../../tree/nodes/numbers/numberNode");
9
+ const coinFlip_1 = require("../../../utils/coinFlip");
10
+ const shuffle_1 = require("../../../utils/shuffle");
11
+ const getColinearityQuestion = () => {
12
+ const u = vector_1.VectorConstructor.random("u", false);
13
+ const isColinear = (0, coinFlip_1.coinFlip)();
14
+ let v;
15
+ if (isColinear) {
16
+ const coeff = new numberNode_1.NumberNode((0, randint_1.randint)(-5, 5));
17
+ v = u.times(coeff, "v");
18
+ }
19
+ else {
20
+ do {
21
+ v = vector_1.VectorConstructor.random("v", false);
22
+ } while (u.isColinear(v));
23
+ }
24
+ // const isColinear = u.isColinear(v);
25
+ const answer = isColinear ? "Oui" : "Non";
26
+ const question = {
27
+ answer,
28
+ instruction: `Soit deux vecteurs $${u.toTexWithCoords()}$ et $${v.toTexWithCoords()}$. $${u.toTex()}$ et $${v.toTex()}$ sont-ils colinéaires ?`,
29
+ keys: [],
30
+ answerFormat: "raw",
31
+ identifiers: {
32
+ xu: u.x.evaluate({}),
33
+ xv: v.x.evaluate({}),
34
+ yu: u.y.evaluate({}),
35
+ yv: v.y.evaluate({}),
36
+ },
37
+ };
38
+ return question;
39
+ };
40
+ const getPropositions = (n, { answer }) => {
41
+ const propositions = [];
42
+ (0, exercise_1.addValidProp)(propositions, answer, "raw");
43
+ (0, exercise_1.tryToAddWrongProp)(propositions, "Oui", "raw");
44
+ (0, exercise_1.tryToAddWrongProp)(propositions, "Non", "raw");
45
+ (0, exercise_1.tryToAddWrongProp)(propositions, "On ne peut pas savoir", "raw");
46
+ return (0, shuffle_1.shuffle)(propositions);
47
+ };
48
+ exports.colinearity = {
49
+ id: "colinearity",
50
+ label: "Déterminer si deux vecteurs sont colinéaires",
51
+ levels: ["2nde", "1reSpé"],
52
+ isSingleStep: true,
53
+ sections: ["Vecteurs"],
54
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getColinearityQuestion, nb),
55
+ qcmTimer: 60,
56
+ freeTimer: 60,
57
+ getPropositions,
58
+ answerType: "QCM",
59
+ };
@@ -4,4 +4,5 @@ export * from "./determinant";
4
4
  export * from "./scalarProductViaCoords";
5
5
  export * from "./vectorCoordinatesFromTwoPoints";
6
6
  export * from "./scalarProductViaCos";
7
+ export * from "./colinearity";
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/geometry/vectors/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/exercises/geometry/vectors/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC;AACrC,cAAc,eAAe,CAAC;AAC9B,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC"}
@@ -20,3 +20,5 @@ __exportStar(require("./determinant"), exports);
20
20
  __exportStar(require("./scalarProductViaCoords"), exports);
21
21
  __exportStar(require("./vectorCoordinatesFromTwoPoints"), exports);
22
22
  __exportStar(require("./scalarProductViaCos"), exports);
23
+ __exportStar(require("./colinearity"), exports);
24
+ // export * from "./alignementViaColinearity";
@@ -0,0 +1,9 @@
1
+ import { MathExercise } from "../../exercises/exercise";
2
+ type Identifiers = {
3
+ pA: number;
4
+ pB: number;
5
+ pUnion: number;
6
+ };
7
+ export declare const independancy: MathExercise<Identifiers>;
8
+ export {};
9
+ //# sourceMappingURL=independancy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"independancy.d.ts","sourceRoot":"","sources":["../../../src/exercises/probaStat/independancy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EASb,MAAM,0BAA0B,CAAC;AAYlC,KAAK,WAAW,GAAG;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAiDF,eAAO,MAAM,YAAY,EAAE,YAAY,CAAC,WAAW,CAalD,CAAC"}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.independancy = void 0;
4
+ const exercise_1 = require("../../exercises/exercise");
5
+ const getDistinctQuestions_1 = require("../../exercises/utils/getDistinctQuestions");
6
+ const decimal_1 = require("../../math/numbers/decimals/decimal");
7
+ const frenchify_1 = require("../../math/utils/latex/frenchify");
8
+ const randint_1 = require("../../math/utils/random/randint");
9
+ const round_1 = require("../../math/utils/round");
10
+ const coinFlip_1 = require("../../utils/coinFlip");
11
+ const shuffle_1 = require("../../utils/shuffle");
12
+ const getIndependancyQuestion = () => {
13
+ const pA = decimal_1.DecimalConstructor.random(0, 1, (0, randint_1.randint)(1, 3));
14
+ const pATree = pA.toTree();
15
+ const pB = decimal_1.DecimalConstructor.random(0, 1, (0, randint_1.randint)(1, 3));
16
+ const pBTree = pB.toTree();
17
+ const areIndependants = (0, coinFlip_1.coinFlip)();
18
+ const answer = areIndependants ? "Oui" : "Non";
19
+ let pUnion;
20
+ const unionValueIfIndependants = (0, round_1.round)(pA.value + pB.value - pA.value * pB.value, 5);
21
+ if (areIndependants)
22
+ pUnion = unionValueIfIndependants;
23
+ else {
24
+ do {
25
+ pUnion = decimal_1.DecimalConstructor.random(0, 1, (0, randint_1.randint)(1, 3)).value;
26
+ } while ((pUnion < pA.value && pUnion < pB.value) ||
27
+ pUnion === unionValueIfIndependants ||
28
+ pUnion > pA.value + pB.value);
29
+ }
30
+ const question = {
31
+ answer,
32
+ instruction: `Soient deux événements $A$ et $B$ tels que $P(A) = ${(0, frenchify_1.frenchify)(pA.value)}$, $P(B) = ${(0, frenchify_1.frenchify)(pB.value)}$ et $P(A\\cup B) = ${(0, frenchify_1.frenchify)(pUnion)}$. Les événements $A$ et $B$ sont-ils indépendants ?`,
33
+ keys: [],
34
+ answerFormat: "raw",
35
+ identifiers: { pA: pA.value, pB: pB.value, pUnion },
36
+ };
37
+ return question;
38
+ };
39
+ const getPropositions = (n, { answer }) => {
40
+ const propositions = [];
41
+ (0, exercise_1.addValidProp)(propositions, answer, "raw");
42
+ (0, exercise_1.tryToAddWrongProp)(propositions, "Oui", "raw");
43
+ (0, exercise_1.tryToAddWrongProp)(propositions, "Non", "raw");
44
+ (0, exercise_1.tryToAddWrongProp)(propositions, "On ne peut pas savoir", "raw");
45
+ return (0, shuffle_1.shuffle)(propositions);
46
+ };
47
+ exports.independancy = {
48
+ id: "independancy",
49
+ connector: "=",
50
+ label: "Déterminer l'indépendance de deux événements via la formule de Poincaré",
51
+ levels: ["1reSpé", "TermTech"],
52
+ isSingleStep: true,
53
+ sections: ["Probabilités"],
54
+ generator: (nb) => (0, getDistinctQuestions_1.getDistinctQuestions)(getIndependancyQuestion, nb),
55
+ qcmTimer: 60,
56
+ freeTimer: 60,
57
+ getPropositions,
58
+ answerType: "QCM",
59
+ };
@@ -5,4 +5,5 @@ export * from "./diceBasicProbas";
5
5
  export * from "./probabilityTree";
6
6
  export * from "./stats1var";
7
7
  export * from "./stats2var";
8
+ export * from "./independancy";
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exercises/probaStat/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/exercises/probaStat/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC"}
@@ -21,3 +21,4 @@ __exportStar(require("./diceBasicProbas"), exports);
21
21
  __exportStar(require("./probabilityTree"), exports);
22
22
  __exportStar(require("./stats1var"), exports);
23
23
  __exportStar(require("./stats2var"), exports);
24
+ __exportStar(require("./independancy"), exports);
@@ -52,7 +52,7 @@ const getPropositions = (n, { answer }) => {
52
52
  return (0, shuffle_1.shuffle)(propositions);
53
53
  };
54
54
  const isAnswerValid = (ans, { mainValue, isCos }) => {
55
- const remarkableValue = remarkableValues_1.remarkableTrigoValues.find((point) => point.angle.evaluate({}) === mainValue);
55
+ const remarkableValue = remarkableValues_1.remarkableTrigoValues.find((point) => Math.abs(point.angle.evaluate({}) - mainValue) < 0.0001);
56
56
  const answer = isCos ? remarkableValue.cos : remarkableValue.sin;
57
57
  const texs = answer.toAllValidTexs({
58
58
  allowFractionToDecimal: true,
package/lib/index.d.ts CHANGED
@@ -510,6 +510,11 @@ declare const mathExercises: (import("./exercises/exercise").MathExercise<{
510
510
  AB: number;
511
511
  AC: number;
512
512
  trigoPoint: string;
513
+ }> | import("./exercises/exercise").MathExercise<{
514
+ xu: number;
515
+ yu: number;
516
+ xv: number;
517
+ yv: number;
513
518
  }> | import("./exercises/exercise").MathExercise<{
514
519
  coeffs: number[];
515
520
  to: string;
@@ -652,6 +657,10 @@ declare const mathExercises: (import("./exercises/exercise").MathExercise<{
652
657
  }> | import("./exercises/exercise").MathExercise<{
653
658
  xValues: number[];
654
659
  yValues: number[];
660
+ }> | import("./exercises/exercise").MathExercise<{
661
+ pA: number;
662
+ pB: number;
663
+ pUnion: number;
655
664
  }> | import("./exercises/exercise").MathExercise<{
656
665
  firstValue: number;
657
666
  askedRank: number;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqCA,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAA2B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqCA,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAA2B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -1,3 +1,13 @@
1
+ import { AlgebraicNode } from "../../tree/nodes/algebraicNode";
2
+ import { Point } from "./point";
1
3
  export declare class Line {
4
+ pointA: Point;
5
+ pointB: Point;
6
+ isVertical: boolean;
7
+ a: AlgebraicNode | undefined;
8
+ b: AlgebraicNode | undefined;
9
+ constructor(pointA: Point, pointB: Point);
10
+ includes(point: Point): boolean;
11
+ getRandomPoint(name?: string): Point;
2
12
  }
3
13
  //# sourceMappingURL=line.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"line.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/line.ts"],"names":[],"mappings":"AAAA,qBAAa,IAAI;CAAG"}
1
+ {"version":3,"file":"line.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/line.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAO/D,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,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,QAAQ,CAAC,KAAK,EAAE,KAAK;IAWrB,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM;CAY7B"}
@@ -1,6 +1,40 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Line = void 0;
4
+ const numberNode_1 = require("../../tree/nodes/numbers/numberNode");
5
+ const addNode_1 = require("../../tree/nodes/operators/addNode");
6
+ const fractionNode_1 = require("../../tree/nodes/operators/fractionNode");
7
+ const multiplyNode_1 = require("../../tree/nodes/operators/multiplyNode");
8
+ const substractNode_1 = require("../../tree/nodes/operators/substractNode");
9
+ const randint_1 = require("../utils/random/randint");
10
+ const point_1 = require("./point");
4
11
  class Line {
12
+ constructor(pointA, pointB) {
13
+ this.pointA = pointA;
14
+ this.pointB = pointB;
15
+ this.isVertical = pointA.x.equals(pointB.x);
16
+ if (this.isVertical) {
17
+ this.a = undefined;
18
+ this.b = undefined;
19
+ }
20
+ else {
21
+ this.a = new fractionNode_1.FractionNode(new substractNode_1.SubstractNode(this.pointB.y, this.pointA.y), new substractNode_1.SubstractNode(this.pointB.x, this.pointA.x)).simplify();
22
+ this.b = new substractNode_1.SubstractNode(this.pointA.y, new multiplyNode_1.MultiplyNode(this.a, this.pointA.x)).simplify();
23
+ }
24
+ }
25
+ includes(point) {
26
+ if (this.isVertical) {
27
+ return point.x.equals(this.pointA.x);
28
+ }
29
+ return (new substractNode_1.SubstractNode(point.y, new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(this.a, point.x), this.b)).evaluate({}) === 0);
30
+ }
31
+ getRandomPoint(name) {
32
+ if (this.isVertical) {
33
+ return new point_1.Point(name ?? "A", this.pointA.x, new numberNode_1.NumberNode((0, randint_1.randint)(-10, 10)));
34
+ }
35
+ const x = new numberNode_1.NumberNode((0, randint_1.randint)(-10, 10));
36
+ const y = new addNode_1.AddNode(new multiplyNode_1.MultiplyNode(this.a, x), this.b).simplify();
37
+ return new point_1.Point(name ?? "A", x, y);
38
+ }
5
39
  }
6
40
  exports.Line = Line;
@@ -1,7 +1,7 @@
1
- import { MathSet } from "../sets/mathSet";
2
1
  import { AlgebraicNode } from "../../tree/nodes/algebraicNode";
3
2
  export declare abstract class PointConstructor {
4
- static random(domainX?: MathSet, domainY?: MathSet): Point;
3
+ static random(name: string): Point;
4
+ static randomDifferent(names: string[]): Point[];
5
5
  }
6
6
  export declare class Point {
7
7
  name: string;
@@ -15,18 +15,7 @@ export declare class Point {
15
15
  getYnumber(): number;
16
16
  midpoint(B: Point, name?: string): Point;
17
17
  distanceTo(B: Point): number;
18
+ equals(B: Point): boolean;
19
+ isAligned(B: Point, C: Point): boolean;
18
20
  }
19
- /**
20
- * Droite{
21
- * constructor :
22
- * depuis 2 points : A,B --> Droite
23
- * depuis 1 point + coeff dir --> Droite
24
- * avec une équation de droite --> Droite
25
- *
26
- * méthodes :
27
- * toEquation() --> y = 3x+2
28
- * toCoeffDIr --> a
29
-
30
- * }
31
- */
32
21
  //# sourceMappingURL=point.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/point.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG1C,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE/D,8BAAsB,gBAAgB;IACpC,MAAM,CAAC,MAAM,CACX,OAAO,GAAE,OAAqC,EAC9C,OAAO,GAAE,OAAqC,GAC7C,KAAK;CAOT;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;IAIf,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;CAK7B;AAED;;;;;;;;;;;;GAYG"}
1
+ {"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/point.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAI/D,8BAAsB,gBAAgB;IACpC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK;IAKlC,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;IAIf,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;CAK7B"}
@@ -3,15 +3,28 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Point = exports.PointConstructor = void 0;
4
4
  const node_1 = require("../../tree/nodes/node");
5
5
  const numberNode_1 = require("../../tree/nodes/numbers/numberNode");
6
- const intervals_1 = require("../sets/intervals/intervals");
7
6
  const rational_1 = require("../numbers/rationals/rational");
7
+ const vector_1 = require("./vector");
8
+ const randint_1 = require("../utils/random/randint");
8
9
  class PointConstructor {
9
- static random(domainX = new intervals_1.Interval("[[-10; 10]]"), domainY = new intervals_1.Interval("[[-10; 10]]")) {
10
- const x = domainX.getRandomElement();
11
- const y = domainY.getRandomElement();
12
- if (x === null || y === null)
13
- throw Error("can't build point with thoses sets");
14
- return new Point("A", new numberNode_1.NumberNode(x.value), new numberNode_1.NumberNode(y.value));
10
+ static random(name) {
11
+ const x = (0, randint_1.randint)(-10, 11);
12
+ const y = (0, randint_1.randint)(-10, 11);
13
+ return new Point(name, new numberNode_1.NumberNode(x), new numberNode_1.NumberNode(y));
14
+ }
15
+ static randomDifferent(names) {
16
+ const res = [];
17
+ const points = [];
18
+ for (let i = 0; i < names.length; i++) {
19
+ let x;
20
+ let y;
21
+ do {
22
+ x = (0, randint_1.randint)(-10, 11);
23
+ y = (0, randint_1.randint)(-10, 11);
24
+ } while (points.some((point) => point[0] === x && point[1] === y));
25
+ res.push(new Point(names[i], new numberNode_1.NumberNode(x), new numberNode_1.NumberNode(y)));
26
+ }
27
+ return res;
15
28
  }
16
29
  }
17
30
  exports.PointConstructor = PointConstructor;
@@ -56,18 +69,13 @@ class Point {
56
69
  const dy = this.getYnumber() - B.getYnumber();
57
70
  return Math.sqrt(dx ** 2 + dy ** 2);
58
71
  }
72
+ equals(B) {
73
+ return this.x.equals(B.x) && this.y.equals(B.y);
74
+ }
75
+ isAligned(B, C) {
76
+ const AB = vector_1.VectorConstructor.fromPoints(this, B);
77
+ const AC = vector_1.VectorConstructor.fromPoints(this, C);
78
+ return AB.isColinear(AC);
79
+ }
59
80
  }
60
81
  exports.Point = Point;
61
- /**
62
- * Droite{
63
- * constructor :
64
- * depuis 2 points : A,B --> Droite
65
- * depuis 1 point + coeff dir --> Droite
66
- * avec une équation de droite --> Droite
67
- *
68
- * méthodes :
69
- * toEquation() --> y = 3x+2
70
- * toCoeffDIr --> a
71
-
72
- * }
73
- */
@@ -1,18 +1,21 @@
1
+ import { AlgebraicNode } from "../../tree/nodes/algebraicNode";
1
2
  import { Node } from "../../tree/nodes/node";
2
3
  import { Point } from "./point";
3
4
  export declare abstract class VectorConstructor {
4
5
  static fromPoints(origin: Point, end: Point): Vector;
5
- static random(name: string): Vector;
6
+ static random(name: string, allowNull?: boolean): Vector;
6
7
  }
7
8
  export declare class Vector {
8
9
  name: string;
9
10
  tex: string;
10
- x: Node;
11
- y: Node;
12
- constructor(name: string, x: Node, y: Node);
11
+ x: AlgebraicNode;
12
+ y: AlgebraicNode;
13
+ constructor(name: string, x: AlgebraicNode, y: AlgebraicNode);
13
14
  toTex(): string;
14
15
  toTexWithCoords(): string;
15
- determinant(v: Vector): Node;
16
+ isColinear(v: Vector): boolean;
17
+ determinant(v: Vector): AlgebraicNode;
18
+ times(k: AlgebraicNode, name?: string): Vector;
16
19
  scalarProduct(v: Vector): Node;
17
20
  }
18
21
  //# sourceMappingURL=vector.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vector.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/vector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAY,MAAM,uBAAuB,CAAC;AAIvD,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,GAAG,MAAM;CAOpC;AAED,qBAAa,MAAM;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,EAAE,IAAI,CAAC;IACR,CAAC,EAAE,IAAI,CAAC;gBACI,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI;IAO1C,KAAK,IAAI,MAAM;IAIf,eAAe,IAAI,MAAM;IAMzB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;IAa5B,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;CAa/B"}
1
+ {"version":3,"file":"vector.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/vector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAY,MAAM,uBAAuB,CAAC;AAKvD,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,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO;IAI9B,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,aAAa;IAcrC,KAAK,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,MAAM;IAOrC,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI;CAa/B"}
@@ -3,14 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Vector = exports.VectorConstructor = void 0;
4
4
  const node_1 = require("../../tree/nodes/node");
5
5
  const numberNode_1 = require("../../tree/nodes/numbers/numberNode");
6
+ const multiplyNode_1 = require("../../tree/nodes/operators/multiplyNode");
6
7
  const substractNode_1 = require("../../tree/nodes/operators/substractNode");
7
8
  const randint_1 = require("../utils/random/randint");
8
9
  class VectorConstructor {
9
10
  static fromPoints(origin, end) {
10
- return new Vector(`${origin.name}${end.name}`, new substractNode_1.SubstractNode(end.x, origin.x), new substractNode_1.SubstractNode(end.y, origin.y));
11
+ return new Vector(`${origin.name}${end.name}`, new substractNode_1.SubstractNode(end.x, origin.x).simplify(), new substractNode_1.SubstractNode(end.y, origin.y).simplify());
11
12
  }
12
- static random(name) {
13
- return new Vector(name, new numberNode_1.NumberNode((0, randint_1.randint)(-10, 11)), new numberNode_1.NumberNode((0, randint_1.randint)(-10, 11)));
13
+ static random(name, allowNull = true) {
14
+ const x = new numberNode_1.NumberNode((0, randint_1.randint)(-10, 11));
15
+ const y = new numberNode_1.NumberNode((0, randint_1.randint)(-10, 11, !allowNull && x.value === 0 ? [0] : undefined));
16
+ return new Vector(name, x, y);
14
17
  }
15
18
  }
16
19
  exports.VectorConstructor = VectorConstructor;
@@ -27,6 +30,10 @@ class Vector {
27
30
  toTexWithCoords() {
28
31
  return `\\overrightarrow{${this.name}}\\begin{pmatrix}${this.x.toTex()} \\\\ ${this.y.toTex()} \\end{pmatrix}`;
29
32
  }
33
+ isColinear(v) {
34
+ const det = this.determinant(v);
35
+ return det.evaluate({}) === 0;
36
+ }
30
37
  determinant(v) {
31
38
  if ([this.x.type, this.y.type, v.x.type, v.y.type].some((el) => el !== node_1.NodeType.number))
32
39
  throw Error("general determinant not implemented");
@@ -36,6 +43,9 @@ class Vector {
36
43
  const vyValue = v.y.value;
37
44
  return new numberNode_1.NumberNode(xValue * vyValue - yValue * vxValue);
38
45
  }
46
+ times(k, name) {
47
+ return new Vector(name ?? "v", new multiplyNode_1.MultiplyNode(this.x, k).simplify(), new multiplyNode_1.MultiplyNode(this.y, k).simplify());
48
+ }
39
49
  scalarProduct(v) {
40
50
  if ([this.x.type, this.y.type, v.x.type, v.y.type].some((el) => el !== node_1.NodeType.number))
41
51
  throw Error("general determinant not implemented");
@@ -1,6 +1,5 @@
1
1
  import { NumberNode } from "../../../tree/nodes/numbers/numberNode";
2
2
  import { MultiplyNode } from "../../../tree/nodes/operators/multiplyNode";
3
- import { Integer } from "../integer/integer";
4
3
  import { Nombre, NumberType } from "../nombre";
5
4
  import { Rational } from "../rationals/rational";
6
5
  export declare abstract class DecimalConstructor {
@@ -26,7 +25,7 @@ export declare class Decimal implements Nombre {
26
25
  multiplyByPowerOfTen(power: number): Decimal;
27
26
  toScientificPart(): NumberNode;
28
27
  toScientificNotation(): NumberNode | MultiplyNode;
29
- toRational(): Rational | Integer;
28
+ toRational(): Rational | import("../integer/integer").Integer;
30
29
  toTree(): NumberNode;
31
30
  }
32
31
  //# sourceMappingURL=decimal.d.ts.map