math-exercises 2.2.76 → 2.2.78
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/euclidianConstructions/buildPointFromAxialSymetry.d.ts +10 -0
- package/lib/exercises/math/geometry/euclidianConstructions/buildPointFromAxialSymetry.d.ts.map +1 -0
- package/lib/exercises/math/geometry/euclidianConstructions/buildPointFromAxialSymetry.js +107 -0
- package/lib/exercises/math/geometry/euclidianConstructions/index.d.ts +1 -0
- package/lib/exercises/math/geometry/euclidianConstructions/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/euclidianConstructions/index.js +1 -0
- package/lib/exercises/math/geometry/euclidianConstructions/pointImageFromTranslation.js +1 -1
- package/lib/exercises/math/geometry/vectors/alignementViaColinearity.js +1 -1
- package/lib/exercises/math/geometry/vectors/fourthParallelogramPoint.js +1 -1
- package/lib/exercises/math/geometry/vectors/index.d.ts +4 -0
- package/lib/exercises/math/geometry/vectors/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/vectors/index.js +4 -0
- package/lib/exercises/math/geometry/vectors/paralellismViaColinearity.js +1 -1
- package/lib/exercises/math/geometry/vectors/parallelogramViaEqualVectors.js +1 -1
- package/lib/exercises/math/geometry/vectors/traceOppositeVector.d.ts +10 -0
- package/lib/exercises/math/geometry/vectors/traceOppositeVector.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/traceOppositeVector.js +109 -0
- package/lib/exercises/math/geometry/vectors/traceVectorDifference.d.ts +11 -0
- package/lib/exercises/math/geometry/vectors/traceVectorDifference.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/traceVectorDifference.js +122 -0
- package/lib/exercises/math/geometry/vectors/traceVectorMultiple.d.ts +11 -0
- package/lib/exercises/math/geometry/vectors/traceVectorMultiple.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/traceVectorMultiple.js +114 -0
- package/lib/exercises/math/geometry/vectors/traceVectorSum.d.ts +11 -0
- package/lib/exercises/math/geometry/vectors/traceVectorSum.d.ts.map +1 -0
- package/lib/exercises/math/geometry/vectors/traceVectorSum.js +122 -0
- package/lib/exercises/utils/geogebra/toGGBCommandsProps.d.ts +1 -0
- package/lib/exercises/utils/geogebra/toGGBCommandsProps.d.ts.map +1 -1
- package/lib/exercises/utils/geogebra/toolBarConstructor.js +2 -2
- package/lib/geogebra/parsers/parseGGBPoints.js +1 -1
- package/lib/index.d.ts +22 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/math/geometry/CloudPoints.d.ts.map +1 -1
- package/lib/math/geometry/CloudPoints.js +1 -1
- package/lib/math/geometry/circle.d.ts +10 -0
- package/lib/math/geometry/circle.d.ts.map +1 -0
- package/lib/math/geometry/circle.js +33 -0
- package/lib/math/geometry/line.d.ts +1 -1
- package/lib/math/geometry/line.d.ts.map +1 -1
- package/lib/math/geometry/line.js +13 -8
- package/lib/math/geometry/point.d.ts +11 -2
- package/lib/math/geometry/point.d.ts.map +1 -1
- package/lib/math/geometry/point.js +30 -20
- package/lib/math/geometry/ray.d.ts.map +1 -1
- package/lib/math/geometry/ray.js +3 -1
- package/lib/math/geometry/segment.d.ts.map +1 -1
- package/lib/math/geometry/segment.js +3 -1
- package/lib/math/geometry/vector.d.ts +1 -0
- package/lib/math/geometry/vector.d.ts.map +1 -1
- package/lib/math/geometry/vector.js +3 -0
- package/lib/utils/alea/random.d.ts +1 -0
- package/lib/utils/alea/random.d.ts.map +1 -1
- package/lib/utils/alea/random.js +13 -1
- package/package.json +1 -1
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.traceVectorSum = void 0;
|
|
4
|
+
const toolBarConstructor_1 = require("../../../../exercises/utils/geogebra/toolBarConstructor");
|
|
5
|
+
const getDistinctQuestions_1 = require("../../../../exercises/utils/getDistinctQuestions");
|
|
6
|
+
const geogebraConstructor_1 = require("../../../../geogebra/geogebraConstructor");
|
|
7
|
+
const ggbPointToCoords_1 = require("../../../../geogebra/parsers/ggbPointToCoords");
|
|
8
|
+
const parseGGBPoints_1 = require("../../../../geogebra/parsers/parseGGBPoints");
|
|
9
|
+
const point_1 = require("../../../../math/geometry/point");
|
|
10
|
+
const vector_1 = require("../../../../math/geometry/vector");
|
|
11
|
+
const randint_1 = require("../../../../math/utils/random/randint");
|
|
12
|
+
const random_1 = require("../../../../utils/alea/random");
|
|
13
|
+
const doWhile_1 = require("../../../../utils/doWhile");
|
|
14
|
+
const getSolutionPoint = (identifiers) => {
|
|
15
|
+
const points = identifiers.points.map(point_1.PointConstructor.fromIdentifiers);
|
|
16
|
+
const origin = points[identifiers.startPointIndex];
|
|
17
|
+
const vecs = [
|
|
18
|
+
vector_1.VectorConstructor.fromPoints(points[identifiers.firstVectorPointsIndexes[0]], points[identifiers.firstVectorPointsIndexes[1]]),
|
|
19
|
+
vector_1.VectorConstructor.fromPoints(points[identifiers.secondVectorPointsIndexes[0]], points[identifiers.secondVectorPointsIndexes[1]]),
|
|
20
|
+
];
|
|
21
|
+
return vecs[0].add(vecs[1]).getEndPoint(origin, "K");
|
|
22
|
+
};
|
|
23
|
+
const getInstruction = (identifiers) => {
|
|
24
|
+
const { startPointIndex, firstVectorPointsIndexes, secondVectorPointsIndexes, } = identifiers;
|
|
25
|
+
const origin = identifiers.points[startPointIndex].name;
|
|
26
|
+
const firstVec = `${identifiers.points[firstVectorPointsIndexes[0]].name}${identifiers.points[firstVectorPointsIndexes[1]].name}`;
|
|
27
|
+
const secondVec = `${identifiers.points[secondVectorPointsIndexes[0]].name}${identifiers.points[secondVectorPointsIndexes[1]].name}`;
|
|
28
|
+
return `Placer le point $K$ tel que :
|
|
29
|
+
|
|
30
|
+
$$
|
|
31
|
+
\\overrightarrow{${origin}K} = \\overrightarrow{${firstVec}} + \\overrightarrow{${secondVec}}
|
|
32
|
+
$$`;
|
|
33
|
+
};
|
|
34
|
+
// const getHint: GetHint<Identifiers> = (identifiers) => {};
|
|
35
|
+
// const getCorrection: GetCorrection<Identifiers> = (identifiers) => {};
|
|
36
|
+
const getGGBAnswer = (identifiers) => {
|
|
37
|
+
return getSolutionPoint(identifiers).toGGBCommand();
|
|
38
|
+
};
|
|
39
|
+
const getStudentGGBOptions = (identifiers) => {
|
|
40
|
+
const commands = identifiers.points.flatMap((p) => point_1.PointConstructor.fromIdentifiers(p).toGGBCommand());
|
|
41
|
+
const ggb = new geogebraConstructor_1.GeogebraConstructor({
|
|
42
|
+
commands,
|
|
43
|
+
customToolBar: (0, toolBarConstructor_1.toolBarConstructor)({
|
|
44
|
+
point: true,
|
|
45
|
+
}),
|
|
46
|
+
hideAxes: true,
|
|
47
|
+
});
|
|
48
|
+
const points = identifiers.points.map((p) => point_1.PointConstructor.fromIdentifiers(p));
|
|
49
|
+
const solutionPoint = getSolutionPoint(identifiers);
|
|
50
|
+
return ggb.getOptions({
|
|
51
|
+
coords: ggb.getCoordsForPoints([...points, solutionPoint]),
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
const isGGBAnswerValid = (ans, { ggbAnswer, ...identifiers }) => {
|
|
55
|
+
const studentAns = ans.filter((c) => !["A", "B", "C", "D"].includes(c[0]));
|
|
56
|
+
if (studentAns.length !== 1)
|
|
57
|
+
return false;
|
|
58
|
+
const solutionPoint = getSolutionPoint(identifiers);
|
|
59
|
+
const pointCoords = (0, parseGGBPoints_1.parseGGBPoints)(studentAns).map((p) => (0, ggbPointToCoords_1.ggbPointToCoords)(p));
|
|
60
|
+
if (pointCoords.length !== 1)
|
|
61
|
+
return false;
|
|
62
|
+
return (new point_1.Point("K", pointCoords[0].x, pointCoords[0].y).distanceTo(solutionPoint) < 1);
|
|
63
|
+
};
|
|
64
|
+
const getTraceVectorSumQuestion = () => {
|
|
65
|
+
const names = ["A", "B", "C", "D"];
|
|
66
|
+
let points = [];
|
|
67
|
+
let startPointIndex;
|
|
68
|
+
let firstVectorPointsIndexes;
|
|
69
|
+
let secondVectorPointsIndexes;
|
|
70
|
+
while (true) {
|
|
71
|
+
points = [];
|
|
72
|
+
points.push(...point_1.PointConstructor.randomDifferent(4, {
|
|
73
|
+
minDistance: 2,
|
|
74
|
+
names,
|
|
75
|
+
minDistanceToOrigin: 3,
|
|
76
|
+
}));
|
|
77
|
+
startPointIndex = (0, randint_1.randint)(0, names.length);
|
|
78
|
+
firstVectorPointsIndexes = (0, random_1.randomMany)([0, 1, 2, 3], 2);
|
|
79
|
+
secondVectorPointsIndexes = (0, doWhile_1.doWhile)(() => (0, random_1.randomMany)([0, 1, 2, 3], 2), (arr) => arr[0] === firstVectorPointsIndexes[0] &&
|
|
80
|
+
arr[1] === firstVectorPointsIndexes[1]);
|
|
81
|
+
//AC = AB+BC
|
|
82
|
+
const firstVec = vector_1.VectorConstructor.fromPoints(points[firstVectorPointsIndexes[0]], points[firstVectorPointsIndexes[1]]);
|
|
83
|
+
const second = vector_1.VectorConstructor.fromPoints(points[secondVectorPointsIndexes[0]], points[secondVectorPointsIndexes[1]]);
|
|
84
|
+
const endPoint = firstVec
|
|
85
|
+
.add(second)
|
|
86
|
+
.getEndPoint(points[startPointIndex], "K");
|
|
87
|
+
if (endPoint.distanceTo(new point_1.Point("O", 0, 0)) > 10 ||
|
|
88
|
+
points.some((p) => p.equals(endPoint)))
|
|
89
|
+
continue;
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
const identifiers = {
|
|
93
|
+
firstVectorPointsIndexes,
|
|
94
|
+
points: points.map((p) => p.toIdentifiers()),
|
|
95
|
+
secondVectorPointsIndexes,
|
|
96
|
+
startPointIndex,
|
|
97
|
+
};
|
|
98
|
+
const question = {
|
|
99
|
+
ggbAnswer: getGGBAnswer(identifiers),
|
|
100
|
+
instruction: getInstruction(identifiers),
|
|
101
|
+
studentGgbOptions: getStudentGGBOptions(identifiers),
|
|
102
|
+
identifiers,
|
|
103
|
+
// hint: getHint(identifiers),
|
|
104
|
+
// correction: getCorrection(identifiers),
|
|
105
|
+
};
|
|
106
|
+
return question;
|
|
107
|
+
};
|
|
108
|
+
exports.traceVectorSum = {
|
|
109
|
+
id: "traceVectorSum",
|
|
110
|
+
label: "Placer un point défini par une somme de vecteurs",
|
|
111
|
+
isSingleStep: true,
|
|
112
|
+
generator: (nb, opts) => (0, getDistinctQuestions_1.getDistinctQuestions)(() => getTraceVectorSumQuestion(opts), nb),
|
|
113
|
+
ggbTimer: 60,
|
|
114
|
+
isGGBAnswerValid,
|
|
115
|
+
subject: "Mathématiques",
|
|
116
|
+
// getHint,
|
|
117
|
+
getInstruction,
|
|
118
|
+
// getCorrection,
|
|
119
|
+
getGGBAnswer,
|
|
120
|
+
getStudentGGBOptions,
|
|
121
|
+
answerType: "GGB",
|
|
122
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toGGBCommandsProps.d.ts","sourceRoot":"","sources":["../../../../src/exercises/utils/geogebra/toGGBCommandsProps.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC"}
|
|
1
|
+
{"version":3,"file":"toGGBCommandsProps.d.ts","sourceRoot":"","sources":["../../../../src/exercises/utils/geogebra/toGGBCommandsProps.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,CAAC"}
|
|
@@ -5,14 +5,14 @@ const toolBarConstructor = (options) => {
|
|
|
5
5
|
let customToolBar = "0||6";
|
|
6
6
|
if (options.point)
|
|
7
7
|
customToolBar += "||1";
|
|
8
|
+
if (options.intersect)
|
|
9
|
+
customToolBar += "||5";
|
|
8
10
|
if (options.join)
|
|
9
11
|
customToolBar += "||2";
|
|
10
12
|
if (options.parallel)
|
|
11
13
|
customToolBar += "||3";
|
|
12
14
|
if (options.orthogonal)
|
|
13
15
|
customToolBar += "||4";
|
|
14
|
-
if (options.intersect)
|
|
15
|
-
customToolBar += "||5";
|
|
16
16
|
if (options.vector)
|
|
17
17
|
customToolBar += "||7";
|
|
18
18
|
if (options.circleTwoPoints)
|
|
@@ -4,7 +4,7 @@ exports.parseGGBPoints = void 0;
|
|
|
4
4
|
const deleteObjectNamesFromAnswer_1 = require("../deleteObjectNamesFromAnswer");
|
|
5
5
|
const parseGGBPoints = (commands) => {
|
|
6
6
|
const unnamed = (0, deleteObjectNamesFromAnswer_1.deleteObjectNamesFromAnswer)(commands);
|
|
7
|
-
const re =
|
|
7
|
+
const re = /^\([^,]*,[^)]*\)/;
|
|
8
8
|
return unnamed.filter((cmd) => !!cmd.match(re)?.length);
|
|
9
9
|
};
|
|
10
10
|
exports.parseGGBPoints = parseGGBPoints;
|
package/lib/index.d.ts
CHANGED
|
@@ -1117,6 +1117,25 @@ declare const mathExercises: (Exercise<{
|
|
|
1117
1117
|
AB: number;
|
|
1118
1118
|
AC: number;
|
|
1119
1119
|
trigoPoint: string;
|
|
1120
|
+
}, {}> | Exercise<{
|
|
1121
|
+
points: import("./math/geometry/point").PointIdentifiers[];
|
|
1122
|
+
startPointIndex: number;
|
|
1123
|
+
firstVectorPointsIndexes: number[];
|
|
1124
|
+
secondVectorPointsIndexes: number[];
|
|
1125
|
+
}, {}> | Exercise<{
|
|
1126
|
+
points: import("./math/geometry/point").PointIdentifiers[];
|
|
1127
|
+
startPointIndex: number;
|
|
1128
|
+
firstVectorPointsIndexes: number[];
|
|
1129
|
+
secondVectorPointsIndexes: number[];
|
|
1130
|
+
}, {}> | Exercise<{
|
|
1131
|
+
points: import("./math/geometry/point").PointIdentifiers[];
|
|
1132
|
+
startPointIndex: number;
|
|
1133
|
+
vectorPointsIndexes: number[];
|
|
1134
|
+
}, {}> | Exercise<{
|
|
1135
|
+
points: import("./math/geometry/point").PointIdentifiers[];
|
|
1136
|
+
startPointIndex: number;
|
|
1137
|
+
vectorPointsIndexes: number[];
|
|
1138
|
+
coeff: number;
|
|
1120
1139
|
}, {}> | Exercise<{
|
|
1121
1140
|
trinom: number[];
|
|
1122
1141
|
}, {}> | Exercise<{
|
|
@@ -1167,6 +1186,9 @@ declare const mathExercises: (Exercise<{
|
|
|
1167
1186
|
}, {
|
|
1168
1187
|
useVector: boolean;
|
|
1169
1188
|
}> | Exercise<{
|
|
1189
|
+
point: import("./math/geometry/point").PointIdentifiers;
|
|
1190
|
+
line: import("./math/geometry/line").LineIdentifiers;
|
|
1191
|
+
}, {}> | Exercise<{
|
|
1170
1192
|
type: number;
|
|
1171
1193
|
commands: string[];
|
|
1172
1194
|
}, {}> | Exercise<{
|
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
|
+
{"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,aA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAA6B,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudPoints.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/CloudPoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAoB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAGjE,OAAO,EAAE,UAAU,EAAgB,MAAM,qCAAqC,CAAC;AAM/E,MAAM,MAAM,sBAAsB,GAAG;IACnC,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;CACvC,CAAC;AACF,8BAAsB,sBAAsB;IAC1C,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"CloudPoints.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/CloudPoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAoB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAGjE,OAAO,EAAE,UAAU,EAAgB,MAAM,qCAAqC,CAAC;AAM/E,MAAM,MAAM,sBAAsB,GAAG;IACnC,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;CACvC,CAAC;AACF,8BAAsB,sBAAsB;IAC1C,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM;IAU9B,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM;CAyBrC;AAED,qBAAa,WAAW;IACtB,MAAM,EAAE,KAAK,EAAE,CAAC;gBAEJ,MAAM,EAAE,KAAK,EAAE;IAI3B,aAAa,IAAI,sBAAsB;IAMvC,kBAAkB,IAAI,SAAS;IA8C/B,mBAAmB;CAsBpB"}
|
|
@@ -16,7 +16,7 @@ class CloudPointsConstructor {
|
|
|
16
16
|
for (let i = 0; i < nbPoints; i++) {
|
|
17
17
|
names.push(`a${i}`);
|
|
18
18
|
}
|
|
19
|
-
return new CloudPoints(point_1.PointConstructor.randomDifferent(names));
|
|
19
|
+
return new CloudPoints(point_1.PointConstructor.randomDifferent(nbPoints, { names }));
|
|
20
20
|
}
|
|
21
21
|
static randomLinear(nbPoints) {
|
|
22
22
|
const points = [];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ToGGBCommandsProps } from "../../exercises/utils/geogebra/toGGBCommandsProps";
|
|
2
|
+
import { Point } from "./point";
|
|
3
|
+
export declare class Circle {
|
|
4
|
+
center: Point;
|
|
5
|
+
point: Point;
|
|
6
|
+
name: string;
|
|
7
|
+
constructor(center: Point, point: Point, name?: string);
|
|
8
|
+
toGGBCommands(shouldBuildPoints: boolean, { isFixed, showLabel, showUnderlyingPointsLabel, showUnderlyingPoints, }?: ToGGBCommandsProps): string[];
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=circle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"circle.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/circle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mDAAmD,CAAC;AACvF,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,qBAAa,MAAM;IACjB,MAAM,EAAE,KAAK,CAAC;IACd,KAAK,EAAE,KAAK,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;gBACD,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,MAAM;IAMtD,aAAa,CACX,iBAAiB,EAAE,OAAO,EAC1B,EACE,OAAc,EACd,SAAiB,EACjB,yBAAgC,EAChC,oBAA2B,GAC5B,GAAE,kBAAuB;CAkC7B"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Circle = void 0;
|
|
4
|
+
class Circle {
|
|
5
|
+
constructor(center, point, name) {
|
|
6
|
+
this.center = center;
|
|
7
|
+
this.point = point;
|
|
8
|
+
this.name = name ?? "C";
|
|
9
|
+
}
|
|
10
|
+
toGGBCommands(shouldBuildPoints, { isFixed = true, showLabel = false, showUnderlyingPointsLabel = true, showUnderlyingPoints = true, } = {}) {
|
|
11
|
+
const commands = [];
|
|
12
|
+
if (shouldBuildPoints) {
|
|
13
|
+
const ACommands = this.center.toGGBCommand({
|
|
14
|
+
isFixed,
|
|
15
|
+
showLabel: showUnderlyingPointsLabel,
|
|
16
|
+
});
|
|
17
|
+
const BCommands = this.point.toGGBCommand({
|
|
18
|
+
isFixed,
|
|
19
|
+
showLabel: showUnderlyingPointsLabel,
|
|
20
|
+
});
|
|
21
|
+
commands.push(...ACommands, ...BCommands, `${this.name}=Circle(${this.center.name},${this.point.name})`);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
commands.push(`${this.name}=Circle(${this.center.toMathString()},${this.point.toMathString()})`);
|
|
25
|
+
}
|
|
26
|
+
commands.push(...[
|
|
27
|
+
`SetFixed(${this.name},${isFixed ? "true" : "false"})`,
|
|
28
|
+
`ShowLabel(${this.name},${showLabel ? "true" : "false"})`,
|
|
29
|
+
]);
|
|
30
|
+
return commands;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.Circle = Circle;
|
|
@@ -49,7 +49,7 @@ export declare class Line {
|
|
|
49
49
|
};
|
|
50
50
|
toTex(): string;
|
|
51
51
|
toTexNoLeftRight(): string;
|
|
52
|
-
toGGBCommands(shouldBuildPoints: boolean, { isFixed, showLabel, showUnderlyingPointsLabel, }?: ToGGBCommandsProps): string[];
|
|
52
|
+
toGGBCommands(shouldBuildPoints: boolean, { isFixed, showLabel, showUnderlyingPointsLabel, showUnderlyingPoints, }?: ToGGBCommandsProps): string[];
|
|
53
53
|
intersect(line: Line, intersectName?: string): Point;
|
|
54
54
|
}
|
|
55
55
|
//# sourceMappingURL=line.d.ts.map
|
|
@@ -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;
|
|
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,sCAAs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AM;IAK7C,aAAa,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,MAAM;IAW7C,cAAc,CAAC,IAAI,CAAC,EAAE,MAAM;IAa5B,WAAW,MAAO,MAAM,KAAK,KAAK,KAAG,SAAS,CAmB5C;IAEF,oBAAoB,IAAI,SAAS;IAuBjC,WAAW;IAMX,iBAAiB;;;;;IAcjB,KAAK;IAGL,gBAAgB;IAIhB,aAAa,CACX,iBAAiB,EAAE,OAAO,EAC1B,EACE,OAAc,EACd,SAAiB,EACjB,yBAAgC,EAChC,oBAA2B,GAC5B,GAAE,kBAAuB;IAmC5B,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,CAAC,EAAE,MAAM;CAW7C"}
|
|
@@ -17,7 +17,9 @@ const vector_1 = require("./vector");
|
|
|
17
17
|
class LineConstructor {
|
|
18
18
|
static random(name) {
|
|
19
19
|
const names = (0, randomSegmentName_1.randomSegmentName)();
|
|
20
|
-
const points = point_1.PointConstructor.randomDifferent(
|
|
20
|
+
const points = point_1.PointConstructor.randomDifferent(2, {
|
|
21
|
+
names: names.split(""),
|
|
22
|
+
});
|
|
21
23
|
return new Line(points[0], points[1], name);
|
|
22
24
|
}
|
|
23
25
|
static fromIdentifiers(identifiers) {
|
|
@@ -170,12 +172,8 @@ class Line {
|
|
|
170
172
|
toTexNoLeftRight() {
|
|
171
173
|
return this.name.replace("\\left", "").replace("\\right", "");
|
|
172
174
|
}
|
|
173
|
-
toGGBCommands(shouldBuildPoints, { isFixed = true, showLabel = false, showUnderlyingPointsLabel = true, } = {}) {
|
|
174
|
-
const commands = [
|
|
175
|
-
`${this.ggbName}=Line(${this.pointA.name},${this.pointB.name})`,
|
|
176
|
-
`SetFixed(${this.ggbName},${isFixed ? "true" : "false"})`,
|
|
177
|
-
`ShowLabel(${this.ggbName},${showLabel ? "true" : "false"})`,
|
|
178
|
-
];
|
|
175
|
+
toGGBCommands(shouldBuildPoints, { isFixed = true, showLabel = false, showUnderlyingPointsLabel = true, showUnderlyingPoints = true, } = {}) {
|
|
176
|
+
const commands = [];
|
|
179
177
|
if (shouldBuildPoints) {
|
|
180
178
|
const ACommands = this.pointA.toGGBCommand({
|
|
181
179
|
isFixed,
|
|
@@ -185,8 +183,15 @@ class Line {
|
|
|
185
183
|
isFixed,
|
|
186
184
|
showLabel: showUnderlyingPointsLabel,
|
|
187
185
|
});
|
|
188
|
-
commands.
|
|
186
|
+
commands.push(...ACommands, ...BCommands, `${this.ggbName}=Line(${this.pointA.name},${this.pointB.name})`);
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
commands.push(`${this.ggbName}=Line(${this.pointA.toMathString()},${this.pointB.toMathString()})`);
|
|
189
190
|
}
|
|
191
|
+
commands.push(...[
|
|
192
|
+
`SetFixed(${this.ggbName},${isFixed ? "true" : "false"})`,
|
|
193
|
+
`ShowLabel(${this.ggbName},${showLabel ? "true" : "false"})`,
|
|
194
|
+
]);
|
|
190
195
|
return commands;
|
|
191
196
|
}
|
|
192
197
|
intersect(line, intersectName) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AlgebraicNode } from "../../tree/nodes/algebraicNode";
|
|
2
2
|
import { ToGGBCommandsProps } from "../../exercises/utils/geogebra/toGGBCommandsProps";
|
|
3
3
|
import { NodeIdentifiers } from "../../tree/nodes/nodeConstructor";
|
|
4
|
+
import { Line } from "./line";
|
|
4
5
|
export type PointIdentifiers = {
|
|
5
6
|
id: "point";
|
|
6
7
|
name: string;
|
|
@@ -8,6 +9,8 @@ export type PointIdentifiers = {
|
|
|
8
9
|
y: NodeIdentifiers;
|
|
9
10
|
};
|
|
10
11
|
export declare abstract class PointConstructor {
|
|
12
|
+
static randomName(excludes?: string[]): string;
|
|
13
|
+
static randomNames(count: number): string[];
|
|
11
14
|
static origin(name?: string): Point;
|
|
12
15
|
static random(name: string, min?: number, max?: number): Point;
|
|
13
16
|
static fromIdentifiers(identifiers: PointIdentifiers): Point;
|
|
@@ -15,14 +18,18 @@ export declare abstract class PointConstructor {
|
|
|
15
18
|
spacing?: number;
|
|
16
19
|
coefficient?: number;
|
|
17
20
|
}): Point;
|
|
18
|
-
static randomDifferent(
|
|
21
|
+
static randomDifferent(count: number, { names, minDistance, minDistanceToOrigin, }: {
|
|
22
|
+
names?: string[];
|
|
23
|
+
minDistance?: number;
|
|
24
|
+
minDistanceToOrigin?: number;
|
|
25
|
+
}): Point[];
|
|
19
26
|
static fromGGBCommand(str: string): Point;
|
|
20
27
|
}
|
|
21
28
|
export declare class Point {
|
|
22
29
|
name: string;
|
|
23
30
|
x: AlgebraicNode;
|
|
24
31
|
y: AlgebraicNode;
|
|
25
|
-
constructor(name: string, x: AlgebraicNode, y: AlgebraicNode);
|
|
32
|
+
constructor(name: string, x: AlgebraicNode | number, y: AlgebraicNode | number);
|
|
26
33
|
toTex(): string;
|
|
27
34
|
toIdentifiers(): PointIdentifiers;
|
|
28
35
|
toTexWithCoords(): string;
|
|
@@ -37,5 +44,7 @@ export declare class Point {
|
|
|
37
44
|
toGGBCommand({ isFixed, showLabel, style, size, color, }?: ToGGBCommandsProps): string[];
|
|
38
45
|
rotate(angle: number, center: Point): Point;
|
|
39
46
|
centralSymetric(center: Point, name?: string): Point;
|
|
47
|
+
project(line: Line, name?: string): Point;
|
|
48
|
+
axialSymetric(line: Line, name?: string): Point;
|
|
40
49
|
}
|
|
41
50
|
//# 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,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAG/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mDAAmD,CAAC;AACvF,OAAO,EAEL,eAAe,EAChB,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/point.ts"],"names":[],"mappings":"AAIA,OAAO,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C,EAAE,aAAa,CAAC;IACjB,CAAC,EAAE,aAAa,CAAC;gBAEf,IAAI,EAAE,MAAM,EACZ,CAAC,EAAE,aAAa,GAAG,MAAM,EACzB,CAAC,EAAE,aAAa,GAAG,MAAM;IAO3B,KAAK,IAAI,MAAM;IAGf,aAAa,IAAI,gBAAgB;IAQjC,eAAe,IAAI,MAAM;IAGzB,QAAQ,IAAI,MAAM;IAIlB,UAAU,IAAI,MAAM;IAIpB,UAAU,IAAI,MAAM;IAIpB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,SAAM,GAAG,KAAK;IAQrC,UAAU,CAAC,CAAC,EAAE,KAAK,GAAG,MAAM;IAM5B,MAAM,CAAC,CAAC,EAAE,KAAK,GAAG,OAAO;IAGzB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK;IAK5B,YAAY;IAGZ,YAAY,CAAC,EACX,OAAc,EACd,SAAgB,EAChB,KAAK,EACL,IAAI,EACJ,KAAK,GACN,GAAE,kBAAuB;IAiB1B,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK;IAiBnC,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,SAAkB;IAIrD,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,SAAkB;IAI1C,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,SAAkB;CAIjD"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Point = exports.PointConstructor = void 0;
|
|
4
|
-
const node_1 = require("../../tree/nodes/node");
|
|
5
4
|
const numberNode_1 = require("../../tree/nodes/numbers/numberNode");
|
|
6
|
-
const rational_1 = require("../numbers/rationals/rational");
|
|
7
5
|
const vector_1 = require("./vector");
|
|
8
6
|
const randint_1 = require("../utils/random/randint");
|
|
9
7
|
const nodeConstructor_1 = require("../../tree/nodes/nodeConstructor");
|
|
@@ -11,7 +9,18 @@ const randfloat_1 = require("../utils/random/randfloat");
|
|
|
11
9
|
const substractNode_1 = require("../../tree/nodes/operators/substractNode");
|
|
12
10
|
const multiplyNode_1 = require("../../tree/nodes/operators/multiplyNode");
|
|
13
11
|
const addNode_1 = require("../../tree/nodes/operators/addNode");
|
|
12
|
+
const randomLetter_1 = require("../../utils/strings/randomLetter");
|
|
13
|
+
const fractionNode_1 = require("../../tree/nodes/operators/fractionNode");
|
|
14
14
|
class PointConstructor {
|
|
15
|
+
static randomName(excludes) {
|
|
16
|
+
return (0, randomLetter_1.randomLetter)(true, ["O", ...(excludes ?? [])]);
|
|
17
|
+
}
|
|
18
|
+
static randomNames(count) {
|
|
19
|
+
const res = [];
|
|
20
|
+
for (let i = 0; i < count; i++)
|
|
21
|
+
res.push(PointConstructor.randomName(res));
|
|
22
|
+
return res;
|
|
23
|
+
}
|
|
15
24
|
static origin(name = "O") {
|
|
16
25
|
return new Point(name, new numberNode_1.NumberNode(0), new numberNode_1.NumberNode(0));
|
|
17
26
|
}
|
|
@@ -29,18 +38,19 @@ class PointConstructor {
|
|
|
29
38
|
const point = vector.getEndPoint(A, name);
|
|
30
39
|
return point;
|
|
31
40
|
}
|
|
32
|
-
static randomDifferent(names) {
|
|
41
|
+
static randomDifferent(count, { names, minDistance, minDistanceToOrigin, }) {
|
|
33
42
|
const res = [];
|
|
34
43
|
const points = [];
|
|
35
|
-
|
|
44
|
+
const pointNames = names ?? PointConstructor.randomNames(count);
|
|
45
|
+
for (let i = 0; i < count; i++) {
|
|
36
46
|
let x;
|
|
37
47
|
let y;
|
|
38
48
|
do {
|
|
39
|
-
x = (0, randint_1.randint)(-10,
|
|
40
|
-
y = (0, randint_1.randint)(-10,
|
|
41
|
-
} while (points.some((point) => point[0]
|
|
49
|
+
x = (0, randint_1.randint)(-(minDistanceToOrigin ?? 10), (minDistanceToOrigin ?? 10) + 1);
|
|
50
|
+
y = (0, randint_1.randint)(-(minDistanceToOrigin ?? 10), (minDistanceToOrigin ?? 10) + 1);
|
|
51
|
+
} while (points.some((point) => Math.hypot(point[0] - x, point[1] - y) < (minDistance ?? 1)));
|
|
42
52
|
points.push([x, y]);
|
|
43
|
-
res.push(new Point(
|
|
53
|
+
res.push(new Point(pointNames[i], new numberNode_1.NumberNode(x), new numberNode_1.NumberNode(y)));
|
|
44
54
|
}
|
|
45
55
|
return res;
|
|
46
56
|
}
|
|
@@ -59,8 +69,8 @@ exports.PointConstructor = PointConstructor;
|
|
|
59
69
|
class Point {
|
|
60
70
|
constructor(name, x, y) {
|
|
61
71
|
this.name = name;
|
|
62
|
-
this.x = x;
|
|
63
|
-
this.y = y;
|
|
72
|
+
this.x = typeof x === "number" ? x.toTree() : x;
|
|
73
|
+
this.y = typeof y === "number" ? y.toTree() : y;
|
|
64
74
|
}
|
|
65
75
|
toTex() {
|
|
66
76
|
return `${this.name}`;
|
|
@@ -86,15 +96,7 @@ class Point {
|
|
|
86
96
|
return this.y.evaluate();
|
|
87
97
|
}
|
|
88
98
|
midpoint(B, name = "I") {
|
|
89
|
-
|
|
90
|
-
if (types.some((type) => type !== node_1.NodeType.number)) {
|
|
91
|
-
throw Error("general midpoint not implemented yet");
|
|
92
|
-
}
|
|
93
|
-
return new Point(name, new rational_1.Rational(this.x.value + B.x.value, 2)
|
|
94
|
-
.simplify()
|
|
95
|
-
.toTree(), new rational_1.Rational(this.y.value + B.y.value, 2)
|
|
96
|
-
.simplify()
|
|
97
|
-
.toTree());
|
|
99
|
+
return new Point(name, (0, fractionNode_1.frac)((0, addNode_1.add)(this.x, B.x), 2).simplify(), (0, fractionNode_1.frac)((0, addNode_1.add)(this.y, B.y), 2).simplify());
|
|
98
100
|
}
|
|
99
101
|
distanceTo(B) {
|
|
100
102
|
const dx = this.getXnumber() - B.getXnumber();
|
|
@@ -137,8 +139,16 @@ class Point {
|
|
|
137
139
|
return new Point(this.name, (0, substractNode_1.substract)((0, multiplyNode_1.multiply)(cos, this.x).simplify(), (0, multiplyNode_1.multiply)(sin, this.y).simplify()).simplify(), (0, addNode_1.add)((0, multiplyNode_1.multiply)(sin, this.x).simplify(), (0, multiplyNode_1.multiply)(cos, this.y).simplify()).simplify());
|
|
138
140
|
}
|
|
139
141
|
centralSymetric(center, name = this.name + "'") {
|
|
140
|
-
const vec = vector_1.VectorConstructor.fromPoints(this, center)
|
|
142
|
+
const vec = vector_1.VectorConstructor.fromPoints(this, center);
|
|
141
143
|
return vec.getEndPoint(center, name);
|
|
142
144
|
}
|
|
145
|
+
project(line, name = this.name + "'") {
|
|
146
|
+
const perp = line.getPerpendicular(this);
|
|
147
|
+
return perp.intersect(line, name);
|
|
148
|
+
}
|
|
149
|
+
axialSymetric(line, name = this.name + "'") {
|
|
150
|
+
const projOrtho = this.project(line);
|
|
151
|
+
return this.centralSymetric(projOrtho, name);
|
|
152
|
+
}
|
|
143
153
|
}
|
|
144
154
|
exports.Point = Point;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ray.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/ray.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mDAAmD,CAAC;AAEvF,OAAO,EAAE,KAAK,EAAoB,MAAM,SAAS,CAAC;AAElD,8BAAsB,cAAc;IAClC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"ray.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/ray.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mDAAmD,CAAC;AAEvF,OAAO,EAAE,KAAK,EAAoB,MAAM,SAAS,CAAC;AAElD,8BAAsB,cAAc;IAClC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM;CAO5B;AAED,qBAAa,GAAG;IACd,UAAU,EAAE,KAAK,CAAC;IAClB,WAAW,EAAE,KAAK,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;gBACJ,UAAU,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,MAAM;IAOhE,KAAK;IAGL,aAAa,CACX,iBAAiB,EAAE,OAAO,EAC1B,EACE,OAAc,EACd,SAAiB,EACjB,yBAAgC,GACjC,GAAE,kBAAuB;CAoB7B"}
|
package/lib/math/geometry/ray.js
CHANGED
|
@@ -6,7 +6,9 @@ const point_1 = require("./point");
|
|
|
6
6
|
class RayConstructor {
|
|
7
7
|
static random(name) {
|
|
8
8
|
const names = (0, randomSegmentName_1.randomSegmentName)();
|
|
9
|
-
const points = point_1.PointConstructor.randomDifferent(
|
|
9
|
+
const points = point_1.PointConstructor.randomDifferent(2, {
|
|
10
|
+
names: names.split(""),
|
|
11
|
+
});
|
|
10
12
|
return new Ray(points[0], points[1], name);
|
|
11
13
|
}
|
|
12
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"segment.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/segment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mDAAmD,CAAC;AAEvF,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE/D,OAAO,EAEL,eAAe,EAEhB,MAAM,kCAAkC,CAAC;AAK1C,OAAO,EAAE,KAAK,EAAoB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,EAAE,MAAM,EAAqB,MAAM,UAAU,CAAC;AAErD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,gBAAgB,CAAC;IACzB,MAAM,EAAE,gBAAgB,CAAC;IACzB,KAAK,CAAC,EAAE,uBAAuB,CAAC;CACjC,CAAC;AACF,8BAAsB,kBAAkB;IACtC,MAAM,CAAC,MAAM;
|
|
1
|
+
{"version":3,"file":"segment.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/segment.ts"],"names":[],"mappings":"AA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AAE,OAAO,EAC1B,EACE,OAAc,EACd,SAAiB,EACjB,yBAAgC,EAChC,UAAkB,EAClB,KAAK,GACN,GAAE,kBAAuB;IA8B5B,QAAQ,CAAC,KAAK,EAAE,KAAK;IAOrB,QAAQ;CAGT"}
|
|
@@ -13,7 +13,9 @@ const vector_1 = require("./vector");
|
|
|
13
13
|
class SegmentConstructor {
|
|
14
14
|
static random() {
|
|
15
15
|
const name = (0, randomSegmentName_1.randomSegmentName)();
|
|
16
|
-
const points = point_1.PointConstructor.randomDifferent(
|
|
16
|
+
const points = point_1.PointConstructor.randomDifferent(2, {
|
|
17
|
+
names: name.split(""),
|
|
18
|
+
});
|
|
17
19
|
return new Segment(points[0], points[1]);
|
|
18
20
|
}
|
|
19
21
|
static fromIdentifiers(identifiers) {
|
|
@@ -21,6 +21,7 @@ export declare class Vector {
|
|
|
21
21
|
opposite(): Vector;
|
|
22
22
|
scalarProduct(v: Vector): AlgebraicNode;
|
|
23
23
|
add(v: Vector): Vector;
|
|
24
|
+
substract(v: Vector): Vector;
|
|
24
25
|
getNorm(): AlgebraicNode;
|
|
25
26
|
getEndPoint(startPoint: Point, name?: string): Point;
|
|
26
27
|
equals(v: Vector): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/vector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAgB/D,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,8BAAsB,iBAAiB;IACrC,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,GAAG,MAAM;IAOpD,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,UAAO,GAAG,MAAM;CAOtD;AAED,qBAAa,MAAM;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,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I,MAAM;IAM3B,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO;IAK9B,sBAAsB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO;IAI1C,kBAAkB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO;IAItC,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,aAAa;IAIrC,KAAK,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,MAAM;IAOrC,QAAQ;IAGR,aAAa,CAAC,CAAC,EAAE,MAAM;IAgBvB,GAAG,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;IAWtB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM;IAG5B,OAAO,IAAI,aAAa;IAUxB,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,MAAM;IAO5C,MAAM,CAAC,CAAC,EAAE,MAAM;IAIhB,YAAY;IAMZ,YAAY;IAOZ,aAAa;CAGd"}
|
|
@@ -80,6 +80,9 @@ class Vector {
|
|
|
80
80
|
const resultY = new addNode_1.AddNode(this.y, y);
|
|
81
81
|
return new Vector(`${this.name}+${v.name}`, resultX.simplify(), resultY.simplify());
|
|
82
82
|
}
|
|
83
|
+
substract(v) {
|
|
84
|
+
return this.add(v.opposite());
|
|
85
|
+
}
|
|
83
86
|
getNorm() {
|
|
84
87
|
const xValue = this.x.simplify().value;
|
|
85
88
|
const yValue = this.y.simplify().value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"random.d.ts","sourceRoot":"","sources":["../../../src/utils/alea/random.ts"],"names":[],"mappings":"AAEA,wBAAgB,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,KAMnD"}
|
|
1
|
+
{"version":3,"file":"random.d.ts","sourceRoot":"","sources":["../../../src/utils/alea/random.ts"],"names":[],"mappings":"AAEA,wBAAgB,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,KAMnD;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,OAUtE"}
|
package/lib/utils/alea/random.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.random = void 0;
|
|
3
|
+
exports.randomMany = exports.random = void 0;
|
|
4
4
|
function random(array, excludes) {
|
|
5
5
|
if (excludes?.length) {
|
|
6
6
|
const filtered = array.filter((t) => !excludes.includes(t));
|
|
@@ -9,3 +9,15 @@ function random(array, excludes) {
|
|
|
9
9
|
return array[Math.floor(Math.random() * array.length)];
|
|
10
10
|
}
|
|
11
11
|
exports.random = random;
|
|
12
|
+
function randomMany(array, count, excludes) {
|
|
13
|
+
const res = [];
|
|
14
|
+
let i = 0;
|
|
15
|
+
while (res.length < count) {
|
|
16
|
+
if (i > 10000)
|
|
17
|
+
throw new Error("randomMany malformed");
|
|
18
|
+
i++;
|
|
19
|
+
res.push(random(array, [...res, ...(excludes ?? [])]));
|
|
20
|
+
}
|
|
21
|
+
return res;
|
|
22
|
+
}
|
|
23
|
+
exports.randomMany = randomMany;
|