math-exercises 2.2.70 → 2.2.72
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/calcul/fractions/fractionsOperations.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionsOperations.js +6 -2
- package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivitySubstract.d.ts +12 -0
- package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivitySubstract.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivitySubstract.js +128 -0
- package/lib/exercises/math/calculLitteral/distributivity/identitiesWithNonIntegers.d.ts +10 -0
- package/lib/exercises/math/calculLitteral/distributivity/identitiesWithNonIntegers.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/distributivity/identitiesWithNonIntegers.js +138 -0
- package/lib/exercises/math/calculLitteral/distributivity/index.d.ts +2 -0
- package/lib/exercises/math/calculLitteral/distributivity/index.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/distributivity/index.js +2 -0
- package/lib/exercises/math/geometry/angles/index.d.ts +2 -0
- package/lib/exercises/math/geometry/angles/index.d.ts.map +1 -0
- package/lib/exercises/math/geometry/angles/index.js +17 -0
- package/lib/exercises/math/geometry/angles/recognizeAngleType.d.ts +11 -0
- package/lib/exercises/math/geometry/angles/recognizeAngleType.d.ts.map +1 -0
- package/lib/exercises/math/geometry/angles/recognizeAngleType.js +272 -0
- package/lib/exercises/math/geometry/euclidianConstructions/pointImageFromTranslation.js +1 -1
- package/lib/exercises/math/geometry/index.d.ts +1 -0
- package/lib/exercises/math/geometry/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/index.js +1 -0
- package/lib/exercises/math/geometry/volumes/parallelepipedVolume.d.ts.map +1 -1
- package/lib/exercises/math/geometry/volumes/parallelepipedVolume.js +0 -1
- package/lib/exercises/math/probaStat/stats1var/index.d.ts +6 -0
- package/lib/exercises/math/probaStat/stats1var/index.d.ts.map +1 -1
- package/lib/exercises/math/probaStat/stats1var/index.js +6 -0
- package/lib/exercises/math/probaStat/stats1var/interquartilesList.d.ts +7 -0
- package/lib/exercises/math/probaStat/stats1var/interquartilesList.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/stats1var/interquartilesList.js +93 -0
- package/lib/exercises/math/probaStat/stats1var/interquartilesTable.d.ts +8 -0
- package/lib/exercises/math/probaStat/stats1var/interquartilesTable.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/stats1var/interquartilesTable.js +98 -0
- package/lib/exercises/math/probaStat/stats1var/quartilesList.js +1 -1
- package/lib/exercises/math/probaStat/stats1var/standardDeviationList.d.ts +7 -0
- package/lib/exercises/math/probaStat/stats1var/standardDeviationList.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/stats1var/standardDeviationList.js +131 -0
- package/lib/exercises/math/probaStat/stats1var/standardDeviationTable.d.ts +8 -0
- package/lib/exercises/math/probaStat/stats1var/standardDeviationTable.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/stats1var/standardDeviationTable.js +144 -0
- package/lib/exercises/math/probaStat/stats1var/varianceList.d.ts +7 -0
- package/lib/exercises/math/probaStat/stats1var/varianceList.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/stats1var/varianceList.js +121 -0
- package/lib/exercises/math/probaStat/stats1var/varianceTable.d.ts +8 -0
- package/lib/exercises/math/probaStat/stats1var/varianceTable.d.ts.map +1 -0
- package/lib/exercises/math/probaStat/stats1var/varianceTable.js +133 -0
- package/lib/exercises/vea/sqrtVEA.d.ts +2 -1
- package/lib/exercises/vea/sqrtVEA.d.ts.map +1 -1
- package/lib/exercises/vea/sqrtVEA.js +6 -3
- package/lib/index.d.ts +30 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/math/geometry/angle.d.ts +22 -1
- package/lib/math/geometry/angle.d.ts.map +1 -1
- package/lib/math/geometry/angle.js +138 -1
- package/lib/math/geometry/line.d.ts +2 -0
- package/lib/math/geometry/line.d.ts.map +1 -1
- package/lib/math/geometry/line.js +16 -0
- package/lib/math/geometry/point.d.ts +1 -0
- package/lib/math/geometry/point.d.ts.map +1 -1
- package/lib/math/geometry/point.js +4 -0
- package/lib/math/geometry/vector.d.ts +3 -0
- package/lib/math/geometry/vector.d.ts.map +1 -1
- package/lib/math/geometry/vector.js +9 -0
- package/lib/math/polynomials/generalAffine.d.ts +3 -0
- package/lib/math/polynomials/generalAffine.d.ts.map +1 -1
- package/lib/math/polynomials/generalAffine.js +4 -0
- package/lib/math/utils/quartiles.d.ts +3 -0
- package/lib/math/utils/quartiles.d.ts.map +1 -0
- package/lib/math/utils/quartiles.js +47 -0
- package/lib/math/utils/standardDeviation.d.ts +3 -0
- package/lib/math/utils/standardDeviation.d.ts.map +1 -0
- package/lib/math/utils/standardDeviation.js +13 -0
- package/lib/math/utils/variance.d.ts +1 -0
- package/lib/math/utils/variance.d.ts.map +1 -1
- package/lib/math/utils/variance.js +9 -1
- package/lib/playground.d.ts.map +1 -1
- package/lib/tree/nodes/node.d.ts +4 -2
- package/lib/tree/nodes/node.d.ts.map +1 -1
- package/lib/tree/nodes/node.js +2 -0
- package/lib/tree/nodes/nodeConstructor.d.ts.map +1 -1
- package/lib/tree/nodes/nodeConstructor.js +4 -0
- package/lib/tree/nodes/operators/addNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/addNode.js +123 -90
- package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/multiplyNode.js +8 -0
- package/lib/tree/nodes/polynomials/monomNode.d.ts +47 -0
- package/lib/tree/nodes/polynomials/monomNode.d.ts.map +1 -0
- package/lib/tree/nodes/polynomials/monomNode.js +216 -0
- package/lib/tree/parsers/affineParser.js +1 -1
- package/lib/tree/parsers/monomParser.d.ts +2 -2
- package/lib/tree/parsers/monomParser.d.ts.map +1 -1
- package/lib/tree/parsers/monomParser.js +84 -6
- package/lib/tree/parsers/polynomialParser.d.ts +3 -0
- package/lib/tree/parsers/polynomialParser.d.ts.map +1 -0
- package/lib/tree/parsers/polynomialParser.js +50 -0
- package/lib/tree/parsers/powerParser.d.ts +1 -1
- package/lib/tree/parsers/trinomParser.js +1 -1
- package/lib/utils/average.d.ts +1 -0
- package/lib/utils/average.d.ts.map +1 -1
- package/lib/utils/average.js +9 -1
- package/lib/utils/latex/approxOrEqual.d.ts +2 -0
- package/lib/utils/latex/approxOrEqual.d.ts.map +1 -0
- package/lib/utils/latex/approxOrEqual.js +11 -0
- package/lib/utils/variance.d.ts +2 -0
- package/lib/utils/variance.d.ts.map +1 -0
- package/lib/utils/variance.js +12 -0
- package/package.json +1 -1
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.varianceList = void 0;
|
|
4
|
+
const exercise_1 = require("../../../../exercises/exercise");
|
|
5
|
+
const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
|
|
6
|
+
const rationalVEA_1 = require("../../../../exercises/vea/rationalVEA");
|
|
7
|
+
const randfloat_1 = require("../../../../math/utils/random/randfloat");
|
|
8
|
+
const randint_1 = require("../../../../math/utils/random/randint");
|
|
9
|
+
const round_1 = require("../../../../math/utils/round");
|
|
10
|
+
const variance_1 = require("../../../../math/utils/variance");
|
|
11
|
+
const average_1 = require("../../../../utils/average");
|
|
12
|
+
const alignTex_1 = require("../../../../utils/latex/alignTex");
|
|
13
|
+
const approxOrEqual_1 = require("../../../../utils/latex/approxOrEqual");
|
|
14
|
+
const getPropositions = (n, { answer, sortedValues }) => {
|
|
15
|
+
const propositions = [];
|
|
16
|
+
(0, exercise_1.addValidProp)(propositions, answer);
|
|
17
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, (0, round_1.round)((0, average_1.average)(sortedValues), 2).frenchify());
|
|
18
|
+
while (propositions.length < n) {
|
|
19
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, (0, randfloat_1.randfloat)(3, 10, 2).frenchify());
|
|
20
|
+
}
|
|
21
|
+
return (0, exercise_1.shuffleProps)(propositions, n);
|
|
22
|
+
};
|
|
23
|
+
const getAnswer = (identifiers) => {
|
|
24
|
+
const vrc = (0, variance_1.variance)(identifiers.sortedValues, (0, average_1.average)(identifiers.sortedValues));
|
|
25
|
+
return (0, round_1.round)(vrc, 2).frenchify();
|
|
26
|
+
};
|
|
27
|
+
const getInstruction = (identifiers) => {
|
|
28
|
+
return `Calculer la variance de la série statistique suivante :
|
|
29
|
+
|
|
30
|
+
$$
|
|
31
|
+
${identifiers.sortedValues.map((e) => e.frenchify()).join("\\ ; \\ ")}
|
|
32
|
+
$$
|
|
33
|
+
|
|
34
|
+
Arrondir au centième.`;
|
|
35
|
+
};
|
|
36
|
+
const getHint = (identifiers) => {
|
|
37
|
+
return `Si on note $N$ le nombre de valeurs, $\\overline x$ la moyenne de cette liste, et $x_1$, $x_2$, $\\ldots$, $x_N$ les valeurs de la liste, alors la variance est :
|
|
38
|
+
|
|
39
|
+
$$
|
|
40
|
+
V = \\frac{(x_1-\\overline{x})^2 + (x_2-\\overline{x})^2 + \\ldots + (x_N-\\overline{x})^2}{N}
|
|
41
|
+
$$`;
|
|
42
|
+
};
|
|
43
|
+
const getCorrection = (identifiers) => {
|
|
44
|
+
const n = identifiers.sortedValues.length;
|
|
45
|
+
const avg = (0, average_1.average)(identifiers.sortedValues);
|
|
46
|
+
const roundedAvg = (0, round_1.round)(avg, 2);
|
|
47
|
+
const vce = (0, variance_1.variance)(identifiers.sortedValues, (0, average_1.average)(identifiers.sortedValues));
|
|
48
|
+
return `La moyenne $\\overline{x}$ de cette série vaut :
|
|
49
|
+
|
|
50
|
+
${(0, alignTex_1.alignTex)([
|
|
51
|
+
[
|
|
52
|
+
`\\overline{x}`,
|
|
53
|
+
"=",
|
|
54
|
+
`\\frac{${identifiers.sortedValues
|
|
55
|
+
.map((e) => e.frenchify())
|
|
56
|
+
.join("+")}}{${n}}`,
|
|
57
|
+
],
|
|
58
|
+
["", ...(0, approxOrEqual_1.approxOrEqual)(avg, 2)],
|
|
59
|
+
])}
|
|
60
|
+
|
|
61
|
+
La variance est donc :
|
|
62
|
+
|
|
63
|
+
${(0, alignTex_1.alignTex)([
|
|
64
|
+
[
|
|
65
|
+
"V",
|
|
66
|
+
"=",
|
|
67
|
+
`\\frac{(x_1-\\overline{x})^2 + (x_2-\\overline{x})^2 + \\ldots + (x_n-\\overline{x})^2}{N}`,
|
|
68
|
+
],
|
|
69
|
+
[
|
|
70
|
+
"",
|
|
71
|
+
"=",
|
|
72
|
+
`\\frac{${identifiers.sortedValues
|
|
73
|
+
.map((e) => `(${e.frenchify()} - ${roundedAvg.frenchify()})^2`)
|
|
74
|
+
.join("+")}}{${n}}`,
|
|
75
|
+
],
|
|
76
|
+
["", ...(0, approxOrEqual_1.approxOrEqual)(vce, 2)],
|
|
77
|
+
])}`;
|
|
78
|
+
};
|
|
79
|
+
const getKeys = (identifiers) => {
|
|
80
|
+
return [];
|
|
81
|
+
};
|
|
82
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
83
|
+
return (0, rationalVEA_1.rationalVEA)(ans, answer);
|
|
84
|
+
};
|
|
85
|
+
const getVarianceListQuestion = (ops) => {
|
|
86
|
+
const nbValues = (0, randint_1.randint)(4, 7);
|
|
87
|
+
const values = [];
|
|
88
|
+
for (let i = 0; i < nbValues; i++) {
|
|
89
|
+
values.push((0, randint_1.randint)(1, 15));
|
|
90
|
+
}
|
|
91
|
+
const identifiers = {
|
|
92
|
+
sortedValues: values.sort((a, b) => a - b),
|
|
93
|
+
};
|
|
94
|
+
const question = {
|
|
95
|
+
answer: getAnswer(identifiers),
|
|
96
|
+
instruction: getInstruction(identifiers),
|
|
97
|
+
keys: getKeys(identifiers),
|
|
98
|
+
answerFormat: "tex",
|
|
99
|
+
identifiers,
|
|
100
|
+
hint: getHint(identifiers),
|
|
101
|
+
correction: getCorrection(identifiers),
|
|
102
|
+
};
|
|
103
|
+
return question;
|
|
104
|
+
};
|
|
105
|
+
exports.varianceList = {
|
|
106
|
+
id: "varianceList",
|
|
107
|
+
connector: "=",
|
|
108
|
+
label: "Calcul de la variance d'une liste de valeurs",
|
|
109
|
+
isSingleStep: true,
|
|
110
|
+
generator: (nb, opts) => (0, getDistinctQuestions_1.getDistinctQuestions)(() => getVarianceListQuestion(opts), nb),
|
|
111
|
+
qcmTimer: 60,
|
|
112
|
+
freeTimer: 60,
|
|
113
|
+
getPropositions,
|
|
114
|
+
isAnswerValid,
|
|
115
|
+
subject: "Mathématiques",
|
|
116
|
+
getInstruction,
|
|
117
|
+
getHint,
|
|
118
|
+
getCorrection,
|
|
119
|
+
getAnswer,
|
|
120
|
+
hasHintAndCorrection: true,
|
|
121
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"varianceTable.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/probaStat/stats1var/varianceTable.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,0BAA0B,CAAC;AAYlC,KAAK,WAAW,GAAG;IACjB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAuHF,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,WAAW,CAiB/C,CAAC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.varianceTable = void 0;
|
|
4
|
+
const exercise_1 = require("../../../../exercises/exercise");
|
|
5
|
+
const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
|
|
6
|
+
const rationalVEA_1 = require("../../../../exercises/vea/rationalVEA");
|
|
7
|
+
const randfloat_1 = require("../../../../math/utils/random/randfloat");
|
|
8
|
+
const randint_1 = require("../../../../math/utils/random/randint");
|
|
9
|
+
const round_1 = require("../../../../math/utils/round");
|
|
10
|
+
const variance_1 = require("../../../../math/utils/variance");
|
|
11
|
+
const average_1 = require("../../../../utils/average");
|
|
12
|
+
const alignTex_1 = require("../../../../utils/latex/alignTex");
|
|
13
|
+
const approxOrEqual_1 = require("../../../../utils/latex/approxOrEqual");
|
|
14
|
+
const mdTable_1 = require("../../../../utils/markdown/mdTable");
|
|
15
|
+
const getPropositions = (n, { answer }) => {
|
|
16
|
+
const propositions = [];
|
|
17
|
+
(0, exercise_1.addValidProp)(propositions, answer);
|
|
18
|
+
while (propositions.length < n) {
|
|
19
|
+
(0, exercise_1.tryToAddWrongProp)(propositions, (0, randfloat_1.randfloat)(3, 10, 2).frenchify());
|
|
20
|
+
}
|
|
21
|
+
return (0, exercise_1.shuffleProps)(propositions, n);
|
|
22
|
+
};
|
|
23
|
+
const getAnswer = (identifiers) => {
|
|
24
|
+
const vce = (0, variance_1.varianceWithEffectifs)(identifiers.sortedValues, identifiers.effectifs);
|
|
25
|
+
return (0, round_1.round)(vce, 2).frenchify();
|
|
26
|
+
};
|
|
27
|
+
const getInstruction = (identifiers) => {
|
|
28
|
+
return `Calculer la variance de la série statistique suivante :
|
|
29
|
+
|
|
30
|
+
${(0, mdTable_1.mdTable)([
|
|
31
|
+
["$x_i$", ...identifiers.sortedValues.map((e) => `$${e.frenchify()}$`)],
|
|
32
|
+
["$n_i$", ...identifiers.effectifs.map((e) => `$${e.frenchify()}$`)],
|
|
33
|
+
])}
|
|
34
|
+
|
|
35
|
+
Arrondir au centième.`;
|
|
36
|
+
};
|
|
37
|
+
const getHint = (identifiers) => {
|
|
38
|
+
return `On note :
|
|
39
|
+
|
|
40
|
+
- $N$ le nombre de valeurs de la liste,
|
|
41
|
+
- $\\overline x$ la moyenne de la liste,
|
|
42
|
+
- $x_1$, $x_2$, $\\ldots$, $x_N$ les valeurs de la liste,
|
|
43
|
+
- $n_1$, $n_2$, $\\ldots$, $n_N$ les effectifs de la liste.
|
|
44
|
+
|
|
45
|
+
Alors la variance est égale à :
|
|
46
|
+
|
|
47
|
+
$$
|
|
48
|
+
V = \\frac{n_1(x_1-\\overline{x})^2 + \\ldots + n_N(x_N-\\overline{x})^2}{N}
|
|
49
|
+
$$`;
|
|
50
|
+
};
|
|
51
|
+
const getCorrection = (identifiers) => {
|
|
52
|
+
const { sortedValues, effectifs } = identifiers;
|
|
53
|
+
const n = effectifs.reduce((acc, curr) => acc + curr, 0);
|
|
54
|
+
const avg = (0, average_1.averageWithEffectifs)(sortedValues, effectifs);
|
|
55
|
+
const roundedAvg = (0, round_1.round)(avg, 2);
|
|
56
|
+
const vce = (0, variance_1.varianceWithEffectifs)(sortedValues, effectifs);
|
|
57
|
+
return `La moyenne $\\overline{x}$ de cette série vaut :
|
|
58
|
+
|
|
59
|
+
${(0, alignTex_1.alignTex)([
|
|
60
|
+
[
|
|
61
|
+
`\\overline{x}`,
|
|
62
|
+
"=",
|
|
63
|
+
`\\frac{${sortedValues
|
|
64
|
+
.map((e, i) => `${effectifs[i].frenchify()}\\times ${e.frenchify()}`)
|
|
65
|
+
.join("+")}}{${n}}`,
|
|
66
|
+
],
|
|
67
|
+
["", ...(0, approxOrEqual_1.approxOrEqual)(avg, 2)],
|
|
68
|
+
])}
|
|
69
|
+
|
|
70
|
+
La variance est donc :
|
|
71
|
+
|
|
72
|
+
${(0, alignTex_1.alignTex)([
|
|
73
|
+
[
|
|
74
|
+
"V",
|
|
75
|
+
"=",
|
|
76
|
+
`\\frac{n_1(x_1-\\overline{x})^2 + \\ldots + n_N(x_N-\\overline{x})^2}{N}`,
|
|
77
|
+
],
|
|
78
|
+
[
|
|
79
|
+
"",
|
|
80
|
+
"=",
|
|
81
|
+
`\\frac{${sortedValues
|
|
82
|
+
.map((e, i) => `${effectifs[i].frenchify()}\\times(${e.frenchify()} - ${roundedAvg.frenchify()})^2`)
|
|
83
|
+
.join("+")}}{${n}}`,
|
|
84
|
+
],
|
|
85
|
+
["", ...(0, approxOrEqual_1.approxOrEqual)(vce, 2)],
|
|
86
|
+
])}`;
|
|
87
|
+
};
|
|
88
|
+
const getKeys = (identifiers) => {
|
|
89
|
+
return [];
|
|
90
|
+
};
|
|
91
|
+
const isAnswerValid = (ans, { answer }) => {
|
|
92
|
+
return (0, rationalVEA_1.rationalVEA)(ans, answer);
|
|
93
|
+
};
|
|
94
|
+
const getVarianceTableQuestion = (ops) => {
|
|
95
|
+
const nbValues = (0, randint_1.randint)(4, 7);
|
|
96
|
+
const values = [];
|
|
97
|
+
const effectifs = [];
|
|
98
|
+
for (let i = 0; i < nbValues; i++) {
|
|
99
|
+
values.push((0, randint_1.randint)(1, 15, values));
|
|
100
|
+
effectifs.push((0, randint_1.randint)(1, 7));
|
|
101
|
+
}
|
|
102
|
+
const identifiers = {
|
|
103
|
+
sortedValues: values.sort((a, b) => a - b),
|
|
104
|
+
effectifs,
|
|
105
|
+
};
|
|
106
|
+
const question = {
|
|
107
|
+
answer: getAnswer(identifiers),
|
|
108
|
+
instruction: getInstruction(identifiers),
|
|
109
|
+
keys: getKeys(identifiers),
|
|
110
|
+
answerFormat: "tex",
|
|
111
|
+
identifiers,
|
|
112
|
+
hint: getHint(identifiers),
|
|
113
|
+
correction: getCorrection(identifiers),
|
|
114
|
+
};
|
|
115
|
+
return question;
|
|
116
|
+
};
|
|
117
|
+
exports.varianceTable = {
|
|
118
|
+
id: "varianceTable",
|
|
119
|
+
connector: "=",
|
|
120
|
+
label: "Calculer la variance d'un tableau d'effectifs",
|
|
121
|
+
isSingleStep: true,
|
|
122
|
+
generator: (nb, opts) => (0, getDistinctQuestions_1.getDistinctQuestions)(() => getVarianceTableQuestion(opts), nb),
|
|
123
|
+
qcmTimer: 60,
|
|
124
|
+
freeTimer: 60,
|
|
125
|
+
getPropositions,
|
|
126
|
+
isAnswerValid,
|
|
127
|
+
subject: "Mathématiques",
|
|
128
|
+
getInstruction,
|
|
129
|
+
getHint,
|
|
130
|
+
getCorrection,
|
|
131
|
+
getAnswer,
|
|
132
|
+
hasHintAndCorrection: true,
|
|
133
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
type Opts = {
|
|
2
2
|
allowNonIrreductible?: boolean;
|
|
3
|
+
decimalApproxAllowed?: number;
|
|
3
4
|
};
|
|
4
|
-
export declare const sqrtVEA: (studentAns: string, answer: string, { allowNonIrreductible }?: Opts) => boolean;
|
|
5
|
+
export declare const sqrtVEA: (studentAns: string, answer: string, { allowNonIrreductible, decimalApproxAllowed }?: Opts) => boolean;
|
|
5
6
|
export {};
|
|
6
7
|
//# sourceMappingURL=sqrtVEA.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqrtVEA.d.ts","sourceRoot":"","sources":["../../../src/exercises/vea/sqrtVEA.ts"],"names":[],"mappings":"AAMA,KAAK,IAAI,GAAG;IACV,oBAAoB,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"sqrtVEA.d.ts","sourceRoot":"","sources":["../../../src/exercises/vea/sqrtVEA.ts"],"names":[],"mappings":"AAMA,KAAK,IAAI,GAAG;IACV,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B,CAAC;AACF,eAAO,MAAM,OAAO,eACN,MAAM,UACV,MAAM,mDACkC,IAAI,YA0BrD,CAAC"}
|
|
@@ -4,20 +4,23 @@ exports.sqrtVEA = void 0;
|
|
|
4
4
|
const numberNode_1 = require("../../tree/nodes/numbers/numberNode");
|
|
5
5
|
const latexParser_1 = require("../../tree/parsers/latexParser");
|
|
6
6
|
const sqrtParser_1 = require("../../tree/parsers/sqrtParser");
|
|
7
|
-
const sqrtVEA = (studentAns, answer, { allowNonIrreductible } = {
|
|
7
|
+
const sqrtVEA = (studentAns, answer, { allowNonIrreductible, decimalApproxAllowed } = {
|
|
8
8
|
allowNonIrreductible: true,
|
|
9
9
|
}) => {
|
|
10
10
|
try {
|
|
11
11
|
allowNonIrreductible = allowNonIrreductible ?? true;
|
|
12
|
+
decimalApproxAllowed = decimalApproxAllowed ?? 0.0000001;
|
|
12
13
|
const parsed = (0, sqrtParser_1.sqrtParser)(studentAns);
|
|
13
14
|
if (!parsed)
|
|
14
15
|
return false;
|
|
15
16
|
const parsedAnswer = (0, latexParser_1.parseAlgebraic)(answer);
|
|
16
17
|
if ((0, numberNode_1.isNumberNode)(parsed)) {
|
|
17
|
-
return Math.abs(parsed.evaluate() - parsedAnswer.evaluate()) <
|
|
18
|
+
return (Math.abs(parsed.evaluate() - parsedAnswer.evaluate()) <
|
|
19
|
+
decimalApproxAllowed);
|
|
18
20
|
}
|
|
19
21
|
else if (allowNonIrreductible) {
|
|
20
|
-
return Math.abs(parsed.evaluate() - parsedAnswer.evaluate()) <
|
|
22
|
+
return (Math.abs(parsed.evaluate() - parsedAnswer.evaluate()) <
|
|
23
|
+
decimalApproxAllowed);
|
|
21
24
|
}
|
|
22
25
|
else {
|
|
23
26
|
return parsed.equals(parsedAnswer);
|
package/lib/index.d.ts
CHANGED
|
@@ -230,6 +230,16 @@ declare const mathExercises: (Exercise<{
|
|
|
230
230
|
a: number;
|
|
231
231
|
b: number;
|
|
232
232
|
c: number;
|
|
233
|
+
}, {}> | Exercise<{
|
|
234
|
+
type: number;
|
|
235
|
+
affine1: import("./math/polynomials/generalAffine").GeneralAffineIdentifiers;
|
|
236
|
+
affine2: import("./math/polynomials/generalAffine").GeneralAffineIdentifiers;
|
|
237
|
+
affine3: import("./math/polynomials/generalAffine").GeneralAffineIdentifiers;
|
|
238
|
+
affine4?: import("./math/polynomials/generalAffine").GeneralAffineIdentifiers | undefined;
|
|
239
|
+
}, {}> | Exercise<{
|
|
240
|
+
type: number;
|
|
241
|
+
a: import("./tree/nodes/nodeConstructor").NodeIdentifiers;
|
|
242
|
+
b: import("./tree/nodes/nodeConstructor").NodeIdentifiers;
|
|
233
243
|
}, {}> | Exercise<{
|
|
234
244
|
randNbr: number;
|
|
235
245
|
}, {}> | Exercise<{
|
|
@@ -1175,6 +1185,11 @@ declare const mathExercises: (Exercise<{
|
|
|
1175
1185
|
showDiagonals: boolean;
|
|
1176
1186
|
drawAngles: boolean;
|
|
1177
1187
|
shapeIdentifiers: import("./math/geometry/parallelogram").ParallelogramIdentifiers | import("./math/geometry/rhombus").RhombusIdentifiers | import("./math/geometry/rectangle").RectangleIdentifiers | import("./math/geometry/square").SquareIdentifiers;
|
|
1188
|
+
}, {}> | Exercise<{
|
|
1189
|
+
points: import("./math/geometry/point").PointIdentifiers[];
|
|
1190
|
+
angleType: string;
|
|
1191
|
+
angleIndex: number;
|
|
1192
|
+
apexIndex: number;
|
|
1178
1193
|
}, {}> | Exercise<{
|
|
1179
1194
|
coeffs: number[];
|
|
1180
1195
|
to: string;
|
|
@@ -1378,6 +1393,21 @@ declare const mathExercises: (Exercise<{
|
|
|
1378
1393
|
sortedValues: number[];
|
|
1379
1394
|
}, {}> | Exercise<{
|
|
1380
1395
|
sortedValues: number[];
|
|
1396
|
+
}, {}> | Exercise<{
|
|
1397
|
+
sortedValues: number[];
|
|
1398
|
+
}, {}> | Exercise<{
|
|
1399
|
+
sortedValues: number[];
|
|
1400
|
+
effectifs: number[];
|
|
1401
|
+
}, {}> | Exercise<{
|
|
1402
|
+
sortedValues: number[];
|
|
1403
|
+
}, {}> | Exercise<{
|
|
1404
|
+
sortedValues: number[];
|
|
1405
|
+
effectifs: number[];
|
|
1406
|
+
}, {}> | Exercise<{
|
|
1407
|
+
sortedValues: number[];
|
|
1408
|
+
}, {}> | Exercise<{
|
|
1409
|
+
sortedValues: number[];
|
|
1410
|
+
effectifs: number[];
|
|
1381
1411
|
}, {}> | Exercise<{
|
|
1382
1412
|
xValues: number[];
|
|
1383
1413
|
yValues: number[];
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAG1D,OAAO,yBAAyB,CAAC;AAEjC,QAAA,MAAM,aAAa
|
|
1
|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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -1,18 +1,39 @@
|
|
|
1
1
|
import { AlgebraicNode } from "../../tree/nodes/algebraicNode";
|
|
2
|
-
import { Point } from "./point";
|
|
2
|
+
import { Point, PointIdentifiers } from "./point";
|
|
3
|
+
import { NodeIdentifiers } from "../../tree/nodes/nodeConstructor";
|
|
4
|
+
export declare abstract class AngleConstructor {
|
|
5
|
+
static fromIdentifiers(identifiers: AngleIdentifiers): Angle;
|
|
6
|
+
}
|
|
3
7
|
type AngleProps = {
|
|
4
8
|
radianValueNode?: AlgebraicNode;
|
|
5
9
|
degreeValueNode?: AlgebraicNode;
|
|
6
10
|
};
|
|
11
|
+
type AnglePropsIdentifiers = {
|
|
12
|
+
radianValueNode?: NodeIdentifiers;
|
|
13
|
+
degreeValueNode?: NodeIdentifiers;
|
|
14
|
+
};
|
|
15
|
+
export type AngleIdentifiers = {
|
|
16
|
+
points: PointIdentifiers[];
|
|
17
|
+
props?: AnglePropsIdentifiers;
|
|
18
|
+
};
|
|
7
19
|
export declare class Angle {
|
|
8
20
|
points: Point[];
|
|
9
21
|
radianValueNode?: AlgebraicNode;
|
|
10
22
|
degreeValueNode?: AlgebraicNode;
|
|
23
|
+
props?: AngleProps;
|
|
11
24
|
/**
|
|
12
25
|
*
|
|
13
26
|
* @param points [pointA, pointB, pointC] with apex = B
|
|
14
27
|
*/
|
|
15
28
|
constructor(points: Point[], props?: AngleProps);
|
|
29
|
+
toIdentifiers(): AngleIdentifiers;
|
|
30
|
+
hasSameApex(a: Angle): boolean;
|
|
31
|
+
equals(a: Angle): boolean;
|
|
32
|
+
isAlterne(a: Angle): boolean;
|
|
33
|
+
isAlterneInterne(a: Angle): boolean;
|
|
34
|
+
isFlat(): boolean;
|
|
35
|
+
isCorrespondant(a: Angle): boolean;
|
|
36
|
+
isSummitOpposite(a: Angle): boolean;
|
|
16
37
|
evaluate(inRadian?: boolean): number;
|
|
17
38
|
getValueNode(inDegree?: boolean): AlgebraicNode | import("../../tree/nodes/numbers/constantNode").ConstantNode | import("../../tree/nodes/numbers/numberNode").NumberNode;
|
|
18
39
|
isRight(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"angle.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/angle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAM/D,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"angle.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/angle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAM/D,OAAO,EAAE,KAAK,EAAoB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,EACL,eAAe,EAEhB,MAAM,kCAAkC,CAAC;AAI1C,8BAAsB,gBAAgB;IACpC,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,gBAAgB;CAUrD;AACD,KAAK,UAAU,GAAG;IAChB,eAAe,CAAC,EAAE,aAAa,CAAC;IAChC,eAAe,CAAC,EAAE,aAAa,CAAC;CACjC,CAAC;AAEF,KAAK,qBAAqB,GAAG;IAC3B,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC,CAAC;AACF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,KAAK,CAAC,EAAE,qBAAqB,CAAC;CAC/B,CAAC;AACF,qBAAa,KAAK;IAChB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,eAAe,CAAC,EAAE,aAAa,CAAC;IAChC,eAAe,CAAC,EAAE,aAAa,CAAC;IAChC,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB;;;OAGG;gBACS,MAAM,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,EAAE,UAAU;IAkB/C,aAAa,IAAI,gBAAgB;IASjC,WAAW,CAAC,CAAC,EAAE,KAAK;IAIpB,MAAM,CAAC,CAAC,EAAE,KAAK;IAqBf,SAAS,CAAC,CAAC,EAAE,KAAK;IASlB,gBAAgB,CAAC,CAAC,EAAE,KAAK;IAwCzB,MAAM;IAMN,eAAe,CAAC,CAAC,EAAE,KAAK;IAsCxB,gBAAgB,CAAC,CAAC,EAAE,KAAK;IAoBzB,QAAQ,CAAC,QAAQ,UAAQ;IAiBzB,YAAY,CAAC,QAAQ,UAAQ;IAW7B,OAAO;IAIP,KAAK;IAGL,UAAU,CAAC,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE;CAgB1D"}
|
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Angle = void 0;
|
|
3
|
+
exports.Angle = exports.AngleConstructor = void 0;
|
|
4
4
|
const piNode_1 = require("../../tree/nodes/numbers/piNode");
|
|
5
5
|
const fractionNode_1 = require("../../tree/nodes/operators/fractionNode");
|
|
6
6
|
const multiplyNode_1 = require("../../tree/nodes/operators/multiplyNode");
|
|
7
7
|
const round_1 = require("../utils/round");
|
|
8
|
+
const point_1 = require("./point");
|
|
9
|
+
const nodeConstructor_1 = require("../../tree/nodes/nodeConstructor");
|
|
10
|
+
const vector_1 = require("./vector");
|
|
11
|
+
const line_1 = require("./line");
|
|
12
|
+
class AngleConstructor {
|
|
13
|
+
static fromIdentifiers(identifiers) {
|
|
14
|
+
return new Angle(identifiers.points.map(point_1.PointConstructor.fromIdentifiers), {
|
|
15
|
+
degreeValueNode: identifiers.props?.degreeValueNode
|
|
16
|
+
? (0, nodeConstructor_1.reifyAlgebraic)(identifiers.props.degreeValueNode)
|
|
17
|
+
: undefined,
|
|
18
|
+
radianValueNode: identifiers.props?.radianValueNode
|
|
19
|
+
? (0, nodeConstructor_1.reifyAlgebraic)(identifiers.props.radianValueNode)
|
|
20
|
+
: undefined,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.AngleConstructor = AngleConstructor;
|
|
8
25
|
class Angle {
|
|
9
26
|
/**
|
|
10
27
|
*
|
|
@@ -12,6 +29,7 @@ class Angle {
|
|
|
12
29
|
*/
|
|
13
30
|
constructor(points, props) {
|
|
14
31
|
this.points = points;
|
|
32
|
+
this.props = props;
|
|
15
33
|
this.radianValueNode = props?.radianValueNode;
|
|
16
34
|
this.degreeValueNode = props?.degreeValueNode;
|
|
17
35
|
if (props?.radianValueNode && !props.degreeValueNode) {
|
|
@@ -21,6 +39,125 @@ class Angle {
|
|
|
21
39
|
this.radianValueNode = (0, fractionNode_1.frac)((0, multiplyNode_1.multiply)(props.degreeValueNode, piNode_1.PiNode), (180).toTree());
|
|
22
40
|
}
|
|
23
41
|
}
|
|
42
|
+
toIdentifiers() {
|
|
43
|
+
return {
|
|
44
|
+
points: this.points.map((p) => p.toIdentifiers()),
|
|
45
|
+
props: {
|
|
46
|
+
degreeValueNode: this.degreeValueNode?.toIdentifiers(),
|
|
47
|
+
radianValueNode: this.radianValueNode?.toIdentifiers(),
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
hasSameApex(a) {
|
|
52
|
+
return this.points[1].equals(a.points[1]);
|
|
53
|
+
}
|
|
54
|
+
equals(a) {
|
|
55
|
+
if (!this.hasSameApex(a))
|
|
56
|
+
return false;
|
|
57
|
+
const vecs = [
|
|
58
|
+
[
|
|
59
|
+
vector_1.VectorConstructor.fromPoints(this.points[1], this.points[0]),
|
|
60
|
+
vector_1.VectorConstructor.fromPoints(this.points[1], this.points[2]),
|
|
61
|
+
],
|
|
62
|
+
[
|
|
63
|
+
vector_1.VectorConstructor.fromPoints(a.points[1], a.points[0]),
|
|
64
|
+
vector_1.VectorConstructor.fromPoints(a.points[1], a.points[2]),
|
|
65
|
+
],
|
|
66
|
+
];
|
|
67
|
+
if (vecs[0][0].hasSameOrientation(vecs[1][0])) {
|
|
68
|
+
return vecs[0][1].hasSameOrientation(vecs[1][1]);
|
|
69
|
+
}
|
|
70
|
+
if (vecs[0][0].hasSameOrientation(vecs[1][1])) {
|
|
71
|
+
return vecs[0][1].hasSameOrientation(vecs[1][0]);
|
|
72
|
+
}
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
isAlterne(a) {
|
|
76
|
+
if (this.hasSameApex(a))
|
|
77
|
+
return false;
|
|
78
|
+
const symetric = new Angle([
|
|
79
|
+
a.points[0].centralSymetric(a.points[1]),
|
|
80
|
+
a.points[1],
|
|
81
|
+
a.points[2].centralSymetric(a.points[1]),
|
|
82
|
+
]);
|
|
83
|
+
return symetric.isCorrespondant(this);
|
|
84
|
+
}
|
|
85
|
+
isAlterneInterne(a) {
|
|
86
|
+
if (this.hasSameApex(a))
|
|
87
|
+
return false;
|
|
88
|
+
if (this.isFlat() || a.isFlat())
|
|
89
|
+
return false;
|
|
90
|
+
const apexesVec = vector_1.VectorConstructor.fromPoints(this.points[1], a.points[1]);
|
|
91
|
+
const line = new line_1.Line(this.points[1], a.points[1]);
|
|
92
|
+
const aPointIndexOnLine = a.points.findIndex((p, i) => i !== 1 && line.includes(p, true));
|
|
93
|
+
const thisPointIndexOnLine = this.points.findIndex((p, i) => i !== 1 && line.includes(p, true));
|
|
94
|
+
if (aPointIndexOnLine < 0 || thisPointIndexOnLine < 0)
|
|
95
|
+
return false;
|
|
96
|
+
const vecs = [
|
|
97
|
+
[
|
|
98
|
+
vector_1.VectorConstructor.fromPoints(this.points[1], this.points[thisPointIndexOnLine]),
|
|
99
|
+
vector_1.VectorConstructor.fromPoints(this.points[1], this.points[2 - thisPointIndexOnLine]),
|
|
100
|
+
],
|
|
101
|
+
[
|
|
102
|
+
vector_1.VectorConstructor.fromPoints(a.points[1], a.points[aPointIndexOnLine]),
|
|
103
|
+
vector_1.VectorConstructor.fromPoints(a.points[1], a.points[2 - aPointIndexOnLine]),
|
|
104
|
+
],
|
|
105
|
+
];
|
|
106
|
+
return (vecs[0][0].hasSameOrientation(apexesVec) &&
|
|
107
|
+
vecs[1][0].hasOppositeOrientation(apexesVec) &&
|
|
108
|
+
vecs[0][1].scalarProduct(vecs[1][1]).evaluate() < 0);
|
|
109
|
+
}
|
|
110
|
+
isFlat() {
|
|
111
|
+
return vector_1.VectorConstructor.fromPoints(this.points[1], this.points[2]).isColinear(vector_1.VectorConstructor.fromPoints(this.points[1], this.points[0]));
|
|
112
|
+
}
|
|
113
|
+
isCorrespondant(a) {
|
|
114
|
+
if (this.hasSameApex(a))
|
|
115
|
+
return false;
|
|
116
|
+
//angles plats ne sont pas créés par intersections de droites donc ne peuvent pas etre correspondants
|
|
117
|
+
if (this.isFlat() || a.isFlat())
|
|
118
|
+
return false;
|
|
119
|
+
const line = new line_1.Line(this.points[1], a.points[1]);
|
|
120
|
+
const aPointIndexOnLine = a.points.findIndex((p, i) => i !== 1 && line.includes(p, true));
|
|
121
|
+
const thisPointIndexOnLine = this.points.findIndex((p, i) => i !== 1 && line.includes(p, true));
|
|
122
|
+
if (aPointIndexOnLine < 0 || thisPointIndexOnLine < 0)
|
|
123
|
+
return false;
|
|
124
|
+
//angle non plat
|
|
125
|
+
if (line.includes(a.points[2 - aPointIndexOnLine], true))
|
|
126
|
+
return false;
|
|
127
|
+
const vecs = [
|
|
128
|
+
[
|
|
129
|
+
vector_1.VectorConstructor.fromPoints(this.points[1], this.points[thisPointIndexOnLine]),
|
|
130
|
+
vector_1.VectorConstructor.fromPoints(this.points[1], this.points[2 - thisPointIndexOnLine]),
|
|
131
|
+
],
|
|
132
|
+
[
|
|
133
|
+
vector_1.VectorConstructor.fromPoints(a.points[1], a.points[aPointIndexOnLine]),
|
|
134
|
+
vector_1.VectorConstructor.fromPoints(a.points[1], a.points[2 - aPointIndexOnLine]),
|
|
135
|
+
],
|
|
136
|
+
];
|
|
137
|
+
return (vecs[0][0].hasSameOrientation(vecs[1][0]) &&
|
|
138
|
+
vecs[0][1].scalarProduct(vecs[1][1]).evaluate() > 0);
|
|
139
|
+
}
|
|
140
|
+
isSummitOpposite(a) {
|
|
141
|
+
if (!this.hasSameApex(a))
|
|
142
|
+
return false;
|
|
143
|
+
const vecs = [
|
|
144
|
+
[
|
|
145
|
+
vector_1.VectorConstructor.fromPoints(this.points[1], this.points[0]),
|
|
146
|
+
vector_1.VectorConstructor.fromPoints(this.points[1], this.points[2]),
|
|
147
|
+
],
|
|
148
|
+
[
|
|
149
|
+
vector_1.VectorConstructor.fromPoints(a.points[1], a.points[0]),
|
|
150
|
+
vector_1.VectorConstructor.fromPoints(a.points[1], a.points[2]),
|
|
151
|
+
],
|
|
152
|
+
];
|
|
153
|
+
if (vecs[0][0].hasOppositeOrientation(vecs[1][0])) {
|
|
154
|
+
return vecs[0][1].hasOppositeOrientation(vecs[1][1]);
|
|
155
|
+
}
|
|
156
|
+
if (vecs[0][0].hasOppositeOrientation(vecs[1][1])) {
|
|
157
|
+
return vecs[0][1].hasOppositeOrientation(vecs[1][0]);
|
|
158
|
+
}
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
24
161
|
evaluate(inRadian = false) {
|
|
25
162
|
if (this.degreeValueNode || this.radianValueNode) {
|
|
26
163
|
if (inRadian)
|
|
@@ -36,6 +36,8 @@ export declare class Line {
|
|
|
36
36
|
getParallele(point: Point): Line;
|
|
37
37
|
getPerpendicular(point: Point): Line;
|
|
38
38
|
includes(point: Point, allowApprox?: boolean): boolean;
|
|
39
|
+
getPointWithX(x: AlgebraicNode, name?: string): Point;
|
|
40
|
+
getPointWithY(y: AlgebraicNode, name?: string): Point;
|
|
39
41
|
getRandomPoint(name?: string): Point;
|
|
40
42
|
getEquation: (u: Vector, a: Point) => EqualNode;
|
|
41
43
|
getCartesianEquation(): EqualNode;
|
|
@@ -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,MAAM,SAAS,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAqB,MAAM,UAAU,CAAC;AAErD,MAAM,MAAM,eAAe,GAAG;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,gBAAgB,CAAC;IACzB,MAAM,EAAE,gBAAgB,CAAC;CAC1B,CAAC;AACF,8BAAsB,eAAe;IACnC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM;IAK3B,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,eAAe;IAOnD,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,OAAO;CAGpC;AACD,qBAAa,IAAI;IACf,MAAM,EAAE,KAAK,CAAC;IACd,MAAM,EAAE,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Approx = false) {
|
|
105
105
|
if (this.isVertical) {
|
|
106
106
|
if (allowApprox) {
|
|
107
|
+
return (Math.abs(point.x.evaluate() - this.pointA.x.evaluate()) < 0.0000001);
|
|
107
108
|
}
|
|
108
109
|
else
|
|
109
110
|
return point.x.equals(this.pointA.x);
|
|
@@ -115,6 +116,21 @@ class Line {
|
|
|
115
116
|
else
|
|
116
117
|
return evaluation === 0;
|
|
117
118
|
}
|
|
119
|
+
getPointWithX(x, name) {
|
|
120
|
+
if (this.isVertical)
|
|
121
|
+
return this.pointA.midpoint(this.pointB, name);
|
|
122
|
+
const y = (0, addNode_1.add)((0, multiplyNode_1.multiply)(this.a, x), this.b).simplify();
|
|
123
|
+
return new point_1.Point(name ?? "P", x, y);
|
|
124
|
+
}
|
|
125
|
+
getPointWithY(y, name) {
|
|
126
|
+
if (this.a?.evaluate() === 0)
|
|
127
|
+
return this.pointA.midpoint(this.pointB, name);
|
|
128
|
+
if (this.isVertical) {
|
|
129
|
+
return new point_1.Point(name ?? "P", this.pointA.x, y);
|
|
130
|
+
}
|
|
131
|
+
const x = (0, fractionNode_1.frac)((0, substractNode_1.substract)(y, this.b), this.a).simplify();
|
|
132
|
+
return new point_1.Point(name ?? "P", x, y);
|
|
133
|
+
}
|
|
118
134
|
//! caution: simplify ne gère pas bien ici
|
|
119
135
|
getRandomPoint(name) {
|
|
120
136
|
if (this.isVertical) {
|
|
@@ -36,5 +36,6 @@ export declare class Point {
|
|
|
36
36
|
toMathString(): string;
|
|
37
37
|
toGGBCommand({ isFixed, showLabel, style, size, color, }?: ToGGBCommandsProps): string[];
|
|
38
38
|
rotate(angle: number, center: Point): Point;
|
|
39
|
+
centralSymetric(center: Point, name?: string): Point;
|
|
39
40
|
}
|
|
40
41
|
//# sourceMappingURL=point.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/point.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aA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