math-exercises 2.2.69 → 2.2.71
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 +6 -1
- package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivitySubstract.d.ts +12 -0
- package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivitySubstract.d.ts.map +1 -0
- package/lib/exercises/math/calculLitteral/distributivity/doubleDistributivitySubstract.js +128 -0
- package/lib/exercises/math/calculLitteral/distributivity/index.d.ts +1 -0
- package/lib/exercises/math/calculLitteral/distributivity/index.d.ts.map +1 -1
- package/lib/exercises/math/calculLitteral/distributivity/index.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/angles/index.d.ts +2 -0
- package/lib/exercises/math/geometry/angles/index.d.ts.map +1 -0
- package/lib/exercises/math/geometry/angles/index.js +17 -0
- package/lib/exercises/math/geometry/angles/recognizeAngleType.d.ts +11 -0
- package/lib/exercises/math/geometry/angles/recognizeAngleType.d.ts.map +1 -0
- package/lib/exercises/math/geometry/angles/recognizeAngleType.js +272 -0
- package/lib/exercises/math/geometry/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/euclidianConstructions/pointImageFromTranslation.js +1 -1
- package/lib/exercises/math/geometry/index.d.ts +2 -0
- package/lib/exercises/math/geometry/index.d.ts.map +1 -1
- package/lib/exercises/math/geometry/index.js +2 -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.js +3 -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 +39 -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 +47 -0
- package/lib/math/geometry/angle.d.ts.map +1 -0
- package/lib/math/geometry/angle.js +210 -0
- package/lib/math/geometry/line.d.ts +7 -1
- package/lib/math/geometry/line.d.ts.map +1 -1
- package/lib/math/geometry/line.js +33 -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 +4 -0
- package/lib/math/geometry/point.d.ts.map +1 -1
- package/lib/math/geometry/point.js +20 -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 +5 -2
- package/lib/math/geometry/vector.d.ts.map +1 -1
- package/lib/math/geometry/vector.js +27 -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 +3 -0
- package/lib/math/polynomials/generalAffine.d.ts.map +1 -1
- package/lib/math/polynomials/generalAffine.js +5 -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 +6 -2
- package/lib/tree/nodes/node.d.ts.map +1 -1
- package/lib/tree/nodes/node.js +3 -0
- package/lib/tree/nodes/nodeConstructor.d.ts.map +1 -1
- package/lib/tree/nodes/nodeConstructor.js +8 -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 +123 -89
- 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/monomNode.d.ts +47 -0
- package/lib/tree/nodes/polynomials/monomNode.d.ts.map +1 -0
- package/lib/tree/nodes/polynomials/monomNode.js +214 -0
- 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 +2 -1
- 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.d.ts +2 -2
- package/lib/tree/parsers/monomParser.d.ts.map +1 -1
- package/lib/tree/parsers/monomParser.js +61 -8
- 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,47 @@
|
|
|
1
|
+
import { AlgebraicNode } from "../../tree/nodes/algebraicNode";
|
|
2
|
+
import { Point, PointIdentifiers } from "./point";
|
|
3
|
+
import { NodeIdentifiers } from "../../tree/nodes/nodeConstructor";
|
|
4
|
+
export declare abstract class AngleConstructor {
|
|
5
|
+
static fromIdentifiers(identifiers: AngleIdentifiers): Angle;
|
|
6
|
+
}
|
|
7
|
+
type AngleProps = {
|
|
8
|
+
radianValueNode?: AlgebraicNode;
|
|
9
|
+
degreeValueNode?: AlgebraicNode;
|
|
10
|
+
};
|
|
11
|
+
type AnglePropsIdentifiers = {
|
|
12
|
+
radianValueNode?: NodeIdentifiers;
|
|
13
|
+
degreeValueNode?: NodeIdentifiers;
|
|
14
|
+
};
|
|
15
|
+
export type AngleIdentifiers = {
|
|
16
|
+
points: PointIdentifiers[];
|
|
17
|
+
props?: AnglePropsIdentifiers;
|
|
18
|
+
};
|
|
19
|
+
export declare class Angle {
|
|
20
|
+
points: Point[];
|
|
21
|
+
radianValueNode?: AlgebraicNode;
|
|
22
|
+
degreeValueNode?: AlgebraicNode;
|
|
23
|
+
props?: AngleProps;
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @param points [pointA, pointB, pointC] with apex = B
|
|
27
|
+
*/
|
|
28
|
+
constructor(points: Point[], props?: AngleProps);
|
|
29
|
+
toIdentifiers(): AngleIdentifiers;
|
|
30
|
+
hasSameApex(a: Angle): boolean;
|
|
31
|
+
equals(a: Angle): boolean;
|
|
32
|
+
isAlterne(a: Angle): boolean;
|
|
33
|
+
isAlterneInterne(a: Angle): boolean;
|
|
34
|
+
isFlat(): boolean;
|
|
35
|
+
isCorrespondant(a: Angle): boolean;
|
|
36
|
+
isSummitOpposite(a: Angle): boolean;
|
|
37
|
+
evaluate(inRadian?: boolean): number;
|
|
38
|
+
getValueNode(inDegree?: boolean): AlgebraicNode | import("../../tree/nodes/numbers/constantNode").ConstantNode | import("../../tree/nodes/numbers/numberNode").NumberNode;
|
|
39
|
+
isRight(): boolean;
|
|
40
|
+
toTex(): string;
|
|
41
|
+
toCommands(opts?: {
|
|
42
|
+
color?: string;
|
|
43
|
+
showValue?: boolean;
|
|
44
|
+
}): string[];
|
|
45
|
+
}
|
|
46
|
+
export {};
|
|
47
|
+
//# 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,EAAoB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,EACL,eAAe,EAEhB,MAAM,kCAAkC,CAAC;AAI1C,8BAAsB,gBAAgB;IACpC,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,gBAAgB;CAUrD;AACD,KAAK,UAAU,GAAG;IAChB,eAAe,CAAC,EAAE,aAAa,CAAC;IAChC,eAAe,CAAC,EAAE,aAAa,CAAC;CACjC,CAAC;AAEF,KAAK,qBAAqB,GAAG;IAC3B,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC,CAAC;AACF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,KAAK,CAAC,EAAE,qBAAqB,CAAC;CAC/B,CAAC;AACF,qBAAa,KAAK;IAChB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,eAAe,CAAC,EAAE,aAAa,CAAC;IAChC,eAAe,CAAC,EAAE,aAAa,CAAC;IAChC,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB;;;OAGG;gBACS,MAAM,EAAE,KAAK,EAAE,EAAE,KAAK,CAAC,EAAE,UAAU;IAkB/C,aAAa,IAAI,gBAAgB;IASjC,WAAW,CAAC,CAAC,EAAE,KAAK;IAIpB,MAAM,CAAC,CAAC,EAAE,KAAK;IAqBf,SAAS,CAAC,CAAC,EAAE,KAAK;IASlB,gBAAgB,CAAC,CAAC,EAAE,KAAK;IAwCzB,MAAM;IAMN,eAAe,CAAC,CAAC,EAAE,KAAK;IAsCxB,gBAAgB,CAAC,CAAC,EAAE,KAAK;IAoBzB,QAAQ,CAAC,QAAQ,UAAQ;IAiBzB,YAAY,CAAC,QAAQ,UAAQ;IAW7B,OAAO;IAIP,KAAK;IAGL,UAAU,CAAC,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE;CAgB1D"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Angle = exports.AngleConstructor = 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
|
+
const point_1 = require("./point");
|
|
9
|
+
const nodeConstructor_1 = require("../../tree/nodes/nodeConstructor");
|
|
10
|
+
const vector_1 = require("./vector");
|
|
11
|
+
const line_1 = require("./line");
|
|
12
|
+
class AngleConstructor {
|
|
13
|
+
static fromIdentifiers(identifiers) {
|
|
14
|
+
return new Angle(identifiers.points.map(point_1.PointConstructor.fromIdentifiers), {
|
|
15
|
+
degreeValueNode: identifiers.props?.degreeValueNode
|
|
16
|
+
? (0, nodeConstructor_1.reifyAlgebraic)(identifiers.props.degreeValueNode)
|
|
17
|
+
: undefined,
|
|
18
|
+
radianValueNode: identifiers.props?.radianValueNode
|
|
19
|
+
? (0, nodeConstructor_1.reifyAlgebraic)(identifiers.props.radianValueNode)
|
|
20
|
+
: undefined,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.AngleConstructor = AngleConstructor;
|
|
25
|
+
class Angle {
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @param points [pointA, pointB, pointC] with apex = B
|
|
29
|
+
*/
|
|
30
|
+
constructor(points, props) {
|
|
31
|
+
this.points = points;
|
|
32
|
+
this.props = props;
|
|
33
|
+
this.radianValueNode = props?.radianValueNode;
|
|
34
|
+
this.degreeValueNode = props?.degreeValueNode;
|
|
35
|
+
if (props?.radianValueNode && !props.degreeValueNode) {
|
|
36
|
+
this.degreeValueNode = (0, fractionNode_1.frac)((0, multiplyNode_1.multiply)(props.radianValueNode, (180).toTree()), piNode_1.PiNode);
|
|
37
|
+
}
|
|
38
|
+
if (props?.degreeValueNode && !props.radianValueNode) {
|
|
39
|
+
this.radianValueNode = (0, fractionNode_1.frac)((0, multiplyNode_1.multiply)(props.degreeValueNode, piNode_1.PiNode), (180).toTree());
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
toIdentifiers() {
|
|
43
|
+
return {
|
|
44
|
+
points: this.points.map((p) => p.toIdentifiers()),
|
|
45
|
+
props: {
|
|
46
|
+
degreeValueNode: this.degreeValueNode?.toIdentifiers(),
|
|
47
|
+
radianValueNode: this.radianValueNode?.toIdentifiers(),
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
hasSameApex(a) {
|
|
52
|
+
return this.points[1].equals(a.points[1]);
|
|
53
|
+
}
|
|
54
|
+
equals(a) {
|
|
55
|
+
if (!this.hasSameApex(a))
|
|
56
|
+
return false;
|
|
57
|
+
const vecs = [
|
|
58
|
+
[
|
|
59
|
+
vector_1.VectorConstructor.fromPoints(this.points[1], this.points[0]),
|
|
60
|
+
vector_1.VectorConstructor.fromPoints(this.points[1], this.points[2]),
|
|
61
|
+
],
|
|
62
|
+
[
|
|
63
|
+
vector_1.VectorConstructor.fromPoints(a.points[1], a.points[0]),
|
|
64
|
+
vector_1.VectorConstructor.fromPoints(a.points[1], a.points[2]),
|
|
65
|
+
],
|
|
66
|
+
];
|
|
67
|
+
if (vecs[0][0].hasSameOrientation(vecs[1][0])) {
|
|
68
|
+
return vecs[0][1].hasSameOrientation(vecs[1][1]);
|
|
69
|
+
}
|
|
70
|
+
if (vecs[0][0].hasSameOrientation(vecs[1][1])) {
|
|
71
|
+
return vecs[0][1].hasSameOrientation(vecs[1][0]);
|
|
72
|
+
}
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
isAlterne(a) {
|
|
76
|
+
if (this.hasSameApex(a))
|
|
77
|
+
return false;
|
|
78
|
+
const symetric = new Angle([
|
|
79
|
+
a.points[0].centralSymetric(a.points[1]),
|
|
80
|
+
a.points[1],
|
|
81
|
+
a.points[2].centralSymetric(a.points[1]),
|
|
82
|
+
]);
|
|
83
|
+
return symetric.isCorrespondant(this);
|
|
84
|
+
}
|
|
85
|
+
isAlterneInterne(a) {
|
|
86
|
+
if (this.hasSameApex(a))
|
|
87
|
+
return false;
|
|
88
|
+
if (this.isFlat() || a.isFlat())
|
|
89
|
+
return false;
|
|
90
|
+
const apexesVec = vector_1.VectorConstructor.fromPoints(this.points[1], a.points[1]);
|
|
91
|
+
const line = new line_1.Line(this.points[1], a.points[1]);
|
|
92
|
+
const aPointIndexOnLine = a.points.findIndex((p, i) => i !== 1 && line.includes(p, true));
|
|
93
|
+
const thisPointIndexOnLine = this.points.findIndex((p, i) => i !== 1 && line.includes(p, true));
|
|
94
|
+
if (aPointIndexOnLine < 0 || thisPointIndexOnLine < 0)
|
|
95
|
+
return false;
|
|
96
|
+
const vecs = [
|
|
97
|
+
[
|
|
98
|
+
vector_1.VectorConstructor.fromPoints(this.points[1], this.points[thisPointIndexOnLine]),
|
|
99
|
+
vector_1.VectorConstructor.fromPoints(this.points[1], this.points[2 - thisPointIndexOnLine]),
|
|
100
|
+
],
|
|
101
|
+
[
|
|
102
|
+
vector_1.VectorConstructor.fromPoints(a.points[1], a.points[aPointIndexOnLine]),
|
|
103
|
+
vector_1.VectorConstructor.fromPoints(a.points[1], a.points[2 - aPointIndexOnLine]),
|
|
104
|
+
],
|
|
105
|
+
];
|
|
106
|
+
return (vecs[0][0].hasSameOrientation(apexesVec) &&
|
|
107
|
+
vecs[1][0].hasOppositeOrientation(apexesVec) &&
|
|
108
|
+
vecs[0][1].scalarProduct(vecs[1][1]).evaluate() < 0);
|
|
109
|
+
}
|
|
110
|
+
isFlat() {
|
|
111
|
+
return vector_1.VectorConstructor.fromPoints(this.points[1], this.points[2]).isColinear(vector_1.VectorConstructor.fromPoints(this.points[1], this.points[0]));
|
|
112
|
+
}
|
|
113
|
+
isCorrespondant(a) {
|
|
114
|
+
if (this.hasSameApex(a))
|
|
115
|
+
return false;
|
|
116
|
+
//angles plats ne sont pas créés par intersections de droites donc ne peuvent pas etre correspondants
|
|
117
|
+
if (this.isFlat() || a.isFlat())
|
|
118
|
+
return false;
|
|
119
|
+
const line = new line_1.Line(this.points[1], a.points[1]);
|
|
120
|
+
const aPointIndexOnLine = a.points.findIndex((p, i) => i !== 1 && line.includes(p, true));
|
|
121
|
+
const thisPointIndexOnLine = this.points.findIndex((p, i) => i !== 1 && line.includes(p, true));
|
|
122
|
+
if (aPointIndexOnLine < 0 || thisPointIndexOnLine < 0)
|
|
123
|
+
return false;
|
|
124
|
+
//angle non plat
|
|
125
|
+
if (line.includes(a.points[2 - aPointIndexOnLine], true))
|
|
126
|
+
return false;
|
|
127
|
+
const vecs = [
|
|
128
|
+
[
|
|
129
|
+
vector_1.VectorConstructor.fromPoints(this.points[1], this.points[thisPointIndexOnLine]),
|
|
130
|
+
vector_1.VectorConstructor.fromPoints(this.points[1], this.points[2 - thisPointIndexOnLine]),
|
|
131
|
+
],
|
|
132
|
+
[
|
|
133
|
+
vector_1.VectorConstructor.fromPoints(a.points[1], a.points[aPointIndexOnLine]),
|
|
134
|
+
vector_1.VectorConstructor.fromPoints(a.points[1], a.points[2 - aPointIndexOnLine]),
|
|
135
|
+
],
|
|
136
|
+
];
|
|
137
|
+
return (vecs[0][0].hasSameOrientation(vecs[1][0]) &&
|
|
138
|
+
vecs[0][1].scalarProduct(vecs[1][1]).evaluate() > 0);
|
|
139
|
+
}
|
|
140
|
+
isSummitOpposite(a) {
|
|
141
|
+
if (!this.hasSameApex(a))
|
|
142
|
+
return false;
|
|
143
|
+
const vecs = [
|
|
144
|
+
[
|
|
145
|
+
vector_1.VectorConstructor.fromPoints(this.points[1], this.points[0]),
|
|
146
|
+
vector_1.VectorConstructor.fromPoints(this.points[1], this.points[2]),
|
|
147
|
+
],
|
|
148
|
+
[
|
|
149
|
+
vector_1.VectorConstructor.fromPoints(a.points[1], a.points[0]),
|
|
150
|
+
vector_1.VectorConstructor.fromPoints(a.points[1], a.points[2]),
|
|
151
|
+
],
|
|
152
|
+
];
|
|
153
|
+
if (vecs[0][0].hasOppositeOrientation(vecs[1][0])) {
|
|
154
|
+
return vecs[0][1].hasOppositeOrientation(vecs[1][1]);
|
|
155
|
+
}
|
|
156
|
+
if (vecs[0][0].hasOppositeOrientation(vecs[1][1])) {
|
|
157
|
+
return vecs[0][1].hasOppositeOrientation(vecs[1][0]);
|
|
158
|
+
}
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
evaluate(inRadian = false) {
|
|
162
|
+
if (this.degreeValueNode || this.radianValueNode) {
|
|
163
|
+
if (inRadian)
|
|
164
|
+
return this.radianValueNode.evaluate();
|
|
165
|
+
return this.degreeValueNode.evaluate();
|
|
166
|
+
}
|
|
167
|
+
const coords = this.points.map((p) => [p.x.evaluate(), p.y.evaluate()]);
|
|
168
|
+
const [x1, y1, x2, y2, x3, y3] = coords.flatMap((p) => p);
|
|
169
|
+
const angleBA = Math.atan2(y1 - y2, x1 - x2);
|
|
170
|
+
const angleBC = Math.atan2(y3 - y2, x3 - x2);
|
|
171
|
+
let angleRadians = angleBC - angleBA;
|
|
172
|
+
if (angleRadians < 0) {
|
|
173
|
+
angleRadians += 2 * Math.PI;
|
|
174
|
+
}
|
|
175
|
+
if (inRadian)
|
|
176
|
+
return (0, round_1.round)(angleRadians, 4);
|
|
177
|
+
return (0, round_1.round)(angleRadians * (180 / Math.PI), 4);
|
|
178
|
+
}
|
|
179
|
+
getValueNode(inDegree = false) {
|
|
180
|
+
if (this.degreeValueNode || this.radianValueNode) {
|
|
181
|
+
if (inDegree)
|
|
182
|
+
return this.degreeValueNode;
|
|
183
|
+
return this.radianValueNode;
|
|
184
|
+
}
|
|
185
|
+
const angle = this.evaluate();
|
|
186
|
+
if (inDegree)
|
|
187
|
+
return angle.toTree();
|
|
188
|
+
return (0, fractionNode_1.frac)((0, multiplyNode_1.multiply)(angle, piNode_1.PiNode), 180).simplify();
|
|
189
|
+
}
|
|
190
|
+
isRight() {
|
|
191
|
+
const value = this.evaluate();
|
|
192
|
+
return Math.abs(value) - 90 < 0.000001 || Math.abs(value) - 270 < 0.000001;
|
|
193
|
+
}
|
|
194
|
+
toTex() {
|
|
195
|
+
return `\\widehat{${this.points[0].name}${this.points[1].name}${this.points[2].name}}`;
|
|
196
|
+
}
|
|
197
|
+
toCommands(opts) {
|
|
198
|
+
const name = `angle_{${this.points[0].name}${this.points[1].name}${this.points[2].name}}`;
|
|
199
|
+
const cmds = [
|
|
200
|
+
`${name} = Angle(${this.points[0].name},${this.points[1].name},${this.points[2].name}, xAxis)`,
|
|
201
|
+
`ShowLabel(${name}, ${opts?.showValue ? "true" : "false"})`,
|
|
202
|
+
];
|
|
203
|
+
cmds.push(`SetCaption(${name}, "$\\footnotesize ${(0, round_1.round)(this.evaluate(), 1).frenchify() + "°"}$")`);
|
|
204
|
+
if (opts?.color) {
|
|
205
|
+
cmds.push(`SetColor(${name}, "${opts.color}")`);
|
|
206
|
+
}
|
|
207
|
+
return cmds;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
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,15 +32,19 @@ 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;
|
|
39
|
+
getPointWithX(x: AlgebraicNode, name?: string): Point;
|
|
40
|
+
getPointWithY(y: AlgebraicNode, name?: string): Point;
|
|
35
41
|
getRandomPoint(name?: string): Point;
|
|
36
42
|
getEquation: (u: Vector, a: Point) => EqualNode;
|
|
37
43
|
getCartesianEquation(): EqualNode;
|
|
38
44
|
toCartesian(): AddNode;
|
|
39
45
|
toCartesianCoeffs(): {
|
|
40
46
|
a: AlgebraicNode;
|
|
41
|
-
b: import("../../tree/nodes/functions/oppositeNode").OppositeNode
|
|
47
|
+
b: import("../../tree/nodes/functions/oppositeNode").OppositeNode<AlgebraicNode>;
|
|
42
48
|
c: SubstractNode;
|
|
43
49
|
};
|
|
44
50
|
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;IAgBnD,aAAa,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,MAAM;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,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,9 +90,21 @@ 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) {
|
|
107
|
+
return (Math.abs(point.x.evaluate() - this.pointA.x.evaluate()) < 0.0000001);
|
|
90
108
|
}
|
|
91
109
|
else
|
|
92
110
|
return point.x.equals(this.pointA.x);
|
|
@@ -98,6 +116,21 @@ class Line {
|
|
|
98
116
|
else
|
|
99
117
|
return evaluation === 0;
|
|
100
118
|
}
|
|
119
|
+
getPointWithX(x, name) {
|
|
120
|
+
if (this.isVertical)
|
|
121
|
+
return this.pointA.midpoint(this.pointB, name);
|
|
122
|
+
const y = (0, addNode_1.add)((0, multiplyNode_1.multiply)(this.a, x), this.b).simplify();
|
|
123
|
+
return new point_1.Point(name ?? "P", x, y);
|
|
124
|
+
}
|
|
125
|
+
getPointWithY(y, name) {
|
|
126
|
+
if (this.a?.evaluate() === 0)
|
|
127
|
+
return this.pointA.midpoint(this.pointB, name);
|
|
128
|
+
if (this.isVertical) {
|
|
129
|
+
return new point_1.Point(name ?? "P", this.pointA.x, y);
|
|
130
|
+
}
|
|
131
|
+
const x = (0, fractionNode_1.frac)((0, substractNode_1.substract)(y, this.b), this.a).simplify();
|
|
132
|
+
return new point_1.Point(name ?? "P", x, y);
|
|
133
|
+
}
|
|
101
134
|
//! caution: simplify ne gère pas bien ici
|
|
102
135
|
getRandomPoint(name) {
|
|
103
136
|
if (this.isVertical) {
|
|
@@ -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,9 @@ 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;
|
|
39
|
+
centralSymetric(center: Point, name?: string): Point;
|
|
36
40
|
}
|
|
37
41
|
//# sourceMappingURL=point.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"point.d.ts","sourceRoot":"","sources":["../../../src/math/geometry/point.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,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;IAiBnC,eAAe,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,SAAkB;CAItD"}
|
|
@@ -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,16 @@ 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
|
+
}
|
|
139
|
+
centralSymetric(center, name = this.name + "'") {
|
|
140
|
+
const vec = vector_1.VectorConstructor.fromPoints(this, center).opposite();
|
|
141
|
+
return vec.getEndPoint(center, name);
|
|
142
|
+
}
|
|
123
143
|
}
|
|
124
144
|
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"}
|