math-exercises 3.0.28 → 3.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/exercises/math/geometry/thales/thales.d.ts +9 -9
- package/lib/exercises/math/geometry/thales/thales.d.ts.map +1 -1
- package/lib/exercises/math/geometry/thales/thales.js +153 -88
- package/lib/exercises/math/geometry/thales/thalesCalcul.js +2 -2
- package/lib/index.d.ts +14 -18
- package/lib/index.d.ts.map +1 -1
- package/lib/tree/nodes/geometry/lengthNode.d.ts +2 -1
- package/lib/tree/nodes/geometry/lengthNode.d.ts.map +1 -1
- package/lib/tree/nodes/geometry/lengthNode.js +7 -1
- package/package.json +1 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Exercise } from "../../../../exercises/exercise.js";
|
|
2
|
+
import { TriangleIdentifiers } from "../../../../math/geometry/triangle.js";
|
|
2
3
|
type Identifiers = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
yB: number;
|
|
8
|
-
xC: number;
|
|
9
|
-
yC: number;
|
|
10
|
-
factor: number;
|
|
4
|
+
ratio: number;
|
|
5
|
+
triangleIdentifiers: TriangleIdentifiers;
|
|
6
|
+
insidePointsNames: string[];
|
|
7
|
+
isPapillon: boolean;
|
|
11
8
|
};
|
|
12
|
-
|
|
9
|
+
type Options = {
|
|
10
|
+
configurationType: string;
|
|
11
|
+
};
|
|
12
|
+
export declare const thales: Exercise<Identifiers, Options>;
|
|
13
13
|
export {};
|
|
14
14
|
//# sourceMappingURL=thales.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"thales.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/thales/thales.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,
|
|
1
|
+
{"version":3,"file":"thales.d.ts","sourceRoot":"","sources":["../../../../../src/exercises/math/geometry/thales/thales.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAcT,MAAM,6BAA6B,CAAC;AAIrC,OAAO,EAGL,mBAAmB,EACpB,MAAM,iCAAiC,CAAC;AAuBzC,KAAK,WAAW,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AAyFF,KAAK,OAAO,GAAG;IACb,iBAAiB,EAAE,MAAM,CAAC;CAC3B,CAAC;AAoIF,eAAO,MAAM,MAAM,EAAE,QAAQ,CAAC,WAAW,EAAE,OAAO,CAgBjD,CAAC"}
|
|
@@ -1,113 +1,176 @@
|
|
|
1
|
-
import { addValidProp, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
1
|
+
import { GeneratorOptionTarget, GeneratorOptionType, addValidProp, tryToAddWrongProp, } from "../../../../exercises/exercise.js";
|
|
2
2
|
import { getDistinctQuestions } from "../../../../exercises/utils/getDistinctQuestions.js";
|
|
3
3
|
import { GeogebraConstructor } from "../../../../geogebra/geogebraConstructor.js";
|
|
4
|
-
import {
|
|
4
|
+
import { Segment } from "../../../../math/geometry/segment.js";
|
|
5
|
+
import { Triangle, TriangleConstructor, } from "../../../../math/geometry/triangle.js";
|
|
6
|
+
import { VectorConstructor } from "../../../../math/geometry/vector.js";
|
|
7
|
+
import { randfloat } from "../../../../math/utils/random/randfloat.js";
|
|
5
8
|
import { MultiEqualNode } from "../../../../tree/nodes/equations/multiEqualNode.js";
|
|
6
|
-
import {
|
|
9
|
+
import { length } from "../../../../tree/nodes/geometry/lengthNode.js";
|
|
7
10
|
import { FractionNode } from "../../../../tree/nodes/operators/fractionNode.js";
|
|
11
|
+
import { coinFlip } from "../../../../utils/alea/coinFlip.js";
|
|
8
12
|
import { shuffle } from "../../../../utils/alea/shuffle.js";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
|
|
13
|
+
import { randomLetter } from "../../../../utils/strings/randomLetter.js";
|
|
14
|
+
const getSubTriangle = ({ triangle, insidePointsNames, ratio, isPapillon, }) => {
|
|
15
|
+
const [A, B, C] = triangle.points;
|
|
16
|
+
const [dName, eName] = insidePointsNames;
|
|
17
|
+
const vecAC = VectorConstructor.fromPoints(A, C).times((1 - ratio).toTree());
|
|
18
|
+
const pointD = vecAC.getEndPoint(A, dName);
|
|
19
|
+
const vecBC = VectorConstructor.fromPoints(B, C).times((1 - ratio).toTree());
|
|
20
|
+
const pointE = vecBC.getEndPoint(B, eName);
|
|
21
|
+
return new Triangle([pointD, pointE, triangle.points[2]]);
|
|
22
|
+
};
|
|
23
|
+
const getInstruction = (identifiers) => {
|
|
24
|
+
const { triangleIdentifiers, insidePointsNames } = identifiers;
|
|
25
|
+
const triangle = TriangleConstructor.fromIdentifiers(triangleIdentifiers);
|
|
26
|
+
return `En utilisant le théoreme de Thalès, écrire l'égalité des quotients sachant que $\\left(${insidePointsNames.join("")}\\right)//\\left(${triangle.sides[2].toInsideName()}\\right)$.`;
|
|
27
|
+
};
|
|
28
|
+
const getAnswer = (identifiers) => {
|
|
29
|
+
const { triangleIdentifiers, insidePointsNames, isPapillon, ratio } = identifiers;
|
|
30
|
+
const triangle = TriangleConstructor.fromIdentifiers(triangleIdentifiers);
|
|
31
|
+
const subTriangle = getSubTriangle({
|
|
32
|
+
triangle,
|
|
33
|
+
insidePointsNames,
|
|
34
|
+
ratio,
|
|
35
|
+
isPapillon,
|
|
36
|
+
});
|
|
37
|
+
const answer = `\\frac{${triangle.sides[0].toInsideName()}}{${subTriangle.sides[0].toInsideName()}}=\\frac{${triangle.sides[1].toInsideName()}}{${subTriangle.sides[1].toInsideName()}}=\\frac{${triangle.sides[2].toInsideName()}}{${subTriangle.sides[2].toInsideName()}}`;
|
|
38
|
+
return answer;
|
|
39
|
+
};
|
|
40
|
+
const getGGBOptions = (identifiers) => {
|
|
41
|
+
const triangle = TriangleConstructor.fromIdentifiers(identifiers.triangleIdentifiers);
|
|
42
|
+
const subTriangle = getSubTriangle({
|
|
43
|
+
triangle,
|
|
44
|
+
insidePointsNames: identifiers.insidePointsNames,
|
|
45
|
+
ratio: identifiers.ratio,
|
|
46
|
+
isPapillon: identifiers.isPapillon,
|
|
47
|
+
});
|
|
48
|
+
const points = [subTriangle.points[0], subTriangle.points[1]];
|
|
49
|
+
const seg = new Segment(points[0], points[1]);
|
|
40
50
|
const commands = [
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
`${vertices[3]} = Point(${vertices[0]}, Vector(${factor}Vector(${vertices[0]},${vertices[1]})))`,
|
|
45
|
-
`${vertices[4]} = Intersect(Line(${vertices[3]}, Line(${vertices[1]}, ${vertices[2]})) , Line(${vertices[0]}, ${vertices[2]}))`,
|
|
46
|
-
`l = Segment(${vertices[0]}, ${vertices[1]})`,
|
|
47
|
-
`i = Segment(${vertices[0]}, ${vertices[2]})`,
|
|
48
|
-
`j = Segment(${vertices[1]}, ${vertices[2]})`,
|
|
49
|
-
`k = Segment(${vertices[3]}, ${vertices[4]})`,
|
|
50
|
-
`If(${factor} < 0, Segment(${vertices[0]}, ${vertices[3]}))`,
|
|
51
|
-
`If(${factor} < 0, Segment(${vertices[0]}, ${vertices[4]}))`,
|
|
52
|
-
`ShowLabel(${vertices[0]}, true)`,
|
|
53
|
-
`ShowLabel(${vertices[1]}, true)`,
|
|
54
|
-
`ShowLabel(${vertices[2]}, true)`,
|
|
55
|
-
`ShowLabel(${vertices[3]}, true)`,
|
|
56
|
-
`ShowLabel(${vertices[4]}, true)`,
|
|
51
|
+
...triangle.commands,
|
|
52
|
+
...points.flatMap((p) => p.toGGBCommand({ color: "#444444", size: 4 })),
|
|
53
|
+
...seg.toGGBCommands(false),
|
|
57
54
|
];
|
|
58
|
-
|
|
55
|
+
if (identifiers.isPapillon) {
|
|
56
|
+
commands.push(...new Segment(points[0], triangle.points[2]).toGGBCommands(false));
|
|
57
|
+
commands.push(...new Segment(points[1], triangle.points[2]).toGGBCommands(false));
|
|
58
|
+
}
|
|
59
59
|
const ggb = new GeogebraConstructor({
|
|
60
60
|
commands,
|
|
61
61
|
hideAxes: true,
|
|
62
62
|
hideGrid: true,
|
|
63
63
|
});
|
|
64
|
+
let coords = triangle.generateCoords();
|
|
65
|
+
if (identifiers.isPapillon) {
|
|
66
|
+
const subCoords = subTriangle.generateCoords();
|
|
67
|
+
coords = [
|
|
68
|
+
Math.min(subCoords[0], coords[0]),
|
|
69
|
+
Math.max(subCoords[1], coords[1]),
|
|
70
|
+
Math.min(subCoords[2], coords[2]),
|
|
71
|
+
Math.max(subCoords[3], coords[3]),
|
|
72
|
+
];
|
|
73
|
+
}
|
|
74
|
+
return ggb.getOptions({
|
|
75
|
+
coords: coords,
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
const options = [
|
|
79
|
+
{
|
|
80
|
+
id: "configurationType",
|
|
81
|
+
label: "Types de figure",
|
|
82
|
+
defaultValue: "Toutes",
|
|
83
|
+
values: ["Toutes", "Uniquement papillon", "Uniquement non papillon"],
|
|
84
|
+
target: GeneratorOptionTarget.generation,
|
|
85
|
+
type: GeneratorOptionType.select,
|
|
86
|
+
},
|
|
87
|
+
];
|
|
88
|
+
const getThales = (opts) => {
|
|
89
|
+
const triangle = TriangleConstructor.randomNiceSides({
|
|
90
|
+
randomName: true,
|
|
91
|
+
});
|
|
92
|
+
const summitNames = triangle.points.map((p) => p.name);
|
|
93
|
+
const isPapillon = !opts || opts?.configurationType === "Toutes"
|
|
94
|
+
? coinFlip()
|
|
95
|
+
: opts.configurationType === "Uniquement papillon"
|
|
96
|
+
? true
|
|
97
|
+
: false;
|
|
98
|
+
//homothety rapport
|
|
99
|
+
const ratio = !isPapillon ? randfloat(0.2, 0.8, 1) : randfloat(-0.2, -0.8, 1);
|
|
100
|
+
// const ratio = 0.5;
|
|
101
|
+
const dName = randomLetter(true, summitNames);
|
|
102
|
+
const eName = randomLetter(true, [...summitNames, dName]);
|
|
103
|
+
const identifiers = {
|
|
104
|
+
triangleIdentifiers: triangle.toIdentifiers(),
|
|
105
|
+
insidePointsNames: [dName, eName],
|
|
106
|
+
isPapillon,
|
|
107
|
+
ratio,
|
|
108
|
+
};
|
|
64
109
|
const question = {
|
|
65
|
-
instruction:
|
|
66
|
-
answer,
|
|
67
|
-
keys: [
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
110
|
+
instruction: getInstruction(identifiers),
|
|
111
|
+
answer: getAnswer(identifiers),
|
|
112
|
+
keys: [
|
|
113
|
+
"equal",
|
|
114
|
+
...triangle.points.map((p) => p.name),
|
|
115
|
+
...[dName, eName],
|
|
116
|
+
],
|
|
117
|
+
ggbOptions: getGGBOptions(identifiers),
|
|
71
118
|
answerFormat: "tex",
|
|
72
|
-
identifiers
|
|
119
|
+
identifiers,
|
|
73
120
|
};
|
|
74
121
|
return question;
|
|
75
122
|
};
|
|
76
|
-
const getPropositions = (n, { answer,
|
|
123
|
+
const getPropositions = (n, { answer, ...identifiers }) => {
|
|
77
124
|
const propositions = [];
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
125
|
+
const { triangleIdentifiers, insidePointsNames, isPapillon, ratio } = identifiers;
|
|
126
|
+
const triangle = TriangleConstructor.fromIdentifiers(triangleIdentifiers);
|
|
127
|
+
const subTriangle = getSubTriangle({
|
|
128
|
+
triangle,
|
|
129
|
+
insidePointsNames,
|
|
130
|
+
ratio,
|
|
131
|
+
isPapillon,
|
|
132
|
+
});
|
|
133
|
+
const lengths = [
|
|
134
|
+
...triangle.sides.map((s) => s.toInsideName()),
|
|
135
|
+
...subTriangle.sides.map((s) => s.toInsideName()),
|
|
87
136
|
];
|
|
88
137
|
addValidProp(propositions, answer);
|
|
89
|
-
const indexRange = Array.from({ length:
|
|
138
|
+
const indexRange = Array.from({ length: 6 }, (_, i) => i);
|
|
90
139
|
while (propositions.length < n) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
140
|
+
let rands = [];
|
|
141
|
+
do {
|
|
142
|
+
rands = shuffle(indexRange);
|
|
143
|
+
} while ((rands[0] - rands[1] === 3 &&
|
|
144
|
+
rands[2] - rands[3] === 3 &&
|
|
145
|
+
rands[4] - rands[5] === 3) ||
|
|
146
|
+
(rands[0] - rands[1] === -3 &&
|
|
147
|
+
rands[2] - rands[3] === -3 &&
|
|
148
|
+
rands[4] - rands[5] === -3));
|
|
149
|
+
//a,b,c,d,e,f
|
|
150
|
+
//interdire distance = 3 entre a,b c,d e,f
|
|
151
|
+
tryToAddWrongProp(propositions, `\\frac{${lengths[rands[0]]}}{${lengths[rands[1]]}} =
|
|
152
|
+
\\frac{${lengths[rands[2]]}}{${lengths[rands[3]]}} =
|
|
153
|
+
\\frac{${lengths[rands[4]]}}{${lengths[rands[5]]}}`);
|
|
95
154
|
}
|
|
96
155
|
return shuffle(propositions);
|
|
97
156
|
};
|
|
98
|
-
const isAnswerValid = (ans, {
|
|
157
|
+
const isAnswerValid = (ans, { ...identifiers }) => {
|
|
158
|
+
const { triangleIdentifiers, insidePointsNames, isPapillon, ratio } = identifiers;
|
|
159
|
+
const triangle = TriangleConstructor.fromIdentifiers(triangleIdentifiers);
|
|
160
|
+
const subTriangle = getSubTriangle({
|
|
161
|
+
triangle,
|
|
162
|
+
insidePointsNames,
|
|
163
|
+
ratio,
|
|
164
|
+
isPapillon,
|
|
165
|
+
});
|
|
99
166
|
const lengths = [
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
new LengthNode(`${vertices[0]}${vertices[2]}`),
|
|
104
|
-
new LengthNode(`${vertices[3]}${vertices[4]}`),
|
|
105
|
-
new LengthNode(`${vertices[1]}${vertices[2]}`),
|
|
106
|
-
];
|
|
167
|
+
...triangle.sides.map((s) => s.toInsideName()),
|
|
168
|
+
...subTriangle.sides.map((s) => s.toInsideName()),
|
|
169
|
+
].map((s) => length(s));
|
|
107
170
|
const fractions = [
|
|
108
|
-
new FractionNode(lengths[0], lengths[
|
|
109
|
-
new FractionNode(lengths[
|
|
110
|
-
new FractionNode(lengths[
|
|
171
|
+
new FractionNode(lengths[0], lengths[3]),
|
|
172
|
+
new FractionNode(lengths[1], lengths[4]),
|
|
173
|
+
new FractionNode(lengths[2], lengths[5]),
|
|
111
174
|
];
|
|
112
175
|
const answers = [
|
|
113
176
|
new MultiEqualNode(fractions),
|
|
@@ -119,15 +182,17 @@ const isAnswerValid = (ans, { vertices }) => {
|
|
|
119
182
|
export const thales = {
|
|
120
183
|
id: "thales",
|
|
121
184
|
connector: "=",
|
|
122
|
-
label: "
|
|
123
|
-
levels: ["5ème", "4ème", "3ème", "2nde"],
|
|
185
|
+
label: "Écrire l'égalité de Thalès",
|
|
124
186
|
isSingleStep: false,
|
|
125
|
-
|
|
126
|
-
generator: (nb) => getDistinctQuestions(getThales, nb),
|
|
187
|
+
generator: (nb, opts) => getDistinctQuestions(() => getThales(opts), nb),
|
|
127
188
|
qcmTimer: 60,
|
|
128
189
|
freeTimer: 60,
|
|
129
190
|
getPropositions,
|
|
130
191
|
isAnswerValid,
|
|
131
192
|
hasGeogebra: true,
|
|
132
193
|
subject: "Mathématiques",
|
|
194
|
+
getAnswer,
|
|
195
|
+
getInstruction,
|
|
196
|
+
getGGBOptions,
|
|
197
|
+
options,
|
|
133
198
|
};
|
|
@@ -137,8 +137,8 @@ const getThalesFindSideQuestion = (opts) => {
|
|
|
137
137
|
? true
|
|
138
138
|
: false;
|
|
139
139
|
//homothety rapport
|
|
140
|
-
|
|
141
|
-
const ratio = 0.5;
|
|
140
|
+
const ratio = !isPapillon ? randfloat(0.2, 0.8, 1) : randfloat(-0.2, -0.8, 1);
|
|
141
|
+
// const ratio = 0.5;
|
|
142
142
|
const dName = randomLetter(true, summitNames);
|
|
143
143
|
const eName = randomLetter(true, [...summitNames, dName]);
|
|
144
144
|
const subTriangle = getSubTriangle({
|
package/lib/index.d.ts
CHANGED
|
@@ -1071,15 +1071,13 @@ declare const mathExercises: (Exercise<{
|
|
|
1071
1071
|
c: number;
|
|
1072
1072
|
vertices: string[];
|
|
1073
1073
|
}, {}> | Exercise<{
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
factor: number;
|
|
1082
|
-
}, {}> | Exercise<{
|
|
1074
|
+
ratio: number;
|
|
1075
|
+
triangleIdentifiers: import("./math/geometry/triangle.js").TriangleIdentifiers;
|
|
1076
|
+
insidePointsNames: string[];
|
|
1077
|
+
isPapillon: boolean;
|
|
1078
|
+
}, {
|
|
1079
|
+
configurationType: string;
|
|
1080
|
+
}> | Exercise<{
|
|
1083
1081
|
ratio: number;
|
|
1084
1082
|
triangleIdentifiers: import("./math/geometry/triangle.js").TriangleIdentifiers;
|
|
1085
1083
|
insidePointsNames: string[];
|
|
@@ -1971,15 +1969,13 @@ declare const pcExercises: (Exercise<{
|
|
|
1971
1969
|
}, {
|
|
1972
1970
|
isLog10: boolean;
|
|
1973
1971
|
}> | Exercise<{
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
factor: number;
|
|
1982
|
-
}, {}> | Exercise<{
|
|
1972
|
+
ratio: number;
|
|
1973
|
+
triangleIdentifiers: import("./math/geometry/triangle.js").TriangleIdentifiers;
|
|
1974
|
+
insidePointsNames: string[];
|
|
1975
|
+
isPapillon: boolean;
|
|
1976
|
+
}, {
|
|
1977
|
+
configurationType: string;
|
|
1978
|
+
}> | Exercise<{
|
|
1983
1979
|
ratio: number;
|
|
1984
1980
|
triangleIdentifiers: import("./math/geometry/triangle.js").TriangleIdentifiers;
|
|
1985
1981
|
insidePointsNames: string[];
|
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,yBAAyB,CAAC;AAG7D,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,QAAA,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAG7D,OAAO,4BAA4B,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AQ,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AlgebraicNode } from "../algebraicNode.js";
|
|
2
2
|
import { Node, NodeIds, NodeOptions, NodeType } from "../node.js";
|
|
3
3
|
export declare function isLengthNode(a: Node): a is LengthNode;
|
|
4
|
+
export declare const length: (a: string) => LengthNode;
|
|
4
5
|
export declare class LengthNode implements AlgebraicNode {
|
|
5
6
|
opts?: NodeOptions | undefined;
|
|
6
7
|
segmentName: string;
|
|
@@ -17,7 +18,7 @@ export declare class LengthNode implements AlgebraicNode {
|
|
|
17
18
|
toMathjs(): string;
|
|
18
19
|
toTex(): string;
|
|
19
20
|
evaluate(vars?: Record<string, number>): number;
|
|
20
|
-
simplify():
|
|
21
|
+
simplify(): LengthNode;
|
|
21
22
|
equals(node: AlgebraicNode): boolean;
|
|
22
23
|
toDetailedEvaluation(vars: Record<string, AlgebraicNode>): this;
|
|
23
24
|
derivative(varName?: string | undefined): AlgebraicNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lengthNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/geometry/lengthNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAClE,wBAAgB,YAAY,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,UAAU,CAErD;
|
|
1
|
+
{"version":3,"file":"lengthNode.d.ts","sourceRoot":"","sources":["../../../../src/tree/nodes/geometry/lengthNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAClE,wBAAgB,YAAY,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,IAAI,UAAU,CAErD;AAED,eAAO,MAAM,MAAM,MAAO,MAAM,eAE/B,CAAC;AACF,qBAAa,UAAW,YAAW,aAAa;IAC9C,IAAI,CAAC,EAAE,WAAW,GAAG,SAAS,CAAC;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;gBACP,WAAW,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW;IAUnD,cAAc;IAGd,aAAa;;;;IAMb,iBAAiB,CAAC,IAAI,CAAC,EAAE,WAAW;IAOpC,YAAY;IAGZ,QAAQ;IAIR,KAAK;IAIL,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAQtC,QAAQ;IAOR,MAAM,CAAC,IAAI,EAAE,aAAa;IAG1B,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC;IAGxD,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,aAAa;CAGxD"}
|
|
@@ -2,6 +2,9 @@ import { NodeIds, NodeType } from "../node.js";
|
|
|
2
2
|
export function isLengthNode(a) {
|
|
3
3
|
return a.type === NodeType.mesure;
|
|
4
4
|
}
|
|
5
|
+
export const length = (a) => {
|
|
6
|
+
return new LengthNode(a);
|
|
7
|
+
};
|
|
5
8
|
export class LengthNode {
|
|
6
9
|
opts;
|
|
7
10
|
segmentName;
|
|
@@ -48,7 +51,10 @@ export class LengthNode {
|
|
|
48
51
|
return value;
|
|
49
52
|
}
|
|
50
53
|
simplify() {
|
|
51
|
-
|
|
54
|
+
const isAlphabeticallyOrdered = (str) => [...str].every((c, i, arr) => i === 0 || arr[i - 1] <= c);
|
|
55
|
+
return isAlphabeticallyOrdered(this.segmentName)
|
|
56
|
+
? this
|
|
57
|
+
: new LengthNode(this.segmentName.split("").reverse().join(""));
|
|
52
58
|
}
|
|
53
59
|
equals(node) {
|
|
54
60
|
return isLengthNode(node) && node.segmentName === this.segmentName;
|