math-exercises 2.2.69 → 2.2.70
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/arithmetics/divisorsList.d.ts.map +1 -1
- package/lib/exercises/math/calcul/arithmetics/divisorsList.js +2 -1
- package/lib/exercises/math/calcul/arithmetics/primeNumbers.d.ts.map +1 -1
- package/lib/exercises/math/calcul/arithmetics/primeNumbers.js +2 -1
- package/lib/exercises/math/calcul/fractions/fractionsOperations.d.ts.map +1 -1
- package/lib/exercises/math/calcul/fractions/fractionsOperations.js +1 -0
- package/lib/exercises/math/calculLitteral/equation/equationType1Exercise.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/equationType1Exercise.js +3 -6
- package/lib/exercises/math/calculLitteral/equation/equationType2Exercise.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/equationType2Exercise.js +3 -8
- package/lib/exercises/math/calculLitteral/equation/equationType3Exercise.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/equationType3Exercise.js +7 -9
- package/lib/exercises/math/calculLitteral/equation/equationType4Exercise.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/equation/equationType4Exercise.js +6 -19
- package/lib/exercises/math/calculLitteral/factorisation/factoByX.d.ts +8 -0
- package/lib/exercises/math/calculLitteral/factorisation/factoByX.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/factorisation/factoByX.js +146 -0
- package/lib/exercises/math/calculLitteral/factorisation/index.d.ts +1 -0
- package/lib/exercises/math/calculLitteral/factorisation/index.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/factorisation/index.js +1 -0
- package/lib/exercises/math/functions/absolute/absolueValueAffineEquation.d.ts.map +1 -1
- package/lib/exercises/math/functions/absolute/absolueValueAffineEquation.js +2 -5
- package/lib/exercises/math/functions/trinoms/coefficientsIdentification.js +3 -3
- package/lib/exercises/math/functions/trinoms/findSecondRoot.d.ts +2 -2
- package/lib/exercises/math/functions/trinoms/findSecondRoot.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/findSecondRoot.js +5 -5
- package/lib/exercises/math/functions/trinoms/rootsProduct.d.ts +2 -2
- package/lib/exercises/math/functions/trinoms/rootsProduct.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/rootsProduct.js +6 -6
- package/lib/exercises/math/functions/trinoms/rootsSum.d.ts +2 -2
- package/lib/exercises/math/functions/trinoms/rootsSum.d.ts.map +1 -1
- package/lib/exercises/math/functions/trinoms/rootsSum.js +7 -7
- package/lib/exercises/math/functions/trinoms/trinomSignFromRoots.js +6 -6
- package/lib/exercises/math/geometry/areas/rightTriangleArea.d.ts +3 -1
- package/lib/exercises/math/geometry/areas/rightTriangleArea.d.ts.map +1 -1
- package/lib/exercises/math/geometry/areas/rightTriangleArea.js +10 -22
- package/lib/exercises/math/geometry/areas/triangleArea.d.ts +6 -1
- package/lib/exercises/math/geometry/areas/triangleArea.d.ts.map +1 -1
- package/lib/exercises/math/geometry/areas/triangleArea.js +34 -48
- 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/pythagore/isTriangleRight.d.ts.map +1 -1
- package/lib/exercises/math/geometry/pythagore/pythagore.d.ts +0 -3
- package/lib/exercises/math/geometry/pythagore/pythagore.d.ts.map +1 -1
- package/lib/exercises/math/geometry/pythagore/pythagore.js +19 -25
- package/lib/exercises/math/geometry/pythagore/pythagoreCalcul.d.ts +1 -2
- package/lib/exercises/math/geometry/pythagore/pythagoreCalcul.d.ts.map +1 -1
- package/lib/exercises/math/geometry/pythagore/pythagoreCalcul.js +30 -65
- package/lib/exercises/math/geometry/quadrilaterals/index.d.ts +2 -0
- package/lib/exercises/math/geometry/quadrilaterals/index.d.ts.map +1 -0
- package/lib/exercises/math/geometry/quadrilaterals/index.js +17 -0
- package/lib/exercises/math/geometry/quadrilaterals/quadrilateralRecognition.d.ts +14 -0
- package/lib/exercises/math/geometry/quadrilaterals/quadrilateralRecognition.d.ts.map +1 -0
- package/lib/exercises/math/geometry/quadrilaterals/quadrilateralRecognition.js +221 -0
- package/lib/exercises/math/geometry/thales/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/thales/index.js +0 -1
- package/lib/exercises/math/geometry/thales/thales.js +2 -2
- package/lib/exercises/math/geometry/thales/thalesCalcul.d.ts +3 -4
- package/lib/exercises/math/geometry/thales/thalesCalcul.d.ts.map +1 -1
- package/lib/exercises/math/geometry/thales/thalesCalcul.js +69 -78
- package/lib/exercises/math/geometry/volumes/parallelepipedVolume.d.ts.map +1 -1
- package/lib/exercises/math/geometry/volumes/parallelepipedVolume.js +4 -3
- package/lib/exercises/math/geometry/volumes/sphereVolume.js +1 -1
- package/lib/exercises/math/trigonometry/trigonometry.d.ts +2 -3
- package/lib/exercises/math/trigonometry/trigonometry.d.ts.map +1 -1
- package/lib/exercises/math/trigonometry/trigonometry.js +32 -31
- package/lib/exercises/math/trigonometry/trigonometryAngleCalcul.d.ts +3 -2
- package/lib/exercises/math/trigonometry/trigonometryAngleCalcul.d.ts.map +1 -1
- package/lib/exercises/math/trigonometry/trigonometryAngleCalcul.js +18 -28
- package/lib/exercises/math/trigonometry/trigonometrySideCalcul.d.ts +5 -4
- package/lib/exercises/math/trigonometry/trigonometrySideCalcul.d.ts.map +1 -1
- package/lib/exercises/math/trigonometry/trigonometrySideCalcul.js +60 -56
- package/lib/exercises/pc/index.d.ts +0 -4
- package/lib/exercises/pc/index.d.ts.map +1 -1
- package/lib/exercises/pc/index.js +6 -4
- package/lib/exercises/utils/geogebra/toGGBCommandsProps.d.ts +1 -0
- package/lib/exercises/utils/geogebra/toGGBCommandsProps.d.ts.map +1 -1
- package/lib/exercises/vea/equationVEA.d.ts +2 -0
- package/lib/exercises/vea/equationVEA.d.ts.map +1 -0
- package/lib/exercises/vea/equationVEA.js +24 -0
- package/lib/exercises/vea/rationalVEA.d.ts.map +1 -1
- package/lib/exercises/vea/sqrtVEA.d.ts +6 -0
- package/lib/exercises/vea/sqrtVEA.d.ts.map +1 -0
- package/lib/exercises/vea/sqrtVEA.js +30 -0
- package/lib/geogebra/geogebraConstructor.d.ts +2 -0
- package/lib/geogebra/geogebraConstructor.d.ts.map +1 -1
- package/lib/geogebra/geogebraConstructor.js +7 -0
- package/lib/index.d.ts +28 -46
- package/lib/index.d.ts.map +1 -1
- package/lib/math/complex/complex.d.ts +1 -1
- package/lib/math/geometry/angle.d.ts +26 -0
- package/lib/math/geometry/angle.d.ts.map +1 -0
- package/lib/math/geometry/angle.js +73 -0
- package/lib/math/geometry/line.d.ts +5 -1
- package/lib/math/geometry/line.d.ts.map +1 -1
- package/lib/math/geometry/line.js +17 -0
- package/lib/math/geometry/parallelogram.d.ts +23 -0
- package/lib/math/geometry/parallelogram.d.ts.map +1 -0
- package/lib/math/geometry/parallelogram.js +70 -0
- package/lib/math/geometry/point.d.ts +3 -0
- package/lib/math/geometry/point.d.ts.map +1 -1
- package/lib/math/geometry/point.js +16 -0
- package/lib/math/geometry/quadrilateral.d.ts +15 -0
- package/lib/math/geometry/quadrilateral.d.ts.map +1 -0
- package/lib/math/geometry/quadrilateral.js +38 -0
- package/lib/math/geometry/rectangle.d.ts +24 -0
- package/lib/math/geometry/rectangle.d.ts.map +1 -0
- package/lib/math/geometry/rectangle.js +64 -0
- package/lib/math/geometry/rhombus.d.ts +19 -0
- package/lib/math/geometry/rhombus.d.ts.map +1 -0
- package/lib/math/geometry/rhombus.js +46 -0
- package/lib/math/geometry/rightTriangle.d.ts +31 -0
- package/lib/math/geometry/rightTriangle.d.ts.map +1 -0
- package/lib/math/geometry/rightTriangle.js +113 -0
- package/lib/math/geometry/segment.d.ts +24 -6
- package/lib/math/geometry/segment.d.ts.map +1 -1
- package/lib/math/geometry/segment.js +70 -4
- package/lib/math/geometry/square.d.ts +22 -0
- package/lib/math/geometry/square.d.ts.map +1 -0
- package/lib/math/geometry/square.js +43 -0
- package/lib/math/geometry/triangle.d.ts +45 -45
- package/lib/math/geometry/triangle.d.ts.map +1 -1
- package/lib/math/geometry/triangle.js +159 -186
- package/lib/math/geometry/vector.d.ts +2 -2
- package/lib/math/geometry/vector.d.ts.map +1 -1
- package/lib/math/geometry/vector.js +18 -9
- package/lib/math/numbers/rationals/rational.d.ts +1 -1
- package/lib/math/numbers/reals/extendedRingElement.d.ts +1 -1
- package/lib/math/numbers/reals/real.d.ts.map +1 -1
- package/lib/math/numbers/reals/real.js +3 -0
- package/lib/math/polynomials/generalAffine.d.ts.map +1 -1
- package/lib/math/polynomials/generalAffine.js +1 -1
- package/lib/math/polynomials/polynomial.d.ts +1 -1
- package/lib/math/polynomials/trinom.d.ts +2 -2
- package/lib/math/utils/geometry/pythagoricianTriplets.d.ts +1 -0
- package/lib/math/utils/geometry/pythagoricianTriplets.d.ts.map +1 -1
- package/lib/math/utils/geometry/pythagoricianTriplets.js +14 -1
- package/lib/math/utils/random/randfloat.d.ts +1 -1
- package/lib/math/utils/random/randfloat.d.ts.map +1 -1
- package/lib/math/utils/random/randfloat.js +8 -1
- package/lib/math/utils/random/randint.d.ts +8 -1
- package/lib/math/utils/random/randint.d.ts.map +1 -1
- package/lib/math/utils/random/randint.js +6 -1
- package/lib/playground.d.ts.map +1 -1
- package/lib/playground.js +1 -8
- package/lib/tree/nodes/functions/absNode.d.ts +1 -1
- package/lib/tree/nodes/functions/functionNode.d.ts +2 -2
- package/lib/tree/nodes/functions/functionNode.d.ts.map +1 -1
- package/lib/tree/nodes/functions/oppositeNode.d.ts +5 -5
- package/lib/tree/nodes/functions/oppositeNode.d.ts.map +1 -1
- package/lib/tree/nodes/node.d.ts +3 -1
- package/lib/tree/nodes/node.d.ts.map +1 -1
- package/lib/tree/nodes/node.js +1 -0
- package/lib/tree/nodes/nodeConstructor.d.ts.map +1 -1
- package/lib/tree/nodes/nodeConstructor.js +4 -0
- package/lib/tree/nodes/numbers/numberNode.d.ts +2 -0
- package/lib/tree/nodes/numbers/numberNode.d.ts.map +1 -1
- package/lib/tree/nodes/numbers/numberNode.js +6 -1
- package/lib/tree/nodes/operators/addNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/addNode.js +2 -1
- package/lib/tree/nodes/operators/multiplyNode.d.ts.map +1 -1
- package/lib/tree/nodes/operators/multiplyNode.js +3 -3
- package/lib/tree/nodes/polynomials/trinomNode.d.ts +70 -0
- package/lib/tree/nodes/polynomials/trinomNode.d.ts.map +1 -0
- package/lib/tree/nodes/polynomials/trinomNode.js +156 -0
- package/lib/tree/nodes/variables/variableNode.d.ts.map +1 -1
- package/lib/tree/nodes/variables/variableNode.js +1 -1
- package/lib/tree/parsers/affineParser.d.ts.map +1 -1
- package/lib/tree/parsers/affineParser.js +1 -0
- package/lib/tree/parsers/discreteSetParser.d.ts +3 -0
- package/lib/tree/parsers/discreteSetParser.d.ts.map +1 -0
- package/lib/tree/parsers/discreteSetParser.js +23 -0
- package/lib/tree/parsers/equationSolutionParser.d.ts +1 -1
- package/lib/tree/parsers/equationSolutionParser.d.ts.map +1 -1
- package/lib/tree/parsers/equationSolutionParser.js +15 -4
- package/lib/tree/parsers/latexParser.d.ts +5 -1
- package/lib/tree/parsers/latexParser.d.ts.map +1 -1
- package/lib/tree/parsers/latexParser.js +17 -3
- package/lib/tree/parsers/monomParser.js +2 -2
- package/lib/tree/parsers/powerParser.d.ts +1 -1
- package/lib/tree/parsers/rationalParser.d.ts +1 -1
- package/lib/tree/parsers/rationalParser.d.ts.map +1 -1
- package/lib/tree/parsers/rationalParser.js +28 -24
- package/lib/tree/parsers/sqrtParser.d.ts +9 -0
- package/lib/tree/parsers/sqrtParser.d.ts.map +1 -0
- package/lib/tree/parsers/sqrtParser.js +52 -0
- package/lib/tree/parsers/trinomParser.d.ts +1 -1
- package/lib/tree/parsers/trinomParser.d.ts.map +1 -1
- package/lib/tree/parsers/trinomParser.js +14 -2
- package/lib/tree/utilities/functionComposition.d.ts +1 -1
- package/lib/tree/utilities/functionComposition.d.ts.map +1 -1
- package/lib/utils/arrays/rotation.d.ts +8 -0
- package/lib/utils/arrays/rotation.d.ts.map +1 -0
- package/lib/utils/arrays/rotation.js +17 -0
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { AlgebraicNode } from "../../tree/nodes/algebraicNode";
|
|
2
|
+
import { Point } from "./point";
|
|
3
|
+
type AngleProps = {
|
|
4
|
+
radianValueNode?: AlgebraicNode;
|
|
5
|
+
degreeValueNode?: AlgebraicNode;
|
|
6
|
+
};
|
|
7
|
+
export declare class Angle {
|
|
8
|
+
points: Point[];
|
|
9
|
+
radianValueNode?: AlgebraicNode;
|
|
10
|
+
degreeValueNode?: AlgebraicNode;
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @param points [pointA, pointB, pointC] with apex = B
|
|
14
|
+
*/
|
|
15
|
+
constructor(points: Point[], props?: AngleProps);
|
|
16
|
+
evaluate(inRadian?: boolean): number;
|
|
17
|
+
getValueNode(inDegree?: boolean): AlgebraicNode | import("../../tree/nodes/numbers/constantNode").ConstantNode | import("../../tree/nodes/numbers/numberNode").NumberNode;
|
|
18
|
+
isRight(): boolean;
|
|
19
|
+
toTex(): string;
|
|
20
|
+
toCommands(opts?: {
|
|
21
|
+
color?: string;
|
|
22
|
+
showValue?: boolean;
|
|
23
|
+
}): string[];
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=angle.d.ts.map
|
|
@@ -0,0 +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;AAEhC,KAAK,UAAU,GAAG;IAChB,eAAe,CAAC,EAAE,aAAa,CAAC;IAChC,eAAe,CAAC,EAAE,aAAa,CAAC;CACjC,CAAC;AACF,qBAAa,KAAK;IAChB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,eAAe,CAAC,EAAE,aAAa,CAAC;IAChC,eAAe,CAAC,EAAE,aAAa,CAAC;IAEhC;;;OAGG;gBACS,MAAM,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,EAAE,UAAU;IAkB/C,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"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Angle = void 0;
|
|
4
|
+
const piNode_1 = require("../../tree/nodes/numbers/piNode");
|
|
5
|
+
const fractionNode_1 = require("../../tree/nodes/operators/fractionNode");
|
|
6
|
+
const multiplyNode_1 = require("../../tree/nodes/operators/multiplyNode");
|
|
7
|
+
const round_1 = require("../utils/round");
|
|
8
|
+
class Angle {
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @param points [pointA, pointB, pointC] with apex = B
|
|
12
|
+
*/
|
|
13
|
+
constructor(points, props) {
|
|
14
|
+
this.points = points;
|
|
15
|
+
this.radianValueNode = props?.radianValueNode;
|
|
16
|
+
this.degreeValueNode = props?.degreeValueNode;
|
|
17
|
+
if (props?.radianValueNode && !props.degreeValueNode) {
|
|
18
|
+
this.degreeValueNode = (0, fractionNode_1.frac)((0, multiplyNode_1.multiply)(props.radianValueNode, (180).toTree()), piNode_1.PiNode);
|
|
19
|
+
}
|
|
20
|
+
if (props?.degreeValueNode && !props.radianValueNode) {
|
|
21
|
+
this.radianValueNode = (0, fractionNode_1.frac)((0, multiplyNode_1.multiply)(props.degreeValueNode, piNode_1.PiNode), (180).toTree());
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
evaluate(inRadian = false) {
|
|
25
|
+
if (this.degreeValueNode || this.radianValueNode) {
|
|
26
|
+
if (inRadian)
|
|
27
|
+
return this.radianValueNode.evaluate();
|
|
28
|
+
return this.degreeValueNode.evaluate();
|
|
29
|
+
}
|
|
30
|
+
const coords = this.points.map((p) => [p.x.evaluate(), p.y.evaluate()]);
|
|
31
|
+
const [x1, y1, x2, y2, x3, y3] = coords.flatMap((p) => p);
|
|
32
|
+
const angleBA = Math.atan2(y1 - y2, x1 - x2);
|
|
33
|
+
const angleBC = Math.atan2(y3 - y2, x3 - x2);
|
|
34
|
+
let angleRadians = angleBC - angleBA;
|
|
35
|
+
if (angleRadians < 0) {
|
|
36
|
+
angleRadians += 2 * Math.PI;
|
|
37
|
+
}
|
|
38
|
+
if (inRadian)
|
|
39
|
+
return (0, round_1.round)(angleRadians, 4);
|
|
40
|
+
return (0, round_1.round)(angleRadians * (180 / Math.PI), 4);
|
|
41
|
+
}
|
|
42
|
+
getValueNode(inDegree = false) {
|
|
43
|
+
if (this.degreeValueNode || this.radianValueNode) {
|
|
44
|
+
if (inDegree)
|
|
45
|
+
return this.degreeValueNode;
|
|
46
|
+
return this.radianValueNode;
|
|
47
|
+
}
|
|
48
|
+
const angle = this.evaluate();
|
|
49
|
+
if (inDegree)
|
|
50
|
+
return angle.toTree();
|
|
51
|
+
return (0, fractionNode_1.frac)((0, multiplyNode_1.multiply)(angle, piNode_1.PiNode), 180).simplify();
|
|
52
|
+
}
|
|
53
|
+
isRight() {
|
|
54
|
+
const value = this.evaluate();
|
|
55
|
+
return Math.abs(value) - 90 < 0.000001 || Math.abs(value) - 270 < 0.000001;
|
|
56
|
+
}
|
|
57
|
+
toTex() {
|
|
58
|
+
return `\\widehat{${this.points[0].name}${this.points[1].name}${this.points[2].name}}`;
|
|
59
|
+
}
|
|
60
|
+
toCommands(opts) {
|
|
61
|
+
const name = `angle_{${this.points[0].name}${this.points[1].name}${this.points[2].name}}`;
|
|
62
|
+
const cmds = [
|
|
63
|
+
`${name} = Angle(${this.points[0].name},${this.points[1].name},${this.points[2].name}, xAxis)`,
|
|
64
|
+
`ShowLabel(${name}, ${opts?.showValue ? "true" : "false"})`,
|
|
65
|
+
];
|
|
66
|
+
cmds.push(`SetCaption(${name}, "$\\footnotesize ${(0, round_1.round)(this.evaluate(), 1).frenchify() + "°"}$")`);
|
|
67
|
+
if (opts?.color) {
|
|
68
|
+
cmds.push(`SetColor(${name}, "${opts.color}")`);
|
|
69
|
+
}
|
|
70
|
+
return cmds;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.Angle = Angle;
|
|
@@ -4,6 +4,7 @@ import { EqualNode } from "../../tree/nodes/equations/equalNode";
|
|
|
4
4
|
import { AddNode } from "../../tree/nodes/operators/addNode";
|
|
5
5
|
import { SubstractNode } from "../../tree/nodes/operators/substractNode";
|
|
6
6
|
import { Point, PointIdentifiers } from "./point";
|
|
7
|
+
import { Segment } from "./segment";
|
|
7
8
|
import { Vector } from "./vector";
|
|
8
9
|
export type LineIdentifiers = {
|
|
9
10
|
name?: string;
|
|
@@ -13,6 +14,7 @@ export type LineIdentifiers = {
|
|
|
13
14
|
export declare abstract class LineConstructor {
|
|
14
15
|
static random(name?: string): Line;
|
|
15
16
|
static fromIdentifiers(identifiers: LineIdentifiers): Line;
|
|
17
|
+
static fromSegment(segment: Segment): Line;
|
|
16
18
|
}
|
|
17
19
|
export declare class Line {
|
|
18
20
|
pointA: Point;
|
|
@@ -30,7 +32,9 @@ export declare class Line {
|
|
|
30
32
|
pointB: PointIdentifiers;
|
|
31
33
|
};
|
|
32
34
|
isParallele(line: Line): boolean;
|
|
35
|
+
getDirectorVector(): Vector;
|
|
33
36
|
getParallele(point: Point): Line;
|
|
37
|
+
getPerpendicular(point: Point): Line;
|
|
34
38
|
includes(point: Point, allowApprox?: boolean): boolean;
|
|
35
39
|
getRandomPoint(name?: string): Point;
|
|
36
40
|
getEquation: (u: Vector, a: Point) => EqualNode;
|
|
@@ -38,7 +42,7 @@ export declare class Line {
|
|
|
38
42
|
toCartesian(): AddNode;
|
|
39
43
|
toCartesianCoeffs(): {
|
|
40
44
|
a: AlgebraicNode;
|
|
41
|
-
b: import("../../tree/nodes/functions/oppositeNode").OppositeNode
|
|
45
|
+
b: import("../../tree/nodes/functions/oppositeNode").OppositeNode<AlgebraicNode>;
|
|
42
46
|
c: SubstractNode;
|
|
43
47
|
};
|
|
44
48
|
toTex(): string;
|
|
@@ -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,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;
|
|
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,KAAK,CAAC;IACd,UAAU,EAAE,OAAO,CAAC;IACpB,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IAC7B,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;gBACJ,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,EAAE,MAAM;IAsBvD,aAAa;;;;;IAOb,WAAW,CAAC,IAAI,EAAE,IAAI;IAYtB,iBAAiB;IAIjB,YAAY,CAAC,KAAK,EAAE,KAAK;IAYzB,gBAAgB,CAAC,KAAK,EAAE,KAAK;IAW7B,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,WAAW,GAAE,OAAe;IAenD,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,GACjC,GAAE,kBAAuB;IAqB5B,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,aAAa,CAAC,EAAE,MAAM;CAW7C"}
|
|
@@ -23,6 +23,9 @@ class LineConstructor {
|
|
|
23
23
|
static fromIdentifiers(identifiers) {
|
|
24
24
|
return new Line(point_1.PointConstructor.fromIdentifiers(identifiers.pointA), point_1.PointConstructor.fromIdentifiers(identifiers.pointB), identifiers.name);
|
|
25
25
|
}
|
|
26
|
+
static fromSegment(segment) {
|
|
27
|
+
return new Line(segment.pointA, segment.pointB);
|
|
28
|
+
}
|
|
26
29
|
}
|
|
27
30
|
exports.LineConstructor = LineConstructor;
|
|
28
31
|
class Line {
|
|
@@ -73,6 +76,9 @@ class Line {
|
|
|
73
76
|
const lineVec = vector_1.VectorConstructor.fromPoints(line.pointA, line.pointB);
|
|
74
77
|
return vec.isColinear(lineVec);
|
|
75
78
|
}
|
|
79
|
+
getDirectorVector() {
|
|
80
|
+
return vector_1.VectorConstructor.fromPoints(this.pointA, this.pointB);
|
|
81
|
+
}
|
|
76
82
|
getParallele(point) {
|
|
77
83
|
if (this.isVertical) {
|
|
78
84
|
const y = (0, addNode_1.add)(point.y, 1).simplify();
|
|
@@ -84,6 +90,17 @@ class Line {
|
|
|
84
90
|
const secondPoint = new point_1.Point("P", x, y);
|
|
85
91
|
return new Line(point, secondPoint);
|
|
86
92
|
}
|
|
93
|
+
getPerpendicular(point) {
|
|
94
|
+
if (this.isVertical) {
|
|
95
|
+
const x = (0, addNode_1.add)(point.x, 1).simplify();
|
|
96
|
+
const secondPoint = new point_1.Point("P", x, point.y);
|
|
97
|
+
return new Line(point, secondPoint);
|
|
98
|
+
}
|
|
99
|
+
const vec = this.getDirectorVector();
|
|
100
|
+
const ortho = vec.getOrthogonal();
|
|
101
|
+
const secondPoint = ortho.getEndPoint(point);
|
|
102
|
+
return new Line(point, secondPoint);
|
|
103
|
+
}
|
|
87
104
|
includes(point, allowApprox = false) {
|
|
88
105
|
if (this.isVertical) {
|
|
89
106
|
if (allowApprox) {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Point, PointIdentifiers } from "./point";
|
|
2
|
+
import { Quadrilateral } from "./quadrilateral";
|
|
3
|
+
export declare abstract class ParallelogramConstructor {
|
|
4
|
+
static random(): Parallelogram;
|
|
5
|
+
static fromIdentifiers(identifiers: ParallelogramIdentifiers): Parallelogram;
|
|
6
|
+
}
|
|
7
|
+
export type ParallelogramIdentifiers = {
|
|
8
|
+
points: PointIdentifiers[];
|
|
9
|
+
};
|
|
10
|
+
export declare class Parallelogram extends Quadrilateral {
|
|
11
|
+
constructor(points: Point[]);
|
|
12
|
+
toIdentifiers(): ParallelogramIdentifiers;
|
|
13
|
+
drawDiagonals({ drawCenter, drawDecorations, isRectangle, isRhombus, }: {
|
|
14
|
+
drawCenter: boolean;
|
|
15
|
+
drawDecorations: boolean;
|
|
16
|
+
isRectangle?: boolean;
|
|
17
|
+
isRhombus?: boolean;
|
|
18
|
+
}): void;
|
|
19
|
+
drawSidesDecoration({ isRhombus }: {
|
|
20
|
+
isRhombus?: boolean;
|
|
21
|
+
}): void;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=parallelogram.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parallelogram.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/parallelogram.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAoB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,8BAAsB,wBAAwB;IAC5C,MAAM,CAAC,MAAM;IA2Bb,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,wBAAwB;CAO7D;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,MAAM,EAAE,gBAAgB,EAAE,CAAC;CAC5B,CAAC;AAEF,qBAAa,aAAc,SAAQ,aAAa;gBAClC,MAAM,EAAE,KAAK,EAAE;IAG3B,aAAa,IAAI,wBAAwB;IAKzC,aAAa,CAAC,EACZ,UAAU,EACV,eAAe,EACf,WAAW,EACX,SAAS,GACV,EAAE;QACD,UAAU,EAAE,OAAO,CAAC;QACpB,eAAe,EAAE,OAAO,CAAC;QACzB,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,SAAS,CAAC,EAAE,OAAO,CAAC;KACrB,GAAG,IAAI;IA6BR,mBAAmB,CAAC,EAAE,SAAS,EAAE,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI;CAclE"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Parallelogram = exports.ParallelogramConstructor = void 0;
|
|
4
|
+
const randfloat_1 = require("../utils/random/randfloat");
|
|
5
|
+
const point_1 = require("./point");
|
|
6
|
+
const quadrilateral_1 = require("./quadrilateral");
|
|
7
|
+
class ParallelogramConstructor {
|
|
8
|
+
static random() {
|
|
9
|
+
const angle = (0, randfloat_1.randfloat)(0, Math.PI / 2);
|
|
10
|
+
const additionalAngle = (0, randfloat_1.randfloat)(Math.PI / 4, (3 * Math.PI) / 4);
|
|
11
|
+
const xRand = (0, randfloat_1.randfloat)(5, 8);
|
|
12
|
+
const xRand2 = (0, randfloat_1.randfloat)(3, 8);
|
|
13
|
+
const origin = new point_1.Point("O", (0).toTree(), (0).toTree());
|
|
14
|
+
const A = new point_1.Point("A", (-xRand).toTree(), (0).toTree()).rotate(angle, origin);
|
|
15
|
+
const C = new point_1.Point("C", xRand.toTree(), (0).toTree()).rotate(angle, origin);
|
|
16
|
+
const yRand = (0, randfloat_1.randfloat)(3, 6);
|
|
17
|
+
const B = new point_1.Point("B", (-xRand2).toTree(), (0).toTree()).rotate(angle + additionalAngle, origin);
|
|
18
|
+
const D = new point_1.Point("D", xRand2.toTree(), (0).toTree()).rotate(angle + additionalAngle, origin);
|
|
19
|
+
return new Parallelogram([A, B, C, D]);
|
|
20
|
+
}
|
|
21
|
+
static fromIdentifiers(identifiers) {
|
|
22
|
+
return new Parallelogram(identifiers.points.map((point) => point_1.PointConstructor.fromIdentifiers(point)));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.ParallelogramConstructor = ParallelogramConstructor;
|
|
26
|
+
class Parallelogram extends quadrilateral_1.Quadrilateral {
|
|
27
|
+
constructor(points) {
|
|
28
|
+
super(points);
|
|
29
|
+
}
|
|
30
|
+
toIdentifiers() {
|
|
31
|
+
return {
|
|
32
|
+
points: this.points.map((point) => point.toIdentifiers()),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
drawDiagonals({ drawCenter, drawDecorations, isRectangle, isRhombus, }) {
|
|
36
|
+
super.drawDiagonals({ drawCenter, drawDecorations });
|
|
37
|
+
if (drawDecorations) {
|
|
38
|
+
this.commands.push(`midDiago1 = Segment(${this.points[0].name}, diagoCenter)`);
|
|
39
|
+
this.commands.push(`midDiago2 = Segment(${this.points[2].name}, diagoCenter)`);
|
|
40
|
+
this.commands.push(`midDiago3 = Segment(${this.points[1].name}, diagoCenter)`);
|
|
41
|
+
this.commands.push(`midDiago4 = Segment(${this.points[3].name}, diagoCenter)`);
|
|
42
|
+
const secondDeco = isRectangle ? 2 : 3;
|
|
43
|
+
this.commands.push(`SetDecoration(midDiago1, 2)`);
|
|
44
|
+
this.commands.push(`SetDecoration(midDiago2, 2)`);
|
|
45
|
+
this.commands.push(`SetDecoration(midDiago3, ${secondDeco})`);
|
|
46
|
+
this.commands.push(`SetDecoration(midDiago4, ${secondDeco})`);
|
|
47
|
+
}
|
|
48
|
+
isRhombus &&
|
|
49
|
+
this.commands.push(...[
|
|
50
|
+
`centerAngle = Angle(${this.points[0].name}, diagoCenter, ${this.points[1].name}, xAxis)`,
|
|
51
|
+
`ShowLabel(centerAngle, false)`,
|
|
52
|
+
]);
|
|
53
|
+
}
|
|
54
|
+
drawSidesDecoration({ isRhombus }) {
|
|
55
|
+
if (isRhombus) {
|
|
56
|
+
this.sides.forEach((side, index) => {
|
|
57
|
+
this.commands.push(`SetDecoration(${side.ggbName}, 2)`);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
this.sides.forEach((side, index) => {
|
|
62
|
+
if (index % 2 === 0)
|
|
63
|
+
this.commands.push(`SetDecoration(${side.ggbName}, 2)`);
|
|
64
|
+
if (index % 2 !== 0)
|
|
65
|
+
this.commands.push(`SetDecoration(${side.ggbName}, 3)`);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.Parallelogram = Parallelogram;
|
|
@@ -8,6 +8,7 @@ export type PointIdentifiers = {
|
|
|
8
8
|
y: NodeIdentifiers;
|
|
9
9
|
};
|
|
10
10
|
export declare abstract class PointConstructor {
|
|
11
|
+
static origin(name?: string): Point;
|
|
11
12
|
static random(name: string, min?: number, max?: number): Point;
|
|
12
13
|
static fromIdentifiers(identifiers: PointIdentifiers): Point;
|
|
13
14
|
static onSegment(A: Point, B: Point, name: string, { spacing, coefficient, }?: {
|
|
@@ -32,6 +33,8 @@ export declare class Point {
|
|
|
32
33
|
distanceTo(B: Point): number;
|
|
33
34
|
equals(B: Point): boolean;
|
|
34
35
|
isAligned(B: Point, C: Point): boolean;
|
|
36
|
+
toMathString(): string;
|
|
35
37
|
toGGBCommand({ isFixed, showLabel, style, size, color, }?: ToGGBCommandsProps): string[];
|
|
38
|
+
rotate(angle: number, center: Point): Point;
|
|
36
39
|
}
|
|
37
40
|
//# 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,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAG/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mDAAmD,CAAC;AACvF,OAAO,EAEL,eAAe,EAChB,MAAM,kCAAkC,CAAC;AAM1C,MAAM,MAAM,gBAAgB,GAAG;IAC7B,EAAE,EAAE,OAAO,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,eAAe,CAAC;IACnB,CAAC,EAAE,eAAe,CAAC;CACpB,CAAC;AACF,8BAAsB,gBAAgB;IACpC,MAAM,CAAC,MAAM,CAAC,IAAI,SAAM;IAGxB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,SAAM,EAAE,GAAG,SAAK,GAAG,KAAK;IAMvD,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,gBAAgB;IAQpD,MAAM,CAAC,SAAS,CACd,CAAC,EAAE,KAAK,EACR,CAAC,EAAE,KAAK,EACR,IAAI,EAAE,MAAM,EACZ,EACE,OAAa,EACb,WAAW,GACZ,GAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAO;IAQpD,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE;IAetC,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,MAAM;CAclC;AAED,qBAAa,KAAK;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,aAAa,CAAC;IACjB,CAAC,EAAE,aAAa,CAAC;gBACL,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,aAAa;IAM5D,KAAK,IAAI,MAAM;IAGf,aAAa,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;IAiBrC,UAAU,CAAC,CAAC,EAAE,KAAK,GAAG,MAAM;IAM5B,MAAM,CAAC,CAAC,EAAE,KAAK,GAAG,OAAO;IAGzB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK;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;CAiBpC"}
|
|
@@ -8,7 +8,13 @@ const vector_1 = require("./vector");
|
|
|
8
8
|
const randint_1 = require("../utils/random/randint");
|
|
9
9
|
const nodeConstructor_1 = require("../../tree/nodes/nodeConstructor");
|
|
10
10
|
const randfloat_1 = require("../utils/random/randfloat");
|
|
11
|
+
const substractNode_1 = require("../../tree/nodes/operators/substractNode");
|
|
12
|
+
const multiplyNode_1 = require("../../tree/nodes/operators/multiplyNode");
|
|
13
|
+
const addNode_1 = require("../../tree/nodes/operators/addNode");
|
|
11
14
|
class PointConstructor {
|
|
15
|
+
static origin(name = "O") {
|
|
16
|
+
return new Point(name, new numberNode_1.NumberNode(0), new numberNode_1.NumberNode(0));
|
|
17
|
+
}
|
|
12
18
|
static random(name, min = -10, max = 11) {
|
|
13
19
|
const x = (0, randint_1.randint)(min, max);
|
|
14
20
|
const y = (0, randint_1.randint)(min, max);
|
|
@@ -103,6 +109,9 @@ class Point {
|
|
|
103
109
|
const AC = vector_1.VectorConstructor.fromPoints(this, C);
|
|
104
110
|
return AB.isColinear(AC);
|
|
105
111
|
}
|
|
112
|
+
toMathString() {
|
|
113
|
+
return `(${this.x.toMathString()}, ${this.y.toMathString()})`;
|
|
114
|
+
}
|
|
106
115
|
toGGBCommand({ isFixed = true, showLabel = true, style, size, color, } = {}) {
|
|
107
116
|
const commands = [
|
|
108
117
|
`${this.name} = (${this.x.toMathString()}, ${this.y.toMathString()})`,
|
|
@@ -120,5 +129,12 @@ class Point {
|
|
|
120
129
|
}
|
|
121
130
|
return commands;
|
|
122
131
|
}
|
|
132
|
+
rotate(angle, center) {
|
|
133
|
+
//x' = cos(t)*x -sin(t)*y
|
|
134
|
+
//y' = sin(t)*x + cos(t)*y
|
|
135
|
+
const cos = Math.cos(angle);
|
|
136
|
+
const sin = Math.sin(angle);
|
|
137
|
+
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
|
+
}
|
|
123
139
|
}
|
|
124
140
|
exports.Point = Point;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Point } from "./point";
|
|
2
|
+
import { Segment } from "./segment";
|
|
3
|
+
export declare class Quadrilateral {
|
|
4
|
+
commands: string[];
|
|
5
|
+
points: Point[];
|
|
6
|
+
sides: Segment[];
|
|
7
|
+
name: string;
|
|
8
|
+
constructor(points: Point[]);
|
|
9
|
+
drawDiagonals({ drawCenter, drawDecorations, }: {
|
|
10
|
+
drawCenter: boolean;
|
|
11
|
+
drawDecorations: boolean;
|
|
12
|
+
}): void;
|
|
13
|
+
toGGBCommands(): string[];
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=quadrilateral.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quadrilateral.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/quadrilateral.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,qBAAa,aAAa;IACxB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,KAAK,EAAE,OAAO,EAAE,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;gBACD,MAAM,EAAE,KAAK,EAAE;IAuB3B,aAAa,CAAC,EACZ,UAAkB,EAClB,eAAuB,GACxB,EAAE;QACD,UAAU,EAAE,OAAO,CAAC;QACpB,eAAe,EAAE,OAAO,CAAC;KAC1B;IAcD,aAAa;CAGd"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Quadrilateral = void 0;
|
|
4
|
+
const segment_1 = require("./segment");
|
|
5
|
+
class Quadrilateral {
|
|
6
|
+
constructor(points) {
|
|
7
|
+
if (points.length !== 4)
|
|
8
|
+
throw new Error("Quadrilateral must have 4 points");
|
|
9
|
+
this.name = points.map((p) => p.name).join("");
|
|
10
|
+
this.points = points;
|
|
11
|
+
this.sides = [
|
|
12
|
+
new segment_1.Segment(points[0], points[1]),
|
|
13
|
+
new segment_1.Segment(points[1], points[2]),
|
|
14
|
+
new segment_1.Segment(points[2], points[3]),
|
|
15
|
+
new segment_1.Segment(points[3], points[0]),
|
|
16
|
+
];
|
|
17
|
+
this.commands = [
|
|
18
|
+
...points.flatMap((p) => p.toGGBCommand({
|
|
19
|
+
isFixed: true,
|
|
20
|
+
showLabel: true,
|
|
21
|
+
})),
|
|
22
|
+
...this.sides.flatMap((s) => s.toGGBCommands(false)),
|
|
23
|
+
];
|
|
24
|
+
}
|
|
25
|
+
drawDiagonals({ drawCenter = false, drawDecorations = false, }) {
|
|
26
|
+
const res = [];
|
|
27
|
+
res.push(`diago1 = Segment(${this.points[0].name}, ${this.points[2].name})`);
|
|
28
|
+
res.push(`diago2 = Segment(${this.points[1].name}, ${this.points[3].name})`);
|
|
29
|
+
if (drawCenter) {
|
|
30
|
+
res.push(`diagoCenter = Intersect(diago1, diago2)`);
|
|
31
|
+
}
|
|
32
|
+
this.commands.push(...res);
|
|
33
|
+
}
|
|
34
|
+
toGGBCommands() {
|
|
35
|
+
return this.commands;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.Quadrilateral = Quadrilateral;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Parallelogram } from "./parallelogram";
|
|
2
|
+
import { Point, PointIdentifiers } from "./point";
|
|
3
|
+
export declare abstract class RectangleConstructor {
|
|
4
|
+
static random(): Rectangle;
|
|
5
|
+
static fromIdentifiers(identifiers: RectangleIdentifiers): Rectangle;
|
|
6
|
+
}
|
|
7
|
+
export type RectangleIdentifiers = {
|
|
8
|
+
points: PointIdentifiers[];
|
|
9
|
+
};
|
|
10
|
+
export declare class Rectangle extends Parallelogram {
|
|
11
|
+
constructor(points: Point[]);
|
|
12
|
+
toIdentifiers(): RectangleIdentifiers;
|
|
13
|
+
drawDiagonals({ drawCenter, drawDecorations, isRhombus, }: {
|
|
14
|
+
drawCenter: boolean;
|
|
15
|
+
drawDecorations: boolean;
|
|
16
|
+
isRhombus?: boolean;
|
|
17
|
+
}): void;
|
|
18
|
+
drawSidesDecoration({ drawAngles, drawSidesLengths, isRhombus, }: {
|
|
19
|
+
drawAngles: boolean;
|
|
20
|
+
drawSidesLengths: boolean;
|
|
21
|
+
isRhombus?: boolean;
|
|
22
|
+
}): void;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=rectangle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rectangle.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/rectangle.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAoB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAIpE,8BAAsB,oBAAoB;IACxC,MAAM,CAAC,MAAM;IAyBb,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,oBAAoB;CAOzD;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,gBAAgB,EAAE,CAAC;CAC5B,CAAC;AACF,qBAAa,SAAU,SAAQ,aAAa;gBAC9B,MAAM,EAAE,KAAK,EAAE;IAG3B,aAAa,IAAI,oBAAoB;IAKrC,aAAa,CAAC,EACZ,UAAU,EACV,eAAe,EACf,SAAS,GACV,EAAE;QACD,UAAU,EAAE,OAAO,CAAC;QACpB,eAAe,EAAE,OAAO,CAAC;QACzB,SAAS,CAAC,EAAE,OAAO,CAAC;KACrB,GAAG,IAAI;IASR,mBAAmB,CAAC,EAClB,UAAU,EACV,gBAAgB,EAChB,SAAS,GACV,EAAE;QACD,UAAU,EAAE,OAAO,CAAC;QACpB,gBAAgB,EAAE,OAAO,CAAC;QAC1B,SAAS,CAAC,EAAE,OAAO,CAAC;KACrB,GAAG,IAAI;CA2BT"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Rectangle = exports.RectangleConstructor = void 0;
|
|
4
|
+
const randfloat_1 = require("../utils/random/randfloat");
|
|
5
|
+
const parallelogram_1 = require("./parallelogram");
|
|
6
|
+
const point_1 = require("./point");
|
|
7
|
+
class RectangleConstructor {
|
|
8
|
+
static random() {
|
|
9
|
+
const angle = (0, randfloat_1.randfloat)(0, Math.PI / 2);
|
|
10
|
+
const additionalAngle = (0, randfloat_1.randfloat)(Math.PI / 4, (3 * Math.PI) / 4);
|
|
11
|
+
const xRand = (0, randfloat_1.randfloat)(5, 8);
|
|
12
|
+
const origin = new point_1.Point("O", (0).toTree(), (0).toTree());
|
|
13
|
+
const A = new point_1.Point("A", (-xRand).toTree(), (0).toTree()).rotate(angle, origin);
|
|
14
|
+
const C = new point_1.Point("C", xRand.toTree(), (0).toTree()).rotate(angle, origin);
|
|
15
|
+
const yRand = (0, randfloat_1.randfloat)(3, 6);
|
|
16
|
+
const B = new point_1.Point("B", (-xRand).toTree(), (0).toTree()).rotate(angle + additionalAngle, origin);
|
|
17
|
+
const D = new point_1.Point("D", xRand.toTree(), (0).toTree()).rotate(angle + additionalAngle, origin);
|
|
18
|
+
return new Rectangle([A, B, C, D]);
|
|
19
|
+
}
|
|
20
|
+
static fromIdentifiers(identifiers) {
|
|
21
|
+
return new Rectangle(identifiers.points.map((point) => point_1.PointConstructor.fromIdentifiers(point)));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.RectangleConstructor = RectangleConstructor;
|
|
25
|
+
class Rectangle extends parallelogram_1.Parallelogram {
|
|
26
|
+
constructor(points) {
|
|
27
|
+
super(points);
|
|
28
|
+
}
|
|
29
|
+
toIdentifiers() {
|
|
30
|
+
return {
|
|
31
|
+
points: this.points.map((point) => point.toIdentifiers()),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
drawDiagonals({ drawCenter, drawDecorations, isRhombus, }) {
|
|
35
|
+
super.drawDiagonals({
|
|
36
|
+
drawCenter,
|
|
37
|
+
drawDecorations,
|
|
38
|
+
isRectangle: true,
|
|
39
|
+
isRhombus,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
drawSidesDecoration({ drawAngles, drawSidesLengths, isRhombus, }) {
|
|
43
|
+
if (drawAngles) {
|
|
44
|
+
const angles = [
|
|
45
|
+
[1, 0, 3],
|
|
46
|
+
[2, 1, 0],
|
|
47
|
+
[3, 2, 1],
|
|
48
|
+
[0, 3, 2],
|
|
49
|
+
];
|
|
50
|
+
angles.forEach((angle, index) => {
|
|
51
|
+
this.commands.push(`angle_${index} = Angle(${this.points[angle[0]].name}, ${this.points[angle[1]].name}, ${this.points[angle[2]].name}, xAxis)`);
|
|
52
|
+
//xAxis sert à obtenir l'angle aigu
|
|
53
|
+
this.commands.push(`ShowLabel(angle_${index}, false)`);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (drawSidesLengths) {
|
|
57
|
+
super.drawSidesDecoration({ isRhombus });
|
|
58
|
+
this.commands.push(`angle_0 = Angle(${this.points[1].name}, ${this.points[0].name}, ${this.points[3].name}, xAxis)`);
|
|
59
|
+
//xAxis sert à obtenir l'angle aigu
|
|
60
|
+
this.commands.push(`ShowLabel(angle_0, false)`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.Rectangle = Rectangle;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Parallelogram } from "./parallelogram";
|
|
2
|
+
import { Point, PointIdentifiers } from "./point";
|
|
3
|
+
export declare abstract class RhombusConstructor {
|
|
4
|
+
static random(): Rhombus;
|
|
5
|
+
static fromIdentifiers(identifiers: RhombusIdentifiers): Rhombus;
|
|
6
|
+
}
|
|
7
|
+
export type RhombusIdentifiers = {
|
|
8
|
+
points: PointIdentifiers[];
|
|
9
|
+
};
|
|
10
|
+
export declare class Rhombus extends Parallelogram {
|
|
11
|
+
constructor(points: Point[]);
|
|
12
|
+
toIdentifiers(): RhombusIdentifiers;
|
|
13
|
+
drawDiagonals({ drawCenter, drawDecorations, }: {
|
|
14
|
+
drawCenter: boolean;
|
|
15
|
+
drawDecorations: boolean;
|
|
16
|
+
}): void;
|
|
17
|
+
drawSidesDecoration(): void;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=rhombus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rhombus.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/rhombus.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAoB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAGpE,8BAAsB,kBAAkB;IACtC,MAAM,CAAC,MAAM;IAwBb,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,kBAAkB;CAOvD;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,MAAM,EAAE,gBAAgB,EAAE,CAAC;CAC5B,CAAC;AAEF,qBAAa,OAAQ,SAAQ,aAAa;gBAC5B,MAAM,EAAE,KAAK,EAAE;IAG3B,aAAa,IAAI,kBAAkB;IAKnC,aAAa,CAAC,EACZ,UAAU,EACV,eAAe,GAChB,EAAE;QACD,UAAU,EAAE,OAAO,CAAC;QACpB,eAAe,EAAE,OAAO,CAAC;KAC1B,GAAG,IAAI;IAUR,mBAAmB,IAAI,IAAI;CAK5B"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Rhombus = exports.RhombusConstructor = void 0;
|
|
4
|
+
const randfloat_1 = require("../utils/random/randfloat");
|
|
5
|
+
const parallelogram_1 = require("./parallelogram");
|
|
6
|
+
const point_1 = require("./point");
|
|
7
|
+
class RhombusConstructor {
|
|
8
|
+
static random() {
|
|
9
|
+
const angle = (0, randfloat_1.randfloat)(0, Math.PI / 2);
|
|
10
|
+
const xRand = (0, randfloat_1.randfloat)(5, 8);
|
|
11
|
+
const origin = new point_1.Point("O", (0).toTree(), (0).toTree());
|
|
12
|
+
const A = new point_1.Point("A", (-xRand).toTree(), (0).toTree()).rotate(angle, origin);
|
|
13
|
+
const C = new point_1.Point("C", xRand.toTree(), (0).toTree()).rotate(angle, origin);
|
|
14
|
+
const yRand = (0, randfloat_1.randfloat)(3, 6);
|
|
15
|
+
const B = new point_1.Point("B", (0).toTree(), yRand.toTree()).rotate(angle, origin);
|
|
16
|
+
const D = new point_1.Point("D", (0).toTree(), (-yRand).toTree()).rotate(angle, origin);
|
|
17
|
+
return new Rhombus([A, B, C, D]);
|
|
18
|
+
}
|
|
19
|
+
static fromIdentifiers(identifiers) {
|
|
20
|
+
return new Rhombus(identifiers.points.map((point) => point_1.PointConstructor.fromIdentifiers(point)));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.RhombusConstructor = RhombusConstructor;
|
|
24
|
+
class Rhombus extends parallelogram_1.Parallelogram {
|
|
25
|
+
constructor(points) {
|
|
26
|
+
super(points);
|
|
27
|
+
}
|
|
28
|
+
toIdentifiers() {
|
|
29
|
+
return {
|
|
30
|
+
points: this.points.map((point) => point.toIdentifiers()),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
drawDiagonals({ drawCenter, drawDecorations, }) {
|
|
34
|
+
super.drawDiagonals({ drawCenter, drawDecorations, isRhombus: true });
|
|
35
|
+
if (drawDecorations) {
|
|
36
|
+
this.commands.push(`centerAngle = Angle(${this.points[1].name}, diagoCenter, ${this.points[0].name}, xAxis)`);
|
|
37
|
+
this.commands.push(`ShowLabel(centerAngle, false)`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
drawSidesDecoration() {
|
|
41
|
+
this.sides.forEach((side, index) => {
|
|
42
|
+
this.commands.push(`SetDecoration(${side.ggbName}, 2)`);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.Rhombus = Rhombus;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Angle } from "./angle";
|
|
2
|
+
import { Point } from "./point";
|
|
3
|
+
import { Triangle, TriangleIdentifiers, TriangleProps } from "./triangle";
|
|
4
|
+
export declare abstract class RightTriangleConstructor {
|
|
5
|
+
static randomNiceSides({ names, randomName, }: {
|
|
6
|
+
names?: string[] | undefined;
|
|
7
|
+
randomName?: boolean | undefined;
|
|
8
|
+
}): RightTriangle;
|
|
9
|
+
static randomNiceAngles({ names, randomName, niceSideIndex, }: {
|
|
10
|
+
names?: string[];
|
|
11
|
+
randomName?: boolean;
|
|
12
|
+
niceSideIndex?: number;
|
|
13
|
+
}): RightTriangle;
|
|
14
|
+
static fromIdentifiers(identifiers: TriangleIdentifiers): RightTriangle;
|
|
15
|
+
}
|
|
16
|
+
type RightTriangleProps = {} & TriangleProps;
|
|
17
|
+
export declare class RightTriangle extends Triangle {
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @param points points[0] is right angle
|
|
21
|
+
* sides[0] is the hypotenuse (side "A" = "BC")
|
|
22
|
+
* angles[0] is angle A (90°)
|
|
23
|
+
*/
|
|
24
|
+
constructor(points: Point[], props?: RightTriangleProps);
|
|
25
|
+
getRightAngle(): Angle;
|
|
26
|
+
getPythagorianTex(): string;
|
|
27
|
+
getOppositeSide(summitIndex: number): import("./segment").Segment;
|
|
28
|
+
getAdjacentSide(summitIndex: number): import("./segment").Segment;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=rightTriangle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rightTriangle.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/rightTriangle.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,KAAK,EAAoB,MAAM,SAAS,CAAC;AAClD,OAAO,EACL,QAAQ,EAER,mBAAmB,EACnB,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB,8BAAsB,wBAAwB;IAC5C,MAAM,CAAC,eAAe,CAAC,EACrB,KAAuB,EACvB,UAAkB,GACnB;;;KAAA,GAAG,aAAa;IAqCjB,MAAM,CAAC,gBAAgB,CAAC,EACtB,KAAuB,EACvB,UAAkB,EAClB,aAAyB,GAC1B,EAAE;QACD,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QACjB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB;IA0CD,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,mBAAmB;CAaxD;AAED,KAAK,kBAAkB,GAAG,EAAE,GAAG,aAAa,CAAC;AAC7C,qBAAa,aAAc,SAAQ,QAAQ;IACzC;;;;;OAKG;gBACS,MAAM,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,EAAE,kBAAkB;IAKvD,aAAa,IAAI,KAAK;IAMtB,iBAAiB;IAIjB,eAAe,CAAC,WAAW,EAAE,MAAM;IAInC,eAAe,CAAC,WAAW,EAAE,MAAM;CAKpC"}
|